From fbc7f238317e5fe54707ff571a37d649f7b03c6d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 18 三月 2020 14:15:21 +0800 Subject: [PATCH] 2020-03-18 --- src/templates/formtabconfig/index.jsx | 401 --------------- src/templates/comtableconfig/index.jsx | 424 +--------------- src/templates/subtableconfig/index.jsx | 425 +--------------- src/templates/tableshare/createfunc/index.scss | 0 src/templates/tableshare/createfunc/index.jsx | 222 ++++++++ 5 files changed, 317 insertions(+), 1,155 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index e1e3787..84aa18d 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -32,6 +32,7 @@ import TabDragElement from '@/templates/tableshare/tabdragelement' import TransferForm from '@/components/transferform' import SourceElement from '@/templates/tableshare/dragelement/source' +import CreateFunc from '@/templates/tableshare/createfunc' import Source from './source' import './index.scss' @@ -70,7 +71,6 @@ originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 copyActions: [], // 澶嶅埗鎸夐挳缁� - funcLoading: false, // 瀛樺偍杩囩▼鍒涘缓涓� showColumnName: false, // 鏄剧ず鍒楀瓧娈靛悕鎺у埗 tabviews: [], // 鎵�鏈夋爣绛鹃〉 profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 @@ -860,9 +860,6 @@ let btn = res // 鎸夐挳淇℃伅 let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let sysTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(浜戠) - let localTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(鏈湴) // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 if (!btn.innerFunc) { @@ -873,11 +870,6 @@ }) return } - - // 鍒涘缓涓� - this.setState({ - funcLoading: true - }) new Promise(resolve => { // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€�� @@ -917,12 +909,12 @@ DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) resolve(true) } else { - resolve(false) notification.warning({ top: 92, message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒', duration: 10 }) + resolve(false) } }) } else if (btn.OpenType === 'excelIn') { @@ -962,208 +954,43 @@ resolve(true) } }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res + if (!res) return - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: btn.innerFunc - }).then(result => { - resolve(result) - }) - }) + this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { + if (result !== 'success') return - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: btn.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - resolve(result) - }) - }) - - return Promise.all([sysDefer, localDefer]) - }).then(res => { - // 浜戠缁撴灉涓庢柊璇彞涓嶅悓鏃讹紝鏇存柊浜戠淇℃伅 - if (res === false) return res - - let isError = false - - res.forEach((result, index) => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - isError = true - } else if (index === 0) { - sysTVPText = result.TVPText - } else { - if (result.Ltext) { // 鏈湴瀛樺偍杩囩▼鏄惁瀛樺湪 - isExit = true + let _action = config.action.map(item => { + if (item.uuid === btn.uuid) { + return btn + } else { + return item } - localTVPText = Utils.formatOptions(result.Ltext) - } - }) - - if (isError) return false - - if ((newLText === localTVPText) && (newLText === sysTVPText)) { - return 'drop' - } else if (!localTVPText || (localTVPText === sysTVPText)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠 - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: localTVPText, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res + _action = _action.filter(item => !item.origin) - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res + // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� + let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 + let _gridBtn = config.gridBtn - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { - this.setState({ - funcLoading: false - }) - return - } - - let _action = config.action.map(item => { - if (item.uuid === btn.uuid) { - return btn + if (_gridBtn) { + _gridBtn.display = _hasGridbtn } else { - return item + _gridBtn = { + display: _hasGridbtn, + Align: 'center', + IsSort: 'false', + uuid: Utils.getuuid(), + label: this.state.dict['header.form.column.action'], + type: 'action', + style: 'button', + show: 'horizontal', + Width: 120 + } } - }) - _action = _action.filter(item => !item.origin) - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 - let _gridBtn = config.gridBtn - - if (_gridBtn) { - _gridBtn.display = _hasGridbtn - } else { - _gridBtn = { - display: _hasGridbtn, - Align: 'center', - IsSort: 'false', - uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], - type: 'action', - style: 'button', - show: 'horizontal', - Width: 120 - } - } - - this.setState({ - config: {...config, action: _action, gridBtn: _gridBtn}, - funcLoading: false + this.setState({ + config: {...config, action: _action, gridBtn: _gridBtn} + }) }) }) }) @@ -1201,195 +1028,15 @@ Api.getLocalConfig(param) } - this.setState({ - funcLoading: true - }) - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - new Promise(resolve => { - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: setting.innerFunc - }).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: setting.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - Promise.all([sysDefer, localDefer]).then(result => { - resolve(result) - }) - }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res - if (res[0] === false || res[1] === false) return false - - let cloudfunc = '' - let localfunc = '' - res.forEach((item, index) => { - if (index === 0 && item && item.TVPText) { - cloudfunc = item.TVPText - } else if (index === 1 && item && item.Ltext) { - isExit = true - localfunc = Utils.formatOptions(item.Ltext) - } - }) - - if ((newLText === localfunc) && (newLText === cloudfunc)) { - return 'drop' - } else if (!localfunc || (cloudfunc === localfunc)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { + this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { + if (result === 'success') { this.setState({ - funcLoading: false + config: {...config, setting: setting} }) - return } - - this.setState({ - config: {...config, setting: setting} - }) }) }) } @@ -3179,7 +2826,7 @@ maskClosable={false} onCancel={this.editModalCancel} footer={[ - modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, + modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> ]} @@ -3343,14 +2990,13 @@ visible={this.state.settingVisible} width={700} maskClosable={false} - // onOk={this.settingSave} onCancel={() => { // 鍙栨秷淇敼 this.setState({ settingVisible: false }) }} footer={[ - <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, + <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> ]} diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 27872ef..a8bfb38 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -25,6 +25,7 @@ import MenuForm from '@/templates/tableshare/menuform' import TabDragElement from '@/templates/tableshare/tabdragelement' import SourceElement from '@/templates/tableshare/dragelement/source' +import CreateFunc from '@/templates/tableshare/createfunc' import Source from './source' import './index.scss' @@ -61,7 +62,6 @@ selectedTables: [], // 宸查�夎〃鍚� originMenu: null, // 鍘熷鑿滃崟 delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 - funcLoading: false, // 瀛樺偍杩囩▼鍒涘缓涓� tabviews: [], // 鎵�鏈夋爣绛鹃〉 profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 editgroup: null, // 褰撳墠缂栬緫缁� @@ -740,13 +740,10 @@ const { menu } = this.props let _config = JSON.parse(JSON.stringify(this.state.config)) - this.formRef.handleConfirm().then(res => { - let btn = res.values // 鎸夐挳淇℃伅 + this.actionFormRef.handleConfirm().then(res => { + let btn = res // 鎸夐挳淇℃伅 let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let sysTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(浜戠) - let localTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(鏈湴) // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 if (!btn.innerFunc) { @@ -757,11 +754,6 @@ }) return } - - // 鍒涘缓涓� - this.setState({ - funcLoading: true - }) new Promise(resolve => { // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€�� @@ -801,12 +793,12 @@ DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) resolve(true) } else { - resolve(false) notification.warning({ top: 92, message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒', duration: 10 }) + resolve(false) } }) } else { @@ -821,193 +813,28 @@ resolve(true) } }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res + if (!res) return - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: btn.innerFunc - }).then(result => { - resolve(result) - }) - }) + this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { + if (result !== 'success') return - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: btn.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - resolve(result) - }) - }) - - return Promise.all([sysDefer, localDefer]) - }).then(res => { - // 浜戠缁撴灉涓庢柊璇彞涓嶅悓鏃讹紝鏇存柊浜戠淇℃伅 - if (res === false) return res - - let isError = false - - res.forEach((result, index) => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - isError = true - } else if (index === 0) { - sysTVPText = result.TVPText - } else { - if (result.Ltext) { // 鏈湴瀛樺偍杩囩▼鏄惁瀛樺湪 - isExit = true + let isupdate = false + _config.action = _config.action.map(item => { + if (item.uuid === btn.uuid) { + isupdate = true + return btn + } else { + return item } - localTVPText = Utils.formatOptions(result.Ltext) + }) + + if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃 + _config.action.push(btn) } - }) - if (isError) return false - - if ((newLText === localTVPText) && (newLText === sysTVPText)) { - return 'drop' - } else if (!localTVPText || (localTVPText === sysTVPText)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠 - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: localTVPText, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { this.setState({ - funcLoading: false + config: _config }) - return - } - - let isupdate = false - _config.action = _config.action.map(item => { - if (item.uuid === btn.uuid) { - isupdate = true - return btn - } else { - return item - } - }) - - if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃 - _config.action.push(btn) - } - - this.setState({ - config: _config, - funcLoading: false }) }) }) @@ -1045,195 +872,15 @@ Api.getLocalConfig(param) } - this.setState({ - funcLoading: true - }) - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - new Promise(resolve => { - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: setting.innerFunc - }).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: setting.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - Promise.all([sysDefer, localDefer]).then(result => { - resolve(result) - }) - }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res - if (res[0] === false || res[1] === false) return false - - let cloudfunc = '' - let localfunc = '' - res.forEach((item, index) => { - if (index === 0 && item.TVPText) { - cloudfunc = item.TVPText - } else if (index === 1 && item.Ltext) { - isExit = true - localfunc = Utils.formatOptions(item.Ltext) - } - }) - - if ((newLText === localfunc) && (newLText === cloudfunc)) { - return 'drop' - } else if (!localfunc || (cloudfunc === localfunc)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { + this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { + if (result === 'success') { this.setState({ - funcLoading: false + config: {...config, setting: setting} }) - return } - - this.setState({ - config: {...config, setting: setting} - }) }) }) } @@ -2432,7 +2079,7 @@ onCancel={this.editModalCancel} footer={[ this.state.card && this.state.card.btnType !== 'cancel' ? - <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, + <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> ]} @@ -2524,7 +2171,7 @@ }) }} footer={[ - <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, + <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> ]} diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index fc2a7e6..edf4641 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -29,6 +29,7 @@ import MenuForm from '@/templates/tableshare/menuform' import TransferForm from '@/components/transferform' import SourceElement from '@/templates/tableshare/dragelement/source' +import CreateFunc from '@/templates/tableshare/createfunc' import Source from './source' import './index.scss' @@ -75,7 +76,6 @@ originActions: null, // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉� delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 copyActions: [], // 澶嶅埗鎸夐挳缁� - funcLoading: false, // 瀛樺偍杩囩▼鍒涘缓涓� showColumnName: false, // 鏄剧ず鍒楀瓧娈靛悕鎺у埗 tabviews: [], // 鎵�鏈夋爣绛鹃〉 profileVisible: false, // 楠岃瘉淇℃伅妯℃�佹 @@ -642,9 +642,6 @@ let btn = res // 鎸夐挳淇℃伅 let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let sysTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(浜戠) - let localTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(鏈湴) // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 if (!btn.innerFunc) { @@ -655,11 +652,6 @@ }) return } - - // 鍒涘缓涓� - this.setState({ - funcLoading: true - }) new Promise(resolve => { // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€�� @@ -699,12 +691,12 @@ DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) resolve(true) } else { - resolve(false) notification.warning({ top: 92, message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒', duration: 10 }) + resolve(false) } }) } else if (btn.OpenType === 'excelIn') { @@ -745,207 +737,42 @@ resolve(true) } }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res + if (!res) return - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: btn.innerFunc - }).then(result => { - resolve(result) - }) - }) + this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => { + if (result !== 'success') return - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: btn.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - resolve(result) - }) - }) - - return Promise.all([sysDefer, localDefer]) - }).then(res => { - // 浜戠缁撴灉涓庢柊璇彞涓嶅悓鏃讹紝鏇存柊浜戠淇℃伅 - if (res === false) return res - - let isError = false - - res.forEach((result, index) => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - isError = true - } else if (index === 0) { - sysTVPText = result.TVPText - } else { - if (result.Ltext) { // 鏈湴瀛樺偍杩囩▼鏄惁瀛樺湪 - isExit = true + _config.action = _config.action.map(item => { + if (item.uuid === btn.uuid) { + return btn + } else { + return item } - localTVPText = Utils.formatOptions(result.Ltext) - } - }) - - if (isError) return false - - if ((newLText === localTVPText) && (newLText === sysTVPText)) { - return 'drop' - } else if (!localTVPText || (localTVPText === sysTVPText)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠 - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: btn.innerFunc, - TVPText: localTVPText, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: btn.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res + _config.action = _config.action.filter(item => !item.origin) - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res + // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� + let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0 - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { - this.setState({ - funcLoading: false - }) - return - } - - _config.action = _config.action.map(item => { - if (item.uuid === btn.uuid) { - return btn + if (_config.gridBtn) { + _config.gridBtn.display = _hasGridbtn } else { - return item + _config.gridBtn = { + display: _hasGridbtn, + Align: 'center', + IsSort: 'false', + uuid: Utils.getuuid(), + label: this.state.dict['header.form.column.action'], + type: 'action', + style: 'button', + show: 'horizontal', + Width: 120 + } } - }) - _config.action = _config.action.filter(item => !item.origin) - - // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒� - let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0 - - if (_config.gridBtn) { - _config.gridBtn.display = _hasGridbtn - } else { - _config.gridBtn = { - display: _hasGridbtn, - Align: 'center', - IsSort: 'false', - uuid: Utils.getuuid(), - label: this.state.dict['header.form.column.action'], - type: 'action', - style: 'button', - show: 'horizontal', - Width: 120 - } - } - - this.setState({ - config: _config, - funcLoading: false + + this.setState({ + config: _config, + }) }) }) }) @@ -982,195 +809,15 @@ Api.getLocalConfig(param) } - this.setState({ - funcLoading: true - }) - let newLText = Utils.formatOptions(Utils.getTableFunc(setting, {MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo}, config)) // 鍒涘缓瀛樺偍杩囩▼sql let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql - let isExit = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - - new Promise(resolve => { - let sysDefer = new Promise(resolve => { - Api.getSystemConfig({ - func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉 - TVPName: setting.innerFunc - }).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - let localDefer = new Promise(resolve => { - let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - func: 's_get_userproc', - LText: setting.innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - Api.getLocalConfig(_param).then(result => { - if (!result.status) { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - resolve(false) - } else { - resolve(result) - } - }) - }) - - Promise.all([sysDefer, localDefer]).then(result => { - resolve(result) - }) - }).then(res => { - // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� - if (res === false) return res - if (res[0] === false || res[1] === false) return false - - let cloudfunc = '' - let localfunc = '' - res.forEach((item, index) => { - if (index === 0 && item.TVPText) { - cloudfunc = item.TVPText - } else if (index === 1 && item.Ltext) { - isExit = true - localfunc = Utils.formatOptions(item.Ltext) - } - }) - - if ((newLText === localfunc) && (newLText === cloudfunc)) { - return 'drop' - } else if (!localfunc || (cloudfunc === localfunc)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� - return Api.getSystemConfig({ - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: setting.innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getSystemConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: setting.innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } - }) - }) - } - }).then(res => { - // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'drop') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else if (isExit) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - // 鍒犻櫎瀛樺偍杩囩▼ - if (res === false || res === 'create') return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋� - if (res === false || res === 'create') return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - return 'create' - } - }).then(res => { - // 鏂板缓瀛樺偍杩囩▼ - if (res === false) return res - - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋� - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.getLocalConfig(_param) - }).then(res => { - // 澶勭悊鏂板缓缁撴灉 - if (res === false) return res - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 10 - }) - return false - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - return true - } - }).then(res => { - // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅 - if (res === false) { + + this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => { + if (result === 'success') { this.setState({ - funcLoading: false + config: {...config, setting: setting} }) - return } - - this.setState({ - config: {...config, setting: setting} - }) }) }) } @@ -2549,7 +2196,7 @@ maskClosable={false} onCancel={this.editModalCancel} footer={[ - modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, + modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> ]} @@ -2692,7 +2339,7 @@ }) }} footer={[ - <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>, + <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>, <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>, <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button> ]} diff --git a/src/templates/tableshare/createfunc/index.jsx b/src/templates/tableshare/createfunc/index.jsx new file mode 100644 index 0000000..bb867db --- /dev/null +++ b/src/templates/tableshare/createfunc/index.jsx @@ -0,0 +1,222 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Button, notification } from 'antd' +import moment from 'moment' + +import Utils from '@/utils/utils.js' +import Api from '@/api' +import './index.scss' + +class CreateFunc extends Component { + static propTypes = { + dict: PropTypes.object, // 瀛楀吀椤� + trigger: PropTypes.func + } + + state = { + loading: false, + } + + exec = (innerFunc, newLText, DelText) => { + this.setState({ + loading: true + }) + + return new Promise(resolve => { + this.createExec(resolve, innerFunc, newLText, DelText) + }) + } + + createExec = (_resolve, innerFunc, newLText, DelText) => { + let isExist = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 + let cloudText = '' // 浜戠瀛樺偍缁撴灉 + let localfunc = '' // 鏈湴瀛樺偍杩囩▼ + + new Promise(resolve => { + // 鑾峰彇浜戠瀛樺偍杩囩▼淇℃伅 + Api.getSystemConfig({ + func: 'sPC_Get_TVP', + TVPName: innerFunc + }).then(result => { + if (!result.status) { + notification.warning({ + top: 92, + message: result.message, + duration: 10 + }) + resolve(false) + } else { + cloudText = result.TVPText + resolve(true) + } + }) + }).then(res => { + if (!res) return res + // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 + + let _param = { + func: 's_get_userproc', + LText: innerFunc + } + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + + return Api.getLocalConfig(_param) + }).then(res => { + if (!res) return res + + // 澶勭悊鏈湴缁撴灉 + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + return false + } else { + isExist = true + localfunc = Utils.formatOptions(res.Ltext) + return true + } + }).then(res => { + if (!res) return res + + // 鏍规嵁鏈湴鍙婅繙绔粨鏋滃垽鏂墽琛屽姩浣� + if ((newLText === localfunc) && (newLText === cloudText)) { + return 'drop' + } else if (!localfunc || (cloudText === localfunc)) { + // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� + return Api.getSystemConfig({ + func: 'sPC_TVP_InUp', + TVPName: innerFunc, + TVPText: newLText, + TypeName: 'P' + }) + } else { + return new Promise(resolve => { + Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 + func: 'sPC_TVP_InUp', + TVPName: innerFunc, + TVPText: localfunc, + TypeName: 'P' + }).then(result => { + if (result.status) { + Api.getSystemConfig({ + func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� + TVPName: innerFunc, + TVPText: newLText, + TypeName: 'P' + }).then(response => { + resolve(response) + }) + } else { + resolve(result) + } + }) + }) + } + }).then(res => { + if (!res || res === 'drop') return res + + // 澶勭悊浜戠鏇存柊缁撴灉 + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + return false + } else if (isExist) { + return 'drop' + } else { + return 'create' + } + }).then(res => { + if (!res || res === 'create') return res + + // 鍒犻櫎瀛樺偍杩囩▼ + let _param = { + func: 'sPC_TableData_InUpDe', + LText: DelText, + TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋嬫爣蹇� + } + + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + + return Api.getLocalConfig(_param) + }).then(res => { + if (!res || res === 'create') return res + + // 鍒犻櫎缁撴灉澶勭悊 + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + return false + } else { + return true + } + }).then(res => { + if (!res) return res + + // 鏂板缓瀛樺偍杩囩▼ + let _param = { + func: 'sPC_TableData_InUpDe', + LText: newLText, + TypeCharOne: 'proc' + } + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + + return Api.getLocalConfig(_param) + }).then(res => { + if (!res) return res + + // 澶勭悊鏂板缓缁撴灉 + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + return false + } else { + notification.success({ + top: 92, + message: '鍒涘缓鎴愬姛', + duration: 2 + }) + return true + } + }).then(res => { + // 缁撴灉澶勭悊 + if (!res) { + _resolve('error') + } else { + _resolve('success') + } + + this.setState({ + loading: false + }) + }) + } + + render() { + + return ( + <Button + className="mk-btn mk-purple" + onClick={this.props.trigger} + loading={this.state.loading} + > + {this.props.dict['header.menu.func.create']} + </Button> + ) + } +} + +export default CreateFunc diff --git a/src/templates/tableshare/createfunc/index.scss b/src/templates/tableshare/createfunc/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/templates/tableshare/createfunc/index.scss -- Gitblit v1.8.0