From 6afdec0062dacbded57e166230eb22cc55ced0c1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 08 五月 2021 14:30:21 +0800 Subject: [PATCH] 2021-05-08 --- src/tabviews/zshare/actionList/normalbutton/index.jsx | 1392 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 1,001 insertions(+), 391 deletions(-) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 027b704..de07156 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -6,11 +6,13 @@ import { Button, Modal, notification, message } from 'antd' import Api from '@/api' -import Utils from '@/utils/utils.js' +import Utils, { getSysDefaultSql } from '@/utils/utils.js' import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import asyncSpinComponent from '@/utils/asyncSpinComponent' +import { updateForm } from '@/utils/utils-update.js' +import MKEmitter from '@/utils/events.js' import './index.scss' const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) @@ -19,17 +21,16 @@ class NormalButton extends Component { static propTpyes = { show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + position: PropTypes.any, // 鎸夐挳浣嶇疆锛屽伐鍏锋爮涓簍oolbar BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + style: PropTypes.any, // 鎸夐挳鏍峰紡 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� - MenuID: PropTypes.string, // 鑿滃崟ID btn: PropTypes.object, // 鎸夐挳 columns: PropTypes.any, // 瀛楁鍒� setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� - updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� - triggerBtn: PropTypes.any, } state = { @@ -40,20 +41,42 @@ confirmLoading: false, btnconfig: null, loading: false, - loadingNumber: '' - } - - /** - * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 - */ - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { - this.actionTrigger(nextProps.triggerBtn.data) - } + loadingNumber: '', + checkParam: null } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + const { position } = this.props + + if (position === 'toolbar') { + MKEmitter.addListener('triggerBtnId', this.actionTrigger) + } else if (position === 'form') { + MKEmitter.addListener('triggerFormSubmit', this.actionSubmit) + } + } + + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('triggerBtnId', this.actionTrigger) + MKEmitter.removeListener('triggerFormSubmit', this.actionSubmit) + } + + actionSubmit = (res) => { + const { btn } = this.props + + if (btn.uuid !== res.menuId) return + + this.setState({ + loading: true + }) + + this.execSubmit(this.state.tabledata, () => {}, res.form) } /** @@ -64,21 +87,22 @@ this.setState({ loading: true }) - this.props.updateStatus('start') } else if (type === 'over') { this.setState({ loading: false, visible: false }) - this.props.updateStatus('over') } } /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (record) => { - const { setting, Tab, BID, btn, selectedData } = this.props + actionTrigger = (triggerId, record) => { + const { Tab, BID, btn, selectedData } = this.props + const { loading } = this.state + + if ((triggerId && btn.uuid !== triggerId) || loading) return if (Tab && Tab.supMenu && !BID) { notification.warning({ @@ -90,13 +114,7 @@ } let _this = this - let data = [] - - if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� - data = [record] - } else { - data = selectedData || [] - } + let data = record || selectedData || [] if (btn.Ot !== 'notRequired' && data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� @@ -111,14 +129,6 @@ notification.warning({ top: 92, message: this.state.dict['main.action.confirm.selectSingleLine'], - duration: 5 - }) - return - } else if (!setting.primaryKey) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� - notification.warning({ - top: 92, - message: '鏈缃富閿紒', duration: 5 }) return @@ -145,19 +155,44 @@ this.actionSettingError() return } + } else if (btn.intertype === 'custom') { + if (btn.callbackType === 'script' && (!btn.verify || !btn.verify.cbScripts || !btn.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) { + this.actionSettingError() + return + } else if (btn.procMode === 'system' && data.length === 0 && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { + notification.warning({ + top: 92, + message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', + duration: 5 + }) + return + } else if (window.GLOB.systemType === 'production' && !btn.proInterface) { + notification.warning({ + top: 92, + message: '灏氭湭璁剧疆姝e紡绯荤粺鎺ュ彛鍦板潃锛�', + 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 } - if (btn.OpenType === 'prompt') { + if (btn.OpenType === 'formSubmit') { + this.setState({ + tabledata: data + }) + MKEmitter.emit('mkFormSubmit', btn.uuid) + return + } else if (btn.OpenType === 'prompt') { this.updateStatus('start') confirm({ title: this.state.dict['main.action.confirm.tip'], @@ -175,300 +210,411 @@ this.execSubmit(data, () => { this.setState({loading: false})}) } else if (btn.OpenType === 'pop') { this.updateStatus('start') + + let modal = this.state.btnconfig + if (!modal && btn.modal) { + modal = this.handleModelConfig(btn.modal) + } + this.setState({ - tabledata: data + tabledata: data, + btnconfig: modal }, () => { this.improveAction() }) } + + if (window.GLOB.systemType === 'production') { + let _change = { + prompt: '鎻愮ず妗�', + exec: '鐩存帴鎵ц', + pop: '寮圭獥锛堣〃鍗曪級' + } + MKEmitter.emit('queryTrigger', {menuId: btn.uuid, name: _change[btn.OpenType]}) + } } - /** - * @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') && setting.primaryKey) { + 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 + + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = 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) + } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟 + 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() + + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = getSysDefaultSql(btn, setting, formdata, 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) + } else { + param.ID = primaryId + + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = getSysDefaultSql(btn, setting, formdata, 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) + } + } + + 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' } 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) // 鏁版嵁婧� + param.ID = primaryId - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = 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, '') + + 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() + + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + 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, '') - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - + param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - } else if (btn.sql) { + param.secretkey = Utils.encrypt('', param.timestamp) + param.LText = Utils.formatOptions(param.LText) + } else { param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + + if (retmsg) { + const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧� + param.LText = sql + param.$callbacksql = callbacksql + } else { + param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + 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, '') - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - + param.exec_type = 'y' // 鍚庡彴瑙g爜 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) + param.LText = Utils.formatOptions(param.LText) } } - if (this.props.menuType === 'HS' && param.timestamp) { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + if (this.props.menuType === 'HS') { // 鍑芥暟 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 浜戠楠岃瘉 + } + + if (param.func === 'sPC_TableData_InUpDe') { + param.menuname = btn.logLabel + } + + 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') && setting.primaryKey) { + let ids = data.map(d => { return d[setting.primaryKey] || ''}) + ids = ids.filter(Boolean) + primaryId = ids.join(',') + } + + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId // 璁剧疆涓婚敭鍙傛暟 + } + + if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 琛ㄥ崟 + formdata.forEach(_data => { + param[_data.key] = _data.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 + } + + 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 + }) + } + + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + } + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId + } + + 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) } - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(res) - } else { - this.execError(res) - } - _resolve() - }, () => { - this.updateStatus('over') - _resolve() - }) - } 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 - } - } + return param + }) + } - let _params = data.map((cell, index) => { - let param = { - func: 'sPC_TableData_InUpDe' - } + return _params + } - if (this.props.BID) { - param.BID = this.props.BID - } + /** + * @description 鎸夐挳鎻愪氦鎵ц + */ + execSubmit = (data, _resolve, formdata) => { + const { setting, btn } = this.props + if (btn.intertype === 'system' || btn.intertype === 'inner') { // 绯荤粺鎺ュ彛 + let params = [] - let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' + if (btn.intertype === 'system') { + params = this.getSystemParam(data, formdata) + } else { + params = this.getInnerParam(data, formdata) + } - 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, cell, columns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - } - } 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 - }) - } - - if (btn.innerFunc) { - param.func = btn.innerFunc - - 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 (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText2 = LText2 - param.LText1 = LText1 - param.LText = LText - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - } - } - - 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) - } - - 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') { /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ @@ -481,7 +627,7 @@ param.BID = this.props.BID } - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 + if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 琛ㄥ崟 formdata.forEach(_data => { param[_data.key] = _data.value }) @@ -530,15 +676,345 @@ // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) + } else if (btn.intertype === 'custom') { // 绯荤粺鎺ュ彛 + let params = [] + + if (btn.procMode === 'system') { + 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 || '' + }) + + let record = { + BID: param.BID || '', + ID: param.ID || '', + callbacksql: param.$callbacksql || '' + } + + delete param.$callbacksql + + Api.genericInterface(param).then(res => { + if (res.status) { + if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length === 0) { + this.execSuccess(res) + _resolve() + } else if ((res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) && params.length > 0) { + this.customLoopRequest(params, _resolve) + } else { + this.customOuterRequest(params, res, record, _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' || result.mk_ex_invoke === false) && params.length === 0) { + _this.execSuccess(result) + _resolve() + } else if ((result.mk_ex_invoke === 'false' || result.mk_ex_invoke === false) && params.length > 0) { + _this.customLoopRequest(params, _resolve) + } else { + _this.customOuterRequest(params, result, record, _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, record, _resolve) => { + const { btn } = this.props + + let url = '' + if (window.GLOB.systemType === 'production') { + url = btn.proInterface + } else { + url = btn.interface + } + + let mkey = result.mk_api_key || '' + + delete result.mk_ex_invoke + delete result.status + delete result.message + delete result.ErrCode + delete result.ErrMesg + delete result.mk_api_key + + let param = {} + + Object.keys(result).forEach(key => { + key = key.replace(/^mk_/ig, '') + param[key] = result[key] + }) + + Api.directRequest(url, btn.method, param, btn.cross).then(res => { + if (typeof(res) !== 'object' || Array.isArray(res)) { + let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒' + + if (typeof(res) === 'string') { + error = res.replace(/'/ig, '"') + } + + let result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: error + } + + this.customCallbackRequest(params, result, record, _resolve) + } else { + res.mk_api_key = mkey + this.customCallbackRequest(params, res, record, _resolve) + } + }, (e) => { + let result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: e && e.statusText ? e.statusText : '' + } + + this.customCallbackRequest([], result, record, _resolve) + }) + } + + /** + * @description 鍥炶皟璇锋眰寰幆鎵ц + */ + customCallbackRequest = (params, result, record, _resolve) => { + const { btn } = this.props + let lines = [] + let pre = btn.callbackType === 'script' ? '@' : '' + + let errSql = '' + if (result.$ErrCode === 'E') { + errSql = ` + set @ErrorCode='E' + set @retmsg='${result.$ErrMesg}' + ` + delete result.$ErrCode + delete result.$ErrMesg + } + + let getDefaultSql = (obj, tb, bid, level) => { + let keys = [] + let vals = [] + let subObjs = [] + let id = Utils.getuuid() + + delete obj.$$key + + Object.keys(obj).forEach(key => { + let val = obj[key] + if (val === null || val === undefined) return + if (typeof(val) === 'object') { + if (Array.isArray(val)) { + val.forEach(item => { + if (typeof(item) !== 'object' || Array.isArray(item)) return + if (Object.keys(item).length > 0) { + item.$$key = tb + '_' + key + subObjs.push(item) + } + }) + } else if (Object.keys(val).length > 0) { + val.$$key = tb + '_' + key + subObjs.push(val) + } + } else { + if (typeof(val) === 'string') { + val = val.replace(/'/ig, '"') + } + keys.push(key) + vals.push(`'${val}'`) + } + }) + + lines.push({ + table: tb, + insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, + select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` + }) + + subObjs.forEach(item => { + getDefaultSql(item, item.$$key, id, level + 1) + }) + } + + getDefaultSql(result, btn.cbTable, '', 1) + + let lineMap = new Map() + lines.forEach(line => { + if (lineMap.has(line.table)) { + let _line = lineMap.get(line.table) + _line.selects.push(line.select) + lineMap.set(line.table, _line) + } else { + lineMap.set(line.table, { + table: line.table, + insert: line.insert, + selects: [line.select] + }) + } + }) + + let param = {} + + if (btn.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈� + param.func = 'sPC_TableData_InUpDe' + + if (record.BID) { + param.BID = this.props.BID + } + if (record.ID) { + param.ID = record.ID + } + + let _prevCustomScript = `${record.callbacksql} + ${errSql} + ` + let _backCustomScript = '' + + btn.verify.cbScripts.forEach(script => { + if (script.status === 'false') return + + if (script.position === 'front') { + _prevCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${script.sql} + ` + } else { + _backCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${script.sql} + ` + } + }) + + _backCustomScript += ` + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + + let sql = [...lineMap.values()].map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + sql = _prevCustomScript + sql + sql = sql + _backCustomScript + + if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + console.info(sql.replace(/\n\s{8}/ig, '\n')) + } + + param.LText = sql + + 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) + param.menuname = btn.logLabel + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + } else { + param.func = 's_ex_result_back' + param.s_ex_result = [...lineMap.values()].map((item, index) => ({ + MenuID: btn.uuid, + MenuName: btn.logLabel, + TableName: item.table, + LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), + Sort: index + 1 + })) + + if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + let sql = [...lineMap.values()].map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + console.info(sql.replace(/\n\s{10}/ig, '\n')) + } + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.customLoopRequest(params, _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({ @@ -629,7 +1105,11 @@ if (btn.sysInterface === 'true' && options.cloudServiceApi) { res.rduri = options.cloudServiceApi } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface + if (window.GLOB.systemType === 'production' && btn.proInterface) { + res.rduri = btn.proInterface + } else { + res.rduri = btn.interface + } } // 鍑芥暟 s_sDataDictb_TBBack 浜戠楠岃瘉 @@ -642,7 +1122,11 @@ if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { res.rduri = window.GLOB.mainSystemApi } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface + if (window.GLOB.systemType === 'production' && btn.proInterface) { + res.rduri = btn.proInterface + } else { + res.rduri = btn.interface + } } } @@ -725,17 +1209,125 @@ } - let _unclose = false if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { this.setState({ loading: false, visible: false }) - } else { - _unclose = true } - this.props.updateStatus('refresh', btn.execSuccess, _unclose) + if (btn.verify && btn.verify.noteEnable === 'true') { + this.sendMessage() + } + + if (btn.execSuccess !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess || '', btn) + } + } + + sendMessage = () => { + const { btn : { verify } } = this.props + + let param = { + func: 's_get_sms_local', + TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭 + TypeCharTwo: verify.noteType // N瀹氭椂锛孻瀹炴椂 + } + + param.LText = Utils.formatOptions(Utils.getuuid()) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + Api.genericInterface(param).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + return + } + + let _param = { + templatecode: verify.noteCode, // 妯℃澘缂栫爜 + TypeCharOne: verify.noteTemp, // N涓嶅悓鍐呭锛孻鐩稿悓鍐呭 + } + + _param.submitdate = res.submitdate + + let limit = 5 // 瀹炴椂鏈�澶т负5鏉★紝瀹氭椂鏈�澶т负100鏉� + let mobMap = new Map() + + if (verify.noteType === 'N') { + _param.func = 's_get_sms_sso_timer' + limit = 100 + } else if (verify.noteType === 'Y') { + _param.func = 's_get_sms_sso_realtime' + } + + let Ltext = [] + let error = false + + if (verify.noteTemp === 'Y') { + _param.p1 = res.p1 || '' + _param.p2 = res.p2 || '' + _param.p3 = res.p3 || '' + _param.p4 = res.p4 || '' + _param.p5 = res.p5 || '' + + let _p = _param.p1 + _param.p2 + _param.p3 + _param.p4 + _param.p5 + + if (/\/|\.|.*鍏�.*浜.*涔�.*杩憒闈㈣瘯|閭�璇穦涓嬭浇|绾㈠寘|鎷涜仒|濂借瘎|璇勪环|鏀垮姟閫氱煡|缂磋垂|淇濋櫓|鑲$エ|閲戣瀺|鎴垮湴浜鏁欒偛|娓告垙|寰俊|Q/.test(_p)) { + error = true + } + } + + res.send_data && res.send_data.forEach(item => { + if (item.mob && !mobMap.has(item.mob) && Ltext.length < limit) { + if (verify.noteTemp === 'Y') { + Ltext.push(`'${item.mob}'`) + } else { + let _p = `'${item.p1 || ''}','${item.p2 || ''}','${item.p3 || ''}','${item.p4 || ''}','${item.p5 || ''}','${item.mob}'` + + if (/\/|\.|.*鍏�.*浜.*涔�.*杩憒闈㈣瘯|閭�璇穦涓嬭浇|绾㈠寘|鎷涜仒|濂借瘎|璇勪环|鏀垮姟閫氱煡|缂磋垂|淇濋櫓|鑲$エ|閲戣瀺|鎴垮湴浜鏁欒偛|娓告垙|寰俊|Q/.test(_p)) { + error = true + } + + Ltext.push(_p) + } + mobMap.set(item.mob, true) + } + }) + + if (error) { + notification.warning({ + top: 92, + message: '娑堟伅涓惈鏈夐潪娉曞瓧绗�', + duration: 5 + }) + return + } + + if (Ltext.length === 0) return + Ltext = Ltext.join(';') + + _param.LText = window.btoa(window.encodeURIComponent(Ltext)) + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + + _param.rduri = 'http://sso.mk9h.cn/webapi/dostar' + _param.appkey = window.GLOB.appkey || '' + + Api.dostarInterface(_param).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + } + }) + }) } /** @@ -746,7 +1338,6 @@ */ execError = (res) => { const { btn } = this.props - const { btnconfig } = this.state if (res.ErrCode === 'E') { Modal.error({ @@ -768,17 +1359,57 @@ } else if (res.ErrCode === 'NM') { message.error(res.message || res.ErrMesg) } + + this.setState({ + loading: false, + loadingNumber: '' + }) - let _unclose = false - if (btn.OpenType === 'pop' && btnconfig && btnconfig.setting.display !== 'prompt') { - _unclose = true - } else { - this.setState({ - loading: false - }) + if (res.ErrCode === 'C') { + const _this = this + if (this.state.checkParam) { + let param = this.state.checkParam + confirm({ + title: res.message || res.ErrMesg, + content: '缁х画鎵ц锛�', + onOk() { + return new Promise(resolve => { + Api.genericInterface(param).then((result) => { + if (result.status) { + _this.execSuccess(result) + } else { + _this.execError(result) + } + resolve() + }, () => { + _this.setState({ + visible: false + }) + resolve() + }) + }) + }, + onCancel() { + _this.setState({ + visible: false + }) + if (btn.execError !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn) + } + } + }) + this.setState({checkParam: null}) + return + } else { + Modal.error({ + title: res.message || res.ErrMesg, + }) + } } - this.props.updateStatus('refresh', btn.execError, _unclose) + if (btn.execError !== 'never') { + MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn) + } } /** @@ -790,6 +1421,29 @@ message: this.state.dict['main.action.settingerror'], duration: 5 }) + } + + handleModelConfig = (config) => { + let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID + config.fields = config.fields.map(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� + if (!cell.blacklist || cell.blacklist.length === 0) return cell + if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + cell.hidden = 'true' + } + + return cell + }) + return config } /** @@ -838,72 +1492,9 @@ }) this.updateStatus('over') } else { - if (_LongParam.groups.length > 0) { - _LongParam.groups.forEach(group => { - group.sublist = group.sublist.map(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛� 鏉冮檺榛戝悕鍗曞瓧娈佃缃负闅愯棌琛ㄥ崟 - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { - let _option = Utils.getSelectQueryOptions(cell) - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - - cell.data_sql = Utils.formatOptions(_option.sql) - cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) - cell.arr_field = _option.field - } - - // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return cell - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - cell.hidden = 'true' - } - - return cell - }) - }) - } else { - _LongParam.fields = _LongParam.fields.map(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { - let _option = Utils.getSelectQueryOptions(cell) - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _option.sql = _option.sql.replace(/\$@/ig, '/*') - _option.sql = _option.sql.replace(/@\$/ig, '*/') - } else { - _option.sql = _option.sql.replace(/@\$|\$@/ig, '') - } - - cell.data_sql = Utils.formatOptions(_option.sql) - cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) - cell.arr_field = _option.field - } - - // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return cell - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - cell.hidden = 'true' - } - - return cell - }) - } - + _LongParam = updateForm(_LongParam) + _LongParam = this.handleModelConfig(_LongParam) + this.setState({ btnconfig: _LongParam }, () => { @@ -952,17 +1543,10 @@ const { BData } = this.props const { btnconfig, tabledata } = this.state let _this = this - let _fields = [] - - if (btnconfig.groups.length > 0) { - btnconfig.groups.forEach(group => { - _fields = [..._fields, ...group.sublist] - }) - } else { - _fields = btnconfig.fields - } - let result = _fields.map(item => { + let result = [] + btnconfig.fields.forEach(item => { + if (!item.field) return let _readin = item.readin !== 'false' let _initval = item.initval @@ -989,14 +1573,19 @@ _fieldlen = item.decimal ? item.decimal : 0 } - return { + if (_initval === undefined) { + _initval = '' + } + + result.push({ key: item.field, readonly: item.readonly === 'true', readin: _readin, fieldlen: _fieldlen, + writein: item.writein !== 'false', type: item.type, value: _initval - } + }) }) confirm({ @@ -1016,19 +1605,22 @@ * @description 鏄剧ず妯℃�佹 */ getModels = () => { - const { setting, BID } = this.props - const { btnconfig } = this.state + const { setting, BID, btn } = this.props + const { btnconfig, visible } = this.state - if (!this.state.visible || !btnconfig || !btnconfig.setting) return null + if (!btnconfig || !btnconfig.setting) return null let title = btnconfig.setting.title let width = btnconfig.setting.width + 'vw' let clickouter = false let container = document.body - if (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) { + if ( + (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || + (btnconfig.setting.container === 'tab' && btn.ContainerId) + ) { width = btnconfig.setting.width + '%' - container = () => document.getElementById(this.props.ContainerId) + container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) } if (btnconfig.setting.clickouter === 'close') { @@ -1041,7 +1633,7 @@ maskClosable={clickouter} getContainer={container} wrapClassName='action-modal' - visible={this.state.visible} + visible={visible} width={width} onOk={this.handleOk} confirmLoading={this.state.confirmLoading} @@ -1063,33 +1655,51 @@ } render() { - const { btn, show } = this.props - const { loadingNumber, loading } = this.state + const { btn, show, style } = this.props + const { loadingNumber, loading, visible } = this.state - return ( - <div className="mk-btn-wrap"> - {!show ? <Button - className={'mk-btn mk-' + btn.class} + if (show === 'actionList') { + return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> + <Button + style={style} icon={btn.icon} - onClick={() => {this.actionTrigger()}} loading={loading} - >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> : null} - {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null} - {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} - {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} - {show && show.indexOf('plus') > -1 ? <Button className="action-cell" style={{fontSize: show.substring(4) + 'px'}} icon={btn.icon || 'plus'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null} - {this.getModels()} + className={'mk-btn mk-' + btn.class} + onClick={() => {this.actionTrigger()}} + >{(loadingNumber ? `(${loadingNumber})` : '') + btn.label}</Button> + {visible ? this.getModels() : null} </div> - ) + } else if (show && show.indexOf('plus') > -1) { + return <div className="mk-btn-wrap"> + <Button + type="link" + loading={loading} + icon={btn.icon || 'plus'} + style={{fontSize: show.substring(4) + 'px'}} + onClick={() => {this.actionTrigger()}} + ></Button> + {visible ? this.getModels() : null} + </div> + } else { // icon銆乼ext銆� all 鍗$墖 + return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> + <Button + type="link" + title={show === 'icon' ? btn.label : ''} + loading={loading} + style={btn.style || style} + icon={show === 'text' ? '' : (btn.icon || '')} + onClick={() => {this.actionTrigger()}} + >{show === 'icon' && btn.icon ? '' : btn.label}</Button> + {visible ? this.getModels() : null} + </div> + } } } const mapStateToProps = (state) => { return { tabviews: state.tabviews, - menuType: state.editLevel, - permRoles: state.permRoles, - dataManager: state.dataManager + menuType: state.editLevel } } -- Gitblit v1.8.0