sanmu
authored
|
1
2
3
4
5
6
7
|
<template>
<BasicDrawer
@register="register"
v-bind="$attrs"
showFooter
title="字段编辑权限申请"
width="60%"
|
sanmu
authored
|
8
|
:destroyOnClose="true"
|
sanmu
authored
|
9
10
11
12
13
14
|
:isDetail="true"
@ok="handleSubmit"
:showDetailBack="false"
okText="申请"
><input />
<div>
|
sanmu
authored
|
15
16
17
18
|
<template v-if="role === ROLE.ADMIN || role === ROLE.TRACKER">
<h3>基本信息</h3>
<BasicForm @register="registerForm" />
</template>
|
sanmu
authored
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<template v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS">
<h3>利润分析</h3>
<BasicForm @register="registerProfitForm" />
</template>
<template v-if="role === ROLE.ADMIN || role === ROLE.BUSINESS">
<h3>项目报告书</h3>
<BasicForm @register="registerReportForm" />
</template>
<template v-if="role === ROLE.ADMIN || role === ROLE.TRACKER">
<h3>跟单信息</h3>
<BasicForm @register="registerTrackForm" />
</template>
<template v-if="role === ROLE.ADMIN || role === ROLE.INSPECT">
<h3>质量信息</h3>
<BasicForm @register="registryInspectForm" />
</template>
|
sanmu
authored
|
35
36
37
|
</div>
<!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
|
sanmu
authored
|
38
|
<!-- <template #appendFooter>
|
sanmu
authored
|
39
|
<a-button type="primary" @click="onGoFormDetail"> 返回编辑</a-button>
|
sanmu
authored
|
40
|
</template> -->
|
sanmu
authored
|
41
42
43
|
</BasicDrawer>
</template>
<script lang="ts">
|
sanmu
authored
|
44
|
import { computed, defineComponent, reactive, ref } from 'vue';
|
sanmu
authored
|
45
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
sanmu
authored
|
46
|
import { orderAuth } from '/@/api/project/order';
|
sanmu
authored
|
47
|
import { ROLE } from './type.d';
|
sanmu
authored
|
48
49
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
sanmu
authored
|
50
51
52
53
54
55
56
57
|
import {
FIELDS_BASE_INFO,
FIELDS_INSPECTION_INFO,
FIELDS_PROFIT_INFO,
FIELDS_REPORT_INFO,
FIELDS_TRACK_STAGE_INFO,
} from './tableData';
import { useUserStoreWithOut } from '/@/store/modules/user';
|
sanmu
authored
|
58
|
|
sanmu
authored
|
59
|
const userStore = useUserStoreWithOut();
|
sanmu
authored
|
60
|
const getSchema = (fields) =>
|
sanmu
authored
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
fields
.map((item) => ({
field: `${item.field}`,
dataIndex: `${item.field}`,
label: item.label,
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 6,
},
}))
.filter((item) => item.field !== 'packetPrice' && item.field !== 'exchangeRate');
|
sanmu
authored
|
76
77
78
79
80
81
82
83
84
85
|
export default defineComponent({
components: { BasicDrawer, BasicForm },
props: {
onGoFormDetail: {
type: Function,
},
},
setup() {
const id = ref('');
|
sanmu
authored
|
86
87
88
|
const schemas = getSchema(FIELDS_BASE_INFO);
const profitSchemas = getSchema(FIELDS_PROFIT_INFO);
const reportSchemas = getSchema(FIELDS_REPORT_INFO);
|
sanmu
authored
|
89
90
|
const inspecSchemas = getSchema(FIELDS_INSPECTION_INFO);
const trackSchemas = getSchema(FIELDS_TRACK_STAGE_INFO);
|
sanmu
authored
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
const [registerForm, { getFieldsValue }] = useForm({
labelWidth: 120,
schemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
const [registerProfitForm, { getFieldsValue: getProfitFieldsValue }] = useForm({
labelWidth: 120,
schemas: profitSchemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
|
sanmu
authored
|
107
108
109
110
111
112
113
114
|
const [registerReportForm, { getFieldsValue: getReportFieldsValue }] = useForm({
labelWidth: 120,
schemas: reportSchemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
|
sanmu
authored
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
const [registryInspectForm, { getFieldsValue: getInspectFieldsValue }] = useForm({
labelWidth: 120,
schemas: inspecSchemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
const [registerTrackForm, { getFieldsValue: getTrackFieldsValue }] = useForm({
labelWidth: 120,
schemas: trackSchemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
|
sanmu
authored
|
131
132
133
134
135
136
|
const lockFields = reactive({});
const [register, { closeDrawer }] = useDrawerInner((data) => {
Object.assign(lockFields, data.lockFields);
id.value = data.id;
});
|
sanmu
authored
|
137
138
139
140
|
const role = computed(() => {
return userStore.getUserInfo?.roleSmallVO?.code;
});
|
sanmu
authored
|
141
142
143
|
const handleSubmit = async () => {
const baseFieldValues = getFieldsValue();
const profitFieldValues = getProfitFieldsValue();
|
sanmu
authored
|
144
|
const reportFieldValues = getReportFieldsValue();
|
sanmu
authored
|
145
146
|
const inspectFieldValues = getInspectFieldsValue();
const trackFieldValues = getTrackFieldsValue();
|
sanmu
authored
|
147
|
|
sanmu
authored
|
148
149
150
151
152
153
154
|
if (baseFieldValues) {
FIELDS_BASE_INFO.map(
({ field }) =>
(baseFieldValues[field] =
baseFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
}
|
sanmu
authored
|
155
|
|
sanmu
authored
|
156
157
158
159
160
161
|
if (reportFieldValues)
FIELDS_REPORT_INFO.map(
({ field }) =>
(reportFieldValues[field] =
reportFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
|
sanmu
authored
|
162
|
|
sanmu
authored
|
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
if (profitFieldValues)
FIELDS_PROFIT_INFO.map(
({ field }) =>
(profitFieldValues[field] =
profitFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
if (trackFieldValues)
FIELDS_TRACK_STAGE_INFO.map(
({ field }) =>
(trackFieldValues[field] =
trackFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
if (inspectFieldValues)
FIELDS_INSPECTION_INFO.map(
({ field }) =>
(inspectFieldValues[field] =
inspectFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
|
sanmu
authored
|
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
207
208
209
210
|
// !isEmpty(baseFieldValues) &&
// Object.keys(baseFieldValues.baseFields)?.map((key) => {
// baseFieldValues.baseFields[key] = baseFieldValues.baseFields[key]
// ? 'UN_LOCKED'
// : 'LOCKED';
// });
// !isEmpty(profitFieldValues) &&
// Object.keys(profitFieldValues.profitAnalysisFields).map((key) => {
// profitFieldValues.profitAnalysisFields[key] = profitFieldValues.profitAnalysisFields[
// key
// ]
// ? 'UN_LOCKED'
// : 'LOCKED';
// });
// !isEmpty(reportFieldValues) &&
// Object.keys(reportFieldValues.reportFields).map((key) => {
// reportFieldValues.reportFields[key] = reportFieldValues.reportFields[key]
// ? 'UN_LOCKED'
// : 'LOCKED';
// });
const values = Object.assign(
{ orderId: id.value },
{ baseFields: baseFieldValues },
{ profitAnalysisFields: profitFieldValues },
{ reportFields: reportFieldValues },
|
sanmu
authored
|
211
212
|
{ trackStageFields: trackFieldValues },
{ inspectionStageFields: inspectFieldValues },
|
sanmu
authored
|
213
|
);
|
sanmu
authored
|
214
215
216
|
await orderAuth(values);
closeDrawer();
};
|
sanmu
authored
|
217
218
219
220
221
222
|
return {
register,
schemas,
registerForm,
registerProfitForm,
registerReportForm,
|
sanmu
authored
|
223
224
|
registryInspectForm,
registerTrackForm,
|
sanmu
authored
|
225
|
handleSubmit,
|
sanmu
authored
|
226
227
|
ROLE,
role,
|
sanmu
authored
|
228
|
};
|
sanmu
authored
|
229
230
231
|
},
});
</script>
|