TabCmInfoList.vue
12.6 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
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
327
328
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<template>
<a-card :bordered="false" :class="'cust-erp-sub-tab'">
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:scroll="{x:true}"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading">
<span slot="action2" slot-scope="text, record">
<a @click="wjInfo(record)">{{ record.htfj }}</a>  
</span>
<span slot="action3" slot-scope="text, record">
<a @click="fpInfo(record)">发票管理</a>  
</span>
<span slot="action4" slot-scope="text, record">
<a @click="fkInfo(record)">付款管理</a>  
</span>
<span slot="action5" slot-scope="text, record">
<a @click="blpInfo(record)">{{record.blpNum}}</a>  
</span>
</a-table>
<!--文件预览-->
<j-modal
title="文件查看"
:visible="visibleWjck"
@ok="handleCancelWjck"
@cancel="handleCancelWjck"
>
<!-- PDF 预览 -->
<div>
<!-- <h3>PDF 预览</h3>-->
<iframe :src="pdfSrc" width="100%" height="500px"></iframe>
</div>
</j-modal>
<!--发票管理-->
<j-modal
@cancel="handleCancelfp"
@ok="handleConfirmfp"
title="发票管理"
:width="width"
:visible="visiblefp"
cancelText="关闭"
>
<a-table :dataSource="dataSourcefp" :columns="columnsfp" :scroll="{x:true}">
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<div v-else>
<span :title="text">{{ text.length > 20 ? text.substring(0, 20) + '...' : text }}</span>
<a-button
:ghost="true"
type="primary"
icon="download"
size="small"
@click="downloadFile(text)">
下载
</a-button>
</div>
</template>
</a-table>
</j-modal>
<!-- 付款管理-->
<j-modal
@cancel="handleCancelpay"
@ok="handleConfirmpay"
title="付款管理"
:width="width"
:visible="visiblepay"
cancelText="关闭"
>
<a-table :dataSource="dataSourcepay" :columns="columnspay" :scroll="{x:true}">
<template slot="fileSlot" slot-scope="text">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<div v-else>
<span :title="text">{{ text.length > 20 ? text.substring(0, 20) + '...' : text }}</span>
<a-button
:ghost="true"
type="primary"
icon="download"
size="small"
@click="downloadFile(text)">
下载
</a-button>
</div>
</template>
</a-table>
</j-modal>
<!-- 不良品库存-->
<j-modal
title="不良品库存"
:width="width"
:visible="visibleBlp"
fullscreen
@ok="handleConfirmblp"
@cancel="handleCancelblp"
cancelText="关闭">
<TblTradeInventoryDefectiveProductList ></TblTradeInventoryDefectiveProductList>
</j-modal>
</a-card>
</template>
<script>
import { getAction, getFileAccessHttpUrl } from '@api/manage'
import TblTradeInventoryDefectiveProductList from '@views/trade/TblTradeInventoryDefectiveProductList.vue'
export default {
name: "TabCmInfoList",
components: { TblTradeInventoryDefectiveProductList },
data(){
return {
loading: false,
ipagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '30'],
showTotal: (total, range) => {
return range[0] + "-" + range[1] + " 共" + total + "条"
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
visibleWjck: false,
visiblefp: false,
visiblepay: false,
visibleBlp: false,
labelCol: {
xs: { span: 24 },
sm: { span: 8 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 }
},
modelpay: {},
dataSourcepay: [],
columnspay: [
{
title: '付款金额(元)',
align: 'center',
dataIndex: 'fsje'
},
{
title: '付款时间',
align: 'center',
dataIndex: 'fksj'
},
{
title: '采购员',
align: 'center',
dataIndex: 'createBy'
},
{
title: '状态',
align: 'center',
dataIndex: 'status',
customRender: (text) => {
let re = ''
if (text === 0) {
re = '待审核'
} else if (text === 1) {
re = '审核通过'
}else if (text === 2) {
re = '拒绝'
}
return re
}
}
],
confirmLoading: false,
width: 892,
pdfSrc: '',
dataSource: [],
dataSourcefp: [],
columnsfp: [
{
title: '发票号码',
align: 'center',
dataIndex: 'fphm'
}, {
title: '发票金额',
align: 'center',
dataIndex: 'fpje'
}, {
title: '发票欠额',
align: 'center',
dataIndex: 'fpqe'
}, {
title: '附件',
align: 'center',
dataIndex: 'fj',
scopedSlots: { customRender: 'fileSlot' }
}, {
title: '备注',
align: 'center',
dataIndex: 'bz'
}
],
columns:[
{
title: '供应商(TEL)',
align: 'center',
dataIndex: 'supplier'
},
{
title: '采购渠道',
align: 'center',
dataIndex: 'procurementChannels'
},
{
title: '合同号/订单号',
align: 'center',
dataIndex: 'hth'
},
{
title: '数量',
align: 'center',
dataIndex: 'purchaseQuantity'
},
{
title: '单价(不含税,元)',
align: 'center',
dataIndex: 'unitPrice'
},
{
title: '税率(%)',
align: 'center',
dataIndex: 'taxRate'
},
{
title: '金额(元)',
align: 'center',
dataIndex: 'amount'
},
{
title: '合同附件 ',
dataIndex: 'action2',
align: 'center',
// fixed: 'right',
width: 147,
scopedSlots: { customRender: 'action2' }
},
{
title: '发票信息',
dataIndex: 'action3',
align: 'center',
// fixed: 'right',
width: 147,
scopedSlots: { customRender: 'action3' }
},
{
title: '付款信息',
dataIndex: 'action4',
align: 'center',
// fixed: 'right',
width: 147,
scopedSlots: { customRender: 'action4' }
},
{
title: '已入库数量',
align: 'center',
dataIndex: 'yrkNum'
},
{
title: '剩余订单未入库数量',
align: 'center',
dataIndex: 'wrkNum'
},
{
title: '不良品数量',
align: 'center',
dataIndex: 'action5',
scopedSlots: { customRender: 'action5' }
},
{
title: '退换货评级',
align: 'center',
dataIndex: 'thhPj',
customRender: function(thhPj) {
var str = ''
if (thhPj === 1) {
str = 'A'
} else if (thhPj === 2) {
str = 'B'
} else if (thhPj === 3) {
str = 'C'
}else if (thhPj === 4) {
str = 'D'
}
return str
}
},
{
title: '供应商评级',
align: 'center',
dataIndex: 'gysPj',
customRender: function(gysPj) {
var str = ''
if (gysPj === 1) {
str = 'A'
} else if (gysPj === 2) {
str = 'B'
} else if (gysPj === 3) {
str = 'C'
} else if (gysPj === 4) {
str = 'D'
}
return str
}
}
],
url:{
getCgInfo: '/trade/tblTradePurchaseInfo/getCgInfo',
file: '/trade/tblTradePurchaseInfo/pdf/base64',
fplist: '/trade/tblTradeFpgl/list',
paylist: '/trade/tblTradePayManage/list',
}
}
},
methods:{
clearData(){
this.dataSource = []
},
handleCancelblp(){
this.visibleBlp = false
},
handleConfirmblp(){
this.visibleBlp = false
},
handleCancelpay() {
this.visiblepay = false
},
handleConfirmpay() {
this.visiblepay = false
},
handleCancelfp() {
this.visiblefp = false
},
handleConfirmfp() {
this.visiblefp = false
},
handleCancelWjck() {
this.visibleWjck = false
},
loadData(rows){
const row = rows[0]
console.log("row",row)
const materialCode = row.code
const xjbswjh = row.xjbswjh
getAction(this.url.getCgInfo, {
wlbh: materialCode
}).then((res) => {
if (res.success) {
this.dataSource = res.result.ycgList
}
})
},
blpInfo(record){
this.visibleBlp = true
},
fkInfo(record) {
this.modelpay = {}
var cmid = record.id
this.modelpay.cmId = cmid
this.modelpay.fkfs = '1'
this.modelpay.supplier = record.supplier
this.modelpay.hth = record.hth
this.modelpay.htje = record.amount
this.paylist(cmid)
this.visiblepay = true
},
//根据
paylist(id) {
getAction(this.url.paylist, { cmId: id }).then(
res => {
this.dataSourcepay = res.result.records
}
)
},
//打开发票管理
fpInfo(record) {
this.modelfp = {}
this.visiblefp = true
var cmid = record.id
this.modelfp.cmId = cmid
this.fplist(cmid)
},
//根据
fplist(id) {
getAction(this.url.fplist, { cmId: id }).then(
res => {
this.dataSourcefp = res.result.records
}
)
},
wjInfo(record) {
var htfjPath = ''
if (record.htfj.indexOf(',') > 0) {
htfjPath = record.htfj.substring(0, record.htfj.indexOf(','))
} else {
htfjPath = record.htfj
}
getAction(this.url.file, { filePath: htfjPath }).then(
res => {
const base64Pdf = res.result
this.pdfSrc = `data:application/pdf;base64,${base64Pdf}`
}
)
this.visibleWjck = true
},
downloadFile(text) {
if (!text) {
this.$message.warning('未知的文件')
return
}
// 将 text 按逗号分割成多个文件的 URL
const fileUrls = text.split(',')
// 遍历每个文件的 URL
fileUrls.forEach((fileUrl, index) => {
// 去除 URL 两端的空格
fileUrl = fileUrl.trim()
// 检查 URL 是否有效
if (!fileUrl) {
this.$message.warning(`第 ${index + 1} 个文件 URL 无效`)
return // 跳过当前文件,继续下一个
}
// 生成文件访问 URL
let url = getFileAccessHttpUrl(fileUrl)
// 检查生成的 URL 是否有效
if (!url) {
this.$message.warning(`第 ${index + 1} 个文件无法生成访问链接`)
return // 跳过当前文件,继续下一个
}
// 使用 fetch 下载文件
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`第 ${index + 1} 个文件下载失败`)
}
return response.blob() // 将响应转换为 Blob 对象
})
.then(blob => {
// 创建 Blob URL
const blobUrl = URL.createObjectURL(blob)
// 创建 <a> 标签并触发下载
const link = document.createElement('a')
link.href = blobUrl
link.download = fileUrl // 替换为实际文件名
link.style.display = 'none'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
// 释放 Blob URL
URL.revokeObjectURL(blobUrl)
})
.catch(error => {
this.$message.error(`第 ${index + 1} 个文件下载失败`)
console.error(`下载错误:`, error)
})
})
},
}
}
</script>
<style scoped>
</style>