柏杨
authored
|
1
2
|
<template>
<div class="p-4">
|
|
3
|
<BasicTable @register="registerTable" :pagination="{ pageSize: 20 }">
|
柏杨
authored
|
4
|
<template #toolbar>
|
柏杨
authored
|
5
6
7
8
9
10
|
<a-button
type="primary"
@click="handleCheckSum"
:style="{ borderRadius: '5px 5px 5px 5px' }"
>应付款汇总</a-button
>
|
柏杨
authored
|
11
12
13
14
15
|
<FinanceEdit @register="registerFinanceEdit" @success="handleSuccess" />
<TrackEdit @register="registerTrackEdit" @success="handleSuccess" />
<CheckSum @register="registerCheckSum" />
<InvoiceUpload @register="registerInvoiceUpload" @success="handleSuccess" />
<CheckDetail @register="registerInvoiceDetail" />
|
柏杨
authored
|
16
|
<DeductShow @register="registerDeductShow" />
|
|
17
|
<InvoiceShow @register="registerInvoiceShow" />
|
|
18
|
<Commit @register="registerCommit" @success="handleSuccess" />
|
|
19
|
<EditRefundTime @register="registerEditRefundTime" @success="handleSuccess" />
|
|
20
|
<Note @register="registerNote" @success="handleSuccess" />
|
柏杨
authored
|
21
22
23
24
|
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
|
|
25
26
27
28
29
30
|
v-if="
role == ROLE.ADMIN ||
role == ROLE.FINANCE ||
role == ROLE.TRACKER ||
role == ROLE.BUSINESS
"
|
柏杨
authored
|
31
|
:actions="[
|
|
32
33
34
35
36
37
38
39
|
...(role == ROLE.ADMIN || role == ROLE.FINANCE
? [
{
label: '财务编辑',
onClick: handleFinanceEdit.bind(null, record),
},
]
: []),
|
柏杨
authored
|
40
41
42
43
44
45
46
47
48
49
|
{
label: '跟单编辑',
onClick: handleTrackEdit.bind(null, record),
},
{
label: '发票上传',
onClick: handleInvoiceUpload.bind(null, record),
},
]"
:dropDownActions="[
|
|
50
51
52
53
54
55
56
57
|
...(role == ROLE.ADMIN || role == ROLE.FINANCE
? [
{
label: '提交审核',
onClick: handleCommit.bind(null, record),
},
]
: []),
|
柏杨
authored
|
58
59
|
{
label: '订单信息',
|
柏杨
authored
|
60
61
62
63
|
onClick: handleDetail.bind(null, record),
},
{
label: '删除',
|
|
64
65
66
67
68
69
|
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
// onClick: handleDelete.bind(null, record),
|
柏杨
authored
|
70
|
},
|
柏杨
authored
|
71
72
73
74
75
76
77
78
|
{
label: '生产科发票',
onClick: handleInvoiceShow.bind(null, record),
},
{
label: '扣款单',
onClick: handleDeductShow.bind(null, record),
},
|
|
79
80
81
82
83
84
85
86
|
...(role == ROLE.ADMIN
? [
{
label: '修改应付款日期',
onClick: handleEditRefundTime.bind(null, record),
},
]
: []),
|
|
87
88
89
90
|
{
label: '添加备注',
onClick: handleNote.bind(null, record),
},
|
柏杨
authored
|
91
92
|
]"
/>
|
|
93
94
95
96
97
98
99
100
101
102
103
104
105
|
<TableAction
v-if="role == ROLE.PRODUCE"
:actions="[
{
label: '发票上传',
onClick: handleInvoiceUpload.bind(null, record),
},
{
label: '生产科发票',
onClick: handleInvoiceShow.bind(null, record),
},
]"
/>
|
柏杨
authored
|
106
107
108
109
110
111
|
</template>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup>
|
|
112
|
import { computed, defineComponent, ref } from 'vue';
|
柏杨
authored
|
113
114
115
116
117
|
import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
import { searchFormSchema, columns } from './pay.data';
import TrackEdit from './TrackEdit.vue';
import FinanceEdit from './FinanceEdit.vue';
import InvoiceUpload from './InvoiceUpload.vue';
|
柏杨
authored
|
118
119
|
import CheckDetail from './CheckDetail.vue';
import CheckSum from './CheckSum.vue';
|
柏杨
authored
|
120
|
import DeductShow from './DeductShow.vue';
|
|
121
|
import InvoiceShow from './InvoiceShow.vue';
|
|
122
|
import Commit from './Commit.vue';
|
|
123
|
import EditRefundTime from './EditRefundTime.vue';
|
|
124
|
import Note from './Note.vue';
|
柏杨
authored
|
125
126
|
import { useDrawer } from '/@/components/Drawer';
import { useModal } from '/@/components/Modal';
|
柏杨
authored
|
127
128
|
import { getCheck, checkDelete, checkCommit, checkDetail } from '@/api/project/invoice';
import { useMessage } from '/@/hooks/web/useMessage';
|
|
129
|
import { ROLE } from './type.d';
|
|
130
|
import { getOrderList } from '/@/api/project/order';
|
|
131
|
import { useUserStoreWithOut } from '/@/store/modules/user';
|
柏杨
authored
|
132
|
|
柏杨
authored
|
133
|
const [registerCheckSum, { openModal: openCheckSum }] = useModal();
|
柏杨
authored
|
134
135
136
|
const [registerFinanceEdit, { openDrawer: openFinanceEdit }] = useDrawer();
const [registerTrackEdit, { openDrawer: openTrackEdit }] = useDrawer();
const [registerInvoiceUpload, { openModal: openInvoiceUpload }] = useModal();
|
柏杨
authored
|
137
|
const [registerDeductShow, { openModal: openDeductShow }] = useModal();
|
|
138
|
const [registerCommit, { openModal: openCommit }] = useModal();
|
|
139
|
const [registerEditRefundTime, { openModal: openEditRefundTime }] = useModal();
|
|
140
|
const [registerInvoiceShow, { openModal: openInvoiceShow }] = useModal();
|
|
141
|
const [registerNote, { openModal: openNote }] = useModal();
|
柏杨
authored
|
142
|
const [registerInvoiceDetail, { openDrawer: openCheckDetail }] = useDrawer();
|
|
143
144
145
146
147
|
const userStore = useUserStoreWithOut();
const user = userStore.getUserInfo;
const role = computed(() => {
return user?.roleSmallVO?.code;
});
|
柏杨
authored
|
148
|
const checkedKeys = ref<Array<string | number>>([]);
|
|
149
150
151
152
153
154
|
// 添加分页状态
const pagination = ref({
current: 1, // 当前页
pageSize: 10, // 每页条数
total: 0, // 数据总数
});
|
柏杨
authored
|
155
|
const [registerTable, { reload }] = useTable({
|
柏杨
authored
|
156
|
title: '',
|
柏杨
authored
|
157
|
api: getCheck,
|
柏杨
authored
|
158
159
|
columns: columns,
bordered: true,
|
柏杨
authored
|
160
|
clickToRowSelect: false,
|
柏杨
authored
|
161
|
rowKey: 'id',
|
|
162
|
pagination: {
|
|
163
|
pageSize: 10,
|
|
164
|
},
|
柏杨
authored
|
165
166
|
rowSelection: {
type: 'checkbox',
|
柏杨
authored
|
167
168
169
|
selectedRowKeys: checkedKeys,
onSelect,
onSelectAll,
|
柏杨
authored
|
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
},
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
},
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
tableSetting: {
setting: false,
},
actionColumn: {
width: 260,
title: 'Action',
dataIndex: 'action',
// slots: { customRender: 'action' },
},
});
|
柏杨
authored
|
189
|
//选择算法:创建二维数组,使客户编码和生产科相同
|
柏杨
authored
|
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
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
325
326
|
type CustomerCodeEntry = [string, number]; // 定义二维数组类型 [customerCode, count]
type ProductionDepartmentEntry = [string, number]; // 定义二维数组类型 [productionDepartment, count]
const selectedCustomCodes = ref<CustomerCodeEntry[]>([]); // 创建一个二维数组的 ref
const selectedProductionDepartment = ref<ProductionDepartmentEntry[]>([]); // 创建一个二维数组的 ref
// const checkedKeys = ref<string[]>([]); // 选中的键值列表
// 单选函数
async function onSelect(record, selected: boolean) {
const res = await checkDetail({ checkNo: record.checkNo });
const customerCode = res[0].customerCode;
const productionDepartment = res[0].productionDepartment;
const customerCodeIndex = selectedCustomCodes.value.findIndex(
([code]) => code === customerCode,
);
const productionDepartmentIndex = selectedProductionDepartment.value.findIndex(
([department]) => department === productionDepartment,
);
if (selected) {
checkedKeys.value = [...checkedKeys.value, record.id];
// 更新 selectedCustomCodes
if (customerCodeIndex !== -1) {
selectedCustomCodes.value[customerCodeIndex][1] += 1;
} else {
selectedCustomCodes.value.push([customerCode, 1]);
}
// 更新 selectedProductionDepartment
if (productionDepartmentIndex !== -1) {
selectedProductionDepartment.value[productionDepartmentIndex][1] += 1;
} else {
selectedProductionDepartment.value.push([productionDepartment, 1]);
}
} else {
checkedKeys.value = checkedKeys.value.filter((id) => id !== record.id);
// 更新 selectedCustomCodes
if (customerCodeIndex !== -1) {
if (selectedCustomCodes.value[customerCodeIndex][1] > 1) {
selectedCustomCodes.value[customerCodeIndex][1] -= 1;
} else {
selectedCustomCodes.value.splice(customerCodeIndex, 1);
}
}
// 更新 selectedProductionDepartment
if (productionDepartmentIndex !== -1) {
if (selectedProductionDepartment.value[productionDepartmentIndex][1] > 1) {
selectedProductionDepartment.value[productionDepartmentIndex][1] -= 1;
} else {
selectedProductionDepartment.value.splice(productionDepartmentIndex, 1);
}
}
}
}
// 全选函数
async function onSelectAll(selected: boolean, selectedRows: any[], changeRows: any[]) {
const changeIds = changeRows.map((item) => item.id);
const changeCustomerCodes = await Promise.all(
changeRows.map(async (item) => {
const res = await checkDetail({ checkNo: item.checkNo });
return res[0].customerCode;
}),
);
const changeProductionDepartments = await Promise.all(
changeRows.map(async (item) => {
const res = await checkDetail({ checkNo: item.checkNo });
return res[0].productionDepartment;
}),
);
if (selected) {
checkedKeys.value = [...checkedKeys.value, ...changeIds];
// 更新 selectedCustomCodes
changeCustomerCodes.forEach((code) => {
const index = selectedCustomCodes.value.findIndex(
([customerCode]) => customerCode === code,
);
if (index !== -1) {
selectedCustomCodes.value[index][1] += 1;
} else {
selectedCustomCodes.value.push([code, 1]);
}
});
// 更新 selectedProductionDepartment
changeProductionDepartments.forEach((department) => {
const index = selectedProductionDepartment.value.findIndex(
([prodDepartment]) => prodDepartment === department,
);
if (index !== -1) {
selectedProductionDepartment.value[index][1] += 1;
} else {
selectedProductionDepartment.value.push([department, 1]);
}
});
} else {
checkedKeys.value = checkedKeys.value.filter((id) => !changeIds.includes(id));
// 更新 selectedCustomCodes
changeCustomerCodes.forEach((code) => {
const index = selectedCustomCodes.value.findIndex(
([customerCode]) => customerCode === code,
);
if (index !== -1) {
if (selectedCustomCodes.value[index][1] > 1) {
selectedCustomCodes.value[index][1] -= 1;
} else {
selectedCustomCodes.value.splice(index, 1);
}
}
});
// 更新 selectedProductionDepartment
changeProductionDepartments.forEach((department) => {
const index = selectedProductionDepartment.value.findIndex(
([prodDepartment]) => prodDepartment === department,
);
if (index !== -1) {
if (selectedProductionDepartment.value[index][1] > 1) {
selectedProductionDepartment.value[index][1] -= 1;
} else {
selectedProductionDepartment.value.splice(index, 1);
}
}
});
}
}
|
柏杨
authored
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
function handleFinanceEdit(record) {
openFinanceEdit(true, {
data: record,
});
}
function handleTrackEdit(record) {
openTrackEdit(true, {
data: record,
});
}
function handleInvoiceUpload(record) {
openInvoiceUpload(true, {
data: record,
});
}
function handleDelete(record) {
|
柏杨
authored
|
343
344
345
346
347
348
|
const id: string[] = Array.isArray(record.id) ? record.id : [record.id];
checkDelete({ ids: id });
setTimeout(() => {
reload();
}, 50);
}
|
柏杨
authored
|
349
|
function handleInvoiceShow(record) {
|
|
350
351
352
|
openInvoiceShow(true, {
data: record,
});
|
柏杨
authored
|
353
|
}
|
|
354
355
356
357
358
|
function handleNote(record) {
openNote(true, {
data: record,
});
}
|
柏杨
authored
|
359
360
|
function handleDeductShow(record) {
openDeductShow(true, {
|
柏杨
authored
|
361
|
data: record,
|
柏杨
authored
|
362
363
|
});
}
|
柏杨
authored
|
364
365
|
function handleDetail(record) {
openCheckDetail(true, {
|
柏杨
authored
|
366
367
368
|
data: record,
});
}
|
柏杨
authored
|
369
|
function handleCommit(record) {
|
|
370
371
372
373
374
375
376
377
378
379
380
|
// const currentDate: string = (() => {
// const date = new Date();
// const year = date.getFullYear();
// const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始
// const day = String(date.getDate()).padStart(2, '0');
// return `${year}-${month}-${day}`;
// })();
// checkCommit({ id: record.id, actualPayedDate: currentDate });
openCommit(true, {
data: record,
});
|
柏杨
authored
|
381
|
}
|
|
382
383
384
385
386
387
388
389
390
391
392
393
394
|
function handleEditRefundTime(record) {
// const currentDate: string = (() => {
// const date = new Date();
// const year = date.getFullYear();
// const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始
// const day = String(date.getDate()).padStart(2, '0');
// return `${year}-${month}-${day}`;
// })();
// checkCommit({ id: record.id, actualPayedDate: currentDate });
openEditRefundTime(true, {
data: record,
});
}
|
柏杨
authored
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
const { createMessage } = useMessage();
const { error } = createMessage;
function handleCheckSum(record) {
if (checkedKeys.value.length == 0) {
error('请选择订单');
return;
}
if (selectedProductionDepartment.value.length > 1) {
error('勾选订单的生产科需一致');
return;
}
openCheckSum(true, {
data: checkedKeys.value,
});
}
function handleSuccess() {
setTimeout(() => {
reload();
}, 150);
}
|
柏杨
authored
|
416
|
</script>
|