| | |
| | | status: false |
| | | } |
| | | } else { |
| | | _temps[res.tempId] = _temp.config |
| | | _temps[res.tempId] = _temp |
| | | } |
| | | } else if (!errorMsg) { |
| | | errorMsg = res |
| | |
| | | } |
| | | |
| | | getPrintConfigParam = (res) => { |
| | | let error = '' |
| | | let configParam = '' |
| | | let _configparam = '' |
| | | let error = '' // 错误信息 |
| | | let configParam = '' // 模板配置信息 |
| | | let _configparam = '' // 打印配置信息 |
| | | let fields = [] // 模板中所需字段 |
| | | let nonEFields = [] // 非空字段 |
| | | |
| | | if (!res.ConfigParam) { |
| | | error = '未获取到打印模板信息!' |
| | |
| | | if (!configParam) { |
| | | error = '打印模板解析错误!' |
| | | } else { |
| | | |
| | | let control = configParam.elements.map(element => { |
| | | let _field = element.field |
| | | |
| | |
| | | item.BarcodeHeight = element.qrcodeWidth |
| | | item.BarcodeLabel = false |
| | | } |
| | | |
| | | if (item.Field) { |
| | | fields.push(item.Field) |
| | | // 条码二维码字段不可为空 |
| | | if (item.Type === 'qrcode' || item.Type === 'barcode') { |
| | | nonEFields.push(item.Field) |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | |
| | | |
| | | return { |
| | | error: error, |
| | | config: _configparam |
| | | config: _configparam, |
| | | fields: fields, |
| | | nonEFields: nonEFields |
| | | } |
| | | } |
| | | |
| | | execPrint = (item, list, template) => { |
| | | let _documents = [] |
| | | let _errors = [] |
| | | |
| | | Object.keys(template).forEach(key => { |
| | | let _data = list.filter(cell => cell.TemplateID === key) |
| | | |
| | | if (_data.length > 0) { |
| | | let _fields = Array.from(new Set(template[key].fields)) |
| | | let _nonEFields = Array.from(new Set(template[key].nonEFields)) |
| | | let lacks = [] |
| | | let emptys = [] |
| | | |
| | | _data.forEach(d => { |
| | | _fields.forEach(f => { |
| | | if (!d.hasOwnProperty(f)) { |
| | | lacks.push(f) |
| | | } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) { |
| | | emptys.push(f) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | let _cell = { |
| | | documentID: Utils.getuuid(), |
| | | contents: [ |
| | | { |
| | | data: _data, |
| | | templateURL: JSON.stringify(template[key]) |
| | | templateURL: JSON.stringify(template[key].config) |
| | | } |
| | | ] |
| | | } |
| | | |
| | | if (lacks.length > 0 || emptys.length > 0) { |
| | | lacks = Array.from(new Set(lacks)) |
| | | emptys = Array.from(new Set(emptys)) |
| | | |
| | | _errors.push({ |
| | | title: template[key].config.Title, |
| | | lacks: lacks, |
| | | emptys: emptys |
| | | }) |
| | | } |
| | | |
| | | _documents.push(_cell) |
| | |
| | | }) |
| | | this.setState({loadingUuid: ''}) |
| | | return |
| | | } else if (_errors.length > 0) { |
| | | let lackerror = [] |
| | | let emptyerror = [] |
| | | _errors.forEach(err => { |
| | | if (err.lacks.length > 0) { |
| | | lackerror.push(`数据中未获取到模板(${err.title})${err.lacks.join('、')} 字段`) |
| | | } |
| | | if (err.emptys.length > 0) { |
| | | emptyerror.push(`数据中模板(${err.title}) ${err.emptys.join('、')} 字段不可为空`) |
| | | } |
| | | }) |
| | | |
| | | let msg = [] |
| | | if (lackerror.length > 0) { |
| | | msg.push(lackerror.join(' ; ')) |
| | | } |
| | | |
| | | if (emptyerror.length > 0) { |
| | | msg.push(emptyerror.join(' ; ')) |
| | | } |
| | | |
| | | notification.warning({ |
| | | top: 92, |
| | | message: msg.join(' ; ') + ' !', |
| | | duration: 10 |
| | | }) |
| | | this.setState({loadingUuid: ''}) |
| | | return |
| | | } |
| | | |
| | | if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + item.verify.linkUrl) { |