Commit f84c5b272490e15fa6e47badc84b8f4453074b03

Authored by gesilong
2 parents b7053a15 7eccee4a

Merge branch 'cjerp-contract-1.0' into test_cjerp

@@ -20,6 +20,14 @@ export const statusMap = { @@ -20,6 +20,14 @@ export const statusMap = {
20 } 20 }
21 21
22 const baseUrl = '/contract'; 22 const baseUrl = '/contract';
  23 +// 打印功能
  24 +export function printStandardContractApi(params) {
  25 + return request({
  26 + url: `${baseUrl}/contractDistributorStandard/printStandardContract`,
  27 + method: 'get',
  28 + params
  29 + })
  30 +}
23 // 查询当前人所在办事处 31 // 查询当前人所在办事处
24 export function getDeptApi(params) { 32 export function getDeptApi(params) {
25 return request({ 33 return request({
@@ -122,6 +122,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -122,6 +122,7 @@ import FileUpload from '@/components/file-upload/index.vue'
122 import SingleSelectSheet from '@/components/single-select/index.vue' 122 import SingleSelectSheet from '@/components/single-select/index.vue'
123 import { fillStandardApprovedName } from '@/utils/dic.js' 123 import { fillStandardApprovedName } from '@/utils/dic.js'
124 import { downloadFile } from '@/utils/downloadFile.js' 124 import { downloadFile } from '@/utils/downloadFile.js'
  125 +import { printFile } from '@/utils/print.js'
125 126
126 export default { 127 export default {
127 name: 'ContractForeignStdDetail', 128 name: 'ContractForeignStdDetail',
@@ -225,6 +226,12 @@ export default { @@ -225,6 +226,12 @@ export default {
225 variant: 'outline', 226 variant: 'outline',
226 event: 'copy' 227 event: 'copy'
227 }, 228 },
  229 + {
  230 + text: '打印',
  231 + visible: true,
  232 + variant: 'outline',
  233 + event: 'print'
  234 + },
228 ], 235 ],
229 } 236 }
230 }, 237 },
@@ -241,6 +248,7 @@ export default { @@ -241,6 +248,7 @@ export default {
241 { ...this.buttons[5], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:review')) }, 248 { ...this.buttons[5], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:review')) },
242 { ...this.buttons[4], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:approve')) }, 249 { ...this.buttons[4], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:approve')) },
243 { ...this.buttons[6], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:copy')) }, 250 { ...this.buttons[6], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:copy')) },
  251 + { ...this.buttons[7], visible: true },
244 ] 252 ]
245 } 253 }
246 }, 254 },
@@ -371,6 +379,10 @@ export default { @@ -371,6 +379,10 @@ export default {
371 if (e === 'audit') return this.onAudit(btn && btn.params) 379 if (e === 'audit') return this.onAudit(btn && btn.params)
372 if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) 380 if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params)
373 if (e === 'copy') return this.onCopy(btn && btn.params) 381 if (e === 'copy') return this.onCopy(btn && btn.params)
  382 + if (e === 'print') return this.onPrint(this.detail.id || '')
  383 + },
  384 + onPrint(id) {
  385 + printFile(id)
374 }, 386 },
375 getBusinessId() { 387 getBusinessId() {
376 return (this.detail && (this.detail.id || this.detail.code)) || '' 388 return (this.detail && (this.detail.id || this.detail.code)) || ''
@@ -396,6 +408,7 @@ export default { @@ -396,6 +408,7 @@ export default {
396 uni.navigateTo({ url: '/pages/flow/audit_detail' }) 408 uni.navigateTo({ url: '/pages/flow/audit_detail' })
397 }, 409 },
398 downloadFile, 410 downloadFile,
  411 + printFile,
399 async loadDetail() { 412 async loadDetail() {
400 if (!this.id) return 413 if (!this.id) return
401 try { 414 try {
@@ -141,6 +141,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -141,6 +141,7 @@ import FileUpload from '@/components/file-upload/index.vue'
141 import SingleSelectSheet from '@/components/single-select/index.vue' 141 import SingleSelectSheet from '@/components/single-select/index.vue'
142 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js' 142 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js'
143 import { downloadFile } from '@/utils/downloadFile.js' 143 import { downloadFile } from '@/utils/downloadFile.js'
  144 +import { printFile } from '@/utils/print.js'
144 145
145 export default { 146 export default {
146 name: 'ContractForeignStockDetail', 147 name: 'ContractForeignStockDetail',
@@ -285,6 +286,12 @@ export default { @@ -285,6 +286,12 @@ export default {
285 variant: 'outline', 286 variant: 'outline',
286 event: 'copy' 287 event: 'copy'
287 }, 288 },
  289 + {
  290 + text: '打印',
  291 + visible: true,
  292 + variant: 'outline',
  293 + event: 'print'
  294 + },
288 ], 295 ],
289 } 296 }
290 }, 297 },
@@ -311,6 +318,7 @@ export default { @@ -311,6 +318,7 @@ export default {
311 { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, 318 { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) },
312 { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:standard-approve')) }, 319 { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:standard-approve')) },
313 { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:copy')) }, 320 { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:copy')) },
  321 + { ...this.buttons[14], visible: true },
