sanmu
authored
|
1
|
<template>
|
sanmu
authored
|
2
3
4
5
6
7
8
9
|
<div className="pb-2">
<BasicForm @register="registerForm" />
</div>
<div
v-if="isInnerNoRepeat"
class="absolute bottom-0 left-0 bg-gray-200 px-2 py-1 w-full text-orange-500"
>{{ isInnerNoRepeat }}</div
>
|
sanmu
authored
|
10
11
|
</template>
<script lang="ts">
|
sanmu
authored
|
12
|
import { computed, defineComponent, onMounted, ref, watch } from 'vue';
|
sanmu
authored
|
13
14
|
import { BasicForm, useForm } from '/@/components/Form/index';
import { FIELDS_BASE_INFO } from '../tableData';
|
sanmu
authored
|
15
|
import { getBaseDisable } from '/@/utils/project';
|
sanmu
authored
|
16
|
import { useOrderStoreWithOut } from '/@/store/modules/order';
|
柏杨
authored
|
17
18
|
import { ROLE } from '../type.d';
import { useUserStoreWithOut } from '/@/store/modules/user';
|
sanmu
authored
|
19
20
|
import { useOrderInfo } from '/@/hooks/component/order';
|
sanmu
authored
|
21
|
import { get } from 'lodash-es';
|
sanmu
authored
|
22
|
import { orderFieldCheck } from '/@/api/project/order';
|
sanmu
authored
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
export default defineComponent({
components: { BasicForm },
props: {
detailData: {
type: Object,
},
onGoCheckDetail: {
type: Function,
},
id: {
type: String,
},
|
sanmu
authored
|
37
38
39
|
isCopy: {
type: Boolean,
},
|
sanmu
authored
|
40
41
42
|
businessUsers: {
type: Array,
},
|
sanmu
authored
|
43
44
45
|
},
emits: ['success'],
setup(props) {
|
sanmu
authored
|
46
47
48
49
50
51
52
53
54
55
56
|
// 子组建获取isCopy,并且自己维护isCopy的状态
let isCopy = ref(props.isCopy);
const isInnerNoRepeat = ref('');
watch(
() => props.isCopy,
(value) => {
isCopy.value = value;
},
);
|
sanmu
authored
|
57
58
59
|
let fields = ref({});
const picUrl = ref('');
const smallPicUrl = ref('');
|
柏杨
authored
|
60
61
62
63
|
const userStore = useUserStoreWithOut();
const role = computed(() => {
return userStore.getUserInfo?.roleSmallVO?.code;
});
|
sanmu
authored
|
64
65
66
67
68
69
70
71
72
73
74
|
const orderStore = useOrderStoreWithOut();
const {
customerCode,
projectNo,
productionDepartment,
innerNo,
poColor,
cnColor,
productStyle,
outboundType,
packetType,
|
sanmu
authored
|
75
76
|
// businessPerson,
|
sanmu
authored
|
77
|
} = useOrderInfo(orderStore);
|
sanmu
authored
|
78
|
var schemas = computed(() => {
|
sanmu
authored
|
79
80
81
82
83
84
85
86
87
88
|
const options = {
customerCode,
projectNo,
productionDepartment,
innerNo,
poColor,
cnColor,
productStyle,
outboundType,
packetType,
|
sanmu
authored
|
89
90
|
businessPerson: props.businessUsers,
|
sanmu
authored
|
91
92
|
};
|
柏杨
authored
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// const res = FIELDS_BASE_INFO.map((item) => {
// if (item.field === 'picUrl') {
// return {
// field: 'picUrl',
// component: 'FieldUpload',
// label: '图片',
// rules: [{ required: true }],
// colProps: {
// span: 24,
// },
// componentProps: {
// imgUrl: picUrl.value,
// // disabled: getDisable(get(fields.value, 'picUrl'), props.id),
// onChange: (res) => {
// if (res.file?.response?.data) {
// picUrl.value = res.file?.response?.data?.picUrl;
// smallPicUrl.value = res.file?.response?.data?.smallPicUrl;
// setFieldsValue({ picUrl: picUrl.value });
// clearValidate('picUrl');
// }
// },
// },
// };
// }
// return {
// ...item,
// field: `${item.field}`,
// componentProps: {
// ...(item.component === 'Select' && { showSearch: true }),
// ...(item.component === 'Select' && { options: options[item.field] }),
// disabled: getBaseDisable(item.field, get(fields.value, `${item.field}`), props.id),
// onChange: async (val) => {
// if (item.field === 'customerCode' && !isCopy.value) {
// if (!props.id) {
// setFieldsValue({ projectNo: val + '-', innerNo: val + '/' });
// }
// }
// isCopy.value = false;
// if (item.field === 'innerNo') {
// val = typeof val === 'string' ? val : val.target.value;
// const res = await orderFieldCheck({
// innerNo: [val],
// });
// if (res) {
// isInnerNoRepeat.value = `内部编码 ${val} 已存在,保存前请确认是否需要修改`;
// } else {
// isInnerNoRepeat.value = '';
// }
// }
// },
// },
// colProps: {
// span: 24,
// },
// };
// });
// return res;
// });
//biaoji
|
sanmu
authored
|
155
156
157
158
159
160
161
162
163
164
165
|
const res = FIELDS_BASE_INFO.map((item) => {
if (item.field === 'picUrl') {
return {
field: 'picUrl',
component: 'FieldUpload',
label: '图片',
rules: [{ required: true }],
colProps: {
span: 24,
},
componentProps: {
|
sanmu
authored
|
166
|
imgUrl: picUrl.value,
|
柏杨
authored
|
167
168
169
170
171
172
|
disabled: getBaseDisable(
item.field,
get(fields.value, `${item.field}`),
props.id,
role.value,
),
|
sanmu
authored
|
173
|
// disabled: getDisable(get(fields.value, 'picUrl'), props.id),
|
sanmu
authored
|
174
175
176
177
|
onChange: (res) => {
if (res.file?.response?.data) {
picUrl.value = res.file?.response?.data?.picUrl;
smallPicUrl.value = res.file?.response?.data?.smallPicUrl;
|
sanmu
authored
|
178
179
180
|
setFieldsValue({ picUrl: picUrl.value });
clearValidate('picUrl');
|
sanmu
authored
|
181
182
183
184
185
|
}
},
},
};
}
|
柏杨
authored
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
if (item.field === 'productionComment') {
return {
field: 'productionComment',
component: 'InputTextArea',
rules: [{ required: true }],
componentProps: {
rows: 10,
disabled: getBaseDisable(
item.field,
get(fields.value, `${item.field}`),
props.id,
role.value,
),
},
labelWidth: 600,
label: '产品意见',
};
}
|
柏杨
authored
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
// if (item.field === 'returnOrder') {
// return {
// field: 'returnOrder',
// component: 'Select',
// rules: [{ required: true }],
// componentProps: {
// options: [
// {
// label: '是',
// value: '1',
// },
// {
// label: '否',
// value: '0',
// },
// ],
// disabled: getBaseDisable(
// item.field,
// get(fields.value, `${item.field}`),
// props.id,
// role.value,
// ),
// },
// labelWidth: 600,
// // default: '请选择',
// label: '是否返单 ',
// };
// }
|
柏杨
authored
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
// const businessNotDisabledFields = ['customerCode', 'projectNo', 'innerNo'];
// const trackerNotDisabledFields = [
// 'customerPo',
// 'customerStyle',
// 'modeleLo',
// 'collection',
// 'poColor',
// 'cnColor',
// 'picUrl',
// 'productStyle',
// 'orderComposition',
// 'productionDepartmentConsignTime',
// 'orderHodTime',
// 'outboundType',
// 'packetType',
// 'productionComment',
// ];
// const isFieldNotDisabledForBusiness = businessNotDisabledFields.includes(item.field);
// const isFieldNotDisabledForTracker = trackerNotDisabledFields.includes(item.field);
|
sanmu
authored
|
251
252
253
254
|
return {
...item,
field: `${item.field}`,
componentProps: {
|
sanmu
authored
|
255
|
...(item.component === 'Select' && { showSearch: true }),
|
柏杨
authored
|
256
257
258
|
...(item.component === 'Select' && {
options: options[item.field] || item?.componentProps?.options,
}),
|
柏杨
authored
|
259
260
261
262
263
264
265
266
267
268
269
270
|
// disabled:
// role.value === ROLE.BUSINESS
// ? !isFieldNotDisabledForBusiness
// : role.value === ROLE.TRACKER
// ? !isFieldNotDisabledForTracker
// : getBaseDisable(item.field, get(fields.value, `${item.field}`), props.id),
disabled: getBaseDisable(
item.field,
get(fields.value, `${item.field}`),
props.id,
role.value,
),
|
sanmu
authored
|
271
272
|
onChange: async (val) => {
if (item.field === 'customerCode' && !isCopy.value) {
|
sanmu
authored
|
273
|
if (!props.id) {
|
sanmu
authored
|
274
|
setFieldsValue({ projectNo: val + '-', innerNo: val + '/' });
|
sanmu
authored
|
275
276
|
}
}
|
sanmu
authored
|
277
278
279
280
281
282
283
284
285
286
287
288
289
|
isCopy.value = false;
if (item.field === 'innerNo') {
val = typeof val === 'string' ? val : val.target.value;
const res = await orderFieldCheck({
innerNo: [val],
});
if (res) {
isInnerNoRepeat.value = `内部编码 ${val} 已存在,保存前请确认是否需要修改`;
} else {
isInnerNoRepeat.value = '';
}
}
|
sanmu
authored
|
290
|
},
|
sanmu
authored
|
291
292
293
294
295
296
297
298
299
|
},
colProps: {
span: 24,
},
};
});
return res;
});
|
柏杨
authored
|
300
|
//biaoji
|
sanmu
authored
|
301
302
303
304
|
var [registerForm, { setFieldsValue, getFieldsValue, resetFields, validate, clearValidate }] =
useForm({
labelWidth: 120,
schemas,
|
sanmu
authored
|
305
|
layout: 'vertical',
|
sanmu
authored
|
306
307
308
309
310
|
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
|
sanmu
authored
|
311
312
313
314
315
316
317
|
return {
fields,
registerForm,
getFieldsValue,
setFieldsValue,
resetFields,
|
sanmu
authored
|
318
|
validate,
|
sanmu
authored
|
319
320
|
picUrl,
smallPicUrl,
|
sanmu
authored
|
321
|
isInnerNoRepeat,
|
柏杨
authored
|
322
|
role,
|
sanmu
authored
|
323
324
325
326
|
};
},
});
</script>
|