From 102be577a7f8df2ae30045d55a1a5fc584f90363 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 19 十二月 2022 18:31:38 +0800 Subject: [PATCH] 2022-12-19 --- src/tabviews/custom/components/iframe/index.scss | 3 src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 190 +++--- src/utils/utils-custom.js | 23 src/templates/sharecomponent/actioncomponent/verifyprint/editable/index.jsx | 17 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 2 src/templates/sharecomponent/actioncomponent/verifyexcelout/utils.jsx | 18 src/tabviews/zshare/actionList/index.jsx | 1 src/templates/sharecomponent/actioncomponent/verifyprint/utils.jsx | 77 ++ src/menu/components/iframe/index.scss | 3 src/menu/components/iframe/options.jsx | 13 src/tabviews/custom/components/iframe/index.jsx | 9 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 8 src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx | 64 - src/tabviews/custom/components/card/cardcellList/index.jsx | 1 src/tabviews/custom/components/card/prop-card/index.jsx | 14 src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx | 559 ++++++++++++++++- src/menu/components/card/data-card/options.jsx | 8 src/menu/components/share/actioncomponent/formconfig.jsx | 1 src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 2 src/templates/zshare/verifycard/index.jsx | 2 src/tabviews/zshare/actionList/printbutton/index.jsx | 642 +++++++++++++++------ src/tabviews/zshare/mutilform/index.jsx | 2 src/templates/sharecomponent/actioncomponent/verifyprint/index.scss | 51 + src/menu/components/share/actioncomponent/actionform/index.jsx | 5 src/templates/sharecomponent/actioncomponent/index.jsx | 3 src/tabviews/custom/index.jsx | 4 src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx | 22 src/tabviews/zshare/cardcomponent/index.jsx | 1 28 files changed, 1,305 insertions(+), 440 deletions(-) diff --git a/src/menu/components/card/data-card/options.jsx b/src/menu/components/card/data-card/options.jsx index 8026bd2..0487c0f 100644 --- a/src/menu/components/card/data-card/options.jsx +++ b/src/menu/components/card/data-card/options.jsx @@ -303,15 +303,15 @@ { type: 'radio', field: 'goback', - label: '绌哄�艰繑鍥�', + label: appType === 'mob' ? '绌哄�艰繑鍥�' : '绌哄�煎叧闂�', initval: wrap.goback || 'false', - tooltip: '褰撴煡璇㈡暟鎹负绌烘椂锛岃繑鍥炰笂涓�鐣岄潰銆�', + tooltip: appType === 'mob' ? '褰撴煡璇㈡暟鎹负绌烘椂锛岃繑鍥炰笂涓�鐣岄潰銆�' : '褰撴煡璇㈡暟鎹负绌烘椂锛屽叧闂綋鍓嶆爣绛鹃〉銆�', required: false, options: [ - {value: 'true', label: '鏄�'}, {value: 'false', label: '鍚�'}, + {value: 'true', label: '鏄�'}, ], - forbid: subtype !== 'propcard' || appType !== 'mob' + forbid: subtype !== 'propcard' || appType === 'pc' }, { type: 'radio', diff --git a/src/menu/components/iframe/index.scss b/src/menu/components/iframe/index.scss index f1a9bf5..0ebffb8 100644 --- a/src/menu/components/iframe/index.scss +++ b/src/menu/components/iframe/index.scss @@ -25,8 +25,7 @@ height: 45px; padding-top: 5px; .ant-input-group-wrapper { - width: 40%; - max-width: 400px; + width: 65%; float: right; } } diff --git a/src/menu/components/iframe/options.jsx b/src/menu/components/iframe/options.jsx index 73bee16..8a54190 100644 --- a/src/menu/components/iframe/options.jsx +++ b/src/menu/components/iframe/options.jsx @@ -79,9 +79,22 @@ ], controlFields: [ {field: 'linkUrl', values: ['fixed']}, + {field: 'focus', values: ['input']}, ] }, { + type: 'radio', + field: 'focus', + label: '鑷姩鑱氱劍', + initval: wrap.focus || 'true', + required: false, + options: [ + {value: 'true', label: '鏄�'}, + {value: 'false', label: '鍚�'}, + ], + forbid: appType === 'mob' + }, + { type: 'textarea', field: 'linkUrl', label: '鍦板潃閾炬帴', diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index ddbb440..8cbf7ca 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -549,14 +549,13 @@ } else if (value === 'excelIn') { _fieldval.intertype = 'system' _fieldval.Ot = 'notRequired' - + _fieldval.execSuccess = 'grid' _fieldval.label = '瀵煎叆Excel' _fieldval.class = 'dgreen' this.record.Ot = 'notRequired' this.record.label = '瀵煎叆Excel' this.record.class = 'dgreen' - - + this.record.execSuccess = 'grid' } else if (value === 'excelOut') { _fieldval.intertype = 'system' _fieldval.label = '瀵煎嚭Excel' diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index ae79d94..4e2ec05 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -147,7 +147,6 @@ } else if (appType === 'pc') { opentypes = opentypes.filter(item => item.value !== 'tab') funTypes = [ - { value: 'refund', text: '閫�娆�' }, { value: 'changeuser', text: '鍒囨崲鐢ㄦ埛' }, ] pageTemps = [ diff --git a/src/tabviews/custom/components/card/cardcellList/index.jsx b/src/tabviews/custom/components/card/cardcellList/index.jsx index a7a0f74..4be6caa 100644 --- a/src/tabviews/custom/components/card/cardcellList/index.jsx +++ b/src/tabviews/custom/components/card/cardcellList/index.jsx @@ -896,6 +896,7 @@ BData={data.$$BData || ''} disabled={_disabled} setting={cards.setting} + columns={cards.columns} selectedData={_data} /> </Col> diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index 14185b5..c6203d6 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -397,12 +397,18 @@ data: _data, loading: false }, () => { - if (selected !== 'false') { - this.checkTopLine() + if (config.wrap.goback === 'true' && _data.$$empty) { + this.timer && this.timer.stop() + + MKEmitter.emit('closeTabView', config.$pageId) } else { - this.transferLine() + if (selected !== 'false') { + this.checkTopLine() + } else { + this.transferLine() + } + this.autoExec() } - this.autoExec() }) if (config.timer && config.clearField) { diff --git a/src/tabviews/custom/components/iframe/index.jsx b/src/tabviews/custom/components/iframe/index.jsx index e8d4fd5..22e48c4 100644 --- a/src/tabviews/custom/components/iframe/index.jsx +++ b/src/tabviews/custom/components/iframe/index.jsx @@ -82,8 +82,17 @@ } componentDidMount () { + const { config } = this.state + MKEmitter.addListener('reloadData', this.reloadData) MKEmitter.addListener('resetSelectLine', this.resetParentParam) + + if (config.wrap.linkType === 'input' && config.wrap.focus !== 'false') { + setTimeout(() => { + let node = document.getElementById(config.uuid) + node && node.select && node.select() + }, 200) + } } shouldComponentUpdate (nextProps, nextState) { diff --git a/src/tabviews/custom/components/iframe/index.scss b/src/tabviews/custom/components/iframe/index.scss index 9ca59f4..88f3569 100644 --- a/src/tabviews/custom/components/iframe/index.scss +++ b/src/tabviews/custom/components/iframe/index.scss @@ -33,8 +33,7 @@ .ant-input-search { margin-top: 5px; - width: 40%; - max-width: 400px; + width: 65%; float: right; } } diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 3a28d2d..b35c3c2 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -838,6 +838,10 @@ component.setting.useMSearch = component.setting.useMSearch === 'true' + if (component.wrap && component.wrap.goback === 'true') { + component.setting.sync = 'false' + } + if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 component.setting.sync = 'false' component.setting.laypage = component.setting.laypage === 'true' diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index f658b86..8dc3084 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -195,7 +195,7 @@ }) viewParam.arr_field = viewParam.arr_field.join(',') - viewParam.orderBy = btn.verify.order || viewParam.orderBy + viewParam.orderBy = btn.verify.order || '' } } if (btn.intertype === 'system' && btn.verify.enable === 'true') { diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 7dd0d4b..dca525f 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -139,6 +139,7 @@ btn={item} BData={BData} setting={setting} + columns={columns} selectedData={selectedData} /> ) diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index 988c039..a3c01ee 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -27,6 +27,7 @@ MenuID: PropTypes.string, // 鑿滃崟ID btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + columns: PropTypes.array, disabled: PropTypes.any, // 琛屾寜閽鐢� } @@ -190,6 +191,13 @@ 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({ @@ -244,70 +252,52 @@ 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) @@ -316,58 +306,64 @@ }) } - resolve(true) + 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) { - result.list.forEach(cell => { - // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 - if (btn.verify.printMode !== 'custom' && (!cell.data || cell.data.length === 0)) return + if (!result.next) { + resolve(false) + return + } - let templateID = baseTemp - let printType = baseType - let printCount = 0 + // 鑷畾涔夋墦鍗� + if (btn.verify.printMode === 'custom') { + this.execCustomPrint(result.list, formdata) + resolve(false) + return + } - Object.keys(cell).forEach(key => { - if (!cell[key]) return + result.list.forEach(cell => { + // 绯荤粺鎵撳嵃鏁版嵁锛屾牎楠宒ata瀛楁 + if (!cell.data || cell.data.length === 0) return + cell.data.forEach(item => { + let _item = {...formdata} + + _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]} + + printcell.printType = _item.printtype || '' + printcell.printCount = +(_item.printcount || 1) + printcell.templateID = _item.templateid || btn.verify.Template || '' - if (isNaN(cell.printCount) || cell.printCount < 1) { - cell.printCount = baseCount + 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)) // 鍘婚噸 @@ -447,10 +443,10 @@ }) } - this.execPrint(printlist, _temps, formdata) + this.execPrint(printlist, _temps) }, 500) } else { - this.execPrint(printlist, _temps, formdata) + this.execPrint(printlist, _temps) } } else { this.execError(errorMsg) @@ -471,7 +467,7 @@ }) 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] @@ -792,72 +788,124 @@ * @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.Ot === 'notRequired') { - let _param = { ...param, ...formdata } - params.push(_param) - } else if (btn.Ot === 'requiredSgl') { - if (setting.primaryKey) { - param[setting.primaryKey] = data[0][setting.primaryKey] - } - - let _param = { ...param, ...formdata } - - params.push(_param) - } else if (btn.Ot === 'requiredOnce') { - if (setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey]}) - ids = ids.filter(Boolean) - ids = ids.join(',') + if (btn.intertype === 'system' && btn.verify.dataType === 'custom') { + if (btn.Ot === 'notRequired') { + let _param = this.getDefaultSql(formlist, null, '') - param[setting.primaryKey] = ids - } - - let _param = { ...param, ...formdata } - - params.push(_param) - } else if (btn.Ot === 'required') { - params = data.map((cell, index) => { - let _param = { ...param } - + params.push(_param) + } else if (btn.Ot === 'requiredSgl') { + let ID = '' if (setting.primaryKey) { - _param[setting.primaryKey] = cell[setting.primaryKey] + ID = data[0][setting.primaryKey] || '' } - let _cell = {} - if (index !== 0) { - Object.keys(cell).forEach(key => { - _cell[key.toLowerCase()] = cell[key] - }) + 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(',') } - formlist.forEach(_data => { - if (index !== 0 && _data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { - _param[_data.key] = _cell[_data.key.toLowerCase()] - } else { - _param[_data.key] = _data.value + 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) }) - return _param - }) + } + } 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 + } + + if (BID) { + _param.BID = BID + } + + params.push(_param) + } else if (btn.Ot === 'required') { + params = data.map((cell, index) => { + let _param = {} + + if (setting.primaryKey) { + _param[setting.primaryKey] = cell[setting.primaryKey] + } + + if (BID) { + _param.BID = BID + } + + let _cell = {} + if (index !== 0) { + Object.keys(cell).forEach(key => { + _cell[key.toLowerCase()] = cell[key] + }) + } + + formlist.forEach(_data => { + if (index !== 0 && _data.readin && _cell.hasOwnProperty(_data.key.toLowerCase())) { + _param[_data.key] = _cell[_data.key.toLowerCase()] + } else { + _param[_data.key] = _data.value + } + }) + return _param + }) + } } - if (btn.intertype === 'inner') { - params = params.map(_param => { - _param.func = btn.innerFunc - - 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 => { @@ -875,7 +923,16 @@ } }) 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: []}) @@ -888,6 +945,233 @@ 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 ? '' : '/*涓嶆墽琛岄粯璁ql*/\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 } /** @@ -986,6 +1270,12 @@ 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) @@ -1003,6 +1293,13 @@ 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) // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� @@ -1026,6 +1323,12 @@ 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) { @@ -1072,7 +1375,7 @@ } configParam.elements.forEach(element => { - let _field = element.field + let _field = element.field || '' if (_field === 'other_field') { _field = element.cusfield || '' @@ -1082,7 +1385,7 @@ 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, @@ -1119,11 +1422,13 @@ item.ImageWidth = element.imgWidth item.ImageHeight = element.imgHeight item.Trimming = '' - if (element.productValue && window.GLOB.systemType === 'production') { - item.Value = element.productValue - imgs.push(item.Value) - } else if (item.Value) { - imgs.push(item.Value) + 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 @@ -1190,8 +1495,8 @@ return { error: error, config: _configparam, - fields: fields, - nonEFields: nonEFields, + fields: Array.from(new Set(fields)), + nonEFields: Array.from(new Set(nonEFields)), imgs: imgs } } @@ -1339,7 +1644,7 @@ }) } - execPrint = (list, template, formdata) => { + execPrint = (list, template) => { const { btn } = this.props let _errors = [] @@ -1379,30 +1684,25 @@ _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, @@ -1490,49 +1790,29 @@ 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.syncMessageSend(printerList) - this.execSuccess({ - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - // } + this.execSuccess({ + ErrCode: 'S', + message: '', + ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) } // 鎵撳紑Socket socket.onopen = () =>{ - // if (lackItems) { - // let request = { - // requestID: '', - // version: '', - // cmd: 'getPrinters' - // } - // socket.send(JSON.stringify(request)) - // } else { - this.syncMessageSend(printerList) + this.syncMessageSend(printerList) - this.execSuccess({ - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - // } + this.execSuccess({ + ErrCode: 'S', + message: '', + ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', + status: true + }) } // 鐩戝惉娑堟伅 socket.onmessage = (event) => { diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index 3bcfd1a..9062213 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -208,6 +208,7 @@ btn={item} BData={BData} setting={setting} + columns={columns} selectedData={[data]} /> ) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 1f25c6c..ec96237 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -301,7 +301,7 @@ }) } else if (item.regular === 'email') { _rules.push({ - pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, + pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, message: item.regularText || '璇锋纭緭鍏ラ偖绠卞湴鍧�' }) } diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index a284146..eaefc28 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -377,9 +377,11 @@ _fieldval.label = '瀵煎叆Excel' _fieldval.class = 'dgreen' + _fieldval.execSuccess = 'grid' this.record.Ot = 'notRequired' this.record.label = '瀵煎叆Excel' this.record.class = 'dgreen' + this.record.execSuccess = 'grid' } else if (value === 'excelOut') { _fieldval.intertype = 'system' _fieldval.label = '瀵煎嚭Excel' diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index 024cfc7..06d1cf2 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -878,7 +878,8 @@ } else if (card.OpenType === 'funcbutton' && card.funcType === 'print') { return <VerifyPrint card={card} - columns={config.columns} + columns={[]} + // columns={config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} /> } else if (card.OpenType === 'funcbutton' && card.funcType === 'megvii') { diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 555ed77..947413b 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -239,8 +239,10 @@ UNSAFE_componentWillMount() { const { card } = this.props - let _verify = fromJS(card.verify || {range: 1}).toJS() + let _verify = fromJS(card.verify || {}).toJS() let _columns = _verify.columns || [] + + delete _verify.dataresource // 鏃ф暟鎹吋瀹� _columns = _columns.map(col => { @@ -260,6 +262,10 @@ return col }) + if (!_verify.hasOwnProperty('range')) { + _verify.range = 1 + } + this.setState({ verify: { ..._verify, diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx index 8ba60e3..7e27b64 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx @@ -1,8 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' +import { Form, Row, Col, Button, notification, Tooltip, Select } from 'antd' import moment from 'moment' import Api from '@/api' @@ -12,39 +11,100 @@ class CustomForm extends Component { static propTpyes = { - scripts: PropTypes.array, // 鑷畾涔夎剼鏈垪琛� - usefulfields: PropTypes.any, // 鍙敤瀛楁 - systemScripts: PropTypes.array, // 绯荤粺鑴氭湰 - scriptsChange: PropTypes.func // 琛ㄥ崟 + searches: PropTypes.any, // 鎼滅储鏉′欢 + linefields: PropTypes.any, + scriptsChange: PropTypes.func } state = { editItem: null, + systemScripts: [], usefulfields: null, loading: false, - verifySql: '' } UNSAFE_componentWillMount () { - this.resetfield(this.props.usefulfields) + this.resetfield(this.props.searches) } - UNSAFE_componentWillReceiveProps (nextProps) { - if (nextProps.usefulfields && !is(fromJS(this.props.usefulfields), fromJS(nextProps.usefulfields))) { - this.resetfield(nextProps.usefulfields) + UNSAFE_componentWillReceiveProps(nextProps) { + if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) { + this.resetfield(nextProps.searches) } } - resetfield = (columns) => { - columns = columns.filter(item => item.Column !== '$Index') - let fields = columns.map(item => item.Column) + componentDidMount () { + this.getsysScript() + } - let _sql = `Declare @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),@ErrorCode nvarchar(50), @retmsg nvarchar(4000) - ` + getsysScript = () => { + if (sessionStorage.getItem('mk_sys_scripts')) { + this.setState({ + systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) + }) + return + } + let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` + + _scriptSql = Utils.formatOptions(_scriptSql) + + let _sParam = { + func: 'sPC_Get_SelectedList', + LText: _scriptSql, + obj_name: 'data', + arr_field: 'funcname,longparam' + } + + _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) + _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 + + Api.getSystemConfig(_sParam).then(res => { + if (res.status) { + let _scripts = res.data.map(item => { + return { + name: item.funcname, + value: window.decodeURIComponent(window.atob(item.longparam)) + } + }) + + sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) + + this.setState({ + systemScripts: _scripts + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } + + resetfield = (searches) => { + let _usefulFields = [] + searches.forEach(item => { + if (!item.field) return + + if (item.type === 'group') { + _usefulFields.push(item.field) + _usefulFields.push(item.datefield) + _usefulFields.push(item.datefield + '1') + } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { + _usefulFields.push(item.field) + _usefulFields.push(item.field + '1') + } else if (item.type === 'date' && _usefulFields.includes(item.field)) { + _usefulFields.push(item.field + '1') + } else { + _usefulFields.push(item.field) + } + }) + this.setState({ - verifySql: _sql, - usefulfields: fields.join(', ') + usefulfields: _usefulFields.join(', ') }) } @@ -116,89 +176,22 @@ return } - let tail = ` - aaa: - ` - - let _initCustomScript = '' // 鍒濆鍖栬剼鏈� - let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� - let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� - - this.props.scripts.forEach(item => { - if (item.status === 'false') return - - if (item.position === 'init') { - _initCustomScript += ` - /* 鍒濆鍖栬剼鏈� */ - ${values.uuid === item.uuid ? values.sql : item.sql} - ` - } else if (item.position === 'front') { - _prevCustomScript += ` - /* 榛樿sql鍓嶈剼鏈� */ - ${values.uuid === item.uuid ? values.sql : item.sql} - ` - } else { - _backCustomScript += ` - /* 榛樿sql鍚庤剼鏈� */ - ${values.uuid === item.uuid ? values.sql : item.sql} - ` - } + this.setState({ + loading: true }) - if (!values.uuid) { - if (values.position === 'init') { - _initCustomScript += ` - /* 鍒濆鍖栬剼鏈� */ - ${values.sql} - ` - } else if (values.position === 'front') { - _prevCustomScript += ` - /* 榛樿sql鍓嶈剼鏈� */ - ${values.sql} - ` - } else { - _backCustomScript += ` - /* 榛樿sql鍚庤剼鏈� */ - ${values.sql} - ` - } - } - - let param = { - func: 's_debug_sql', - exec_type: 'y', - LText: this.state.verifySql + _initCustomScript + _prevCustomScript + _backCustomScript + tail - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) - param.LText = param.LText.replace(/\n/g, ' ') - - // 澶栬仈鏁版嵁搴撴浛鎹� - if (window.GLOB.externalDatabase !== null) { - param.LText = param.LText.replace(/@db@/ig, window.GLOB.externalDatabase) - } - - param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt('', param.timestamp) - - this.setState({loading: true}) - Api.genericInterface(param).then(res => { - if (res.status) { + this.props.scriptsChange(values, (status) => { + if (status) { this.setState({ loading: false, editItem: null - }, () => { - this.props.scriptsChange(values) }) this.props.form.setFieldsValue({ sql: '' }) } else { - this.setState({loading: false}) - - Modal.error({ - title: res.message + this.setState({ + loading: false }) } }) @@ -250,8 +243,8 @@ } render() { - const { systemScripts, sheet } = this.props - const { usefulfields } = this.state + const { sheet, linefields } = this.props + const { usefulfields, systemScripts } = this.state const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { @@ -280,11 +273,12 @@ <Col span={24} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id</span></Tooltip>, - <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>, - {usefulfields} + <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip> + {usefulfields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鎼滅储鏉′欢锛岃鎸夌収@xxx@鏍煎紡浣跨敤銆�'}>, {usefulfields}</Tooltip> : null} + {linefields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'琛ㄥ崟鍙婅鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}>, {linefields}</Tooltip> : null} </Form.Item> </Col> - <Col span={8} style={{whiteSpace: 'nowrap'}}> + {/* <Col span={8} style={{whiteSpace: 'nowrap'}}> <Form.Item style={{marginBottom: 0}} label={ <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌榛樿sql浣嶇疆鍏崇郴銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -301,8 +295,8 @@ </Radio.Group> )} </Form.Item> - </Col> - <Col span={10}> + </Col> */} + <Col span={8}> <Form.Item style={{marginBottom: 0}} label={'蹇嵎娣诲姞'}> <Select showSearch diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx index cd970a6..557bf84 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/datasource/index.jsx @@ -11,6 +11,7 @@ class SettingForm extends Component { static propTpyes = { + btnType: PropTypes.any, setting: PropTypes.object, // 鏁版嵁婧愰厤缃� } @@ -20,10 +21,10 @@ } UNSAFE_componentWillMount () { - const { setting } = this.props + const { setting, btnType } = this.props this.setState({ - dataType: setting.dataType, + dataType: btnType === 'print' ? 'custom' : setting.dataType, defaultSql: setting.defaultSql || 'true' }) } @@ -104,7 +105,7 @@ } render() { - const { setting } = this.props + const { setting, btnType } = this.props const { getFieldDecorator } = this.props.form const { dataType, defaultSql } = this.state @@ -123,7 +124,7 @@ <div className="excelout-datasource-wrap"> <Form {...formItemLayout}> <Row gutter={24}> - <Col span={8}> + {btnType !== 'print' ? <Col span={8}> <Form.Item label="瀵煎嚭鏁版嵁"> {getFieldDecorator('dataType', { initialValue: setting.dataType @@ -134,7 +135,7 @@ </Radio.Group> )} </Form.Item> - </Col> + </Col> : null} {dataType === 'custom' ? <Col className="short-label" span={8}> <Form.Item label="琛ㄥ悕"> {getFieldDecorator('tableName', { @@ -198,12 +199,7 @@ </Form.Item> </Col> : null} {dataType === 'custom' && defaultSql === 'true' ? <Col className="short-label" span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鎺掑簭鏂瑰紡涓虹┖鏃讹紝浣跨敤琛ㄦ牸鎴栫粍浠朵腑鐨勬帓搴忔柟寮忋��"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鎺掑簭鏂瑰紡 - </Tooltip> - }> + <Form.Item label="鎺掑簭鏂瑰紡"> {getFieldDecorator('order', { initialValue: setting.order || '', rules: [ @@ -215,9 +211,9 @@ })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} </Form.Item> </Col> : null} - {dataType === 'custom' ? <Col span={8}> + {dataType === 'custom' && btnType !== 'print' ? <Col span={8}> <Form.Item label={ - <Tooltip placement="topLeft" title="涓嶄娇鐢ㄦ悳绱㈡潯浠舵椂锛屼笉浼氳繘琛屾悳绱㈡潯浠剁殑鎷兼帴涓庣浉鍏崇粺璁″瓧娈电殑鏇挎崲銆傛敞锛氳嚜瀹氫箟鏁版嵁鏉ユ簮鏃讹紝鍙娇鐢ㄥ唴閮ㄦ悳绱€��"> + <Tooltip placement="topLeft" title="涓嶄娇鐢ㄦ悳绱㈡潯浠舵椂锛屼笉浼氳繘琛屾悳绱㈡潯浠剁殑鎷兼帴涓庣浉鍏崇粺璁″瓧娈电殑鏇挎崲銆�"> <QuestionCircleOutlined className="mk-form-tip" /> 鎼滅储鏉′欢 </Tooltip> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx index eb8ffeb..d3bc305 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx @@ -29,7 +29,6 @@ state = { verify: {}, activeKey: 'setting', - systemScripts: [], defaultscript: '', // 鑷畾涔夎剼鏈� excelColumns: [ { @@ -353,57 +352,6 @@ searches: searches, activeKey: card.intertype === 'system' && _verify.dataType === 'custom' ? 'setting' : 'columns', defaultscript: defaultscript - }) - } - - componentDidMount () { - this.getsysScript() - } - - getsysScript = () => { - if (sessionStorage.getItem('mk_sys_scripts')) { - this.setState({ - systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts')) - }) - return - } - - let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` - - _scriptSql = Utils.formatOptions(_scriptSql) - - let _sParam = { - func: 'sPC_Get_SelectedList', - LText: _scriptSql, - obj_name: 'data', - arr_field: 'funcname,longparam' - } - - _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) - _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 - - Api.getSystemConfig(_sParam).then(res => { - if (res.status) { - let _scripts = res.data.map(item => { - return { - name: item.funcname, - value: window.decodeURIComponent(window.atob(item.longparam)) - } - }) - - sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts)) - - this.setState({ - systemScripts: _scripts - }) - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } }) } @@ -945,7 +893,7 @@ } } - scriptsChange = (values) => { + scriptsChange = (values, callback) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) if (values.uuid) { @@ -968,10 +916,12 @@ loading: false, verify: verify }) + callback(true) }, () => { // 楠岃瘉澶辫触 this.setState({ loading: false }) + callback(false) }, verify.scripts) } @@ -984,7 +934,7 @@ } let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - let sql = SettingUtils.getDebugSql(verify, scripts, searches, Utils, timestamp) + let sql = SettingUtils.getDebugSql(verify, scripts, (verify.useSearch === 'true' ? searches : []), Utils, timestamp) let param = { func: 's_debug_sql', exec_type: 'y', @@ -1012,7 +962,7 @@ render() { const { card } = this.props - const { verify, excelColumns, defaultscript, scriptsColumns, activeKey, loading } = this.state + const { verify, excelColumns, defaultscript, scriptsColumns, activeKey, loading, searches } = this.state const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { @@ -1058,9 +1008,7 @@ <CustomScript btn={card} sheet={verify.tableName} - usefulfields={verify.columns} - scripts={verify.scripts} - systemScripts={this.state.systemScripts} + searches={verify.useSearch === 'true' ? searches : []} scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} /> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/utils.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/utils.jsx index 72f7c39..306c80d 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/utils.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/utils.jsx @@ -23,6 +23,10 @@ }) arr_field = arr_field.join(',') + if (!arr_field) { + arr_field = '*' + } + let _customScript = '' scripts && scripts.forEach(script => { if (script.status === 'false') return @@ -39,14 +43,6 @@ if (verify.defaultSql === 'false') { _dataresource = '' - } - - if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { - window.GLOB.funcs.forEach(item => { - let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') - _dataresource = _dataresource.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) - _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) - }) } _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) @@ -105,15 +101,15 @@ } // 鏁版嵁婧愬鐞�, 瀛樺湪鏄剧ず鍒楁椂 - if (arr_field && _dataresource) { + if (_dataresource) { if (/\s/.test(_dataresource)) { _dataresource = '(' + _dataresource + ') tb' } if (verify.order) { - _dataresource = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${verify.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` + _dataresource = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${verify.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` } else { - _dataresource = `select ${arr_field} from ${_dataresource} ${_search}` + _dataresource = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search}` } } diff --git a/src/templates/sharecomponent/actioncomponent/verifyprint/editable/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyprint/editable/index.jsx index bf99d3c..9c93a48 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyprint/editable/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyprint/editable/index.jsx @@ -1,4 +1,5 @@ import React, {Component} from 'react' +import { fromJS } from 'immutable' import { Table, Input, Popconfirm, Form } from 'antd' import { ArrowUpOutlined, ArrowDownOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons' import Utils from '@/utils/utils.js' @@ -160,11 +161,14 @@ this.setState({ dataSource: _data }) + + this.props.onChange(fromJS(_data).toJS()) } handleDelete = key => { - const dataSource = [...this.state.dataSource] - this.setState({ dataSource: dataSource.filter(item => item.key !== key) }) + const dataSource = [...this.state.dataSource].filter(item => item.key !== key) + this.setState({ dataSource: dataSource }) + this.props.onChange(fromJS(dataSource).toJS()) } handleAdd = () => { @@ -174,11 +178,13 @@ Value: `${count}`, Text: `${count}` } + let list = [...dataSource, newData] this.setState({ - dataSource: [...dataSource, newData], + dataSource: list, count: count + 1 }) + this.props.onChange(fromJS(list).toJS()) } handleSave = row => { @@ -190,10 +196,7 @@ ...row }) this.setState({ dataSource: newData }) - } - - UNSAFE_componentWillReceiveProps () { - + this.props.onChange(fromJS(newData).toJS()) } render() { diff --git a/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx index 324f63b..06aca79 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyprint/index.jsx @@ -1,16 +1,25 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio, Tooltip } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' +import { fromJS } from 'immutable' +import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio, Tooltip, Typography, Popconfirm, Spin } from 'antd' +import { QuestionCircleOutlined, EditOutlined, StopOutlined, CheckCircleOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' +import SettingUtils from './utils.jsx' import CodeMirror from '@/templates/zshare/codemirror' +import DataSource from '../verifyexcelout/datasource' +import CustomScript from '../verifyexcelout/customscript' +import asyncComponent from '@/utils/asyncComponent' +import ColForm from '@/menu/datasource/verifycard/columnform' import EditTable from './editable' import './index.scss' +const EditMTable = asyncComponent(() => import('@/templates/zshare/editTable')) +const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) +const { Paragraph } = Typography const { TabPane } = Tabs class VerifyCard extends Component { @@ -25,20 +34,239 @@ state = { verify: {}, templates: [], + loading: false, + activeKey: 'base', selectimg: '', - printMode: 'normal' + dataType: 'line', + printMode: 'normal', + usefulfields: '', + declareSql: '', + scriptsColumns: [ + { + title: 'SQL', + dataIndex: 'sql', + width: '60%', + render: (text) => { + let title = text.match(/^\s*\/\*.+\*\//) + title = title && title[0] ? title[0] : '' + let _text = title ? text.replace(title, '') : text + + return ( + <div> + {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null} + <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph> + </div> + ) + } + }, + { + title: '鎵ц浣嶇疆', + dataIndex: 'position', + width: '10%', + render: (text, record) => { + if (record.position === 'init') { + return <span style={{color: 'orange'}}>鍒濆鍖�</span> + } else if (record.position === 'front') { + return <span style={{color: '#26C281'}}>sql鍓�</span> + } else { + return <span style={{color: '#1890ff'}}>sql鍚�</span> + } + } + }, + { + title: '鐘舵��', + dataIndex: 'status', + width: '10%', + render: (text, record) => record.status === 'false' ? + ( + <div style={{color: '#ff4d4f'}}> + 绂佺敤 + <StopOutlined style={{marginLeft: '5px'}} /> + </div> + ) : + ( + <div style={{color: '#26C281'}}> + 鍚敤 + <CheckCircleOutlined style={{marginLeft: '5px'}}/> + </div> + ) + }, + { + title: '鎿嶄綔', + align: 'center', + width: '140px', + dataIndex: 'operation', + render: (text, record) => + (<div style={{textAlign: 'center'}}> + <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> + <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> + <Popconfirm + overlayClassName="popover-confirm" + title="纭畾鍒犻櫎鍚�?" + onConfirm={() => this.handleDelete(record, 'scripts') + }> + <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> + </Popconfirm> + </div>) + } + ], + colColumns: [ + { + title: '鍚嶇О', + dataIndex: 'label', + inputType: 'input', + editable: true, + width: '28%' + }, + { + title: '瀛楁', + dataIndex: 'field', + inputType: 'input', + editable: true, + unique: true, + copy: true, + rules: [{ + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, + message: '瀛楁鍚嶅彧鍏佽鍖呭惈鏁板瓧銆佸瓧姣嶃�佹眽瀛椾互鍙奯' + }], + width: '28%' + }, + { + title: '鏁版嵁绫诲瀷', + dataIndex: 'datatype', + inputType: 'select', + options: [ + { value: 'Nvarchar(10)', text: 'Nvarchar(10)' }, + { value: 'Nvarchar(20)', text: 'Nvarchar(20)' }, + { value: 'Nvarchar(50)', text: 'Nvarchar(50)' }, + { value: 'Nvarchar(100)', text: 'Nvarchar(100)' }, + { value: 'Nvarchar(256)', text: 'Nvarchar(256)' }, + { value: 'Nvarchar(512)', text: 'Nvarchar(512)' }, + { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' }, + { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' }, + { value: 'Nvarchar(max)', text: 'Nvarchar(max)' }, + { value: 'Int', text: 'Int' }, + { value: 'Decimal(18,0)', text: 'Decimal(18,0)' }, + { value: 'Decimal(18,1)', text: 'Decimal(18,1)' }, + { value: 'Decimal(18,2)', text: 'Decimal(18,2)' }, + { value: 'Decimal(18,3)', text: 'Decimal(18,3)' }, + { value: 'Decimal(18,4)', text: 'Decimal(18,4)' }, + { value: 'Decimal(18,5)', text: 'Decimal(18,5)' }, + { value: 'Decimal(18,6)', text: 'Decimal(18,6)' }, + { value: 'Decimal(18,7)', text: 'Decimal(18,7)' }, + { value: 'Decimal(18,8)', text: 'Decimal(18,8)' }, + { value: 'Decimal(18,9)', text: 'Decimal(18,9)' }, + { value: 'Decimal(18,10)', text: 'Decimal(18,10)' }, + { value: 'Decimal(18,11)', text: 'Decimal(18,11)' }, + { value: 'Decimal(18,12)', text: 'Decimal(18,12)' }, + { value: 'Decimal(18,13)', text: 'Decimal(18,13)' }, + { value: 'Decimal(18,14)', text: 'Decimal(18,14)' }, + { value: 'Decimal(18,15)', text: 'Decimal(18,15)' }, + { value: 'Decimal(18,16)', text: 'Decimal(18,16)' }, + { value: 'Decimal(18,17)', text: 'Decimal(18,17)' }, + { value: 'Decimal(18,18)', text: 'Decimal(18,18)' }, + { value: 'date', text: 'date' }, + { value: 'datetime', text: 'datetime' }, + ], + editable: true, + width: '25%', + } + ] } UNSAFE_componentWillMount() { - let _verify = this.props.card.verify || {} + const { columns, card } = this.props + let _verify = fromJS(card.verify || {}).toJS() _verify.Template = _verify.Template || '' _verify.printerTypeList = _verify.printerTypeList || [] _verify.linkType = _verify.linkType || 'system' _verify.printMode = _verify.printMode || 'normal' + _verify.scripts = _verify.scripts || [] + _verify.columns = _verify.columns || [] + + let _usefulfields = [] + let _declare = [] + let _select = [] + let fieldArr = [] + + let _sql = '' + + if (card.execMode === 'pop' && card.modal && card.modal.fields) { + card.modal.fields.forEach(_f => { + if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return + + fieldArr.push(_f.field.toLowerCase()) + + _usefulfields.push(_f.field) + + let _fieldlen = _f.fieldlength || 50 + + if (_f.type === 'number') { + _fieldlen = _f.decimal ? _f.decimal : 0 + } + + if (_fieldlen > 2048) { + _fieldlen = 'max' + } + + let _type = `nvarchar(${_fieldlen})` + + if (_f.type.match(/date/ig)) { + _type = 'datetime' + _select.push(`@${_f.field}='1949-10-01'`) + } else if (_f.type === 'number') { + _type = `decimal(18,${_fieldlen})` + _select.push(`@${_f.field}=0`) + } else if (_f.type === 'rate') { + _type = `decimal(18,2)` + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } + + _declare.push(`@${_f.field} ${_type}`) + }) + + if (_declare.length > 0) { + _sql = `/* 琛ㄥ崟鍙橀噺 */ + Declare ${_declare.join(', ')} + Select ${_select.join(', ')} + ` + } + _declare = [] + _select = [] + } + + if (columns && columns.length > 0 && card.Ot !== 'notRequired') { + columns.forEach(_f => { + if (!_f.field || fieldArr.includes(_f.field.toLowerCase()) || !_f.datatype) return + + fieldArr.push(_f.field.toLowerCase()) + _usefulfields.push(_f.field) + + if (/decimal/ig.test(_f.datatype)) { + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } + + _declare.push(`@${_f.field} ${_f.datatype}`) + }) + + if (_declare.length > 0) { + _sql += `/* 鏄剧ず鍒楀彉閲� */ + Declare ${_declare.join(', ')} + Select ${_select.join(', ')} + ` + } + } this.setState({ verify: _verify, + declareSql: _sql, + usefulfields: _usefulfields.join(', '), + dataType: _verify.dataType || 'line', linkType: _verify.linkType, printMode: _verify.printMode, printFunc: _verify.printFunc || '// Function(data, form, printer, notification) data-鎵撳嵃鏁版嵁鍒楄〃锛宖orm-琛ㄥ崟淇℃伅锛堜笉瀛樺湪鏃朵负{}锛夛紝printer-鎵撳嵃璁剧疆锛宯otification-淇℃伅鎻愮ず鎺т欢' @@ -157,56 +385,67 @@ } handleConfirm = () => { - const { verify } = this.state + const { verify, activeKey } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - let _verify = {...verify, ...values} - - if (this.refs.editTable && this.refs.editTable.state) { - let printTypes = this.refs.editTable.state.dataSource + if (activeKey === 'base') { + this.props.form.validateFieldsAndScroll((err, values) => { + if (err) return - let emptys = printTypes.filter(item => !item.Value || !item.Text) - let valMap = new Map() - let isvalid = true + resolve({...verify, ...values}) + }) + } else if (activeKey === 'print') { + if (verify.printerTypeList.length > 0) { + let printTypes = verify.printerTypeList.map(item => item.Value) + printTypes = Array.from(new Set(printTypes)) - printTypes.forEach(item => { - if (valMap.has(item.Value)) { - isvalid = false - } else { - valMap.set(item.Value, item.Text) - } + if (verify.printerTypeList.length > printTypes.length) { + notification.warning({ + top: 92, + message: '鎵撳嵃绫诲瀷涓璙alue瀛楁涓嶅彲閲嶅!', + duration: 5 }) - - if (emptys.length > 0) { - notification.warning({ - top: 92, - message: '鎵撳嵃绫诲瀷琛ㄦ牸涓璙alue銆乀ext瀛楁涓嶅彲涓虹┖!', - duration: 5 - }) - return - } else if (!isvalid) { - notification.warning({ - top: 92, - message: '鎵撳嵃绫诲瀷琛ㄦ牸涓璙alue瀛楁涓嶅彲閲嶅!', - duration: 5 - }) - return - } - - _verify.printerTypeList = printTypes + return } - - resolve(_verify) - } else { + } + resolve(verify) + } else if (activeKey === 'setting') { + this.settingForm.handleConfirm().then(res => { + let _verify = {...verify, setting: res} + this.setState({ + verify: _verify + }, () => { + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + resolve(_verify) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + }, _verify.scripts) + }) + }) + } else if (activeKey === 'scripts') { + if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { notification.warning({ top: 92, - message: '閾炬帴鍦板潃涓庢墦鍗版ā鏉夸笉鍙负绌�!', + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', duration: 5 }) + return } - }) + + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + resolve(verify) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + }, verify.scripts) + } else { + resolve(verify) + } }) } @@ -254,10 +493,182 @@ }) } + changeDataType = (e) => { + let value = e.target.value + + this.setState({ + dataType: value + }) + } + + // 鏍囩鍒囨崲 + tabchange = (val) => { + const { activeKey, verify } = this.state + + if (activeKey === 'base') { + this.props.form.validateFieldsAndScroll((err, values) => { + if (err) return + + this.setState({ + verify: {...verify, ...values}, + activeKey: val + }) + }) + } else if (activeKey === 'print') { + if (verify.printerTypeList.length > 0) { + let printTypes = verify.printerTypeList.map(item => item.Value) + printTypes = Array.from(new Set(printTypes)) + + if (verify.printerTypeList.length > printTypes.length) { + notification.warning({ + top: 92, + message: '鎵撳嵃绫诲瀷涓璙alue瀛楁涓嶅彲閲嶅!', + duration: 5 + }) + return + } + } + this.setState({ + activeKey: val + }) + } else if (activeKey === 'setting') { + this.settingForm.handleConfirm().then(res => { + this.setState({ + verify: {...verify, setting: res} + }, () => { + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + activeKey: val, + loading: false + }) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + activeKey: val, + loading: false + }) + }, verify.scripts) + }) + }) + } else if (activeKey === 'scripts') { + if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) { + notification.warning({ + top: 92, + message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒', + duration: 5 + }) + return + } + + this.setState({loading: true}) + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + activeKey: val, + loading: false + }) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + activeKey: val, + loading: false + }) + }, verify.scripts) + } else { + this.setState({ + activeKey: val + }) + } + } + + scriptsChange = (values, callback) => { + let verify = JSON.parse(JSON.stringify(this.state.verify)) + + if (values.uuid) { + verify.scripts = verify.scripts.map(item => { + if (item.uuid === values.uuid) { + return values + } else { + return item + } + }) + } else { + values.uuid = Utils.getuuid() + verify.scripts.push(values) + } + + this.setState({loading: true}) + + this.sqlverify(() => { // 楠岃瘉鎴愬姛 + this.setState({ + loading: false, + verify: verify + }) + callback(true) + }, () => { // 楠岃瘉澶辫触 + this.setState({ + loading: false + }) + callback(false) + }, verify.scripts) + } + + sqlverify = (_resolve, _reject, scripts) => { + const { verify, declareSql } = this.state + + let timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + let sql = SettingUtils.getDebugSql(verify.setting || {}, verify.columns, scripts, declareSql, timestamp) + let param = { + func: 's_debug_sql', + exec_type: 'y', + LText: sql + } + param.LText = Utils.formatOptions(param.LText) + param.timestamp = timestamp + param.secretkey = Utils.encrypt('', timestamp) + + Api.genericInterface(param).then(result => { + if (result.status) { + _resolve() + } else { + _reject() + Modal.error({ + title: result.message + }) + } + }) + } + + columnChange = (values, resolve) => { + let verify = fromJS(this.state.verify).toJS() + + let fields = verify.columns.map(item => item.field.toLowerCase()) + if (fields.includes(values.field.toLowerCase())) { + notification.warning({ + top: 92, + message: '瀛楁宸插瓨鍦紒', + duration: 5 + }) + return + } + + resolve() + + values.uuid = Utils.getuuid() + verify.columns.push(values) + + this.setState({verify}) + } + + updatefields = (columns) => { + let verify = fromJS(this.state.verify).toJS() + verify.columns = columns + + this.setState({verify}) + } + render() { const { card } = this.props const { getFieldDecorator } = this.props.form - const { verify, linkType, printMode, printFunc } = this.state + const { verify, linkType, printMode, printFunc, scriptsColumns, dataType, loading, activeKey, usefulfields, colColumns } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -270,10 +681,11 @@ } return ( - <div> + <div className="verify-card-print-box"> {card.label ? <div className="mk-com-name">{card.label} - 楠岃瘉淇℃伅</div> : null} - <Tabs defaultActiveKey="1" className="verify-card-print-box" onChange={this.tabchange}> - <TabPane tab="鎵撳嵃楠岃瘉" key="1"> + {loading && <Spin size="large" />} + <Tabs activeKey={activeKey} onChange={this.tabchange}> + <TabPane tab="鎵撳嵃楠岃瘉" key="base"> <Form {...formItemLayout}> <Row gutter={24}> <Col span={8}> @@ -339,6 +751,18 @@ })(<Input placeholder="" autoComplete="off" />)} </Form.Item> </Col>} + {card.intertype === 'system' ? <Col span={8}> + <Form.Item label="鏁版嵁绫诲瀷"> + {getFieldDecorator('dataType', { + initialValue: dataType || 'line' + })( + <Radio.Group onChange={this.changeDataType}> + <Radio value="line">琛屾暟鎹�</Radio> + <Radio value="custom">鑷畾涔�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} {printMode === 'custom' ? <Col span={24}> <Form.Item label={'澶勭悊鍑芥暟'} className="printFunc"> {getFieldDecorator('printFunc', { @@ -433,7 +857,7 @@ )} </Form.Item> </Col> : null} - {printMode !== 'custom' ? <Col span={8} offset={printMode === 'RFID' ? 16 : 0}> + {printMode !== 'custom' ? <Col span={8} offset={16}> <img className="legend" src={this.state.selectimg} alt=""/> </Col> : null } </Row> @@ -444,7 +868,7 @@ 鎵撳嵃绫诲瀷 {verify.printerTypeList.length ? <span className="count-tip">{verify.printerTypeList.length}</span> : null} </span> - } disabled={printMode === 'RFID'} key="2"> + } disabled={printMode === 'RFID'} key="print"> <Form {...formItemLayout}> <Row gutter={24}> <Col span={24} className="print-tip"> @@ -455,12 +879,45 @@ </Form.Item> </Col> <Col span={24}> - <EditTable data={verify.printerTypeList} ref="editTable"/> + <EditTable data={verify.printerTypeList} onChange={(list) => this.setState({verify: {...verify, printerTypeList: list}})}/> </Col> </Row> </Form> </TabPane> - <TabPane tab="淇℃伅鎻愮ず" key="7"> + {card.intertype === 'system' ? <TabPane tab="鏁版嵁婧�" disabled={dataType !== 'custom'} key="setting"> + <DataSource setting={verify.setting || {}} btnType="print" wrappedComponentRef={(inst) => this.settingForm = inst}/> + </TabPane> : null} + {card.intertype === 'system' ? <TabPane tab={ + <span> + 瀛楁闆� + {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null} + </span> + } key="columns"> + <ColForm columnChange={this.columnChange}/> + <FieldsComponent + config={verify} + type="fields" + updatefield={this.updatefields} + /> + <EditMTable actions={['edit', 'move', 'copy', 'del', 'clear']} type="datasourcefield" data={verify.columns} columns={colColumns} onChange={(columns) => this.setState({verify: {...verify, columns}})}/> + </TabPane> : null} + {card.intertype === 'system' ? <TabPane tab={ + <span> + 鑷畾涔夎剼鏈� + {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} + </span> + } key="scripts" disabled={dataType !== 'custom'} id="mk-exout-script"> + <CustomScript + btn={card} + sheet={verify.setting ? verify.setting.tableName : ''} + searches={[]} + linefields={usefulfields} + scriptsChange={this.scriptsChange} + wrappedComponentRef={(inst) => this.scriptsForm = inst} + /> + <EditMTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> + </TabPane> : null} + <TabPane tab="淇℃伅鎻愮ず" key="message"> <div style={{textAlign: 'center', fontSize: '13px', marginBottom: '10px'}}>鎵撳嵃淇℃伅涓鏋滃瓨鍦ㄧ綉缁滆祫婧愶紙鍥剧墖锛夛紝璇风‘淇濊祫婧愬彲浠ユ甯歌闂紝璧勬簮涓嶅瓨鍦ㄦ椂浼氭姤鏁版嵁寮傚父銆�</div> <Form {...formItemLayout}> <Row gutter={24}> diff --git a/src/templates/sharecomponent/actioncomponent/verifyprint/index.scss b/src/templates/sharecomponent/actioncomponent/verifyprint/index.scss index 1da8ed1..7d406e1 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyprint/index.scss +++ b/src/templates/sharecomponent/actioncomponent/verifyprint/index.scss @@ -1,4 +1,5 @@ .verify-card-print-box { + position: relative; .ant-tabs-nav-scroll { text-align: center; } @@ -60,6 +61,56 @@ color: #1890ff; font-size: 12px; } + .verify-form { + .sql { + .ant-col-sm-8 { + width: 10.5%; + } + .ant-col-sm-16 { + width: 89.5%; + padding-top: 4px; + } + .CodeMirror { + height: 350px; + } + } + .sqlfield { + .ant-form-item { + margin-bottom: 5px; + } + .ant-form-item-control { + line-height: 24px; + } + .ant-form-item-label { + line-height: 25px; + } + .ant-form-item-children { + line-height: 22px; + } + .ant-col-sm-8 { + width: 10.5%; + } + .ant-col-sm-16 { + width: 89.5%; + } + } + .add { + padding-top: 4px; + } + } + .ant-spin { + position: absolute; + top: calc(50% - 16px); + left: calc(50% - 16px); + z-index: 1; + } + .quickly-add { + position: absolute; + width: 100px; + right: 24px; + top: 5px; + z-index: 2; + } } .print-template-setting { .ant-select-dropdown-menu-item { diff --git a/src/templates/sharecomponent/actioncomponent/verifyprint/utils.jsx b/src/templates/sharecomponent/actioncomponent/verifyprint/utils.jsx new file mode 100644 index 0000000..0e8275c --- /dev/null +++ b/src/templates/sharecomponent/actioncomponent/verifyprint/utils.jsx @@ -0,0 +1,77 @@ + +export default class SettingUtils { + static getDebugSql (setting, columns, scripts, declareSql, timestamp) { + let sql = '' + let _dataresource = setting.dataresource || '' + + let _customScript = '' + scripts && scripts.forEach(script => { + if (script.status === 'false') return + _customScript += ` + ${script.sql} + ` + }) + + if (_customScript) { + _customScript = `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 ='' + ${declareSql} + ${_customScript} + ` + } + + if (setting.defaultSql === 'false') { + _dataresource = '' + } + + _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) + _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + _customScript = _customScript.replace(/@\$|\$@/ig, '') + + // 澶栬仈鏁版嵁搴撴浛鎹� + if (window.GLOB.externalDatabase !== null) { + _dataresource = _dataresource.replace(/@db@/ig, window.GLOB.externalDatabase) + _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + let arr_field = columns.map(col => col.field) + arr_field = arr_field.join(',') + + if (!arr_field) { + arr_field = '*' + } + + // 鏁版嵁婧愬鐞�, 瀛樺湪鏄剧ず鍒楁椂 + if (_dataresource) { + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + if (setting.order) { + _dataresource = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource}) tmptable order by tmptable.rows` + } else { + _dataresource = `/*system_query*/select ${arr_field} from ${_dataresource}` + } + } + + if (_customScript) { + sql = `/* sql 楠岃瘉 */ + ${_customScript} + ${_dataresource} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } else { + sql = `/* sql 楠岃瘉 */ + 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 ='' + ${declareSql} + ${_dataresource}` + } + sql = sql.replace(/\n\s{8}/ig, '\n') + console.info(sql) + sql = sql.replace(/\n/g, ' ') + + return sql + } +} \ No newline at end of file diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 8b7680b..e6e6c4f 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -626,7 +626,7 @@ _fields.push(...group.sublist) }) resolve(_fields) - } else if (card.modal) { + } else if (card.modal && card.OpenType === 'pop') { _fields = card.modal.fields || [] resolve(_fields) } else if (card.OpenType === 'pop') { diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index a7a4398..35123de 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -943,6 +943,8 @@ if (cell.eleType !== 'button') return if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { action.push(cell) + } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { + action.push(cell) } else if (cell.OpenType === 'popview') { if (pops) { pops.push({...cell, parentId: config.uuid}) @@ -956,6 +958,8 @@ item.backElements.forEach(cell => { if (cell.eleType !== 'button') return if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { + action.push(cell) + } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { action.push(cell) } else if (cell.OpenType === 'popview') { if (pops) { @@ -974,6 +978,8 @@ col.elements.forEach(cell => { if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { action.push(cell) + } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { + action.push(cell) } else if (cell.OpenType === 'popview') { if (pops) { pops.push({...cell, parentId: config.uuid}) @@ -989,6 +995,8 @@ if (cell.eleType !== 'button') return if (['form', 'pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { action.push(cell) + } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { + action.push(cell) } else if (cell.OpenType === 'popview') { if (pops) { pops.push({...cell, parentId: config.uuid}) @@ -1000,6 +1008,8 @@ config.action && config.action.forEach(cell => { if (['pop', 'prompt', 'exec', 'excelIn', 'excelOut'].includes(cell.OpenType)) { + action.push(cell) + } else if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { action.push(cell) } else if (cell.OpenType === 'popview') { if (pops) { @@ -1026,6 +1036,19 @@ tbs && cuts.push(...tbs) }) } + } else if (btn.OpenType === 'funcbutton') { + if (btn.intertype !== 'system' || !btn.verify || !btn.verify.setting) return + if (btn.verify.dataType === 'custom') { + if (btn.verify.setting.defaultSql !== 'false') { + let tbs = btn.verify.setting.dataresource.match(cutreg) + tbs && cuts.push(...tbs) + } + btn.verify.scripts && btn.verify.scripts.forEach(script => { + if (script.status === 'false') return + let tbs = script.sql.match(cutreg) + tbs && cuts.push(...tbs) + }) + } } else if (btn.OpenType === 'excelOut') { if (btn.intertype !== 'system' || !btn.verify) return if (btn.verify.dataType === 'custom') { -- Gitblit v1.8.0