314 ] 322 ]
315 } 323 }
316 }, 324 },
@@ -459,7 +467,10 @@ export default { @@ -459,7 +467,10 @@ export default {
459 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') 467 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT')
460 if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') 468 if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal')
461 if (e === 'copy') return this.onCopy(btn && btn.params) 469 if (e === 'copy') return this.onCopy(btn && btn.params)
462 - 470 + if (e === 'print') return this.onPrint(this.detail.id || '')
  471 + },
  472 + onPrint(id) {
  473 + printFile(id)
463 }, 474 },
464 getBusinessId() { 475 getBusinessId() {
465 return (this.detail && (this.detail.id || this.detail.code)) || '' 476 return (this.detail && (this.detail.id || this.detail.code)) || ''
@@ -490,6 +501,7 @@ export default { @@ -490,6 +501,7 @@ export default {
490 uni.navigateTo({ url: '/pages/flow/audit_detail' }) 501 uni.navigateTo({ url: '/pages/flow/audit_detail' })
491 }, 502 },
492 downloadFile, 503 downloadFile,
  504 + printFile,
493 async loadDetail() { 505 async loadDetail() {
494 if (!this.id) return 506 if (!this.id) return
495 try { 507 try {
@@ -142,6 +142,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -142,6 +142,7 @@ import FileUpload from '@/components/file-upload/index.vue'
142 import SingleSelectSheet from '@/components/single-select/index.vue' 142 import SingleSelectSheet from '@/components/single-select/index.vue'
143 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js' 143 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js'
144 import { downloadFile } from '@/utils/downloadFile.js' 144 import { downloadFile } from '@/utils/downloadFile.js'
  145 +import { printFile } from '@/utils/print.js'
145 146
146 export default { 147 export default {
147 name: 'ContractForeignUnplanDetail', 148 name: 'ContractForeignUnplanDetail',
@@ -291,6 +292,12 @@ export default { @@ -291,6 +292,12 @@ export default {
291 variant: 'outline', 292 variant: 'outline',
292 event: 'copy' 293 event: 'copy'
293 }, 294 },
  295 + {
  296 + text: '打印',
  297 + visible: true,
  298 + variant: 'outline',
  299 + event: 'print'
  300 + },
294 ], 301 ],
295 } 302 }
296 }, 303 },
@@ -318,6 +325,7 @@ export default { @@ -318,6 +325,7 @@ export default {
318 { ...this.buttons[8], visible: (s === 'STANDARD' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 325 { ...this.buttons[8], visible: (s === 'STANDARD' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同
319 { ...this.buttons[9], visible: (s === 'STANDARD' && f && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:standard-approve')) }, //审核标准合同 326 { ...this.buttons[9], visible: (s === 'STANDARD' && f && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:standard-approve')) }, //审核标准合同
320 { ...this.buttons[14], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:copy')) }, 327 { ...this.buttons[14], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:copy')) },
  328 + { ...this.buttons[15], visible: true },
321 ] 329 ]
322 } 330 }
323 }, 331 },
@@ -455,6 +463,7 @@ export default { @@ -455,6 +463,7 @@ export default {
455 this.sheet = { ...this.sheet, visible: true, title: '合同是否规范', options, value: match ? match.value : '' } 463 this.sheet = { ...this.sheet, visible: true, title: '合同是否规范', options, value: match ? match.value : '' }
456 }, 464 },
457 downloadFile, 465 downloadFile,
  466 + printFile,
