柏杨
authored
|
1
2
3
4
5
6
7
8
|
<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"
|
|
9
10
|
:src="record?.producePaymentCheckBillFieldVO?.smallPicUrl"
@click="handlePreview(record?.producePaymentCheckBillFieldVO?.picUrl)"
|
柏杨
authored
|
11
12
13
14
|
/>
</template>
<template v-if="column.key === 'action'">
<TableAction
|
柏杨
authored
|
15
|
v-if="!isApproved"
|
柏杨
authored
|
16
17
|
:actions="[
{
|
|
18
|
label: '审核',
|
柏杨
authored
|
19
20
21
22
23
|
// icon: 'ic:outline-delete-outline',
onClick: handleDetail.bind(null, record),
},
]"
/>
|
柏杨
authored
|
24
25
26
27
28
29
30
31
32
33
|
<TableAction
v-if="isApproved"
:actions="[
{
label: '详情',
// icon: 'ic:outline-delete-outline',
onClick: handleDetail.bind(null, record),
},
]"
/>
|
柏杨
authored
|
34
35
36
|
</template>
</template>
</BasicTable>
|
柏杨
authored
|
37
38
|
<!-- :showFooter="!isApproved && role === ROLE.ADMIN" -->
|
柏杨
authored
|
39
|
<BasicModal
|
|
40
|
:formFooter="(!isApproved && role === ROLE.ADMIN) || showInvoice"
|
柏杨
authored
|
41
42
43
|
@register="registerModal"
title="申请信息"
okText="通过"
|
|
44
|
width="900px"
|
柏杨
authored
|
45
|
@ok="handleTrue"
|
|
46
|
@visible-change="handleShow"
|
|
47
48
|
:showCancelBtn="(!isApproved && role === ROLE.ADMIN) || (showInvoice && role === ROLE.FINANCE)"
:showOkBtn="(!isApproved && role === ROLE.ADMIN) || (showInvoice && role === ROLE.FINANCE)"
|
柏杨
authored
|
49
|
>
|
|
50
|
<!-- <Description
|
|
51
|
v-if="!showInvoice"
|
柏杨
authored
|
52
53
54
55
56
57
|
class="mt-4"
layout="vertical"
:collapseOptions="{ canExpand: true, helpMessage: 'help me' }"
:column="2"
:data="mockData"
:schema="schema"
|
|
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
|
/> -->
<table
v-if="!showInvoice"
style="
width: 100%;
border-collapse: collapse;
text-align: center;
border: 1px solid black;
font-size: 16px;
"
>
<thead>
<!-- <tr>
<th colspan="4" style="border: 1px solid black">净利润分析表</th>
</tr> -->
</thead>
<tbody>
<tr
><td colspan="7" style="text-align: center; font-weight: bold; font-size: 24px"
>付款单</td
></tr
>
<tr>
<td style="border: 1px solid black; width: 14%">生产科对账单号</td>
<td style="border: 1px solid black; width: 14%">实际应付金额</td>
<td style="border: 1px solid black; width: 14%">扣款金额</td>
<td style="border: 1px solid black; width: 14%">实际付款金额</td>
<td style="border: 1px solid black; width: 14%">未付金额</td>
<td style="border: 1px solid black; width: 14%">必须付款日期</td>
<td style="border: 1px solid black; width: 14%">实际付款日期</td>
</tr>
<tr>
<td style="border: 1px solid black; width: 14%">{{ checkNo }}</td>
<td style="border: 1px solid black; width: 14%">¥{{ actualPayedAmount }}</td>
<td style="border: 1px solid black; width: 14%">¥{{ deductAmount }}</td>
<td style="border: 1px solid black; width: 14%">¥{{ totalActualPayedAmount }}</td>
<td style="border: 1px solid black; width: 14%">¥{{ unPayedAmount }}</td>
<td style="border: 1px solid black; width: 14%">{{ payedDate }}</td>
<td style="border: 1px solid black; width: 14%">{{ actualPayedDate }}</td>
</tr>
</tbody>
</table>
|
|
100
|
<a v-if="showInvoice" @click="openPic(mockData.invoiceUrl)" rel="noopener noreferrer">{{
|
|
101
102
103
104
105
106
107
108
109
110
111
112
113
|
mockData.invoiceName
}}</a>
<!-- <a-list item-layout="horizontal" :data-source="itemArray">
<template #renderItem="{ item }">
<a-list-item>
<a-list-item-meta>
<template #title>
<a :href="item.url" target="_blank" rel="noopener noreferrer">{{ item.name }}</a>
</template>
</a-list-item-meta>
</a-list-item>
</template>
</a-list> -->
|
柏杨
authored
|
114
|
<template #appendFooter>
|
|
115
|
<a-button
|
|
116
|
v-if="
|
|
117
|
(!isApproved && (role === ROLE.ADMIN || role === ROLE.FINANCE)) ||
|
|
118
|
(!isApproved && showInvoice && role === ROLE.FINANCE)
|
|
119
|
"
|
|
120
121
122
123
124
|
@click="handleFalse"
>
不通过</a-button
>
<a-button
|
|
125
126
127
128
|
v-if="
(isApproved && role === ROLE.ADMIN) ||
(isApproved && showInvoice && role === ROLE.FINANCE)
"
|
|
129
130
131
132
|
@click="handleFalse"
>
驳回重填</a-button
>
|
|
133
|
<a-button @click="handleExport"> 导出</a-button>
|
柏杨
authored
|
134
135
136
137
138
139
140
141
142
|
</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';
|
|
143
144
145
|
import { getExportReceipt } from '@/api/project/invoice';
import { view } from '@/utils/pdfShow';
import axios from 'axios';
|
柏杨
authored
|
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
|
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('');
|
|
179
|
const showInvoice = ref(false);
|
柏杨
authored
|
180
181
|
const mockData = ref();
|
|
182
183
184
185
186
|
interface Item {
name: string;
url: string;
}
const itemArray = ref<Item[]>([]);
|
柏杨
authored
|
187
|
const actualPayCalculate = ref(0);
|
|
188
189
190
191
192
193
194
|
const checkNo = ref();
const actualPayedAmount = ref(); // 生产科实际应付金额汇总
const payedDate = ref(); // 生产科付款日期
const actualPayedDate = ref(); // 实际付款日期
const unPayedAmount = ref(); // 未付金额
const totalActualPayedAmount = ref(); // 实际付款金额汇总
const deductAmount = ref(); // 生产科扣款金额汇总
|
|
195
196
197
|
const projectNo = ref(); // 生产科扣款金额汇总
const status = ref(); // 生产科扣款金额汇总
const type = ref(); // 生产科扣款金额汇总
|
|
198
199
|
const financePerson = ref('');
const trackerUser = ref('');
|
柏杨
authored
|
200
|
const schema = [
|
柏杨
authored
|
201
|
{
|
柏杨
authored
|
202
|
field: 'actualPayedAmount',
|
柏杨
authored
|
203
204
205
|
label: '生产科实际应付金额汇总',
},
{
|
柏杨
authored
|
206
|
field: 'payedDate',
|
柏杨
authored
|
207
208
209
|
label: '生产科付款日期',
},
{
|
柏杨
authored
|
210
|
field: 'actualPayedDate',
|
柏杨
authored
|
211
212
213
|
label: '实际付款日期',
},
{
|
|
214
215
|
field: 'unPayedAmount',
label: '未付金额',
|
柏杨
authored
|
216
217
|
},
{
|
柏杨
authored
|
218
|
field: 'totalActualPayedAmount',
|
柏杨
authored
|
219
220
221
|
label: '实际付款金额汇总',
},
{
|
柏杨
authored
|
222
|
field: 'deductAmount',
|
柏杨
authored
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
label: '生产科扣款金额汇总',
},
];
// const [register] = useDescription({
// title: 'useDescription',
// data: mockData,
// schema: schema,
// });
let columns = [
{
title: '申请人',
dataIndex: 'createBy',
width: 150,
|
|
237
238
|
customRender: (column) => {
const { record } = column || {};
|
|
239
|
const data = ref();
|
|
240
|
if (record?.type === 40) {
|
|
241
|
data.value = record?.fieldInfos?.producePaymentCheckBillFieldVO;
|
|
242
|
} else if (record?.type == 50) {
|
|
243
|
data.value = record?.fieldInfos?.checkBillVO;
|
|
244
245
246
247
248
|
}
if (record?.type === 40) {
return data.value?.financePerson;
} else if (record?.type == 50) {
return record.createBy;
|
|
249
250
|
}
},
|
柏杨
authored
|
251
252
|
},
{
|
柏杨
authored
|
253
254
|
title: '内部编号',
dataIndex: 'innerNo',
|
柏杨
authored
|
255
256
257
|
width: 150,
customRender: (column) => {
const { record } = column || {};
|
|
258
259
260
261
262
263
|
const data = ref();
if (record?.type === 40) {
data.value = record?.fieldInfos?.producePaymentCheckBillFieldVO;
const extractedValues = ref<string[]>(data.value?.innerNo.map((item) => item));
return extractedValues.value.join(',');
} else if (record?.type == 50) {
|
|
264
|
return record?.fieldInfos?.checkBillVO?.innerNo;
|
|
265
266
|
}else if (record?.type == 70) {
return record?.fieldInfos?.deductionUrlFieldVO?.innerNo;
|
|
267
|
}
|
柏杨
authored
|
268
269
270
|
},
},
{
|
柏杨
authored
|
271
272
273
|
title: '审核类型',
dataIndex: 'productionDepartment',
width: 150,
|
柏杨
authored
|
274
275
276
|
customRender: (column) => {
const { record } = column || {};
if (record?.type === 40) {
|
|
277
|
return '应付账单申请';
|
柏杨
authored
|
278
|
} else if (record?.type == 50) {
|
|
279
|
return '生产科发票申请';
|
|
280
281
|
}else if (record?.type == 70) {
return `生产科扣款单申请${record?.fieldInfos?.deductionUrlFieldVO?.deductAmount ? `(¥${record?.fieldInfos?.deductionUrlFieldVO?.deductAmount?.toFixed(2)})` : ''}`;
|
柏杨
authored
|
282
283
|
}
},
|
柏杨
authored
|
284
285
|
},
{
|
柏杨
authored
|
286
|
title: '生产科',
|
|
287
|
dataIndex: 'productionName',
|
柏杨
authored
|
288
|
width: 150,
|
柏杨
authored
|
289
290
|
customRender: (column) => {
const { record } = column || {};
|
|
291
292
293
294
|
const data = ref();
if (record?.type === 40) {
data.value = record?.fieldInfos?.producePaymentCheckBillFieldVO;
} else if (record?.type == 50) {
|
|
295
|
data.value = record?.fieldInfos?.checkBillVO;
|
|
296
297
|
} else if (record?.type == 70) {
data.value = record?.fieldInfos?.deductionUrlFieldVO;
|
|
298
299
|
}
return data.value?.productionName;
|
柏杨
authored
|
300
|
},
|
柏杨
authored
|
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
},
];
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,
|
|
322
|
searchInfo: { type: 4050 },
|
柏杨
authored
|
323
324
325
326
327
|
// scroll: {
// scrollToFirstRowOnChange: true,
// },
columns,
useSearchForm: true,
|
|
328
|
formConfig: getFormConfig('checkNo'),
|
柏杨
authored
|
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
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) {
|
|
362
|
if (data.type == 50 ) {
|
|
363
|
showInvoice.value = true;
|
|
364
|
mockData.value = data.fieldInfos.checkBillVO;
|
|
365
366
|
} else if (data.type == 40) {
showInvoice.value = false;
|
|
367
|
mockData.value = data.fieldInfos.producePaymentCheckBillFieldVO;
|
|
368
369
|
financePerson.value = mockData.value?.financePerson;
trackerUser.value = mockData.value?.trackerUser;
|
|
370
371
372
373
|
}else if(data.type == 70){
showInvoice.value = true;
mockData.value = data.fieldInfos.deductionUrlFieldVO;
mockData.value.invoiceUrl = mockData.value.deductUrl;
|
|
374
|
}
|
柏杨
authored
|
375
|
openModal(true, { data });
|
|
376
|
id.value = data.id;
|
|
377
|
itemArray.value = [];
|
|
378
379
|
actualPayCalculate.value = mockData.value?.actualPayCalculate?.toFixed(2); // 实际付款金额计算
checkNo.value = mockData.value?.checkNo; // 对账单号
|
|
380
381
382
|
projectNo.value = mockData.value?.projectNo; // 对账单号
status.value = data?.status; // 对账单号
type.value = data?.type; // 对账单号
|
|
383
384
385
386
387
388
389
390
|
actualPayedAmount.value = mockData.value?.actualPayedAmount?.toFixed(2); // 实际应付金额
payedDate.value = mockData.value?.payedDate; // 付款日期
// actualPayedDate.value = mockData.value?.actualPayedDate; // 实际付款日期
actualPayedDate.value = ''; // 实际付款日期
unPayedAmount.value = mockData.value?.unPayedAmount?.toFixed(2); // 未付金额
totalActualPayedAmount.value = mockData.value?.totalActualPayedAmount?.toFixed(2); // 实际付款金额汇总
deductAmount.value = mockData.value?.deductAmount?.toFixed(2); // 扣款金额
const match = mockData.value?.invoiceUrl?.match(/aliyuncs\.com\/(.*?)\?/);
|
|
391
392
393
394
|
if (match && match[1]) {
// 对提取的部分进行解码
mockData.value.invoiceName = decodeURIComponent(match[1]);
} else {
|
|
395
|
mockData.value.invoiceName = mockData.value?.invoiceUrl;
|
|
396
|
}
|
柏杨
authored
|
397
|
}
|
|
398
|
function handleShow() {
|
|
399
|
// showInvoice.value = false;
|
|
400
|
}
|
柏杨
authored
|
401
402
403
404
405
406
407
408
409
410
411
412
413
|
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();
}
|
|
414
415
416
417
418
419
420
421
422
423
424
425
|
async function handleExport() {
axios
.post(
'/basic-api/order/erp/check_bill/exportReceipt',
{
checkNo: checkNo.value,
actualPayedAmount: actualPayedAmount.value,
deductAmount: deductAmount.value,
totalActualPayedAmount: totalActualPayedAmount.value,
unPayedAmount: unPayedAmount.value,
payedDate: payedDate.value,
actualPayedDate: actualPayedDate.value,
|
|
426
427
|
financePerson: financePerson.value,
trackerUser: trackerUser.value,
|
|
428
429
430
|
projectNo: projectNo.value,
status: status.value,
type: type.value,
|
|
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
},
{
responseType: 'blob', // 设置响应类型为 'blob'
},
)
.then((response) => {
// 创建一个 Blob 对象来保存二进制数据
const blob = new Blob([response.data], { type: 'application/octet-stream' });
const getFormattedDate = (): string => {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
const date = getFormattedDate();
// 创建一个链接元素用于下载
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
|
|
456
|
link.download = `付款单${date}.xlsx`; // 你可以为文件命名
|
|
457
458
459
460
461
462
463
464
465
|
document.body.appendChild(link);
link.click(); // 自动点击链接,触发下载
document.body.removeChild(link); // 下载完成后移除链接
})
.catch((error) => {
console.error(error);
});
closeModal();
}
|
柏杨
authored
|
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
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;
};
|
|
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
// 新增的函数:判断 URL 是否为图片格式
function isImageUrl(url: string): boolean {
const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'svg'];
const baseUrl = url.split('?')[0];
return imageExtensions.some((ext) => baseUrl.toLowerCase().endsWith(ext));
}
// function openPic(url) {
// window.open('', '', '').document.write(`<!DOCTYPE html>
// <html>
// <body
// style="display: flex;
// justify-content: center;
// align-items: center;">
// <img src='${url}' width="500px" height="500px"/>
// </body>
// </html>`);
// }
// 检查 URL 是否为 PDF 格式
function isPdfUrl(url: string): boolean {
return url.toLowerCase().endsWith('.pdf');
}
// 打开图片或 PDF
function openPic(url: string) {
const baseUrl = url.split('?')[0]; // 获取问号前的部分
if (isImageUrl(baseUrl)) {
window.open('', '', '').document.write(`<!DOCTYPE html>
<html>
<body style="display: flex; justify-content: center; align-items: center;">
|
|
513
|
<img src='${url}' width="300px" height="auto"/>
|
|
514
515
516
517
518
519
520
|
</body>
</html>`);
} else if (isPdfUrl(baseUrl)) {
view(url); // 新标签页打开 PDF
} else {
console.log('不支持的文件类型');
}
|
|
521
522
|
}
|
柏杨
authored
|
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
return {
handleProfitModal,
registerTable,
checkedKeys,
currentKey,
onSelect,
handleEdit,
onSelectAll,
handleDetail,
registerModal,
fieldInfos,
baseInfos,
handleTrue,
handleFalse,
role,
ROLE,
msgVisible,
handleMsgModalClose,
handlePreview,
mockData,
schema,
|
|
544
|
showInvoice,
|
|
545
|
openPic,
|
|
546
|
handleShow,
|
|
547
548
549
550
551
552
553
554
555
|
actualPayCalculate,
checkNo,
actualPayedAmount,
payedDate,
actualPayedDate,
unPayedAmount,
totalActualPayedAmount,
deductAmount,
handleExport,
|
柏杨
authored
|
556
557
558
559
|
};
},
});
</script>
|