From ff045a6a19e2e0bd5c2433aae71145401627c22d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 19 十二月 2019 19:08:32 +0800 Subject: [PATCH] 2019-12-19 --- src/templates/comtableconfig/index.jsx | 284 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 241 insertions(+), 43 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 8bf970a..3db24cb 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -650,20 +650,6 @@ text: this.state.dict['header.form.refresh.view'] }] }, - // { - // type: 'select', - // key: 'method', - // label: this.state.dict['header.form.request.method'], - // initVal: card.method || 'POST', - // required: true, - // options: [{ - // MenuID: 'POST', - // text: 'POST' - // }, { - // MenuID: 'GET', - // text: 'GET' - // }] - // }, { type: 'select', key: 'icon', @@ -695,22 +681,7 @@ initVal: card.sqlType || '', tooltip: this.state.dict['header.form.actionhelp.sqlType'], required: false, - options: [{ - MenuID: '', - text: this.state.dict['header.form.empty'] - }, { - MenuID: 'insert', - text: this.state.dict['header.form.action.insert'] - }, { - MenuID: 'update', - text: this.state.dict['header.form.action.update'] - }, { - MenuID: 'LogicDelete', - text: this.state.dict['header.form.action.LogicDelete'] - }, { - MenuID: 'delete', - text: this.state.dict['header.form.action.delete'] - }] + options: [] } ] }) @@ -1125,7 +1096,7 @@ } newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config.columns)) DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(false) + resolve(true) } else { resolve(false) notification.warning({ @@ -1144,7 +1115,7 @@ } newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config.columns)) DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) - resolve(false) + resolve(true) } }).then(res => { // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭� @@ -1201,8 +1172,8 @@ if ((newLText === localTVPText) && (newLText === sysTVPText)) { return 'drop' - } else if (!localTVPText || (sysTVPText === localTVPText)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� + } else if (!localTVPText || (localTVPText === sysTVPText)) { + // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠 return Api.getSystemConfig({ func: 'sPC_TVP_InUp', TVPName: btn.innerFunc, @@ -1364,6 +1335,227 @@ this.setState({ actionloading: false }) + }) + }) + }) + } + + /** + * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ + */ + tableCreatFunc = () => { + const { menu } = this.props + let config = JSON.parse(JSON.stringify(this.state.config)) + + this.settingRef.handleConfirm().then(res => { + const setting = res + if (!(setting.interType === 'inner') || !setting.innerFunc) { + notification.warning({ + top: 92, + message: '鎺ュ彛绫诲瀷涓�-鍐呴儴锛屼笖瀛樺湪鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', + duration: 10 + }) + return + } + + if (setting.dataresource.length > 50 && config.setting.dataresource !== setting.dataresource) { + let param = { + func: 's_DataSrc_Save', + LText: setting.dataresource, + MenuID: menu.MenuID + } + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + 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 + + 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) { + 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 { + 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 + }) + return + } + + this.setState({ + config: {...config, setting: setting} }) }) }) @@ -1783,10 +1975,10 @@ date: 'like' } const selectmatch = { // 閫夋嫨select鏃跺尮閰嶈鍒� - text: 'equal', - number: 'equal', - datetime: 'equal', - date: 'equal' + text: '=', + number: '=', + datetime: '=', + date: '=' } const datematch = { // 閫夋嫨dateRange鏃跺尮閰嶈鍒� text: 'between', @@ -1894,8 +2086,8 @@ label: item.label, field: item.field, Hide: 'false', - IsSort: 'true', - type: 'text', + IsSort: item.type === 'picture' ? 'false' : 'true', + type: item.type, Width: 120 } @@ -2301,7 +2493,7 @@ visible={this.state.visible} width={700} onCancel={() => { this.setState({ visible: false }) }} - onOk={this.handleSubmit} + // onOk={this.handleSubmit} footer={[ this.state.formtemp === 'action' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null, @@ -2379,19 +2571,25 @@ title={this.state.dict['header.edit']} visible={this.state.settingVisible} width={700} - onOk={this.settingSave} + // 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>, + <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> + ]} destroyOnClose > <SettingForm + dict={this.state.dict} menu={this.props.menu} data={this.state.config.setting} columns={this.state.config.columns} - dict={this.state.dict} + usefulFields={this.props.permFuncField} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> -- Gitblit v1.8.0