king
2022-06-14 669839c40c0080786cefa6a8e62d3ada68a39b8e
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') { // 使用系统时,直接从表格或表单中选取数据
        if (btn.Ot === 'notRequired') {
        let printcell = {}
        printcell.printType = formdata.printType || formdata.PrintType || formdata.printtype || formdata.Printtype || ''
        printcell.printCount = printCount
        printcell.templateID = btn.verify.Template || ''
        if (btn.Ot === 'notRequired') {
          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)
          })
        }
        resolve(true)
      } else {
@@ -281,16 +320,27 @@
              // 系统打印数据,校验data字段
              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]
              }
              })
              
              cell.printCount = _printCount
              if (isNaN(cell.printCount) || cell.printCount < 1) {
                cell.printCount = baseCount
              }
              templates.push(cell.templateID)