CheckDetail.vue
4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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
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
155
156
157
158
<template>
<BasicDrawer
@register="register"
v-bind="$attrs"
showFooter
title="字段编辑权限申请"
width="60%"
:isDetail="true"
@ok="handleSubmit"
:showDetailBack="false"
okText="申请"
><input />
<div>
<h3>基本信息</h3>
<BasicForm @register="registerForm" />
<h3>利润分析</h3>
<BasicForm @register="registerProfitForm" />
<h3>项目报告书</h3>
<BasicForm @register="registerReportForm" />
</div>
<!-- <template #titleToolbar> <a-button type="primary"> 申请编辑权限 </a-button></template> -->
<!-- <template #appendFooter>
<a-button type="primary" @click="onGoFormDetail"> 返回编辑</a-button>
</template> -->
</BasicDrawer>
</template>
<script lang="ts">
import { defineComponent, reactive, ref } from 'vue';
import { BasicForm, useForm } from '/@/components/Form/index';
import { orderAuth } from '/@/api/project/order';
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO, FIELDS_REPORT_INFO } from './tableData';
const getSchema = (fields) =>
fields.map((item) => ({
field: `${item.field}`,
dataIndex: `${item.field}`,
label: item.label,
component: 'Switch',
componentProps: {
checkedValue: 'UN_LOCKED',
unCheckedValue: 'LOCKED',
},
colProps: {
span: 6,
},
}));
export default defineComponent({
components: { BasicDrawer, BasicForm },
props: {
onGoFormDetail: {
type: Function,
},
},
setup() {
const id = ref('');
const schemas = getSchema(FIELDS_BASE_INFO);
const profitSchemas = getSchema(FIELDS_PROFIT_INFO);
const reportSchemas = getSchema(FIELDS_REPORT_INFO);
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,
},
});
const [registerReportForm, { getFieldsValue: getReportFieldsValue }] = useForm({
labelWidth: 120,
schemas: reportSchemas,
showActionButtonGroup: false,
actionColOptions: {
span: 24,
},
});
const lockFields = reactive({});
const [register, { closeDrawer }] = useDrawerInner((data) => {
Object.assign(lockFields, data.lockFields);
id.value = data.id;
});
const handleSubmit = async () => {
const baseFieldValues = getFieldsValue();
const profitFieldValues = getProfitFieldsValue();
const reportFieldValues = getReportFieldsValue();
FIELDS_BASE_INFO.map(
({ field }) =>
(baseFieldValues[field] =
baseFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
FIELDS_REPORT_INFO.map(
({ field }) =>
(reportFieldValues[field] =
reportFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
FIELDS_PROFIT_INFO.map(
({ field }) =>
(profitFieldValues[field] =
profitFieldValues[field] === 'UN_LOCKED' ? 'UN_LOCKED' : 'LOCKED'),
);
// !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 },
);
await orderAuth(values);
closeDrawer();
};
return {
register,
schemas,
registerForm,
registerProfitForm,
registerReportForm,
handleSubmit,
};
},
});
</script>