From bc4ee6130db80f8f2020bb3bb7248b6e55ae90cc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 20 三月 2020 17:47:01 +0800 Subject: [PATCH] 2020-03-20 --- src/tabviews/zshare/actionList/index.jsx | 81 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 282ad5d..ed8ab47 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -332,7 +332,7 @@ status: false } } else { - _temps[res.tempId] = _temp.config + _temps[res.tempId] = _temp } } else if (!errorMsg) { errorMsg = res @@ -567,9 +567,11 @@ } getPrintConfigParam = (res) => { - let error = '' - let configParam = '' - let _configparam = '' + let error = '' // 閿欒淇℃伅 + let configParam = '' // 妯℃澘閰嶇疆淇℃伅 + let _configparam = '' // 鎵撳嵃閰嶇疆淇℃伅 + let fields = [] // 妯℃澘涓墍闇�瀛楁 + let nonEFields = [] // 闈炵┖瀛楁 if (!res.ConfigParam) { error = '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�' @@ -583,6 +585,7 @@ if (!configParam) { error = '鎵撳嵃妯℃澘瑙f瀽閿欒锛�' } else { + let control = configParam.elements.map(element => { let _field = element.field @@ -640,6 +643,15 @@ 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 }) @@ -670,25 +682,54 @@ 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) @@ -715,6 +756,34 @@ }) 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) { -- Gitblit v1.8.0