|
@@ -4,20 +4,40 @@
|
4
|
4
|
<uni-forms ref="baseForm" :model="formValues" :rules="rules" class="form" label-position="top">
|
5
|
5
|
<template v-for="(item, index) of baseFormData" :key="index">
|
6
|
6
|
<!-- 下拉 -->
|
7
|
|
- <uni-forms-item v-if="item.type === '1'" class="formItem" :label="item.name" :exception="item.isException" :required="item.required" :name="item.key">
|
|
7
|
+ <uni-forms-item v-if="item.type === '1'" class="formItem" :required="item.required" :name="item.key">
|
|
8
|
+ <template v-slot:label>
|
|
9
|
+ <view class="customLabelWrap">
|
|
10
|
+ <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
11
|
+ </view>
|
|
12
|
+ </template>
|
8
|
13
|
<uni-data-picker :placeholder="'请选择' + item.name" :popup-title="'请选择' + item.name" :localdata="item.list" v-model="formValues[item.key]" @change="changeForm()">
|
9
|
14
|
</uni-data-picker>
|
10
|
15
|
</uni-forms-item>
|
11
|
16
|
<!-- 单选 -->
|
12
|
|
- <uni-forms-item v-if="item.type === '2'" class="formItem" :label="item.name" :exception="item.isException" :required="item.required" :name="item.key">
|
|
17
|
+ <uni-forms-item v-if="item.type === '2'" class="formItem" :required="item.required" :name="item.key">
|
|
18
|
+ <template v-slot:label>
|
|
19
|
+ <view class="customLabelWrap">
|
|
20
|
+ <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
21
|
+ </view>
|
|
22
|
+ </template>
|
13
|
23
|
<uni-data-checkbox v-model="formValues[item.key]" @change="changeForm()" :localdata="item.list" />
|
14
|
24
|
</uni-forms-item>
|
15
|
25
|
<!-- 多选 -->
|
16
|
|
- <uni-forms-item v-if="item.type === '3'" class="formItem" :label="item.name" :exception="item.isException" :required="item.required" :name="item.key">
|
|
26
|
+ <uni-forms-item v-if="item.type === '3'" class="formItem" :required="item.required" :name="item.key">
|
|
27
|
+ <template v-slot:label>
|
|
28
|
+ <view class="customLabelWrap">
|
|
29
|
+ <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
30
|
+ </view>
|
|
31
|
+ </template>
|
17
|
32
|
<uni-data-checkbox v-model="formValues[item.key]" @change="changeForm()" multiple :localdata="item.list" />
|
18
|
33
|
</uni-forms-item>
|
19
|
34
|
<!-- 数字 -->
|
20
|
|
- <uni-forms-item v-if="item.type === '4'" class="formItem" :label="item.name" :exception="item.isException" :required="item.required" :name="item.key">
|
|
35
|
+ <uni-forms-item v-if="item.type === '4'" class="formItem" :required="item.required" :name="item.key">
|
|
36
|
+ <template v-slot:label>
|
|
37
|
+ <view class="customLabelWrap">
|
|
38
|
+ <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
39
|
+ </view>
|
|
40
|
+ </template>
|
21
|
41
|
<uni-number-box v-model="formValues[item.key]" @change="changeForm()" :min="-9999" :max="9999" :placeholder="'请输入' + item.name"></uni-number-box>
|
22
|
42
|
</uni-forms-item>
|
23
|
43
|
<!-- 单行 -->
|
|
@@ -68,24 +88,24 @@ import { forIn } from 'lodash-es';
|
68
|
88
|
|
69
|
89
|
// 主题颜色
|
70
|
90
|
const primaryColor = ref(defaultColor)
|
71
|
|
-
|
|
91
|
+
|
72
|
92
|
// 所有页码数据
|
73
|
93
|
const formPageList = reactive([]);
|
74
|
|
-
|
|
94
|
+
|
75
|
95
|
// 表单
|
76
|
96
|
const baseForm = ref()
|
77
|
|
-
|
|
97
|
+
|
78
|
98
|
const inspectionExecuteId = ref()
|
79
|
99
|
|
80
|
100
|
// 数据-原始
|
81
|
101
|
const dataInfo = reactive({})
|
82
|
|
-
|
|
102
|
+
|
83
|
103
|
// 数据-检验
|
84
|
104
|
const rules = reactive({})
|
85
|
|
-
|
|
105
|
+
|
86
|
106
|
// 数据-填写值
|
87
|
107
|
const formValues = reactive({})
|
88
|
|
-
|
|
108
|
+
|
89
|
109
|
// 表单数据-渲染
|
90
|
110
|
// 下拉框 1
|
91
|
111
|
// 单选 2
|
|
@@ -104,12 +124,12 @@ import { forIn } from 'lodash-es';
|
104
|
124
|
// { type: 6, name: '', value: '', list: [], required: false, checkType: 0, valueMin: '', valueMax: '', },
|
105
|
125
|
// { type: 7, name: '', value: [], list: [], required: false, checkType: 0, valueMin: '', valueMax: '', },
|
106
|
126
|
])
|
107
|
|
-
|
|
127
|
+
|
108
|
128
|
// 修改
|
109
|
129
|
function changeForm(){
|
110
|
130
|
handleData(true);
|
111
|
131
|
}
|
112
|
|
-
|
|
132
|
+
|
113
|
133
|
// 保存
|
114
|
134
|
function submit(){
|
115
|
135
|
baseForm.value.validate().then(res => {
|
|
@@ -165,18 +185,18 @@ import { forIn } from 'lodash-es';
|
165
|
185
|
console.log('err', err);
|
166
|
186
|
})
|
167
|
187
|
}
|
168
|
|
-
|
|
188
|
+
|
169
|
189
|
// 处理数据
|
170
|
190
|
function handleData(isException = false){
|
171
|
191
|
// 目前只取第一页
|
172
|
192
|
let firstPage = formPageList[0]?.formItemList || [];
|
173
|
|
-
|
|
193
|
+
|
174
|
194
|
firstPage = firstPage.filter( v => v.display === 1);
|
175
|
|
-
|
|
195
|
+
|
176
|
196
|
firstPage = firstPage.map((v, i) => {
|
177
|
197
|
let value = '';
|
178
|
198
|
v.formItemConfigList = v.formItemConfigList || [];
|
179
|
|
-
|
|
199
|
+
|
180
|
200
|
// value
|
181
|
201
|
if(v.type.value === '3'){
|
182
|
202
|
// 多选
|
|
@@ -195,7 +215,7 @@ import { forIn } from 'lodash-es';
|
195
|
215
|
// 其他
|
196
|
216
|
value = v.defaultValue;
|
197
|
217
|
}
|
198
|
|
-
|
|
218
|
+
|
199
|
219
|
return {
|
200
|
220
|
id: v.id,
|
201
|
221
|
key: `field${i}`,
|
|
@@ -211,10 +231,10 @@ import { forIn } from 'lodash-es';
|
211
|
231
|
valueMax: v.checkType === 2 ? v.valueUp : ( v.checkType === 1 ? (v.valuex + v.valueGap) : undefined),
|
212
|
232
|
}
|
213
|
233
|
});
|
214
|
|
-
|
|
234
|
+
|
215
|
235
|
let firstPageBottom = firstPage.filter(v => v.type === '5' || v.type === '6');
|
216
|
236
|
firstPage = firstPage.filter(v => v.type !== '5' && v.type !== '6' && v.type !== '7');
|
217
|
|
-
|
|
237
|
+
|
218
|
238
|
// 其他项
|
219
|
239
|
if(isException){
|
220
|
240
|
firstPage.forEach(v => {
|
|
@@ -256,7 +276,7 @@ import { forIn } from 'lodash-es';
|
256
|
276
|
}
|
257
|
277
|
})
|
258
|
278
|
}
|
259
|
|
-
|
|
279
|
+
|
260
|
280
|
// 单行|多行|图片上传
|
261
|
281
|
let someIsException = firstPage.filter(v => v.type !== '8').some(v => v.isException);
|
262
|
282
|
console.log('someIsException=>', someIsException)
|
|
@@ -264,19 +284,19 @@ import { forIn } from 'lodash-es';
|
264
|
284
|
console.log('v.showError=>', v.showError)
|
265
|
285
|
v.isException = (v.showError === 1 && someIsException) || v.showError === 0;
|
266
|
286
|
})
|
267
|
|
-
|
|
287
|
+
|
268
|
288
|
firstPage = firstPage.concat(firstPageBottom).sort((a, b) => a.orders - b.orders);
|
269
|
289
|
console.log('firstPage=>', firstPage);
|
270
|
|
-
|
|
290
|
+
|
271
|
291
|
Object.assign(baseFormData, firstPage);
|
272
|
292
|
console.log('baseFormData=>', baseFormData);
|
273
|
|
-
|
|
293
|
+
|
274
|
294
|
Object.assign(formValues, fromPairs(firstPage.filter(v => v.type !== '8').map(v => ([v.key, v.value]))));
|
275
|
295
|
console.log('formValues=>', formValues);
|
276
|
|
-
|
|
296
|
+
|
277
|
297
|
let rulesObj = keyBy(firstPage.filter(v => v.type !== '8'), 'key');
|
278
|
298
|
console.log(rulesObj)
|
279
|
|
-
|
|
299
|
+
|
280
|
300
|
for(let key in rulesObj){
|
281
|
301
|
rulesObj[key] = {
|
282
|
302
|
rules: [
|
|
@@ -287,7 +307,7 @@ import { forIn } from 'lodash-es';
|
287
|
307
|
Object.assign(rules, rulesObj);
|
288
|
308
|
console.log('rules=>', rules);
|
289
|
309
|
}
|
290
|
|
-
|
|
310
|
+
|
291
|
311
|
onLoad((option) => {
|
292
|
312
|
inspectionExecuteId.value = +option.inspectionExecuteId;
|
293
|
313
|
// 巡检项
|