ProduceFieldPanel.vue
6.46 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
<BasicTable @register="registerTable" className="p-0">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '详情',
// icon: 'ic:outline-delete-outline',
onClick: handleDetail.bind(null, record),
},
]"
/>
</template>
</template>
</BasicTable>
<BasicDrawer
width="500"
:showFooter="!isApproved && (role === ROLE.ADMIN || role === ROLE.BUSINESS)"
@register="registerDrawer"
title="申请信息"
okText="通过"
@ok="handleTrue"
:showOkBtn="!isApproved && role === ROLE.ADMIN"
>
<BaseInfo :baseInfos="baseInfos" />
<h2 style="margin-top: 20px">申请字段</h2>
<div>{{ fieldInfos.baseFields.join(' , ') }}</div>
<template #appendFooter>
<a-button @click="handleFalse" v-if="!isApproved && role === ROLE.ADMIN"> 不通过</a-button>
</template>
</BasicDrawer>
<MsgModal v-if="msgVisible" @msg-modal-close="handleMsgModalClose" />
</template>
<script lang="ts">
import MsgModal from './MsgModal.vue';
import { computed, defineComponent, ref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { BasicDrawer, useDrawer } from '/@/components/Drawer';
import { approveAuditApi, getApprovedListApi, getWaitListApi } from '/@/api/project/approve';
import { COLUMNS } from '../finance/financeProfit/ServiceProfit/PackageProfit/data';
import { getAuditApply, getApplyList } from '/@/api/project/invoice';
import { EDIT_INFO } from '../finance/financeProfit/ProductProfit/InnerData/tableData';
import { find, isEmpty } from 'lodash-es';
import { ROLE } from '../order//type.d';
import { useUserStoreWithOut } from '/@/store/modules/user';
import BaseInfo from './BaseInfo.vue';
import { createImgPreview } from '/@/components/Preview';
import { getFormConfig } from './data';
import { FIELDS_BASE_INFO } from '../order/tableData';
const userStore = useUserStoreWithOut();
export default defineComponent({
components: {
BasicTable,
BasicDrawer,
TableAction,
BaseInfo,
MsgModal,
},
props: {
isApproved: { type: Boolean },
},
setup(props) {
// visible 用于msgModal显示隐藏
const msgVisible = ref(false);
const checkedKeys = ref<Array<string | number>>([]);
const currentKey = ref('1');
const [registerDrawer, { openDrawer, closeDrawer }] = useDrawer();
const fieldInfos = ref({
baseFields: [],
});
const baseInfos = ref({});
const id = ref('');
let columns = [
{
title: '申请人',
dataIndex: 'createBy',
width: 150,
},
{
title: '审核字段类型',
dataIndex: 'auditRoleCodes',
width: 150,
customRender: (column) => {
return column.record.type === 60 ? '包装费用字段' : '内部生产费用字段';
},
},
{
title: '内部编号',
dataIndex: 'innerNo',
width: 150,
customRender: (column) => {
return column.record.orderBaseInfo?.innerNo || '-';
},
},
{
title: '项目号',
dataIndex: 'projectNo',
width: 150,
customRender: (column) => {
return column.record.orderBaseInfo?.projectNo || '-';
},
},
{
title: '申请原因',
dataIndex: 'applyRemark',
width: 150,
},
];
if (props.isApproved) {
columns = columns.concat([
{
title: '状态',
dataIndex: 'status',
width: 150,
customRender: (column) => {
const { record } = column || {};
return record.status === 10 ? '通过' : '拒绝';
},
},
{ title: '拒绝原因', dataIndex: 'refuseRemark', width: 250 },
]);
}
const [registerTable, { reload }] = useTable({
scroll: false,
api: props.isApproved ? getApprovedListApi : getWaitListApi,
searchInfo: { typeIn: [60, 70] },
columns,
useSearchForm: false,
formConfig: getFormConfig('true'),
rowKey: 'id',
actionColumn: {
width: 160,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
function handleEdit(record, e) {
e?.stopPropagation();
return false;
}
function handleProfitModal() {}
async function handleDetail(data) {
id.value = data.id;
fieldInfos.value = {
baseFields: [],
};
openDrawer(true, { data });
!isEmpty(data.fieldInfos.costInfolockFieldVO) &&
Object.entries(data.fieldInfos.costInfolockFieldVO)?.map(([key, value]) => {
if (value === 'UN_LOCKED') {
const obj = find(EDIT_INFO, { field: key });
fieldInfos.value.baseFields.push(obj?.label);
}
});
baseInfos.value = FIELDS_BASE_INFO.map((field) => {
return {
label: field.label,
value: data.orderBaseInfo[field.field],
};
}).filter((item) => !!item.value);
}
async function handleTrue() {
await approveAuditApi({ status: 10, id: id.value });
reload();
closeDrawer();
}
async function handleFalse() {
msgVisible.value = true;
}
const role = computed(() => {
return userStore.getUserInfo?.roleSmallVO?.code;
});
// 定义MsgModalClose的事件,方便子组件调用
const handleMsgModalClose = async (data) => {
if (data) {
await approveAuditApi({ status: 20, id: id.value, refuseRemark: data });
reload();
closeDrawer();
}
msgVisible.value = false;
};
const handlePreview = (url) => {
createImgPreview({ imageList: [url], defaultWidth: 500 });
return false;
};
return {
handleProfitModal,
registerTable,
checkedKeys,
currentKey,
handleEdit,
handleDetail,
registerDrawer,
fieldInfos,
baseInfos,
handleTrue,
handleFalse,
ROLE,
role,
msgVisible,
handleMsgModalClose,
handlePreview,
};
},
});
</script>