458 handleButtonClick(btn) { 467 handleButtonClick(btn) {
459 if (!btn || btn.disabled) return 468 if (!btn || btn.disabled) return
460 if (typeof btn.onClick === 'function') return btn.onClick(this.detail, btn.params) 469 if (typeof btn.onClick === 'function') return btn.onClick(this.detail, btn.params)
@@ -474,6 +483,10 @@ export default { @@ -474,6 +483,10 @@ export default {
474 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') 483 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT')
475 if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') 484 if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal')
476 if (e === 'copy') return this.onCopy(btn && btn.params) 485 if (e === 'copy') return this.onCopy(btn && btn.params)
  486 + if (e === 'print') return this.onPrint(this.detail.id || '')
  487 + },
  488 + onPrint(id) {
  489 + printFile(id)
477 }, 490 },
478 getBusinessId() { 491 getBusinessId() {
479 return (this.detail && (this.detail.id || this.detail.code)) || '' 492 return (this.detail && (this.detail.id || this.detail.code)) || ''
@@ -120,6 +120,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -120,6 +120,7 @@ import FileUpload from '@/components/file-upload/index.vue'
120 import SingleSelectSheet from '@/components/single-select/index.vue' 120 import SingleSelectSheet from '@/components/single-select/index.vue'
121 import { fillStandardApprovedName } from '@/utils/dic.js' 121 import { fillStandardApprovedName } from '@/utils/dic.js'
122 import { downloadFile } from '@/utils/downloadFile.js' 122 import { downloadFile } from '@/utils/downloadFile.js'
  123 +import { printFile } from '@/utils/print.js'
123 124
124 export default { 125 export default {
125 name: 'ContractProcessDetail', 126 name: 'ContractProcessDetail',
@@ -216,6 +217,12 @@ export default { @@ -216,6 +217,12 @@ export default {
216 variant: 'outline', 217 variant: 'outline',
217 event: 'copy' 218 event: 'copy'
218 }, 219 },
  220 + {
  221 + text: '打印',
  222 + visible: true,
  223 + variant: 'outline',
  224 + event: 'print'
  225 + },
219 ], 226 ],
220 } 227 }
221 }, 228 },
@@ -231,6 +238,7 @@ export default { @@ -231,6 +238,7 @@ export default {
231 { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:processed-standard-contract:review')) }, 238 { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:processed-standard-contract:review')) },
232 { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:processed-standard-contract:approve')) }, 239 { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:processed-standard-contract:approve')) },
233 { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:processed-standard-contract:copy')) }, 240 { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:processed-standard-contract:copy')) },
  241 + { ...this.buttons[6], visible: true },
