PayPanel.vue
7.39 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<template>
<BasicTable @register="registerTable" className="p-0">
<template #form-custom> custom-slot </template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'picUrl'">
<img
:width="50"
:height="50"
:src="record?.orderBaseInfo?.smallPicUrl"
@click="handlePreview(record?.orderBaseInfo?.picUrl)"
/>
</template>
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
label: '编辑',
// icon: 'ic:outline-delete-outline',
onClick: handleDetail.bind(null, record),
},
]"
/>
</template>
</template>
</BasicTable>
<BasicModal
:showFooter="!isApproved && role === ROLE.ADMIN"
@register="registerModal"
title="申请信息"
okText="通过"
@ok="handleTrue"
>
<Description
class="mt-4"
layout="vertical"
:collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
:column="2"
:data="mockData"
:schema="schema"
/>
<template #appendFooter>
<a-button @click="handleFalse"> 不通过</a-button>
</template>
</BasicModal>
<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 { BasicModal, useModal } from '/@/components/Modal';
import { approveAuditApi, getApprovedListApi, getWaitListApi } from '/@/api/project/approve';
import { FIELDS_BASE_INFO, FIELDS_PROFIT_INFO, FIELDS_REPORT_INFO } from '../order/tableData';
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 { Description, DescItem, useDescription } from '@/components/Description';
const userStore = useUserStoreWithOut();
export default defineComponent({
components: {
BasicTable,
BasicModal,
TableAction,
Description,
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 [registerModal, { openModal, closeModal }] = useModal();
const fieldInfos = ref({});
const baseInfos = ref({});
const id = ref('');
const mockData = ref();
const schema: DescItem[] = [
{
field: 'actualReceivableAmount',
label: '生产科实际应付金额汇总',
},
{
field: 'all',
label: '生产科付款日期',
},
{
field: 'deductAmount',
label: '实际付款日期',
},
{
field: 'productionDepartmentTotalPrice',
label: '生产科总金额汇总',
},
{
field: 'actualPayedAmount',
label: '实际付款金额汇总',
},
{
field: 'actualReceivableAmount',
label: '生产科扣款金额汇总',
},
];
// const [register] = useDescription({
// title: 'useDescription',
// data: mockData,
// schema: schema,
// });
let columns = [
{
title: '申请人',
dataIndex: 'createBy',
width: 150,
},
{
title: '内部编号',
dataIndex: 'innerNo',
width: 150,
customRender: (column) => {
const { record } = column || {};
console.log(record, '56565repro');
return record?.fieldInfos?.invoiceBillOrderDO?.innerNo;
},
},
{
title: '审核类型',
dataIndex: 'productionDepartment',
width: 150,
},
{
title: '生产科',
dataIndex: 'productionDepartment',
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({
api: props.isApproved ? getApprovedListApi : getWaitListApi,
searchInfo: { type: 40 },
// scroll: {
// scrollToFirstRowOnChange: true,
// },
columns,
useSearchForm: true,
formConfig: getFormConfig(),
rowKey: 'id',
actionColumn: {
width: 160,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
function onSelect(record, selected) {
if (selected) {
checkedKeys.value = [...checkedKeys.value, record.id];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
}
}
function onSelectAll(selected, selectedRows, changeRows) {
const changeIds = changeRows.map((item) => item.id);
if (selected) {
checkedKeys.value = [...checkedKeys.value, ...changeIds];
} else {
checkedKeys.value = checkedKeys.value.filter((id) => {
return !changeIds.includes(id);
});
}
}
function handleEdit(record, e) {
e?.stopPropagation();
return false;
}
function handleProfitModal() {}
async function handleDetail(data) {
openModal(true, { data });
mockData.value = data.fieldInfos.invoiceBillOrderDO;
console.log(mockData.value, 5656);
id.value = data.id;
}
async function handleTrue() {
await approveAuditApi({ status: 10, id: id.value });
reload();
closeModal();
}
async function handleFalse() {
msgVisible.value = true;
// await approveAuditApi({ status: 20, id: id.value });
// reload();
// closeModal();
}
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();
closeModal();
}
msgVisible.value = false;
};
const handlePreview = (url) => {
createImgPreview({ imageList: [url], defaultWidth: 500 });
return false;
};
return {
handleProfitModal,
registerTable,
checkedKeys,
currentKey,
onSelect,
handleEdit,
onSelectAll,
handleDetail,
registerModal,
fieldInfos,
baseInfos,
handleTrue,
handleFalse,
role,
ROLE,
msgVisible,
handleMsgModalClose,
handlePreview,
mockData,
schema,
};
},
});
</script>