From 669839c40c0080786cefa6a8e62d3ada68a39b8e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 六月 2022 14:10:50 +0800 Subject: [PATCH] 2022-06-14 --- src/tabviews/zshare/actionList/printbutton/index.jsx | 94 ++++++++++++++++++++++++++++++++++++----------- 1 files changed, 72 insertions(+), 22 deletions(-) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index 6e4cead..cf92e72 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -240,38 +240,77 @@ triggerPrint = (data, formlist = []) => { const { btn } = this.props let formdata = {} + let baseCount = 1 + let baseType = '' + let baseTemp = btn.verify.Template || '' formlist.forEach(_data => { formdata[_data.key] = _data.value + + if (!_data.value) return + + if (_data.key.toLowerCase() === 'printcount') { + baseCount = +_data.value + } else if (_data.key.toLowerCase() === 'printtype') { + baseType = _data.value + } else if (_data.key.toLowerCase() === 'templateid') { + baseTemp = _data.value + } }) let printlist = [] let templates = [] - let printCount = +(formdata.printCount || formdata.PrintCount || formdata.printcount || formdata.Printcount || 1) - if (isNaN(printCount) || printCount < 1) { - printCount = 1 + if (isNaN(baseCount) || baseCount < 1) { + baseCount = 1 } new Promise(resolve => { if (btn.intertype === 'system') { // 浣跨敤绯荤粺鏃讹紝鐩存帴浠庤〃鏍兼垨琛ㄥ崟涓�夊彇鏁版嵁 - let printcell = {} - - printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' - printcell.printCount = printCount - printcell.templateID = btn.verify.Template || '' - if (btn.Ot === 'notRequired') { + let printcell = {} + + printcell.printType = baseType + printcell.printCount = baseCount + printcell.templateID = baseTemp printcell.data = [formdata] + + templates.push(printcell.templateID) + + printlist.push(printcell) } else { - printcell.data = data.map(cell => { - return {...cell, ...formdata} + data.forEach(cell => { + let _cell = {...cell, ...formdata} + + let printcell = {data: [_cell]} + + printcell.templateID = baseTemp + printcell.printType = baseType + printcell.printCount = 0 + + Object.keys(_cell).forEach(key => { + if (!_cell[key]) return + + let _key = key.toLowerCase() + + if (_key === 'templateid') { + printcell.templateID = _cell[key] + } else if (_key === 'printtype') { + printcell.printType = _cell[key] + } else if (_key === 'printcount') { + printcell.printCount = +_cell[key] + } + }) + + if (isNaN(printcell.printCount) || printcell.printCount < 1) { + printcell.printCount = baseCount + } + + templates.push(printcell.templateID) + + printlist.push(printcell) }) } - - templates.push(printcell.templateID) - - printlist.push(printcell) resolve(true) } else { @@ -281,16 +320,27 @@ // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return - cell.templateID = cell.templateID || cell.TemplateID || cell.Templateid || cell.templateid || btn.verify.Template - cell.printType = cell.printType || cell.PrintType || cell.printtype || cell.Printtype || formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || '' + cell.templateID = baseTemp + cell.printType = baseType + cell.printCount = 0 - let _printCount = +(cell.printCount || cell.PrintCount || cell.printcount || cell.Printcount || 0) + Object.keys(cell).forEach(key => { + if (!cell[key]) return - if (isNaN(_printCount) || _printCount < 1) { - _printCount = printCount + let _key = key.toLowerCase() + + if (_key === 'templateid') { + cell.templateID = cell[key] + } else if (_key === 'printtype') { + cell.printType = cell[key] + } else if (_key === 'printcount') { + cell.printCount = +cell[key] + } + }) + + if (isNaN(cell.printCount) || cell.printCount < 1) { + cell.printCount = baseCount } - - cell.printCount = _printCount templates.push(cell.templateID) -- Gitblit v1.8.0