sanmu
authored
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<template>
<BasicDrawer
v-bind="$attrs"
showFooter
@register="register"
@ok="handleSubmit"
title=""
:destroyOnClose="true"
width="28%"
ref="formRef"
:isDetail="true"
:showDetailBack="false"
okText="保存"
:mask="false"
class="z-20"
>
|
sanmu
authored
|
17
|
<div className="mt-[-16px] order-drawer-panel">
|
sanmu
authored
|
18
|
<Tabs v-model:activeKey="activeKey">
|
sanmu
authored
|
19
20
21
22
23
24
25
|
<TabPanel
key="1"
tab="基本信息"
:forceRender="true"
v-if="role === ROLE.ADMIN || role === ROLE.TRACKER"
>
<BaseFormPanel ref="baseFormPanelRef" :id="id" :businessUsers="businessUsers" />
|
sanmu
authored
|
26
27
28
29
30
31
32
|
</TabPanel>
<TabPanel
key="2"
tab="利润分析"
:forceRender="true"
v-if="!!id && (role === ROLE.ADMIN || role === ROLE.BUSINESS)"
>
|
sanmu
authored
|
33
|
<ProfitFormPanel ref="profitFormPanelRef" :id="id" :profitFormData="profitFormData" />
|
sanmu
authored
|
34
35
36
37
38
39
40
|
</TabPanel>
<TabPanel
key="3"
tab="项目报告书"
:forceRender="true"
v-if="!!id && (role === ROLE.ADMIN || role === ROLE.BUSINESS)"
>
|
sanmu
authored
|
41
|
<ReportFormPanel ref="reportFormPanelRef" :id="id" :reportFormData="reportFormData" />
|
sanmu
authored
|
42
43
44
45
46
47
48
|
</TabPanel>
<TabPanel
key="4"
tab="跟单信息"
:forceRender="true"
v-if="!!id && (role === ROLE.ADMIN || role === ROLE.TRACKER)"
>
|
sanmu
authored
|
49
|
<TrackFormPanel ref="trackFormPanelRef" :id="id" :trackFormData="trackFormData" />
|
sanmu
authored
|
50
51
52
53
54
55
56
|
</TabPanel>
<TabPanel
key="5"
tab="质检信息"
:forceRender="true"
v-if="!!id && (role === ROLE.ADMIN || role === ROLE.INSPECT)"
>
|
sanmu
authored
|
57
58
59
60
61
|
<InspectionFormPanel
ref="inspectionFormPanelRef"
:id="id"
:inspectFormData="inspectFormData"
/>
|
sanmu
authored
|
62
63
64
65
66
67
68
69
70
71
72
|
</TabPanel>
</Tabs>
</div>
<!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
<!-- <template #appendFooter>
<a-button type="primary" @click="onGoCheckDetail"> 申请权限</a-button>
</template> -->
</BasicDrawer>
</template>
<script lang="ts">
|
sanmu
authored
|
73
|
import { computed, defineComponent, reactive, ref, toRaw, watch, toRefs, onMounted } from 'vue';
|
sanmu
authored
|
74
75
76
77
78
79
80
81
82
83
84
|
import { FormActionType, FormSchema, useForm } from '/@/components/Form/index';
import { orderCreate, orderUpdate, uploadImg } from '/@/api/project/order';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { dateUtil } from '/@/utils/dateUtil';
import ProfitFormPanel from './ProfitFormPanel.vue';
import ReportFormPanel from './ReportFormPanel.vue';
import TrackFormPanel from './TrackFormPanel.vue';
import InspectionFormPanel from './InspectionFormPanel.vue';
import BaseFormPanel from './BaseFormPanel.vue';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { ROLE } from '../type.d';
|
sanmu
authored
|
85
|
import { getList as getConfigList } from '/@/api/sys/config';
|
sanmu
authored
|
86
87
|
import { Tabs } from 'ant-design-vue';
|
sanmu
authored
|
88
89
90
|
import { find } from 'lodash-es';
import { getUserList } from '/@/api/project/account';
import message from '/@/views/form-design/utils/message';
|
sanmu
authored
|
91
92
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
|
const userStore = useUserStoreWithOut();
const TabPanel = Tabs.TabPane;
export default defineComponent({
components: {
BasicDrawer,
BaseFormPanel,
Tabs,
TabPanel,
ProfitFormPanel,
ReportFormPanel,
TrackFormPanel,
InspectionFormPanel,
},
props: {
detailData: {
type: Object,
},
onGoCheckDetail: {
type: Function,
},
},
emits: ['success'],
setup(_, { emit }) {
const activeKey = ref('1');
const baseFormPanelRef = ref();
const profitFormPanelRef = ref();
const reportFormPanelRef = ref();
const trackFormPanelRef = ref();
const inspectionFormPanelRef = ref();
|
sanmu
authored
|
125
126
127
128
129
130
131
|
// 编辑从接口获取的value
const baseFormData = ref();
const profitFormData = ref();
const reportFormData = ref();
const trackFormData = ref();
const inspectFormData = ref();
|
sanmu
authored
|
132
133
|
const formRef = ref<FormActionType | null>(null);
const id = ref('');
|
sanmu
authored
|
134
135
136
137
138
139
140
141
142
143
|
const configList = ref([]);
const businessUsers = ref([]);
onMounted(async () => {
// 获取包装费用和客户编码的关联关系
const res = await getConfigList({
page: 1,
pageSize: 1000,
// relationCode: 'packetPrice',
});
|
sanmu
authored
|
144
145
|
configList.value = res?.items || [];
|
sanmu
authored
|
146
147
148
149
150
151
152
|
// 获取业务员
const res1 = await getUserList({ page: 1, pageSize: 1000 });
businessUsers.value = res1.items
.filter((item) => item.roleCode === ROLE.BUSINESS)
.map((item) => ({ value: item.userName, label: item.userName }));
});
|
sanmu
authored
|
153
154
155
156
157
158
159
160
161
|
const role = computed(() => {
return userStore.getUserInfo?.roleSmallVO?.code;
});
const picUrl = ref('');
let fields = reactive({ baseFields: {} });
const [register, { closeDrawer }] = useDrawerInner((data) => {
|
sanmu
authored
|
162
163
|
activeKey.value =
role.value === ROLE.INSPECT ? '5' : role.value === ROLE.BUSINESS ? '2' : '1';
|
sanmu
authored
|
164
165
166
167
168
169
170
171
172
173
174
175
176
|
if (!data.id) {
id.value = '';
picUrl.value = '';
// 新建
baseFormPanelRef?.value?.resetFields();
profitFormPanelRef?.value?.resetFields();
reportFormPanelRef?.value?.resetFields();
trackFormPanelRef?.value?.resetFields();
inspectionFormPanelRef?.value?.resetFields();
return;
}
id.value = data.id;
|
sanmu
authored
|
177
178
179
180
|
profitFormData.value = data.profitAnalysisInfo;
inspectFormData.value = data.inspectionStageInfo;
reportFormData.value = data.reportInfo;
trackFormData.value = data.trackStageInfo;
|
sanmu
authored
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
// 方式1
picUrl.value = data.picUrl;
data.orderHodTime = data.orderHodTime ? dateUtil(data.orderHodTime) : null;
data.productionDepartmentConsignTime = data.productionDepartmentConsignTime
? dateUtil(data.productionDepartmentConsignTime)
: null;
fields.baseFields = {
...fields.baseFields,
...data.lockFields.baseFields,
};
if (id.value) {
setTimeout(() => {
// 基本信息
if (baseFormPanelRef.value) {
baseFormPanelRef.value.fields = { ...data.lockFields?.baseFields } || {};
baseFormPanelRef.value.setFieldsValue({
...toRaw(data),
});
baseFormPanelRef.value.picUrl = data.picUrl;
baseFormPanelRef.value.smallPicUrl = data.smallPicUrl;
}
if (profitFormPanelRef.value) {
|
sanmu
authored
|
207
208
209
210
211
212
213
214
215
216
|
// 包装费用通过客户编码去查
const packetPrice = find(configList.value, (item) => {
return (
data.customerCode === item.settingValue && item.relationCode === 'packetPrice'
);
});
const exchangeRate = find(configList.value, (item) => {
return item.settingCode === 'exchangeRate';
});
|
sanmu
authored
|
217
218
|
// 利润分析
profitFormPanelRef.value.fields = { ...data.lockFields?.profitAnalysisFields } || {};
|
sanmu
authored
|
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
if (data?.orderUpdateInfoVO?.profitAnalysisFields) {
const { customerPrice, productionDepartmentPrice } =
data?.orderUpdateInfoVO?.profitAnalysisFields || {};
// 编辑了但是还没审核,先将页面的值变化
profitFormPanelRef?.value?.setFieldsValue({
...toRaw(data?.orderUpdateInfoVO?.profitAnalysisFields),
customerPrice: Number(customerPrice || 0),
productionDepartmentPrice: Number(productionDepartmentPrice || 0),
packetPrice: packetPrice?.relationValue || 0,
exchangeRate: exchangeRate?.settingValue,
});
} else {
profitFormPanelRef?.value?.setFieldsValue({
...toRaw(data.profitAnalysisInfo),
packetPrice: packetPrice?.relationValue || 0,
exchangeRate: exchangeRate?.settingValue,
});
}
|
sanmu
authored
|
237
238
239
240
241
|
}
if (reportFormPanelRef.value) {
// 项目报告书
reportFormPanelRef.value.fields = { ...data.lockFields?.reportFields } || {};
|
sanmu
authored
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
if (data?.orderUpdateInfoVO?.reportFields) {
const { ideaSourceRate, manualPreform1Rate, manualPreform2Rate } =
data?.orderUpdateInfoVO?.reportFields || {};
data?.orderUpdateInfoVO?.reportFields;
// 编辑了但是还没审核,先将页面的值变化
reportFormPanelRef?.value?.setFieldsValue({
...toRaw(data?.orderUpdateInfoVO?.reportFields),
ideaSourceRate: Number(ideaSourceRate || 0),
manualPreform1Rate: Number(manualPreform1Rate || 0),
manualPreform2Rate: Number(manualPreform2Rate || 0),
});
} else {
reportFormPanelRef?.value?.setFieldsValue({
...toRaw(data.reportInfo),
});
}
|
sanmu
authored
|
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
}
if (trackFormPanelRef.value) {
// 跟单信息
trackFormPanelRef.value.fields = { ...data.lockFields?.trackStageFields } || {};
trackFormPanelRef?.value?.setFieldsValue({
...toRaw(data.trackStageInfo),
});
}
if (inspectionFormPanelRef.value) {
// 质检信息
inspectionFormPanelRef.value.fields =
{ ...data.lockFields?.inspectionStageFields } || {};
inspectionFormPanelRef?.value?.setFieldsValue({
|
sanmu
authored
|
272
|
...toRaw(data.inspectionStageInfo),
|
sanmu
authored
|
273
274
275
276
277
278
279
280
281
|
});
}
}, 100);
} else {
baseFormPanelRef.value.resetFields();
}
});
const handleSubmit = async () => {
|
sanmu
authored
|
282
283
284
285
|
try {
if (id.value) {
const forms = { orderId: id.value } as any;
if (activeKey.value === '1') {
|
sanmu
authored
|
286
287
288
289
290
291
292
293
294
295
296
|
await baseFormPanelRef?.value?.validate();
forms.baseInfo = baseFormPanelRef?.value?.getFieldsValue() || {};
forms.baseInfo = {
...forms.baseInfo,
picUrl: baseFormPanelRef?.value?.picUrl || '',
smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '',
};
await orderUpdate(forms);
closeDrawer();
emit('success', {});
|
sanmu
authored
|
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
} else {
if (activeKey.value === '2') {
await profitFormPanelRef?.value?.validate();
forms.profitAnalysisInfo = profitFormPanelRef?.value?.getFieldsValue() || {};
// 方式如果没有变化,默认方式1
if (!forms.profitAnalysisInfo.profitType) {
forms.profitAnalysisInfo.profitType = '0';
}
} else if (activeKey.value === '3') {
await reportFormPanelRef?.value?.validate();
// 比重相加等于1
const values = reportFormPanelRef?.value?.getFieldsValue() || {};
if (
values.ideaSourceRate + values.manualPreform1Rate + values.manualPreform2Rate !==
1
) {
return message.error('占比相加不等于1');
}
forms.reportInfo = values;
} else if (activeKey.value === '4') {
forms.trackStageInfo = trackFormPanelRef?.value?.getFieldsValue() || {};
} else if (activeKey.value === '5') {
forms.inspectionStageInfo = inspectionFormPanelRef?.value?.getFieldsValue() || {};
}
await orderUpdate(forms);
closeDrawer();
emit('success', {});
|
sanmu
authored
|
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
}
} else {
await baseFormPanelRef?.value?.validate();
// 新建只有基本信息
const values = baseFormPanelRef?.value?.getFieldsValue() || {};
const forms = {
baseInfo: {
...values,
picUrl: baseFormPanelRef?.value?.picUrl || '',
smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '',
},
};
await orderCreate(forms);
closeDrawer();
emit('success', {});
}
|
sanmu
authored
|
343
344
|
} catch (error) {
console.log(error);
|
sanmu
authored
|
345
346
347
348
349
350
351
352
353
354
355
356
357
|
}
};
return {
id,
profitFormPanelRef,
reportFormPanelRef,
trackFormPanelRef,
baseFormPanelRef,
inspectionFormPanelRef,
activeKey,
formRef,
ROLE,
role,
|
sanmu
authored
|
358
359
360
361
|
profitFormData,
inspectFormData,
reportFormData,
trackFormData,
|
sanmu
authored
|
362
363
|
register,
handleSubmit,
|
sanmu
authored
|
364
|
businessUsers,
|
sanmu
authored
|
365
366
367
368
369
|
};
},
});
</script>
|
sanmu
authored
|
370
|
<style>
|
sanmu
authored
|
371
372
373
374
|
.ant-drawer {
position: fixed;
z-index: 9999;
}
|
sanmu
authored
|
375
376
377
378
|
.order-drawer-panel .ant-picker {
width: 100% !important;
}
|
sanmu
authored
|
379
|
</style>
|