234 ] 242 ]
235 } 243 }
236 }, 244 },
@@ -354,6 +362,10 @@ export default { @@ -354,6 +362,10 @@ export default {
354 if (e === 'audit') return this.onAudit(this.detail.id || '', 'PROCESS_STD_AGMT') 362 if (e === 'audit') return this.onAudit(this.detail.id || '', 'PROCESS_STD_AGMT')
355 if (e === 'auditDetail') return this.onAuditDetail(this.detail.id || '', 'PROCESS_STD_AGMT') 363 if (e === 'auditDetail') return this.onAuditDetail(this.detail.id || '', 'PROCESS_STD_AGMT')
356 if (e === 'copy') return this.onCopy(btn && btn.params) 364 if (e === 'copy') return this.onCopy(btn && btn.params)
  365 + if (e === 'print') return this.onPrint(this.detail.id || '')
  366 + },
  367 + onPrint(id) {
  368 + printFile(id)
357 }, 369 },
358 getBusinessId() { 370 getBusinessId() {
359 return (this.detail && (this.detail.id || this.detail.code)) || '' 371 return (this.detail && (this.detail.id || this.detail.code)) || ''
@@ -383,6 +395,7 @@ export default { @@ -383,6 +395,7 @@ export default {
383 uni.navigateTo({ url: '/pages/flow/audit_detail' }) 395 uni.navigateTo({ url: '/pages/flow/audit_detail' })
384 }, 396 },
385 downloadFile, 397 downloadFile,
  398 + printFile,
386 async loadDetail() { 399 async loadDetail() {
387 if (!this.id) return 400 if (!this.id) return
388 try { 401 try {
@@ -123,6 +123,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -123,6 +123,7 @@ import FileUpload from '@/components/file-upload/index.vue'
123 import SingleSelectSheet from '@/components/single-select/index.vue' 123 import SingleSelectSheet from '@/components/single-select/index.vue'
124 import { getDicByCodes, getDicName } from '@/utils/dic.js' 124 import { getDicByCodes, getDicName } from '@/utils/dic.js'
125 import { downloadFile } from '@/utils/downloadFile.js' 125 import { downloadFile } from '@/utils/downloadFile.js'
  126 +import { printFile } from '@/utils/print.js'
126 127
127 export default { 128 export default {
128 name: 'ContractRetailDetail', 129 name: 'ContractRetailDetail',
@@ -214,6 +215,12 @@ export default { @@ -214,6 +215,12 @@ export default {
214 visible: true, 215 visible: true,
215 variant: 'outline', 216 variant: 'outline',
216 event: 'copy' 217 event: 'copy'
  218 + },
  219 + {
  220 + text: '打印',
  221 + visible: true,
  222 + variant: 'outline',
  223 + event: 'print'
217 } 224 }
218 ], 225 ],
219 statusStyle: statusStyle, 226 statusStyle: statusStyle,
@@ -232,6 +239,7 @@ export default { @@ -232,6 +239,7 @@ export default {
232 { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:review')) }, 239 { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:review')) },
233 { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:approve')) }, 240 { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:approve')) },
234 { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:copy')) }, 241 { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:copy')) },
  242 + { ...this.buttons[6], visible: true },
235 ] 243 ]
236 } 244 }
237 }, 245 },
@@ -358,6 +366,7 @@ export default { @@ -358,6 +366,7 @@ export default {
358 }) 366 })
359 }, 367 },
360 downloadFile, 368 downloadFile,
  369 + printFile,
361 onUpload() { 370 onUpload() {
362 this.$refs.uploadPopup.open() 371 this.$refs.uploadPopup.open()
363 }, 372 },
@@ -371,7 +380,11 @@ export default { @@ -371,7 +380,11 @@ export default {
371 if (e === 'audit') return this.onAudit(btn && btn.params) 380 if (e === 'audit') return this.onAudit(btn && btn.params)
372 if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) 381 if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params)
373 if (e === 'copy') return this.onCopy(btn && btn.params) 382 if (e === 'copy') return this.onCopy(btn && btn.params)
  383 + if (e === 'print') return this.onPrint(btn && btn.params)
374 }, 384 },
  385 + onPrint() {
  386 + printFile(this.detail.id)
  387 + },
375 getBusinessId() { 388 getBusinessId() {
376 return (this.detail && (this.detail.id || this.detail.code)) || '' 389 return (this.detail && (this.detail.id || this.detail.code)) || ''
377 }, 390 },
@@ -138,6 +138,8 @@ import DetailButtons from '@/components/detail-buttons/index.vue' @@ -138,6 +138,8 @@ import DetailButtons from '@/components/detail-buttons/index.vue'
138 import FileUpload from '@/components/file-upload/index.vue' 138 import FileUpload from '@/components/file-upload/index.vue'
139 import SingleSelectSheet from '@/components/single-select/index.vue' 139 import SingleSelectSheet from '@/components/single-select/index.vue'
140 import { downloadFile } from '@/utils/downloadFile.js' 140 import { downloadFile } from '@/utils/downloadFile.js'
  141 +import { printFile } from '@/utils/print.js'
  142 +
