From c7df5603e14b98d6f80da425fab31d30574ca417 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 22 一月 2021 19:10:18 +0800 Subject: [PATCH] 2021-01-22 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 658 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 406 insertions(+), 252 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 8b5131f..3bcf302 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -147,13 +147,25 @@ this.actionSettingError() return } + } else if (btn.intertype === 'custom') { + if (!btn.innerFunc && (!btn.sql || !btn.sqlType)) { + this.actionSettingError() + return + } else if (!btn.innerFunc && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { + notification.warning({ + top: 92, + message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', + duration: 5 + }) + return + } } else if (btn.intertype === 'outer') { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 if (!btn.interface && btn.sysInterface !== 'true') { this.actionSettingError() return } - } else if (!['inner', 'outer', 'system'].includes(btn.intertype)) { + } else if (!['inner', 'outer', 'system', 'custom'].includes(btn.intertype)) { // 鎺ュ彛绫诲瀷閿欒 this.actionSettingError() return @@ -196,92 +208,172 @@ } } - /** - * @description 鎸夐挳鎻愪氦鎵ц - */ - execSubmit = (data, _resolve, formdata) => { + getSystemParam = (data, formdata, retmsg) => { const { setting, columns, btn } = this.props - if (btn.intertype === 'inner' || btn.intertype === 'system') { - // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� - // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�) - if ( - btn.Ot === 'notRequired' || - btn.Ot === 'requiredSgl' || - btn.Ot === 'requiredOnce' - ) { - let param = { // 绯荤粺瀛樺偍杩囩▼ + let _params = [] + + if ( btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce' ) { + let param = { // 绯荤粺瀛樺偍杩囩▼ + func: 'sPC_TableData_InUpDe' + } + let check_param = null + + if (this.props.BID) { + param.BID = this.props.BID + } + + let primaryId = '' + + if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let ids = data.map(d => { return d[setting.primaryKey] || ''}) + ids = ids.filter(Boolean) + primaryId = ids.join(',') + } + + if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + + param.exec_type = 'y' // 鍚庡彴瑙g爜 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + check_param = fromJS(param).toJS() + check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') + check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') + check_param.LText = Utils.formatOptions(check_param.LText) + + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + + param.LText = Utils.formatOptions(param.LText) + } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + primaryId = '' + + if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� + let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] + if (_form) { + primaryId = _form.value + } + } + + param.ID = primaryId || Utils.getguid() + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + + param.exec_type = 'y' // 鍚庡彴瑙g爜 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + check_param = fromJS(param).toJS() + check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') + check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') + check_param.LText = Utils.formatOptions(check_param.LText) + + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + + param.LText = Utils.formatOptions(param.LText) + } else { + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + + param.exec_type = 'y' // 鍚庡彴瑙g爜 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + + if (/\$check@|@check\$/ig.test(param.LText)) { + check_param = fromJS(param).toJS() + check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') + check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') + check_param.LText = Utils.formatOptions(check_param.LText) + + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + } + + param.LText = Utils.formatOptions(param.LText) + } + } + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + if (check_param) { + check_param.open_key = Utils.encryptOpenKey(check_param.secretkey, check_param.timestamp) + } + } + + param.menuname = btn.logLabel + + if (check_param) { + check_param.menuname = btn.logLabel + this.setState({checkParam: check_param}) + } + + _params.push(param) + } else if (btn.Ot === 'required') { + _params = data.map((cell, index) => { + let param = { func: 'sPC_TableData_InUpDe' } - let check_param = null if (this.props.BID) { param.BID = this.props.BID } - - let primaryId = '' - if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let ids = data.map(d => { return d[setting.primaryKey] || ''}) - ids = ids.filter(Boolean) - primaryId = ids.join(',') - } + let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - if (btn.innerFunc) { // 浣跨敤鑷畾涔夊嚱鏁� - param.func = btn.innerFunc - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 鏁版嵁婧� - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.exec_type = 'y' // 鍚庡彴瑙g爜 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - - if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - } - - param.LText = Utils.formatOptions(param.LText) + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + + param.exec_type = 'y' // 鍚庡彴瑙g爜 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt('', param.timestamp) + param.LText = Utils.formatOptions(param.LText) } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (btn.innerFunc) { - param.func = btn.innerFunc - - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - primaryId = '' - - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - primaryId = _form.value + if (index !== 0) { + formdata = formdata.map(_data => { + if (_data.readin && cell.hasOwnProperty(_data.key)) { + _data.value = cell[_data.key] } - } + return _data + }) + } - param.ID = primaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + param.ID = Utils.getguid() + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -289,24 +381,15 @@ } else { param.LText = param.LText.replace(/@\$|\$@/ig, '') } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) - - if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - } - param.LText = Utils.formatOptions(param.LText) - } else if (btn.sql) { + } else { param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -314,202 +397,152 @@ } else { param.LText = param.LText.replace(/@\$|\$@/ig, '') } + param.LText = param.LText.replace(/\$check@|@check\$/ig, '') param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) - - if (/\$check@|@check\$/ig.test(param.LText)) { - check_param = fromJS(param).toJS() - check_param.LText = check_param.LText.replace(/\$check@/ig, '/*') - check_param.LText = check_param.LText.replace(/@check\$/ig, '*/') - check_param.LText = Utils.formatOptions(check_param.LText) - - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - } - param.LText = Utils.formatOptions(param.LText) } } - if (this.props.menuType === 'HS' && param.timestamp) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - if (check_param) { - check_param.open_key = Utils.encryptOpenKey(check_param.secretkey, check_param.timestamp) - } - } else if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } if (param.func === 'sPC_TableData_InUpDe') { param.menuname = btn.logLabel - if (check_param) { - check_param.menuname = btn.logLabel - } - } - if (check_param) { - this.setState({checkParam: check_param}) } - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(res) - } else { - this.execError(res) - } - _resolve() - }, () => { - this.updateStatus('over') - _resolve() + return param + }) + } + + return _params + } + + getInnerParam = (data, formdata) => { + const { setting, btn } = this.props + let _params = [] + + if ( btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce' ) { + let param = { + func: btn.innerFunc + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + let primaryId = '' + + if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let ids = data.map(d => { return d[setting.primaryKey] || ''}) + ids = ids.filter(Boolean) + primaryId = ids.join(',') + } + + param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟 + + if (btn.OpenType === 'pop') { // 琛ㄥ崟 + formdata.forEach(_data => { + param[_data.key] = _data.value }) - } else if (btn.Ot === 'required') { - let _formPrimaryId = '' - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - _formPrimaryId = _form.value - } + } + + if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + _params.push(param) + } else if (btn.Ot === 'required') { + _params = data.map((cell, index) => { + let param = { + func: btn.innerFunc } - let _params = data.map((cell, index) => { - let param = { - func: 'sPC_TableData_InUpDe' + if (this.props.BID) { + param.BID = this.props.BID + } + + let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' + + if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (index !== 0) { + formdata = formdata.map(_data => { + if (_data.readin && cell.hasOwnProperty(_data.key)) { + _data.value = cell[_data.key] + } + return _data + }) } - if (this.props.BID) { - param.BID = this.props.BID - } + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + } + param[setting.primaryKey] = primaryId - let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' + if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� + return param + }) + } - if (btn.innerFunc) { - param.func = btn.innerFunc - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 鏁版嵁婧� - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') + return _params + } - param.exec_type = 'y' // 鍚庡彴瑙g爜 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - } - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (index !== 0) { - formdata = formdata.map(_data => { - if (_data.readin && cell.hasOwnProperty(_data.key)) { - _data.value = cell[_data.key] - } - return _data - }) - } + /** + * @description 鎸夐挳鎻愪氦鎵ц + */ + execSubmit = (data, _resolve, formdata) => { + const { setting, btn } = this.props + if (btn.intertype === 'system' || btn.intertype === 'inner') { // 绯荤粺鎺ュ彛 + let params = [] - if (btn.innerFunc) { - param.func = btn.innerFunc + if (btn.intertype === 'system') { + params = this.getSystemParam(data, formdata) + } else { + params = this.getInnerParam(data, formdata) + } - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - param.ID = _formPrimaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - - param.exec_type = 'y' // 鍚庡彴瑙g爜 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - - param.exec_type = 'y' // 鍚庡彴瑙g爜 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - } - } - - if (this.props.menuType === 'HS' && param.timestamp) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } else if (this.props.menuType === 'HS' && param.func === 's_sDataDictb_TBBack' && param.LTextOut) { // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - if (param.func === 'sPC_TableData_InUpDe') { - param.menuname = btn.logLabel - } - - return param - }) - - if (_params.length <= 20) { - let deffers = _params.map(param => { - return new Promise(resolve => { - Api.genericInterface(param).then(res => { - resolve(res) - }, () => { - this.updateStatus('over') - _resolve() - }) + if (params.length <= 20) { + let deffers = params.map(param => { + return new Promise(resolve => { + Api.genericInterface(param).then(res => { + resolve(res) + }, () => { + this.updateStatus('over') + _resolve() }) }) - Promise.all(deffers).then(result => { - let iserror = false - let errorMsg = '' - result.forEach(res => { - if (res.status) { - errorMsg = res - } else { - iserror = true - errorMsg = res - } - }) - if (!iserror) { - this.execSuccess(errorMsg) + }) + Promise.all(deffers).then(result => { + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (res.status) { + errorMsg = res } else { - this.execError(errorMsg) + iserror = true + errorMsg = res } - _resolve() }) - } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц - this.innerLoopRequest(_params, btn, _resolve) - } + if (!iserror) { + this.execSuccess(errorMsg) + } else { + this.execError(errorMsg) + } + _resolve() + }) + } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц + this.innerLoopRequest(params, btn, _resolve) } } else if (btn.intertype === 'outer') { /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ @@ -571,15 +604,136 @@ // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) + } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛 + let params = [] + + if (!btn.innerFunc) { + params = this.getSystemParam(data, formdata, true) + params = params.map(item => { + item.script_type = 'Y' + return item + }) + } else { + params = this.getInnerParam(data, formdata) + } + + this.customLoopRequest(params, _resolve) } + } + + /** + * @description 鑷畾涔夎姹傚惊鐜墽琛� + */ + customLoopRequest = (params, _resolve) => { + let param = params.shift() + + this.setState({ + loadingNumber: params.length || '' + }) + + Api.genericInterface(param).then(res => { + if (res.status) { + if (res.mk_ex_invoke === 'false' && params.length === 0) { + this.execSuccess(res) + _resolve() + } else if (res.mk_ex_invoke === 'false' && params.length > 0) { + this.customLoopRequest(params, _resolve) + } else { + this.customOuterRequest(params, res, _resolve) + } + } else if (res.ErrCode === 'C' && this.state.checkParam) { + const _this = this + confirm({ + title: res.message || res.ErrMesg, + content: '缁х画鎵ц锛�', + onOk() { + return new Promise(resolve => { + Api.genericInterface(_this.state.checkParam).then((result) => { + if (result.status) { + if (result.mk_ex_invoke === 'false' && params.length === 0) { + _this.execSuccess(result) + _resolve() + } else if (result.mk_ex_invoke === 'false' && params.length > 0) { + _this.customLoopRequest(params, _resolve) + } else { + _this.customOuterRequest(params, result, _resolve) + } + } else { + _this.execError(result) + _resolve() + } + resolve() + }, () => { + _this.updateStatus('over') + resolve() + _resolve() + }) + }) + }, + onCancel() { + _this.execError({...res, ErrCode: 'P'}) + _resolve() + } + }) + this.setState({checkParam: null}) + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus('over') + _resolve() + }) + } + + /** + * @description 鑷畾涔夎姹傚惊鐜墽琛� + */ + customOuterRequest = (params, result, _resolve) => { + const { btn } = this.props + + let url = '' + if (window.GLOB.systemType === 'production') { + url = btn.proInterface + } else { + url = btn.interface + } + + delete result.mk_ex_invoke + delete result.status + delete result.message + delete result.ErrCode + delete result.ErrMesg + + let param = {} + + Object.keys(result).forEach(key => { + key = key.replace(/^mk_/ig, '') + param[key] = result[key] + }) + + Api.directRequest(url, btn.method, param).then(res => { + if (res.status) { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.customLoopRequest(params, btn, _resolve) + } + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus('over') + _resolve() + }) } /** * @description 鍐呴儴璇锋眰寰幆鎵ц */ innerLoopRequest = (params, btn, _resolve) => { - if (!params && params.length === 0) return - let param = params.shift() this.setState({ -- Gitblit v1.8.0