detail.vue
28.5 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
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
<template>
<view class="page">
<scroll-view class="scroll" scroll-y>
<view class="detail-page">
<view class="section">
<text class="row company">{{ safeText(form.code) }}</text>
<view class="row"><text class="label">公司简称</text><text class="value">{{ safeText(form.companyShortName || form.companyName) }}</text></view>
<view class="row"><text class="label">供应商名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view>
<view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName || form.purchaseDepartment) }}</text></view>
<view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName || form.region) }}</text></view>
<view class="row"><text class="label">日期</text><text class="value">{{ formatDateOnly(form.date) }}</text></view>
<view class="row"><text class="label">报价时效</text><text class="value">{{ safeText(form.validityPeriod) }}</text></view>
<view class="row"><text class="label">报价人</text><text class="value">{{ safeText(form.quoterName) }}</text></view>
<view class="row"><text class="label">是否长单操作</text><text class="value">{{ boolText(form.longTermOperation) }}</text></view>
<view class="row"><text class="label">是否终端客户</text><text class="value">{{ boolText(form.terminalCustomer) }}</text></view>
<view class="row"><text class="label">是否未点价</text><text class="value">{{ boolText(form.priced) }}</text></view>
<view v-if="form.priced === true" class="row"><text class="label">点价截止日期</text><text class="value">{{ formatDateOnly(form.pricingDeadline) }}</text></view>
<view v-if="form.priced === true" class="row"><text class="label">是否暂定价</text><text class="value">{{ boolText(form.temporaryPrice) }}</text></view>
<view class="row"><text class="label">其他费用凭票到厂另行结算</text><text class="value">{{ boolText(form.otherExpenseSettlement) }}</text></view>
<view class="row"><text class="label">交提货方式</text><text class="value">{{ getDeliveryMethodLabel() }}</text></view>
<view class="row"><text class="label">是否通货买断</text><text class="value">{{ boolText(form.commodityBuyout) }}</text></view>
<view class="row"><text class="label">是否质量买断</text><text class="value">{{ boolText(form.qualityBuyout) }}</text></view>
<view class="row"><text class="label">是否数量买断</text><text class="value">{{ boolText(form.quantityBuyout) }}</text></view>
<view class="row"><text class="label">是否送货上门</text><text class="value">{{ boolText(form.doorDelivery) }}</text></view>
<view class="row"><text class="label">另付运费</text><text class="value">{{ formatNumber(form.shippingCost) }}</text></view>
<view class="row"><text class="label">装车费</text><text class="value">{{ formatNumber(form.loadingFee) }}</text></view>
<view class="row"><text class="label">开票品名</text><text class="value">{{ safeText(form.invoiceProductName) }}</text></view>
<view class="row"><text class="label">交货日期</text><text class="value">{{ formatDateOnly(form.deliveryDate) }}</text></view>
<view class="row"><text class="label">结算方式</text><text class="value">{{ safeText(form.settlementMethod) }}</text></view>
<view class="row"><text class="label">结算比例(%)</text><text class="value">{{ formatNumber(form.settlementRatio) }}</text></view>
<view class="row"><text class="label">价格表编号</text><text class="value">{{ getPriceTableLabel() }}</text></view>
<view class="row"><text class="label">协调事由</text><text class="value">{{ safeText(form.coordinationReason) }}</text></view>
<view class="row"><text class="label">票类状况</text><text class="value">{{ safeText(form.invoiceTypeStatus) }}</text></view>
<view class="row" v-if="attachmentList.length">
<text class="label">附件</text>
<view class="attach-list">
<view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
<text class="attach-name">{{ at.name }}</text>
<text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
</view>
</view>
</view>
</view>
<ProductRel
mode="view"
:list="lineListWithName"
:product-options="productOptions"
:workshop-options="workshopOptions"
/>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>料质状况</span>
</view>
<view class="section">
<view class="row"><text class="label">是否启用料质状况</text><text class="value">{{ boolText(form.materialConditionEnabled) }}</text></view>
<template v-if="form.materialConditionEnabled">
<view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
<text class="material-label">{{ mc.label }}</text>
<view class="tag-list">
<view v-for="opt in getDictOptions(mc.dictCode)" :key="opt.code" class="tag-btn" :class="{ active: isTagSelected(mc.field, opt.code) }">{{ opt.name }}</view>
</view>
</view>
</template>
</view>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>备注</span>
</view>
<view class="section">
<text class="remark-text">{{ safeText(form.remark) }}</text>
</view>
</view>
</scroll-view>
<detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
</view>
</template>
<script>
import DetailButtons from '@/components/detail-buttons/index.vue'
import ProductRel from './productRel.vue'
import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi } from '@/api/procure-manage/procurementPlan.js'
import { buyoutApplyCreateApi, buyoutApplyAbolishApi } from '@/api/procure-manage/buyout.js'
import { getDicByCodes, getDicName } from '@/utils/dic.js'
import { getInfo } from '@/api/login.js'
import { priceTableQueryApi, breedRelationshipQueryApi, workshopQueryApi } from '@/api/devManage.js'
export default {
name: 'DomesticPlanDetail',
components: { DetailButtons, ProductRel },
data() {
return {
id: '',
form: {},
lineList: [],
attachmentList: [],
materialConditionConfigs: [
{ field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
{ field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
{ field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
{ field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
{ field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
{ field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
{ field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
{ field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
],
dicOptions: {
AUDIT_STATUS: [],
PROCESS_STATUS: [],
DELIVERY_METHOD: []
},
dictData: {},
currentUserId: '',
priceTableList: [],
productOptions: [],
workshopOptions: [],
planRoleFlags: {
isPlanner: false
},
PROCESS_STATUS_CODE: {
TO_SUPPLEMENT: 'TO_SUPPLEMENT',
TO_SPLIT: 'TO_SPLIT',
TO_SUBMIT_REVIEW: 'TO_SUBMIT_REVIEW',
AUDIT: 'AUDIT',
REFUSE: 'REFUSE',
COMPLETED: 'COMPLETED',
ABORTED: 'ABORTED'
},
buttonTemplates: [
{ text: '补充', variant: 'primary', event: 'supplement' },
{ text: '生成合同', variant: 'primary', event: 'generateContract' },
{ text: '选择分厂', variant: 'primary', event: 'selectWorkshop' },
{ text: '提交', variant: 'primary', event: 'submitSplit' },
{ text: '提交审核', variant: 'primary', event: 'submitReview' },
{ text: '终止', variant: 'danger', event: 'abort' },
{ text: '审核', variant: 'primary', event: 'approve' },
{ text: '审核详情', variant: 'outline', event: 'approveDetail' },
{ text: '打印', variant: 'outline', event: 'print' },
{ text: '生成买断操作申请单', variant: 'outline', event: 'generate' },
{ text: '废除买断操作申请单', variant: 'danger', event: 'cancel' },
{ text: '查看买断操作申请单', variant: 'outline', event: 'look' },
// { text: '上传附件', variant: 'primary', event: 'upload' }
]
}
},
computed: {
productMap() {
var list = Array.isArray(this.productOptions) ? this.productOptions : []
var m = {}
list.forEach(function (o) {
var key = String(o.productId || o.id || o.value || '')
if (key) m[key] = o
})
return m
},
workshopMap() {
var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
var m = {}
list.forEach(function (o) {
var key = String(o.workshopId || o.id || o.value || '')
if (key) m[key] = o
})
return m
},
lineListWithName() {
var self = this
var list = Array.isArray(this.lineList) ? this.lineList : []
return list.map(function (row) {
var pid = String(row.productId || '')
var wid = String(row.workshopId || '')
var p = pid ? self.productMap[pid] : null
var w = wid ? self.workshopMap[wid] : null
return Object.assign({}, row, {
productName: row.productName || (p ? (p.productName || p.name || p.label || '') : ''),
workshopName: row.workshopName || (w ? (w.workshopName || w.name || w.label || '') : '')
})
})
},
displayButtons() {
var self = this
var f = this.form || {}
var ps = String(f.processStatus != null ? f.processStatus : '')
var aStatus = String(f.approvalStatus != null ? f.approvalStatus : '')
var SC = this.PROCESS_STATUS_CODE
var inStatus = function (codes) { return codes.indexOf(ps) >= 0 }
var perms = {
supplement: this.hasPerm('plan-manage:domestic-plan:supple'),
generateContract: this.hasPerm('plan-manage:domestic-plan:do'),
selectWorkshop: this.hasPerm('plan-manage:domestic-plan:split'),
submitSplit: this.hasPerm('plan-manage:domestic-plan:submit'),
submitReview: this.hasPerm('plan-manage:domestic-plan:goapprove'),
abort: this.hasPerm('plan-manage:domestic-plan:stop'),
approve: this.hasPerm('plan-manage:domestic-plan:approve'),
approveDetail: this.hasPerm('plan-manage:domestic-plan:view'),
print: this.hasPerm('plan-manage:domestic-plan:print'),
generate: this.hasPerm('plan-manage:domestic-plan:generate'),
cancel: this.hasPerm('plan-manage:domestic-plan:cancel'),
look: this.hasPerm('plan-manage:domestic-plan:look'),
// upload: this.hasPerm('plan-manage:domestic-plan:upload')
}
var visibleMap = {
supplement: inStatus([SC.TO_SUPPLEMENT]) && perms.supplement,
generateContract: inStatus([SC.TO_SUPPLEMENT]) && perms.generateContract,
selectWorkshop: inStatus([SC.TO_SPLIT]) && perms.selectWorkshop,
submitSplit: inStatus([SC.TO_SPLIT]) && perms.submitSplit,
submitReview: inStatus([SC.TO_SUBMIT_REVIEW]) && perms.submitReview,
abort: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.REFUSE]) && perms.abort,
approve: (inStatus([SC.AUDIT, SC.REFUSE]) && aStatus === 'AUDIT' && !!f.showExamine) && perms.approve,
approveDetail: !!f.showExamineDetail && (inStatus([SC.AUDIT, SC.COMPLETED, SC.REFUSE])) && perms.approveDetail,
print: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.ABORTED, SC.REFUSE]) && perms.print,
generate: !!f.showGenerateBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.generateBuyoutApply,
cancel: !!f.showAbolishBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.abolishBuyoutApply,
look: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE]) && perms.viewBuyoutApply,
// uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
}
var out = []
for (var i = 0; i < this.buttonTemplates.length; i++) {
var tpl = this.buttonTemplates[i]
var visible = !!visibleMap[tpl.event]
if (visible) {
out.push(Object.assign({}, tpl))
}
}
return out
}
},
onLoad(query) {
this.id = (query && query.id) || ''
this.loadDictData()
this.loadRefData()
this.getUserInfo()
this.loadDetail()
},
methods: {
hasPerm(code) {
try {
return !!(this.$auth && this.$auth.hasPermi && this.$auth.hasPermi(code))
} catch (e) {
return true
}
},
async getUserInfo() {
try {
var res = await getInfo()
this.currentUserId = (res && res.id) ? res.id : ''
} catch (e) {
this.currentUserId = ''
}
},
async loadDictData() {
var codes = [].concat(
this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
['DELIVERY_METHOD', 'AUDIT_STATUS', 'PROCESS_STATUS']
)
try {
var results = await getDicByCodes(codes)
var d = results || {}
this.dictData = d
this.dicOptions.AUDIT_STATUS = (d.AUDIT_STATUS && d.AUDIT_STATUS.data) || []
this.dicOptions.PROCESS_STATUS = (d.PROCESS_STATUS && d.PROCESS_STATUS.data) || []
this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
} catch (e) {
this.dictData = {}
}
},
getDictOptions(dictCode) {
var data = this.dictData[dictCode]
return (data && data.data) ? data.data : []
},
isTagSelected(field, code) {
var selected = this.form ? this.form[field] : undefined
if (Array.isArray(selected)) return selected.indexOf(code) >= 0
if (typeof selected === 'string' && selected) {
return selected.split(',').indexOf(code) >= 0
}
return false
},
getAuditStatusText(status) {
var v = status == null ? '' : String(status)
if (!v) return '-'
return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
},
getProcessStatusText(status) {
var v = status == null ? '' : String(status)
if (!v) return '-'
return getDicName('PROCESS_STATUS', v, this.dicOptions.PROCESS_STATUS) || v
},
getDeliveryMethodLabel() {
var opts = this.getDictOptions('DELIVERY_METHOD') || []
var v = String(this.form.deliveryMode != null ? this.form.deliveryMode : '')
if (!v) return '-'
for (var i = 0; i < opts.length; i++) {
var o = opts[i]
var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
if (code === v) return o.name || o.label || '-'
}
return v
},
getPriceTableLabel() {
var code = this.form.priceTableCode != null ? this.form.priceTableCode : (this.form.priceId != null ? this.form.priceId : '')
if (code == null || String(code).trim() === '') return '-'
var sc = String(code)
var list = Array.isArray(this.priceTableList) ? this.priceTableList : []
for (var i = 0; i < list.length; i++) {
var o = list[i]
var id = String(o.id || o.priceId || o.value || '')
var c = String(o.priceTableCode || o.code || o.priceCode || '')
if (id === sc || c === sc) {
var name = o.priceTableName || o.tableName || o.name || o.label || ''
var cd = o.priceTableCode || o.code || c
return (name ? name + ' ' : '') + (cd ? cd : '') || '-'
}
}
return sc
},
async loadRefData() {
var self = this
try {
var results = await Promise.all([
this.pCall(priceTableQueryApi, { pageIndex: 1, pageSize: 1000 }),
this.pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
this.pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
])
var r1 = (results[0] && results[0].data) ? results[0].data : {}
var r2 = (results[1] && results[1].data) ? results[1].data : {}
var r3 = (results[2] && results[2].data) ? results[2].data : {}
self.priceTableList = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
self.productOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
self.workshopOptions = (r3.datas && Array.isArray(r3.datas)) ? r3.datas : ((r3.list && Array.isArray(r3.list)) ? r3.list : ((r3.records && Array.isArray(r3.records)) ? r3.records : []))
} catch (e) {
self.priceTableList = []
self.productOptions = []
self.workshopOptions = []
}
},
pCall(fn, params) {
try {
return Promise.resolve(fn(params))
} catch (e) {
return Promise.reject(e)
}
},
boolText(v) {
if (typeof v !== 'boolean') return '-'
return v ? '是' : '否'
},
formatDateOnly(v) {
var s = v == null ? '' : String(v).trim()
if (!s) return '-'
if (s.length >= 10) return s.slice(0, 10)
return s
},
safeText(v) {
var s = v == null ? '' : String(v)
return s.trim() ? s : '-'
},
formatNumber(v) {
if (v == null || v === '') return '-'
var n = Number(v)
if (isNaN(n)) return String(v)
return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
},
buildAttachmentList() {
var ids = this.form.attachmentFileIds
var names = this.form.attachmentFileNames
var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
var len = Math.max(idArr.length, nameArr.length)
var list = []
for (var i = 0; i < len; i++) {
list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
}
this.attachmentList = list
},
async loadDetail() {
if (!this.id) return
try {
var res = await procurementPlanDetailApi({ id: this.id })
var d = (res && res.data) ? res.data : {}
var self = this
this.materialConditionConfigs.forEach(function (mc) {
var v = d[mc.field]
if (typeof v === 'string' && v) {
d[mc.field] = v.split(',').filter(Boolean)
} else if (!Array.isArray(v)) {
d[mc.field] = []
}
})
this.form = d
this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList : []
this.buildAttachmentList()
} catch (e) {
uni.showToast({ title: '加载详情失败', icon: 'none' })
}
},
onPreviewAttachment(at) {
if (!at || !at.id) {
uni.showToast({ title: '无法查看', icon: 'none' })
return
}
uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
},
handleButtonClick(btn) {
if (!btn || btn.disabled) return
var e = btn.event || ''
if (e === 'view') return this.onView()
if (e === 'supplement') return this.onSupplement()
if (e === 'generateContract') return this.onGenerateContract()
if (e === 'selectWorkshop') return this.onSelectWorkshop()
if (e === 'submitSplit') return this.onSubmitSplit()
if (e === 'submitReview') return this.onSubmitReview()
if (e === 'abort') return this.onAbort()
if (e === 'approve') return this.onApprove()
if (e === 'approveDetail') return this.onApproveDetail()
if (e === 'print') return this.onPrint()
if (e === 'generateBuyoutApply') return this.onGenerateBuyoutApply()
if (e === 'abolishBuyoutApply') return this.onAbolishBuyoutApply()
if (e === 'look') return this.onViewBuyoutApply()
if (e === 'uploadAttachment') return this.onUploadAttachment()
},
onView() {
uni.showToast({ title: '查看', icon: 'none' })
},
onSupplement() {
uni.navigateTo({ url: '/pages/domestic-plan/supplement?id=' + this.id })
},
onGenerateContract() {
var self = this
var id = this.id || (this.form && this.form.id) || ''
if (!id) {
uni.showToast({ title: '缺少单据id', icon: 'none' })
return
}
uni.showModal({
title: '生成合同',
content: '合同生成之后无法再编辑,确定生成吗?',
confirmText: '确定',
cancelText: '取消',
success: function (res) {
if (!res || !res.confirm) return
uni.showLoading({ title: '生成中', mask: true })
procurementPlanGenerateContractApi(id).then(function () {
uni.hideLoading()
uni.showToast({ title: '生成成功', icon: 'none' })
try {
uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
} catch (e) {}
self.loadDetail()
}).catch(function (e) {
uni.hideLoading()
uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '生成合同失败', icon: 'none' })
})
}
})
},
refreshListFlags() {
try {
uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
} catch (e) {}
},
runWithConfirm(opts) {
var self = this
var title = opts.title || '提示'
var content = opts.content || ''
var run = opts.run
var loading = opts.loading || '处理中'
var successText = opts.successText || '操作成功'
var failText = opts.failText || '操作失败'
if (!this.id) {
uni.showToast({ title: '缺少单据id', icon: 'none' })
return
}
var apiFn = function () {
uni.showLoading({ title: loading, mask: true })
Promise.resolve(run(self.id)).then(function () {
uni.hideLoading()
uni.showToast({ title: successText, icon: 'none' })
self.refreshListFlags()
self.loadDetail()
}).catch(function (e) {
uni.hideLoading()
uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : failText, icon: 'none' })
})
}
if (opts.skipConfirm) {
apiFn()
return
}
uni.showModal({
title: title,
content: content,
confirmText: '确定',
cancelText: '取消',
success: function (res) {
if (!res || !res.confirm) return
apiFn()
}
})
},
onSelectWorkshop() {
var id = this.id || (this.form && this.form.id) || ''
if (!id) {
uni.showToast({ title: '缺少单据id', icon: 'none' })
return
}
uni.navigateTo({ url: '/pages/domestic-plan/selectWorkshop?id=' + id })
},
onSubmitSplit() {
this.runWithConfirm({
title: '提交',
content: '提交之后无法再选择分厂,确定提交吗?',
loading: '提交中',
successText: '提交成功',
failText: '提交失败',
run: function (id) { return procurementPlanSubmitApi(id) }
})
},
onSubmitReview() {
this.runWithConfirm({
title: '提交审核',
content: '确认提交审核吗?',
loading: '提交中',
successText: '提交成功',
failText: '提交审核失败',
run: function (id) { return procurementPlanSubmitAuditApi(id) }
})
},
onAbort() {
this.runWithConfirm({
title: '中止',
content: '若有关联计划,则关联计划会受到影响,是否确认中止?',
loading: '中止中',
successText: '中止成功',
failText: '中止失败',
run: function (id) { return procurementPlanStopApi(id) }
})
},
onPrint() {
uni.showToast({ title: '打印(待对接)', icon: 'none' })
},
onGenerateBuyoutApply() {
var self = this
var id = this.id || (this.form && this.form.id) || ''
this.runWithConfirm({
title: '生成买断操作申请单',
content: '确定生成买断操作申请单吗?',
loading: '生成中',
successText: '生成成功',
failText: '生成买断操作申请单失败',
run: function () { return buyoutApplyCreateApi({ procurementPlanId: id }) }
})
},
onAbolishBuyoutApply() {
var self = this
var id = this.id || (this.form && this.form.id) || ''
this.runWithConfirm({
title: '废除买断操作申请单',
content: '确定废除买断操作申请单吗?',
loading: '废除中',
successText: '废除成功',
failText: '废除买断操作申请单失败',
run: function () { return buyoutApplyAbolishApi(id) }
})
},
onViewBuyoutApply() {
var id = this.id || (this.form && this.form.id) || ''
if (!id) {
uni.showToast({ title: '缺少单据id', icon: 'none' })
return
}
uni.navigateTo({ url: '/pages/domestic-plan/viewBuyoutApply?planId=' + id })
},
onUploadAttachment() {
uni.showToast({ title: '上传附件(待对接)', icon: 'none' })
},
onApprove() {
var id = this.id || (this.form && this.form.id) || ''
if (!id) return
try {
uni.setStorageSync('contractType', 'PROCUREMENT_PLAN')
uni.setStorageSync('sourceBusinessId', id)
} catch (e) {}
uni.navigateTo({ url: '/pages/flow/audit' })
},
onApproveDetail() {
var id = this.id || (this.form && this.form.id) || ''
if (!id) return
try {
uni.setStorageSync('contractType', 'PROCUREMENT_PLAN')
uni.setStorageSync('sourceBusinessId', id)
} catch (e) {}
uni.navigateTo({ url: '/pages/flow/audit_detail' })
}
}
}
</script>
<style lang="scss" scoped>
.page {
display: flex;
flex-direction: column;
height: 100%;
}
.scroll {
flex: 1;
padding: 8rpx 0 144rpx;
}
.detail-page {
background: #f3f3f3;
}
.title-header {
display: flex;
align-items: center;
padding: 24rpx 32rpx 12rpx;
background-color: #ffffff;
.title-header_icon {
width: 36rpx;
height: 36rpx;
margin-right: 12rpx;
}
span {
font-size: 34rpx;
font-weight: 600;
color: rgba(0, 0, 0, 0.9);
}
}
.section {
padding: 32rpx;
background: #fff;
margin-bottom: 20rpx;
}
.row {
display: flex;
margin-bottom: 28rpx;
&:last-child { margin-bottom: 0; }
&.company {
font-size: 36rpx;
font-weight: 600;
color: rgba(0, 0, 0, 0.9);
padding-top: 8rpx;
line-height: 50rpx;
}
.label {
max-width: 420rpx;
margin-right: 20rpx;
line-height: 32rpx;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.6);
}
.value {
flex: 1;
line-height: 32rpx;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.9);
text-align: right;
word-break: break-all;
}
}
.attach-list {
flex: 1;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8rpx;
}
.attach-item {
display: flex;
align-items: center;
gap: 16rpx;
.attach-name {
font-size: 26rpx;
color: rgba(0, 0, 0, 0.9);
}
.attach-view {
font-size: 26rpx;
color: $theme-primary;
}
}
.material-group {
margin-top: 32rpx;
&:first-child { margin-top: 0; }
}
.material-label {
display: block;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.6);
margin-bottom: 20rpx;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.tag-btn {
padding: 12rpx 24rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
font-size: 28rpx;
color: #999;
background: #f5f5f5;
}
.tag-btn.active {
background: $theme-primary;
border-color: $theme-primary;
color: #fff;
}
.remark-text {
font-size: 28rpx;
color: rgba(0, 0, 0, 0.9);
line-height: 1.6;
white-space: pre-wrap;
}
.empty-tip {
text-align: center;
font-size: 28rpx;
color: rgba(0, 0, 0, 0.4);
padding: 24rpx 0;
}
</style>