141 export default { 143 export default {
142 name: 'ContractStockDetail', 144 name: 'ContractStockDetail',
143 components: { ProductRel, DetailButtons, FileUpload, SingleSelectSheet }, 145 components: { ProductRel, DetailButtons, FileUpload, SingleSelectSheet },
@@ -271,6 +273,12 @@ export default { @@ -271,6 +273,12 @@ export default {
271 visible: true, 273 visible: true,
272 variant: 'outline', 274 variant: 'outline',
273 event: 'copy' 275 event: 'copy'
  276 + },
  277 + {
  278 + text: '打印',
  279 + visible: true,
  280 + variant: 'outline',
  281 + event: 'print'
274 } 282 }
275 ], 283 ],
276 uploadId: '', 284 uploadId: '',
@@ -299,6 +307,7 @@ export default { @@ -299,6 +307,7 @@ export default {
299 { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, 307 { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) },
300 { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:standard-approve')) }, 308 { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:standard-approve')) },
301 { ...this.buttons[12], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:copy')) }, 309 { ...this.buttons[12], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:copy')) },
  310 + { ...this.buttons[13], visible: true },
302 ] 311 ]
303 } 312 }
304 }, 313 },
@@ -402,6 +411,7 @@ export default { @@ -402,6 +411,7 @@ export default {
402 411
403 }, 412 },
404 downloadFile, 413 downloadFile,
  414 + printFile,
405 onSheetConfirm({ value, label }) { 415 onSheetConfirm({ value, label }) {
406 this.standardStandardized = value 416 this.standardStandardized = value
407 this.standardStandardizedName = label || '' 417 this.standardStandardizedName = label || ''
@@ -434,6 +444,10 @@ export default { @@ -434,6 +444,10 @@ export default {
434 if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') 444 if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT')
435 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') 445 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT')
436 if (e === 'copy') return this.onCopy(this.detail) 446 if (e === 'copy') return this.onCopy(this.detail)
  447 + if (e === 'print') return this.onPrint(this.detail.id || '')
  448 + },
  449 + onPrint(id) {
  450 + printFile(id)
437 }, 451 },
438 onAudit(id, type) { 452 onAudit(id, type) {
439 const CACHE_KEY = 'sourceBusinessId' 453 const CACHE_KEY = 'sourceBusinessId'
@@ -139,6 +139,7 @@ import FileUpload from '@/components/file-upload/index.vue' @@ -139,6 +139,7 @@ import FileUpload from '@/components/file-upload/index.vue'
139 import SingleSelectSheet from '@/components/single-select/index.vue' 139 import SingleSelectSheet from '@/components/single-select/index.vue'
140 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js' 140 import { fillStandardApprovedName, fillFormalApprovedName } from '@/utils/dic.js'
141 import { downloadFile } from '@/utils/downloadFile.js' 141 import { downloadFile } from '@/utils/downloadFile.js'
  142 +import { printFile } from '@/utils/print.js'
142 143
143 export default { 144 export default {
144 name: 'ContractUnplanDetail', 145 name: 'ContractUnplanDetail',
@@ -277,6 +278,12 @@ export default { @@ -277,6 +278,12 @@ export default {
277 variant: 'outline', 278 variant: 'outline',
278 event: 'copy' 279 event: 'copy'
279 }, 280 },
  281 + {
  282 + text: '打印',
  283 + visible: true,
  284 + variant: 'outline',
  285 + event: 'print'
  286 + },
280 ], 287 ],
281 } 288 }
282 }, 289 },
@@ -303,6 +310,7 @@ export default { @@ -303,6 +310,7 @@ export default {
303 { ...this.buttons[8], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, 310 { ...this.buttons[8], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) },
304 { ...this.buttons[9], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:standard-approve')) }, 311 { ...this.buttons[9], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:standard-approve')) },
305 { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:copy')) }, 312 { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:copy')) },
  313 + { ...this.buttons[14], visible: true },
