diff --git a/src/utils/print.js b/src/utils/print.js index 871440a..eddffd9 100644 --- a/src/utils/print.js +++ b/src/utils/print.js @@ -1,5 +1,13 @@ import store from '@/store' import moment from 'moment' + +function sanitizePrintFieldHtml(html) { + const wrapper = document.createElement('div') + wrapper.innerHTML = html || '' + wrapper.querySelectorAll('input[type="file"], .el-upload__input').forEach(el => el.remove()) + return wrapper.innerHTML +} + /** * @param{string} printJs 打印模版 * @param{boolean} isLog 是否带审批 @@ -78,7 +86,7 @@ export async function print(printJs, isLog, form, logContent) { printStr = printStr.replace(fieldMath,subFormBody) // console.log(fieldMath, printStr) } else { - printStr = printStr.replace(fieldMath,`${value}`) + printStr = printStr.replace(fieldMath,`${sanitizePrintFieldHtml(value)}`) } } } else { diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index 452223a..375d463 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -507,7 +507,8 @@ export default { try { await this.getFlows(); const res = await getInfo() - this.usualFlows = res.quick_enter?res.quick_enter:[] + const quickEnterIds = this.normalizeQuickEnter(res.quick_enter) + this.usualFlows = this.flows.filter(flow => quickEnterIds.includes(Number(flow.id))) // const res = await configIndex({ // filter: [ // { @@ -533,16 +534,27 @@ export default { console.error(err); } }, + normalizeQuickEnter(quickEnter) { + if (!quickEnter) return [] + if (!Array.isArray(quickEnter)) return [] + return quickEnter.map(item => { + if (item && typeof item === 'object') { + return Number(item.id) + } + return Number(item) + }).filter(id => Number.isInteger(id) && id > 0) + }, openQucik(){ + const quickEnterIds = this.normalizeQuickEnter(this.usualFlows) this.flows.map(flow => { - const isChecked = this.usualFlows.some(usualFlow => usualFlow.id === flow.id); + const isChecked = quickEnterIds.includes(Number(flow.id)); flow.checked = isChecked }); this.isShowQuick = true }, updatequick(){ this.quickLoading = true - let arr = this.flows.filter((i)=> i.checked===true) + let arr = this.flows.filter((i)=> i.checked===true).map(i => Number(i.id)) saveMyself({ quick_enter:arr }).then(res=>{ diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index ca09dae..960540a 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -2281,25 +2281,30 @@ export default { // 加载关联的支付信息 async loadRelatedPayments() { if (!this.$route.query.flow_id) { - return; + return } - + this.loadingPayments = true; try { - // request.js 成功时会直接返回 res.data(也就是 payment 对象或 null) - const payment = await getPaymentsByFlowId(this.$route.query.flow_id, { all: true }); - // 接口约定:要么无数据(null),要么唯一的一条记录 - if (payment) { + // request.js 成功时会直接返回 res.data;兼容旧接口单对象和新接口数组。 + const result = await getPaymentsByFlowId(this.$route.query.flow_id, { all: true }) + const payments = Array.isArray(result) ? result : (result ? [result] : []) + if (payments.length > 0) { // 兼容 breadcrumb 为字符串或数组 - if (payment.payment_type_info && payment.payment_type_info.breadcrumb) { - const bc = payment.payment_type_info.breadcrumb; + payments.forEach((payment) => { + if (!payment.payment_type_info || !payment.payment_type_info.breadcrumb) { + return + } + const bc = payment.payment_type_info.breadcrumb if (Array.isArray(bc)) { - payment.payment_type_info.breadcrumb = bc; + payment.payment_type_info.breadcrumb = bc } else if (typeof bc === 'string') { - payment.payment_type_info.breadcrumb = bc.split(/\s*>\s*|\s*\/\s*/).filter(Boolean); + payment.payment_type_info.breadcrumb = bc.split(/\s*>\s*|\s*\/\s*/).filter(Boolean) } - } - this.relatedPayments = [payment]; + }) + this.relatedPayments = payments + + const payment = payments[0] // 支付模板元素(用于展示 fields) await this.loadPaymentTemplateElements(payment);