| | |
| | | MenuID: PropTypes.string, // 菜单ID |
| | | btn: PropTypes.object, // 按钮 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | columns: PropTypes.array, |
| | | disabled: PropTypes.any, // 行按钮禁用 |
| | | } |
| | | |
| | |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (btn.intertype === 'system' && btn.verify.dataType === 'custom' && (!btn.verify.setting || btn.verify.columns.length === 0)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '自定义打印数据请设置数据源!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | triggerNormalPrint = (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 _key = _data.key.toLowerCase() |
| | | formdata[_key] = _data.value |
| | | }) |
| | | |
| | | let printlist = [] |
| | | let templates = [] |
| | | |
| | | if (isNaN(baseCount) || baseCount < 1) { |
| | | baseCount = 1 |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.intertype === 'system' && btn.verify.dataType !== 'custom') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.Ot === 'notRequired') { |
| | | let printcell = {} |
| | | |
| | | printcell.printType = baseType |
| | | printcell.printCount = baseCount |
| | | printcell.templateID = baseTemp |
| | | printcell.printType = formdata.printtype || '' |
| | | printcell.printCount = +(formdata.printcount || 1) |
| | | printcell.templateID = formdata.templateid || btn.verify.Template || '' |
| | | |
| | | printcell.data = [formdata] |
| | | |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(printcell.templateID) |
| | | |
| | | printlist.push(printcell) |
| | | } else { |
| | | data.forEach(cell => { |
| | | let _cell = {...cell, ...formdata} |
| | | let _cell = {} |
| | | |
| | | Object.keys(cell).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | _cell[_key] = cell[key] |
| | | }) |
| | | |
| | | _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] |
| | | } |
| | | }) |
| | | printcell.printType = _cell.printtype || '' |
| | | printcell.printCount = +(_cell.printcount || 1) |
| | | printcell.templateID = _cell.templateid || btn.verify.Template || '' |
| | | |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = baseCount |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(printcell.templateID) |
| | |
| | | }) |
| | | } |
| | | |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(printlist, formdata) |
| | | resolve(false) |
| | | } else { |
| | | resolve(true) |
| | | } |
| | | } else { |
| | | this.getprintdata(btn, data, formdata, formlist).then(result => { |
| | | if (result.next) { |
| | | if (!result.next) { |
| | | resolve(false) |
| | | return |
| | | } |
| | | |
| | | // 自定义打印 |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(result.list, formdata) |
| | | resolve(false) |
| | | return |
| | | } |
| | | |
| | | result.list.forEach(cell => { |
| | | // 系统打印数据,校验data字段 |
| | | if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return |
| | | if (!cell.data || cell.data.length === 0) return |
| | | |
| | | let templateID = baseTemp |
| | | let printType = baseType |
| | | let printCount = 0 |
| | | cell.data.forEach(item => { |
| | | let _item = {...formdata} |
| | | |
| | | Object.keys(cell).forEach(key => { |
| | | if (!cell[key]) return |
| | | _item.printtype = cell.printtype || '' |
| | | _item.printcount = cell.printcount || 1 |
| | | _item.templateid = cell.templateid || '' |
| | | |
| | | Object.keys(item).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | |
| | | if (_key === 'templateid') { |
| | | templateID = cell[key] |
| | | } else if (_key === 'printtype') { |
| | | printType = cell[key] |
| | | } else if (_key === 'printcount') { |
| | | printCount = +cell[key] |
| | | } |
| | | _item[_key] = item[key] |
| | | }) |
| | | |
| | | cell.templateID = templateID |
| | | cell.printType = printType |
| | | cell.printCount = printCount |
| | | let printcell = {data: [_item]} |
| | | |
| | | if (isNaN(cell.printCount) || cell.printCount < 1) { |
| | | cell.printCount = baseCount |
| | | printcell.printType = _item.printtype || '' |
| | | printcell.printCount = +(_item.printcount || 1) |
| | | printcell.templateID = _item.templateid || btn.verify.Template || '' |
| | | |
| | | if (isNaN(printcell.printCount) || printcell.printCount < 1) { |
| | | printcell.printCount = 1 |
| | | } |
| | | |
| | | templates.push(cell.templateID) |
| | | templates.push(printcell.templateID) |
| | | |
| | | printlist.push(cell) |
| | | printlist.push(printcell) |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | resolve(result.next) |
| | | resolve(true) |
| | | }) |
| | | } |
| | | }).then(res => { |
| | | // 获取打印模板 getTemp |
| | | if (!res) return false |
| | | |
| | | if (btn.verify.printMode === 'custom') { |
| | | this.execCustomPrint(printlist, formdata) |
| | | |
| | | return false |
| | | } |
| | | |
| | | templates = Array.from(new Set(templates)) // 去重 |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | this.execPrint(printlist, _temps, formdata) |
| | | this.execPrint(printlist, _temps) |
| | | }, 500) |
| | | } else { |
| | | this.execPrint(printlist, _temps, formdata) |
| | | this.execPrint(printlist, _temps) |
| | | } |
| | | } else { |
| | | this.execError(errorMsg) |
| | |
| | | }) |
| | | |
| | | new Promise(resolve => { |
| | | if (btn.intertype === 'system') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.intertype === 'system' && btn.verify.dataType !== 'custom') { // 使用系统时,直接从表格或表单中选取数据 |
| | | if (btn.Ot === 'notRequired') { |
| | | if (formlist.length > 0) { |
| | | list = [formdata] |
| | |
| | | * @description 获取打印数据 |
| | | */ |
| | | getprintdata = (btn, data, formdata, formlist) => { |
| | | const { setting } = this.props |
| | | const { setting, BID } = this.props |
| | | |
| | | let _list = [] |
| | | return new Promise(resolve => { |
| | | let params = [] |
| | | let param = {} |
| | | |
| | | if (this.props.BID) { |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | if (btn.intertype === 'system' && btn.verify.dataType === 'custom') { |
| | | if (btn.Ot === 'notRequired') { |
| | | let _param = { ...param, ...formdata } |
| | | let _param = this.getDefaultSql(formlist, null, '') |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | let ID = '' |
| | | if (setting.primaryKey) { |
| | | param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | ID = data[0][setting.primaryKey] || '' |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | let _param = this.getDefaultSql(formlist, data[0], ID) |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let ID = '' |
| | | |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ID = ids.join(',') |
| | | } |
| | | |
| | | let _param = this.getDefaultSql(formlist, data[0], ID) |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map(cell => { |
| | | let ID = '' |
| | | if (setting.primaryKey) { |
| | | ID = cell[setting.primaryKey] || '' |
| | | } |
| | | |
| | | return this.getDefaultSql(formlist, cell, ID) |
| | | }) |
| | | } |
| | | } else { |
| | | if (btn.Ot === 'notRequired') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredSgl') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = data[0][setting.primaryKey] |
| | | } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'requiredOnce') { |
| | | let _param = { ...formdata } |
| | | |
| | | if (setting.primaryKey) { |
| | | let ids = data.map(d => { return d[setting.primaryKey]}) |
| | | ids = ids.filter(Boolean) |
| | | ids = ids.join(',') |
| | | |
| | | param[setting.primaryKey] = ids |
| | | _param[setting.primaryKey] = ids |
| | | } |
| | | |
| | | let _param = { ...param, ...formdata } |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | params.push(_param) |
| | | } else if (btn.Ot === 'required') { |
| | | params = data.map((cell, index) => { |
| | | let _param = { ...param } |
| | | let _param = {} |
| | | |
| | | if (setting.primaryKey) { |
| | | _param[setting.primaryKey] = cell[setting.primaryKey] |
| | | } |
| | | |
| | | if (BID) { |
| | | _param.BID = BID |
| | | } |
| | | |
| | | let _cell = {} |
| | |
| | | return _param |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (btn.intertype === 'inner' || btn.intertype === 'system') { |
| | | if (btn.intertype === 'inner') { |
| | | params = params.map(_param => { |
| | | _param.func = btn.innerFunc |
| | | |
| | | return _param |
| | | }) |
| | | } |
| | | |
| | | if (params.length <= 20) { |
| | | let deffers = params.map(par => { |
| | |
| | | } |
| | | }) |
| | | if (!errorMsg) { |
| | | resolve({next: true, list: result}) |
| | | resolve({next: true, list: result.map(res => { |
| | | Object.keys(res).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | res[_key] = res[key] |
| | | } |
| | | }) |
| | | |
| | | return res |
| | | })}) |
| | | } else { |
| | | this.execError(errorMsg) |
| | | resolve({next: false, list: []}) |
| | |
| | | this.printOuterLoopRequest(params, btn, _list, resolve) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 获取默认存储过程请求参数 |
| | | */ |
| | | getDefaultSql = (formlist, data, ID) => { |
| | | const { BID, btn, columns } = this.props |
| | | |
| | | let arrFields = btn.verify.columns.map(col => col.field).join(',') |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | exec_type: 'y', |
| | | arr_field: arrFields, |
| | | default_sql: btn.verify.setting.defaultSql |
| | | } |
| | | |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | if (ID) { |
| | | param.ID = ID |
| | | } |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let RoleID = sessionStorage.getItem('role_id') || '' |
| | | let departmentcode = sessionStorage.getItem('departmentcode') || '' |
| | | let organization = sessionStorage.getItem('organization') || '' |
| | | let mk_user_type = sessionStorage.getItem('mk_user_type') || '' |
| | | let nation = sessionStorage.getItem('nation') || '' |
| | | let province = sessionStorage.getItem('province') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | let district = sessionStorage.getItem('district') || '' |
| | | let address = sessionStorage.getItem('address') || '' |
| | | |
| | | let _dataresource = btn.verify.setting.dataresource |
| | | let _customScript = '' |
| | | |
| | | btn.verify.scripts && btn.verify.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | |
| | | if (btn.verify.setting.defaultSql === 'false') { |
| | | _dataresource = '' |
| | | } |
| | | |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | _dataresource = _dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _dataresource = _dataresource.replace(/@\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') |
| | | _customScript = _customScript.replace(/@\$/ig, '*/') |
| | | } else { |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | } |
| | | |
| | | let initsql = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) |
| | | Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' |
| | | ` |
| | | |
| | | let _vars = [] |
| | | let _initvars = [] |
| | | let _declare = [] |
| | | // 获取字段键值对 |
| | | formlist.forEach(form => { |
| | | let _key = form.key.toLowerCase() |
| | | |
| | | if (_vars.includes(_key)) return |
| | | |
| | | _vars.push(_key) |
| | | |
| | | if (form.type === 'number' || form.type === 'rate') { |
| | | let val = form.value |
| | | if (isNaN(val)) { |
| | | val = 0 |
| | | } |
| | | _initvars.push(`@${_key}=${val}`) |
| | | } else if (['date', 'datemonth'].includes(form.type)) { |
| | | _initvars.push(`@${_key}='${form.value || '1949-10-01'}'`) |
| | | } else { |
| | | _initvars.push(`@${_key}='${form.value}'`) |
| | | } |
| | | |
| | | if (form.fieldlen && form.fieldlen > 2048) { |
| | | form.fieldlen = 'max' |
| | | } |
| | | |
| | | let _type = `nvarchar(${form.fieldlen})` |
| | | |
| | | if (form.type.match(/date/ig)) { |
| | | _type = 'datetime' |
| | | } else if (form.type === 'number') { |
| | | _type = `decimal(18,${form.fieldlen})` |
| | | } else if (form.type === 'rate') { |
| | | _type = `decimal(18,2)` |
| | | } |
| | | |
| | | _declare.push(`@${_key} ${_type}`) |
| | | }) |
| | | |
| | | if (_declare.length > 0) { |
| | | initsql += `/* 表单变量 */ |
| | | Declare ${_declare.join(',')} |
| | | select ${_initvars.join(',')} |
| | | ` |
| | | |
| | | _declare = [] |
| | | _initvars = [] |
| | | } |
| | | |
| | | if (data && columns && columns.length > 0) { |
| | | let datavars = {} |
| | | |
| | | Object.keys(data).forEach(key => { |
| | | datavars[key.toLowerCase()] = data[key] |
| | | }) |
| | | |
| | | columns.forEach(col => { |
| | | if (!col.field || !col.datatype) return |
| | | |
| | | let _key = col.field.toLowerCase() |
| | | |
| | | if (_vars.includes(_key)) return |
| | | |
| | | let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' |
| | | |
| | | if (/^date/ig.test(col.datatype) && !_val) { |
| | | _val = '1949-10-01' |
| | | } |
| | | |
| | | _initvars.push(`@${_key}='${_val}'`) |
| | | _declare.push(`@${_key} ${col.datatype}`) |
| | | }) |
| | | } |
| | | |
| | | if (_declare.length > 0) { |
| | | initsql += `/* 显示列变量 */ |
| | | Declare ${_declare.join(',')} |
| | | select ${_initvars.join(',')} |
| | | ` |
| | | } |
| | | |
| | | |
| | | if (_customScript) { |
| | | _customScript = `${initsql} |
| | | ${_customScript} |
| | | ` |
| | | } |
| | | |
| | | _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') |
| | | _customScript = _customScript.replace(/@select\$|\$select@/ig, '') |
| | | _dataresource = _dataresource.replace(/\$sum@/ig, '/*') |
| | | _dataresource = _dataresource.replace(/@sum\$/ig, '*/') |
| | | _customScript = _customScript.replace(/\$sum@/ig, '/*') |
| | | _customScript = _customScript.replace(/@sum\$/ig, '*/') |
| | | |
| | | _dataresource = _dataresource.replace(/@ID@/ig, `'${ID}'`) |
| | | _customScript = _customScript.replace(/@ID@/ig, `'${ID}'`) |
| | | _dataresource = _dataresource.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _customScript = _customScript.replace(/@BID@/ig, `'${BID || ''}'`) |
| | | _dataresource = _dataresource.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _customScript = _customScript.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _customScript = _customScript.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _customScript = _customScript.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) |
| | | _dataresource = _dataresource.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | _customScript = _customScript.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) |
| | | |
| | | |
| | | let LText = '' |
| | | |
| | | if (_dataresource) { |
| | | LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${btn.verify.setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows ` |
| | | } |
| | | |
| | | if (_customScript) { |
| | | if (LText) { |
| | | LText = `${LText} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } else { |
| | | _customScript = `${_customScript} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | ` |
| | | } |
| | | } else { |
| | | LText = `${initsql} |
| | | ${LText} |
| | | ` |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | _customScript && console.info(`${btn.logLabel ? `/*${btn.logLabel} 自定义脚本*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.info(`${btn.logLabel ? `/*${btn.logLabel} 数据源*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) |
| | | } |
| | | |
| | | if (btn.logLabel) { |
| | | param.menuname = btn.logLabel |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(_customScript) |
| | | param.LText = Utils.formatOptions(LText) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (window.GLOB.probation) { |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | return Api.genericInterface(_callbackparam) |
| | | } else if (response.status) { |
| | | Object.keys(response).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | response[_key] = response[key] |
| | | } |
| | | }) |
| | | |
| | | _list.push(response) |
| | | |
| | |
| | | if (!response) return |
| | | |
| | | if (response.status) { |
| | | Object.keys(response).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | response[_key] = response[key] |
| | | } |
| | | }) |
| | | |
| | | _list.push(response) |
| | | |
| | | // 一次请求成功,进行下一项请求 |
| | |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | Object.keys(res).forEach(key => { |
| | | let _key = key.toLowerCase() |
| | | if (['templateid', 'printtype', 'printcount'].includes(_key)) { |
| | | res[_key] = res[key] |
| | | } |
| | | }) |
| | | _list.push(res) |
| | | |
| | | if (params.length === 0) { |
| | |
| | | } |
| | | |
| | | configParam.elements.forEach(element => { |
| | | let _field = element.field |
| | | let _field = element.field || '' |
| | | |
| | | if (_field === 'other_field') { |
| | | _field = element.cusfield || '' |
| | |
| | | Name: element.name || '', |
| | | Type: element.type, |
| | | Value: element.value || '', |
| | | Field: _field, |
| | | Field: _field.toLowerCase(), |
| | | Left: element.left + offsetLeft, |
| | | Top: element.top + offsetTop, |
| | | Width: element.width, |
| | |
| | | item.ImageWidth = element.imgWidth |
| | | item.ImageHeight = element.imgHeight |
| | | item.Trimming = '' |
| | | if (!item.Field) { |
| | | if (element.productValue && window.GLOB.systemType === 'production') { |
| | | item.Value = element.productValue |
| | | imgs.push(item.Value) |
| | | } else if (item.Value) { |
| | | imgs.push(item.Value) |
| | | } |
| | | } |
| | | } else if (item.Type === 'text') { |
| | | item.FontFamily = element.fontFamily |
| | |
| | | return { |
| | | error: error, |
| | | config: _configparam, |
| | | fields: fields, |
| | | nonEFields: nonEFields, |
| | | fields: Array.from(new Set(fields)), |
| | | nonEFields: Array.from(new Set(nonEFields)), |
| | | imgs: imgs |
| | | } |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | execPrint = (list, template, formdata) => { |
| | | execPrint = (list, template) => { |
| | | const { btn } = this.props |
| | | let _errors = [] |
| | | |
| | |
| | | _datalist.forEach(res => { |
| | | res.data.forEach(_cell => { |
| | | for (let i = 0; i < res.printCount; i++) { |
| | | _data.push({...formdata, ..._cell}) |
| | | _data.push(_cell) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | 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 => { |
| | | template[key].fields.forEach(f => { |
| | | if (!d.hasOwnProperty(f)) { |
| | | lacks.push(f) |
| | | } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) { |
| | | } else if (template[key].nonEFields.includes(f) && !d[f] && d[f] !== 0) { |
| | | emptys.push(f) |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | 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, |
| | |
| | | return |
| | | } |
| | | |
| | | // let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] |
| | | |
| | | if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { |
| | | socket = new WebSocket('ws://' + btn.verify.linkUrl) |
| | | } else { |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | // } |
| | | } |
| | | |
| | | // 打开Socket |
| | | socket.onopen = () =>{ |
| | | // if (lackItems) { |
| | | // let request = { |
| | | // requestID: '', |
| | | // version: '', |
| | | // cmd: 'getPrinters' |
| | | // } |
| | | // socket.send(JSON.stringify(request)) |
| | | // } else { |
| | | this.syncMessageSend(printerList) |
| | | |
| | | this.execSuccess({ |
| | |
| | | ErrMesg: '打印请求已发出。', |
| | | status: true |
| | | }) |
| | | // } |
| | | } |
| | | // 监听消息 |
| | | socket.onmessage = (event) => { |