306 ] 314 ]
307 } 315 }
308 }, 316 },
@@ -453,6 +461,10 @@ export default { @@ -453,6 +461,10 @@ export default {
453 if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') 461 if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT')
454 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') 462 if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT')
455 if (e === 'copy') return this.onCopy(btn && btn.params) 463 if (e === 'copy') return this.onCopy(btn && btn.params)
  464 + if (e === 'print') return this.onPrint(this.detail.id || '')
  465 + },
  466 + onPrint(id) {
  467 + printFile(id)
456 }, 468 },
457 getBusinessId() { 469 getBusinessId() {
458 return (this.detail && (this.detail.id || this.detail.code)) || '' 470 return (this.detail && (this.detail.id || this.detail.code)) || ''
@@ -482,6 +494,7 @@ export default { @@ -482,6 +494,7 @@ export default {
482 uni.navigateTo({ url: '/pages/flow/audit_detail' }) 494 uni.navigateTo({ url: '/pages/flow/audit_detail' })
483 }, 495 },
484 downloadFile, 496 downloadFile,
  497 + printFile,
485 async loadDetail() { 498 async loadDetail() {
486 if (!this.id) return 499 if (!this.id) return
487 try { 500 try {
  1 +import config from '@/config'
  2 +import { getToken } from '@/utils/auth.js'
  3 +
  4 +export async function printFile(id, fileName = '合同.pdf') {
  5 + const bizId = id != null ? String(id) : ''
  6 + if (!bizId) {
  7 + uni.showToast({ title: '未获取到合同ID', icon: 'none' })
  8 + return
  9 + }
  10 +
  11 + uni.showLoading({ title: '下载中' })
  12 + try {
  13 + const baseUrl = (config && config.baseUrl) ? String(config.baseUrl).replace(/\/$/, '') : ''
  14 + const rawUrl = `${baseUrl}/contract/contractDistributorStandard/printStandardContract?id=${encodeURIComponent(bizId)}`
  15 + const token = getToken()
  16 + const header = {}
  17 + if (token) header['X-Auth-Token'] = token
  18 +
  19 + let url = rawUrl
  20 + // #ifdef H5
  21 + if (token) {
  22 + const separator = url.includes('?') ? '&' : '?'
  23 + url = `${url}${separator}X-Auth-Token=${encodeURIComponent(token)}`
  24 + }
  25 + // #endif
  26 +
  27 + const res = await new Promise((resolve, reject) => {
  28 + uni.downloadFile({
  29 + url,
  30 + header,
  31 + success: resolve,
  32 + fail: reject
  33 + })
  34 + })
  35 +
  36 + if (!(res && res.statusCode === 200)) {
  37 + uni.showToast({ title: '下载失败', icon: 'none' })
  38 + return
  39 + }
  40 +
  41 + const filePath = res.tempFilePath
  42 +
  43 + // #ifdef H5
  44 + const ua = navigator.userAgent.toLowerCase()
  45 + const isAndroid = ua.indexOf('android') > -1 || ua.indexOf('adr') > -1
  46 + const isWeChat = ua.indexOf('micromessenger') !== -1
  47 + if (isWeChat && isAndroid) {
  48 + uni.showModal({
  49 + title: '提示',
  50 + content: '微信环境下不支持直接打开,请复制链接后在浏览器打开',
  51 + confirmText: '复制链接',
  52 + showCancel: false,
  53 + success: function (r) {
  54 + if (r.confirm) {
  55 + uni.setClipboardData({
  56 + data: url,
  57 + success: function () { uni.showToast({ title: '链接已复制', icon: 'success' }) }
  58 + })
  59 + }
  60 + }
  61 + })
  62 + } else {
  63 + const win = window.open(filePath, '_blank')
  64 + if (!win) {
  65 + const link = document.createElement('a')
  66 + link.href = filePath
  67 + link.download = fileName || 'download'
  68 + document.body.appendChild(link)
  69 + link.click()
  70 + document.body.removeChild(link)
  71 + }
  72 + }
  73 + // #endif
  74 +
  75 + // #ifndef H5
  76 + const ext = fileName && String(fileName).includes('.') ? String(fileName).split('.').pop().toLowerCase() : 'pdf'
  77 + uni.openDocument({
  78 + filePath,
  79 + fileType: ext || 'pdf',
  80 + showMenu: true,
  81 + fail: function () {
  82 + uni.showToast({ title: '无法打开此文件', icon: 'none' })
  83 + }
  84 + })
  85 + // #endif
  86 + } catch (e) {
  87 + uni.showToast({ title: '下载出错', icon: 'none' })
  88 + } finally {
  89 + uni.hideLoading()
  90 + }
  91 +}