|
@@ -7,7 +7,7 @@
|
7
|
7
|
<uni-forms-item v-if="item.type === '1'" class="formItem" :required="item.required" :name="item.key">
|
8
|
8
|
<template v-slot:label>
|
9
|
9
|
<view class="customLabelWrap">
|
10
|
|
- <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
10
|
+ <text :class="{'is-required': item.required}">*</text><text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
11
|
11
|
</view>
|
12
|
12
|
</template>
|
13
|
13
|
<uni-data-picker :placeholder="'请选择' + item.name" :popup-title="'请选择' + item.name" :localdata="item.list" v-model="formValues[item.key]" @change="changeForm()">
|
|
@@ -17,7 +17,7 @@
|
17
|
17
|
<uni-forms-item v-if="item.type === '2'" class="formItem" :required="item.required" :name="item.key">
|
18
|
18
|
<template v-slot:label>
|
19
|
19
|
<view class="customLabelWrap">
|
20
|
|
- <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
20
|
+ <text :class="{'is-required': item.required}">*</text><text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
21
|
21
|
</view>
|
22
|
22
|
</template>
|
23
|
23
|
<uni-data-checkbox v-model="formValues[item.key]" @change="changeForm()" :localdata="item.list" />
|
|
@@ -26,7 +26,7 @@
|
26
|
26
|
<uni-forms-item v-if="item.type === '3'" class="formItem" :required="item.required" :name="item.key">
|
27
|
27
|
<template v-slot:label>
|
28
|
28
|
<view class="customLabelWrap">
|
29
|
|
- <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
29
|
+ <text :class="{'is-required': item.required}">*</text><text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
30
|
30
|
</view>
|
31
|
31
|
</template>
|
32
|
32
|
<uni-data-checkbox v-model="formValues[item.key]" @change="changeForm()" multiple :localdata="item.list" />
|
|
@@ -35,7 +35,7 @@
|
35
|
35
|
<uni-forms-item v-if="item.type === '4'" class="formItem" :required="item.required" :name="item.key">
|
36
|
36
|
<template v-slot:label>
|
37
|
37
|
<view class="customLabelWrap">
|
38
|
|
- <text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
|
38
|
+ <text :class="{'is-required': item.required}">*</text><text class="customLabel">{{item.name}}</text><text v-if="item.isException" class="customLabel red"> 异</text>
|
39
|
39
|
</view>
|
40
|
40
|
</template>
|
41
|
41
|
<uni-number-box v-model="formValues[item.key]" @change="changeForm()" :min="-9999" :max="9999" :placeholder="'请输入' + item.name"></uni-number-box>
|
|
@@ -50,7 +50,7 @@
|
50
|
50
|
</uni-forms-item>
|
51
|
51
|
<!-- 图片上传 -->
|
52
|
52
|
<uni-forms-item v-if="item.type === '7' && item.isException" class="formItem" :label="item.name" :required="item.required" :name="item.key">
|
53
|
|
- <DsFilePicker v-model="formValues[item.key]"></DsFilePicker>
|
|
53
|
+ <DsFilePicker :extra="item.id" :inspectionExecuteId="inspectionExecuteId" :ref="(el) => itemRefs[item.id] = el"></DsFilePicker>
|
54
|
54
|
</uni-forms-item>
|
55
|
55
|
<!-- 分割线 -->
|
56
|
56
|
<view class="detail_head" v-if="item.type === '8'">
|
|
@@ -70,7 +70,7 @@
|
70
|
70
|
import fromPairs from 'lodash-es/fromPairs'
|
71
|
71
|
import keyBy from 'lodash-es/keyBy'
|
72
|
72
|
import DsFilePicker from '@/components/DsFilePicker.vue';
|
73
|
|
- import { ref, reactive } from 'vue'
|
|
73
|
+ import { ref, reactive, nextTick } from 'vue'
|
74
|
74
|
import { onLoad } from '@dcloudio/uni-app'
|
75
|
75
|
import { api_addModel } from "@/http/api.js"
|
76
|
76
|
import { defaultColor } from '@/static/js/theme.js'
|
|
@@ -79,7 +79,7 @@
|
79
|
79
|
import { useGoBack } from '@/share/useGoBack.js'
|
80
|
80
|
import { useLoginUserStore } from '@/stores/loginUser'
|
81
|
81
|
import { useInspectionValueStore } from '@/stores/inspectionValue'
|
82
|
|
-import { forIn } from 'lodash-es';
|
|
82
|
+ import { forIn } from 'lodash-es';
|
83
|
83
|
|
84
|
84
|
useSetTitle();
|
85
|
85
|
const loginUserStore = useLoginUserStore();
|
|
@@ -94,6 +94,9 @@ import { forIn } from 'lodash-es';
|
94
|
94
|
|
95
|
95
|
// 表单
|
96
|
96
|
const baseForm = ref()
|
|
97
|
+
|
|
98
|
+ // 图片上传ref数组
|
|
99
|
+ const itemRefs = ref({});
|
97
|
100
|
|
98
|
101
|
const inspectionExecuteId = ref()
|
99
|
102
|
|
|
@@ -132,57 +135,81 @@ import { forIn } from 'lodash-es';
|
132
|
135
|
|
133
|
136
|
// 保存
|
134
|
137
|
function submit(){
|
135
|
|
- baseForm.value.validate().then(res => {
|
136
|
|
- console.log('success', res);
|
137
|
|
- uni.showLoading({
|
138
|
|
- title: "加载中",
|
139
|
|
- mask: true,
|
140
|
|
- });
|
141
|
|
- console.log(formValues);
|
142
|
|
- let postData = {
|
143
|
|
- account: loginUserStore.loginUser.user.account,
|
144
|
|
- valuesList: [],
|
145
|
|
- };
|
146
|
|
- // baseFormData
|
147
|
|
- for(let key in formValues){
|
148
|
|
- let obj = baseFormData.find(v => v.key === key);
|
149
|
|
- if(!((obj.type === '5' && !obj.isException) || (obj.type === '6' && !obj.isException) || (obj.type === '7' && !obj.isException))){
|
150
|
|
- let name = obj.name;
|
151
|
|
- let itemId = obj.id;
|
152
|
|
- let _formPageList = dataInfo.inspectionFormDTO?.formPageList || [];
|
153
|
|
- _formPageList = _formPageList.map(v => v.formItemList).flat();
|
154
|
|
- let formItem = _formPageList.find(v => v.id === itemId);
|
155
|
|
- postData.valuesList.push({
|
156
|
|
- taskId: inspectionExecuteId.value,
|
157
|
|
- nodeId: dataInfo.id,
|
158
|
|
- formId: dataInfo.inspectionFormDTO.id,
|
159
|
|
- itemId: formItem.id,
|
160
|
|
- pageId: formItem.pageId,
|
161
|
|
- orders: formItem.orders,
|
162
|
|
- name,
|
163
|
|
- valuex: (formItem.type.value === '1' || formItem.type.value === '2' || formItem.type.value === '3') ? '' : formValues[key].toString(),
|
164
|
|
- configIds: (formItem.type.value === '1' || formItem.type.value === '2' || formItem.type.value === '3') ? formValues[key].toString() : undefined,
|
165
|
|
- hosId: dataInfo.inspectionFormDTO.hosId,
|
166
|
|
- })
|
167
|
|
- }
|
|
138
|
+ console.log(itemRefs.value);
|
|
139
|
+ console.log(formValues);
|
|
140
|
+ console.log(baseFormData);
|
|
141
|
+ // 处理图片上传检验问题
|
|
142
|
+ Object.values(itemRefs.value).forEach(v => {
|
|
143
|
+ console.log(v.inspectionExecuteId);
|
|
144
|
+ console.log(v.extra);
|
|
145
|
+ if(v && v.baseFormData.handlerImgList.length){
|
|
146
|
+ baseFormData.forEach(vv => {
|
|
147
|
+ if(vv.id == v.extra){
|
|
148
|
+ formValues[vv.key] = v.inspectionExecuteId;
|
|
149
|
+ vv.value = v.inspectionExecuteId;
|
|
150
|
+ }
|
|
151
|
+ })
|
168
|
152
|
}
|
169
|
|
- console.log(postData);
|
170
|
|
- api_addModel(postData).then((res) => {
|
171
|
|
- uni.hideLoading();
|
172
|
|
- if (res.status == 200) {
|
173
|
|
- inspectionValueStore.clearInspectionValueData();
|
174
|
|
- uni.reLaunch({
|
175
|
|
- url: `/pages/inspection/inspectionExecute/inspectionExecute`
|
176
|
|
- })
|
177
|
|
- } else {
|
178
|
|
- uni.showToast({
|
179
|
|
- icon: 'none',
|
180
|
|
- title: res.msg || '请求数据失败!'
|
181
|
|
- });
|
|
153
|
+ })
|
|
154
|
+
|
|
155
|
+ nextTick(() => {
|
|
156
|
+ baseForm.value.validate().then(res => {
|
|
157
|
+ console.log('success', res);
|
|
158
|
+ uni.showLoading({
|
|
159
|
+ title: "加载中",
|
|
160
|
+ mask: true,
|
|
161
|
+ });
|
|
162
|
+ console.log(formValues);
|
|
163
|
+ let postData = {
|
|
164
|
+ account: loginUserStore.loginUser.user.account,
|
|
165
|
+ valuesList: [],
|
|
166
|
+ };
|
|
167
|
+ // baseFormData
|
|
168
|
+ for(let key in formValues){
|
|
169
|
+ let obj = baseFormData.find(v => v.key === key);
|
|
170
|
+ if(!((obj.type === '5' && !obj.isException) || (obj.type === '6' && !obj.isException) || (obj.type === '7' && !obj.isException))){
|
|
171
|
+ let name = obj.name;
|
|
172
|
+ let itemId = obj.id;
|
|
173
|
+ let _formPageList = dataInfo.inspectionFormDTO?.formPageList || [];
|
|
174
|
+ _formPageList = _formPageList.map(v => v.formItemList).flat();
|
|
175
|
+ let formItem = _formPageList.find(v => v.id === itemId);
|
|
176
|
+ postData.valuesList.push({
|
|
177
|
+ taskId: inspectionExecuteId.value,
|
|
178
|
+ nodeId: dataInfo.id,
|
|
179
|
+ formId: dataInfo.inspectionFormDTO.id,
|
|
180
|
+ itemId: formItem.id,
|
|
181
|
+ pageId: formItem.pageId,
|
|
182
|
+ orders: formItem.orders,
|
|
183
|
+ name,
|
|
184
|
+ valuex: (formItem.type.value === '1' || formItem.type.value === '2' || formItem.type.value === '3') ? '' : formValues[key].toString(),
|
|
185
|
+ configIds: (formItem.type.value === '1' || formItem.type.value === '2' || formItem.type.value === '3') ? formValues[key].toString() : undefined,
|
|
186
|
+ hosId: dataInfo.inspectionFormDTO.hosId,
|
|
187
|
+ })
|
|
188
|
+ }
|
182
|
189
|
}
|
183
|
|
- });
|
184
|
|
- }).catch(err => {
|
185
|
|
- console.log('err', err);
|
|
190
|
+ console.log(postData);
|
|
191
|
+ console.log(itemRefs.value);
|
|
192
|
+ // return;
|
|
193
|
+ api_addModel(postData).then((res) => {
|
|
194
|
+ uni.hideLoading();
|
|
195
|
+ if (res.status == 200) {
|
|
196
|
+ Object.values(itemRefs.value).forEach(v => {
|
|
197
|
+ v && v.uploadFn();
|
|
198
|
+ })
|
|
199
|
+ inspectionValueStore.clearInspectionValueData();
|
|
200
|
+ uni.reLaunch({
|
|
201
|
+ url: `/pages/inspection/inspectionExecute/inspectionExecute`
|
|
202
|
+ })
|
|
203
|
+ } else {
|
|
204
|
+ uni.showToast({
|
|
205
|
+ icon: 'none',
|
|
206
|
+ title: res.msg || '请求数据失败!'
|
|
207
|
+ });
|
|
208
|
+ }
|
|
209
|
+ });
|
|
210
|
+ }).catch(err => {
|
|
211
|
+ console.log('err', err);
|
|
212
|
+ })
|
186
|
213
|
})
|
187
|
214
|
}
|
188
|
215
|
|
|
@@ -232,11 +259,11 @@ import { forIn } from 'lodash-es';
|
232
|
259
|
}
|
233
|
260
|
});
|
234
|
261
|
|
235
|
|
- let firstPageBottom = firstPage.filter(v => v.type === '5' || v.type === '6');
|
|
262
|
+ let firstPageBottom = firstPage.filter(v => v.type === '5' || v.type === '6' || v.type === '7');
|
236
|
263
|
firstPage = firstPage.filter(v => v.type !== '5' && v.type !== '6' && v.type !== '7');
|
237
|
264
|
|
238
|
265
|
// 其他项
|
239
|
|
- if(isException){
|
|
266
|
+ if(!isException){
|
240
|
267
|
firstPage.forEach(v => {
|
241
|
268
|
// 下拉,单选
|
242
|
269
|
if(v.type === '1' || v.type === '2'){
|
|
@@ -320,6 +347,13 @@ import { forIn } from 'lodash-es';
|
320
|
347
|
</script>
|
321
|
348
|
|
322
|
349
|
<style lang="scss" scoped>
|
|
350
|
+.customLabelWrap{
|
|
351
|
+ .is-required{
|
|
352
|
+ color: #dd524d;
|
|
353
|
+ font-weight: bold;
|
|
354
|
+ margin-top: 8rpx;
|
|
355
|
+ }
|
|
356
|
+}
|
323
|
357
|
.inspectionValue{
|
324
|
358
|
height: 100%;
|
325
|
359
|
display: flex;
|