From 95f2f60ba9eb343c2605e1ae68c221443d75f704 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 30 十一月 2019 00:55:07 +0800 Subject: [PATCH] commontable-update --- src/templates/comtableconfig/actionform/index.jsx | 43 ++ src/locales/zh-CN/main.js | 3 src/tabviews/commontable/mainAction/index.jsx | 488 +++++++++++++++++++++++++++++++++++---- src/templates/comtableconfig/source.jsx | 8 src/templates/comtableconfig/index.jsx | 29 ++ src/templates/comtableconfig/settingform/index.jsx | 48 ++-- src/templates/comtableconfig/actionform/index.scss | 8 src/api/index.js | 16 + src/locales/en-US/main.js | 2 src/locales/zh-CN/comtable.js | 2 src/tabviews/commontable/index.jsx | 24 + src/templates/comtableconfig/dragelement/index.jsx | 32 +- src/locales/en-US/comtable.js | 2 13 files changed, 586 insertions(+), 119 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 8eef60d..268be70 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -125,6 +125,22 @@ } /** + * @description 鑾峰彇涓氬姟閫氱敤鎺ュ彛 + */ + genericInterface (param) { + param.userid = sessionStorage.getItem('UserID') + param.lang = localStorage.getItem('lang') || '' + param.SessionUid = sessionStorage.getItem('SessionUid') || '' + param.LoginUID = sessionStorage.getItem('LoginUID') || '' + param.appkey = window.GLOB.appkey || '' + + return axios({ + url: '/webapi/dostar', + data: param + }) + } + + /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 * @param {String} MenuNo 椤甸潰鑿滃崟鍙傛暟 */ diff --git a/src/locales/en-US/comtable.js b/src/locales/en-US/comtable.js index 6acfc08..f5bda9c 100644 --- a/src/locales/en-US/comtable.js +++ b/src/locales/en-US/comtable.js @@ -87,6 +87,7 @@ 'header.form.resourceType': '閫夐」鏉ユ簮', 'header.form.custom': '鑷畾涔�', 'header.form.datasource': '鏁版嵁婧�', + 'header.form.datasource.actionhelp': '浣跨敤绯荤粺鍑芥暟鏃讹紝璇峰~鍐欐暟鎹簮銆�', 'header.form.valueField': '鍊悸峰瓧娈�', 'header.form.valueText': '鏂囨湰路瀛楁', 'header.form.orderBy': '鎺掑簭路瀛楁', @@ -99,6 +100,7 @@ 'header.form.dropdown': '涓嬫媺鑿滃崟', 'header.form.button': '鎸夐挳', 'header.form.selectItem.error': '涓嬫媺閫夐」璁剧疆閿欒锛�', + 'header.form.request.method': '璇锋眰鏂瑰紡', 'form.required.input': 'Please enter the ', 'form.required.select': '璇烽�夋嫨' } \ No newline at end of file diff --git a/src/locales/en-US/main.js b/src/locales/en-US/main.js index 150c340..42097e4 100644 --- a/src/locales/en-US/main.js +++ b/src/locales/en-US/main.js @@ -3,9 +3,11 @@ 'main.reset': 'Reset', 'main.confirm': 'OK', 'main.return': 'Cancel', + 'main.all': 'All', 'main.copy.success': 'Copy success', 'main.pagination.of': 'of', 'main.pagination.items': 'items', + 'main.page.settingerror': '椤甸潰閰嶇疆閿欒锛�', 'main.action.settingerror': 'Button setting error!', 'main.action.confirm.tip': 'Do you want to execute?', 'main.action.confirm.success': 'Execute successfully!', diff --git a/src/locales/zh-CN/comtable.js b/src/locales/zh-CN/comtable.js index efc3ac8..2dbe1ab 100644 --- a/src/locales/zh-CN/comtable.js +++ b/src/locales/zh-CN/comtable.js @@ -87,6 +87,7 @@ 'header.form.resourceType': '閫夐」鏉ユ簮', 'header.form.custom': '鑷畾涔�', 'header.form.datasource': '鏁版嵁婧�', + 'header.form.datasource.actionhelp': '浣跨敤绯荤粺鍑芥暟鏃讹紝璇峰~鍐欐暟鎹簮銆�', 'header.form.valueField': '鍊悸峰瓧娈�', 'header.form.valueText': '鏂囨湰路瀛楁', 'header.form.orderBy': '鎺掑簭路瀛楁', @@ -99,6 +100,7 @@ 'header.form.dropdown': '涓嬫媺鑿滃崟', 'header.form.button': '鎸夐挳', 'header.form.selectItem.error': '涓嬫媺閫夐」璁剧疆閿欒锛�', + 'header.form.request.method': '璇锋眰鏂瑰紡', 'form.required.input': '璇疯緭鍏�', 'form.required.select': '璇烽�夋嫨' } \ No newline at end of file diff --git a/src/locales/zh-CN/main.js b/src/locales/zh-CN/main.js index 371128f..aa3cd16 100644 --- a/src/locales/zh-CN/main.js +++ b/src/locales/zh-CN/main.js @@ -3,9 +3,12 @@ 'main.reset': '閲嶇疆', 'main.confirm': '纭畾', 'main.return': '杩斿洖', + 'main.all': '鍏ㄩ儴', 'main.copy.success': '澶嶅埗鎴愬姛', 'main.pagination.of': '鍏�', 'main.pagination.items': '鏉�', + 'main.page.settingerror': '椤甸潰閰嶇疆閿欒锛�', + 'main.datasource.settingerror': '鏁版嵁婧愰厤缃敊璇紒', 'main.action.settingerror': '鎸夐挳璁剧疆閿欒锛�', 'main.action.confirm.tip': '纭畾瑕佹墽琛屽悧?', 'main.action.confirm.success': '鎵ц鎴愬姛锛�', diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index e99a0c4..c87be74 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -63,7 +63,7 @@ }) notification.warning({ top: 92, - message: result.message || '椤甸潰閰嶇疆閿欒', + message: this.state.dict['main.page.settingerror'], duration: 10 }) } @@ -83,7 +83,7 @@ }) notification.warning({ top: 92, - message: result.message || '椤甸潰閰嶇疆閿欒', + message: result.message, duration: 10 }) } @@ -101,7 +101,7 @@ item.options.unshift({ key: Utils.getuuid(), Value: '', - Text: '鍏ㄩ儴' + Text: this.state.dict['main.all'] }) } @@ -122,7 +122,7 @@ } else if (item.resourceType === '1' && !item.dataSource) { notification.warning({ top: 92, - message: item.label + '鏁版嵁婧愰厤缃敊璇�', + message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], duration: 10 }) } @@ -214,13 +214,15 @@ // }) } - refreshbyaction = () => { + refreshbyaction = (btn, type) => { // 鎸夐挳鎿嶄綔鍚庡埛鏂拌〃鏍�,閲嶇疆椤电爜鍙婇�夋嫨椤� - this.refs.mainTable.resetTable() - this.loadmaindata(1, this.state.param.pageSize, this.state.param.orderColumn, this.state.param.orderType, this.state.param.search) - this.setState({ - loading: true - }) + console.log(btn) + console.log(type) + // this.refs.mainTable.resetTable() + // this.loadmaindata(1, this.state.param.pageSize, this.state.param.orderColumn, this.state.param.orderType, this.state.param.search) + // this.setState({ + // loading: true + // }) } gettableselected = () => { @@ -275,7 +277,7 @@ {actions && <MainAction MenuID={this.props.MenuID} - fixed={setting && setting.actionfixed} + setting={setting} refreshdata={this.refreshbyaction} gettableselected={this.gettableselected} actions={actions} diff --git a/src/tabviews/commontable/mainAction/index.jsx b/src/tabviews/commontable/mainAction/index.jsx index 277e536..4124488 100644 --- a/src/tabviews/commontable/mainAction/index.jsx +++ b/src/tabviews/commontable/mainAction/index.jsx @@ -13,7 +13,7 @@ MenuID: PropTypes.string, actions: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 dict: PropTypes.object, // 瀛楀吀椤� - fixed: PropTypes.any + setting: PropTypes.any } state = { @@ -21,29 +21,40 @@ formdata: null, tabledata: null, confirmLoading: false, - execAction: null + execAction: null, + loadingUuid: '' } - refreshdata = () => { - this.props.refreshdata() + refreshdata = (item, type) => { + this.props.refreshdata(item, type) } actionTrigger = (item) => { + const { setting } = this.props let _this = this let data = this.props.gettableselected() || [] - console.log(item) - console.log(data) + if (item.Ot !== 'notRequired' && data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� notification.warning({ top: 92, - message: this.props.dict['main.action.confirm.selectline'] + message: this.props.dict['main.action.confirm.selectline'], + duration: 10 }) return } else if (item.Ot === 'requiredSgl' && data.length !== 1) { // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 notification.warning({ top: 92, - message: this.props.dict['main.action.confirm.selectSingleLine'] + message: this.props.dict['main.action.confirm.selectSingleLine'], + duration: 10 + }) + return + } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 10 }) return } @@ -52,45 +63,377 @@ confirm({ title: this.props.dict['main.action.confirm.tip'], onOk() { - return Api.setActionSubmit({ - func: 'SetActionSubmitSuccess' - // func: 'SetActionSubmitError' - }).then((res) => { - if (res.status) { - notification.success({ - top: 92, - message: _this.props.dict['main.action.confirm.success'] - // duration: 0 - // description: - }) - _this.refreshdata() - } else { - notification.error({ - top: 92, - message: res.message - }) - } + return new Promise(resolve => { + _this.execSubmit(item, data, resolve) }) }, onCancel() {} }) } else if (item.OpenType === 'exec') { - Api.getModelFormData(item.MenuID).then(res => { - if (res.status) { - this.setState({ - formdata: res.data.map(input => { - let validate = input.Validate && JSON.parse(input.Validate) - input.DynOptions = JSON.parse(input.DynOptions) - input.required = (validate && validate.required) || false - return input - }), - visible: true, - execAction: item, - tabledata: data[0] - }) - } + this.setState({loadingUuid: item.uuid}) + this.execSubmit(item, data, () => { + this.setState({loadingUuid: ''}) }) } + } + + execSubmit = (btn, data, _resolve) => { + const { setting } = this.props + if (btn.intertype === 'inner') { + // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖ + if (!btn.innerFunc && !btn.sql) { + this.actionSettingError() + _resolve() + return + } + + if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + // 鑾峰彇id + let param = { + func: 'sPC_TableData_InUpDe' + } + let ID = '' + if (btn.Ot === 'notRequired') { + + } else if (btn.Ot === 'requiredSgl') { + ID = data[0][setting.primaryKey] + } else if (btn.Ot === 'requiredOnce') { + let ids = data.map(d => { return d[setting.primaryKey]}) + ID = ids.join(',') + } + + if (btn.innerFunc) { + param.func = btn.innerFunc + param.ID = ID + param.BID = '' + } else if (btn.sql) { + param.LText = btn.sql // 鏁版嵁婧� + } + + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(btn) + } else { + this.execError(res, btn) + } + _resolve() + }) + } else if (btn.Ot === 'required') { + let deffers = data.map(cell => { + let param = { + func: 'sPC_TableData_InUpDe' + } + let ID = cell[setting.primaryKey] + + if (btn.innerFunc) { + param.func = btn.innerFunc + param.ID = ID + param.BID = '' + } else if (btn.sql) { + param.LText = btn.sql // 鏁版嵁婧� + } + + return new Promise(resolve => { + Api.genericInterface(param).then(res => { + resolve(res) + }) + }) + }) + Promise.all(deffers).then(result => { + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (res.status) { + + } else { + iserror = true + errorMsg = res.message + } + }) + if (!iserror) { + this.execSuccess(btn) + } else { + notification.error({ + top: 92, + message: errorMsg, + duration: 15 + }) + this.refreshdata(btn, 'error') + } + _resolve() + }) + } else { + this.actionSettingError() + _resolve() + return + } + } else if (btn.intertype === 'outer') { + /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ + let param = { + ID: '', + BID: '' + } + + if (!btn.interface) { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 + this.actionSettingError() + _resolve() + return + } + + if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + // 鑾峰彇id + if (btn.Ot === 'notRequired') { + + } else if (btn.Ot === 'requiredSgl') { + param.ID = data[0][setting.primaryKey] + } else if (btn.Ot === 'requiredOnce') { + let ids = data.map(d => { return d[setting.primaryKey]}) + param.ID = ids.join(',') + } + + new Promise(resolve => { + // 鍐呴儴璇锋眰 + if (btn.innerFunc) { + param.func = btn.innerFunc + // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + res.rduri = btn.interface + // res.method = btn.method + if (btn.outerFunc) { + res.func = btn.outerFunc + } + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + resolve(res) + } else { + this.execError(res, btn) + _resolve() + } + }) + } else { + // 涓嶅瓨鍦ㄥ唴閮ㄥ嚱鏁版椂锛岀敓鎴愬閮ㄨ姹傚弬鏁� + param.rduri = btn.interface + // param.method = btn.method + if (btn.outerFunc) { + param.func = btn.outerFunc + } + resolve(param) + } + }).then(res => { + if (!res) return + // 澶栭儴璇锋眰 + console.log(res) + return Api.genericInterface(res) + }).then(response => { + // 鍥炶皟璇锋眰 + if (response.status) { + if (btn.callbackFunc) { + // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 + delete response.ErrCode + delete response.ErrMesg + delete response.message + delete response.status + + response.func = btn.callbackFunc + return Api.genericInterface(response) + } else { + this.execSuccess(btn) + _resolve() + } + } else { + this.execError(response, btn) + _resolve() + } + }).then(res => { + if (!res) return + + if (res.status) { + this.execSuccess(btn) + } else { + this.execError(res, btn) + } + _resolve() + }) + + } else if (btn.Ot === 'required') { + // 閫夋嫨澶氳锛屽惊鐜皟鐢� + + new Promise(resolve => { + // 鍐呴儴璇锋眰 + if (btn.innerFunc) { + let deffers = data.map(cell => { + let _param = { + BID: '', + func: btn.innerFunc + } + _param.ID = cell[setting.primaryKey] + return new Promise(resolve => { + Api.genericInterface(_param).then(res => { + resolve(res) + }) + }) + }) + Promise.all(deffers).then(result => { + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (!res.status) { + iserror = true + errorMsg = res.message + } + }) + if (!iserror) { + resolve(result) + } else { + notification.error({ + top: 92, + message: errorMsg, + duration: 15 + }) + this.refreshdata(btn, 'error') + _resolve() + } + }) + } else { + let params = data.map(cell => { + return { + BID: '', + ID: cell[setting.primaryKey] + } + }) + resolve(params) + } + }).then(result => { + // 澶栭儴璇锋眰 + if (!result) return + + let deffers = result.map(res => { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + res.rduri = btn.interface + // res.method = btn.method + if (btn.outerFunc) { + res.func = btn.outerFunc + } + return new Promise(resolve => { + Api.genericInterface(res).then(response => { + resolve(response) + }) + }) + }) + return Promise.all(deffers) + + }).then(result => { + // 鍥炶皟璇锋眰 + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (!res.status) { + iserror = true + errorMsg = res.message + } + }) + if (iserror) { + notification.error({ + top: 92, + message: errorMsg, + duration: 15 + }) + this.refreshdata(btn, 'error') + _resolve() + return + } + + if (btn.callbackFunc) { + // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 + let deffers = result.map(res => { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + res.func = btn.callbackFunc + return new Promise(resolve => { + Api.genericInterface(res).then(response => { + resolve(response) + }) + }) + }) + return Promise.all(deffers) + } else { + _resolve() + this.execSuccess(btn) + } + }).then(result => { + if (!result) return + + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (!res.status) { + iserror = true + errorMsg = res.message + } + }) + if (iserror) { + notification.error({ + top: 92, + message: errorMsg, + duration: 15 + }) + this.refreshdata(btn, 'error') + return + } else { + this.execSuccess(btn) + } + _resolve() + }) + + } else { + this.actionSettingError() + _resolve() + return + } + + } else { + this.actionSettingError() + _resolve() + return + } + } + + execSuccess = (btn) => { + notification.success({ + top: 92, + message: this.props.dict['main.action.confirm.success'], + duration: 5 + }) + this.refreshdata(btn, 'success') + } + + execError = (res, btn) => { + notification.error({ + top: 92, + message: res.message, + duration: 15 + }) + this.refreshdata(btn, 'error') + } + + actionSettingError = () => { + notification.warning({ + top: 92, + message: this.props.dict['main.action.settingerror'], + duration: 10 + }) } getModels = () => { @@ -151,11 +494,53 @@ } render() { - if (this.props.fixed) { // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� + const { loadingUuid } = this.state + + if (this.props.setting.actionfixed) { // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� return ( <Affix offsetTop={48}> <div className="button-list" id={this.props.MenuID + 'mainaction'}> {this.props.actions.map((item, index) => { + if (loadingUuid === item.uuid) { + return ( + <Button + className={'mk-btn mk-' + item.class} + icon={item.icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + loading + >{item.label}</Button> + ) + } else { + return ( + <Button + className={'mk-btn mk-' + item.class} + icon={item.icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + >{item.label}</Button> + ) + } + })} + {this.getModels()} + </div> + </Affix> + ) + } else { + return ( + <div className="button-list"> + {this.props.actions.map((item, index) => { + if (loadingUuid === item.uuid) { + return ( + <Button + className={'mk-btn mk-' + item.class} + icon={item.icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + loading + >{item.label}</Button> + ) + } else { return ( <Button className={'mk-btn mk-' + item.class} @@ -164,26 +549,11 @@ onClick={() => {this.actionTrigger(item)}} >{item.label}</Button> ) - })} - {this.getModels()} - </div> - </Affix> + } + })} + </div> ) } - return ( - <div className="button-list"> - {this.props.actions.map((item, index) => { - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - >{item.label}</Button> - ) - })} - </div> - ) } } diff --git a/src/templates/comtableconfig/actionform/index.jsx b/src/templates/comtableconfig/actionform/index.jsx index e299728..c9c3d81 100644 --- a/src/templates/comtableconfig/actionform/index.jsx +++ b/src/templates/comtableconfig/actionform/index.jsx @@ -1,7 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Icon, Radio } from 'antd' +import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd' import './index.scss' + +const { TextArea } = Input const btnIcons = [{ MenuID: '', @@ -105,9 +107,9 @@ _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position'] } else { if (_intertype === 'outer') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'method'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] } } this.setState({ @@ -144,9 +146,9 @@ _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position'] } else { if (this.state.interType === 'inner') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc', 'method'] } } this.setState({ @@ -193,9 +195,9 @@ if (key === 'intertype') { let _options = null if (value === 'inner') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'interface', 'outerFunc', 'callbackFunc', 'method'] } this.setState({ interType: value, @@ -284,6 +286,16 @@ </Form.Item> </Col> ) + } else if (item.type === 'textarea') { + fields.push( + <Col span={24} key={index}> + <Form.Item label={item.label} help={this.props.dict['header.form.datasource.actionhelp']} className="textarea"> + {getFieldDecorator(item.key, { + initialValue: item.initVal + })(<TextArea rows={4} />)} + </Form.Item> + </Col> + ) } }) return fields @@ -296,10 +308,19 @@ if (!err) { values.id = this.props.card.id values.uuid = this.props.card.uuid - resolve({ - type: 'action', - values - }) + + if (values.innerFunc === '' && values.sql === '') { + notification.warning({ + top: 92, + message: this.props.dict['header.form.datasource.actionhelp'], + duration: 10 + }) + } else { + resolve({ + type: 'action', + values + }) + } } else { reject(err) } diff --git a/src/templates/comtableconfig/actionform/index.scss b/src/templates/comtableconfig/actionform/index.scss index 12de954..9f25df9 100644 --- a/src/templates/comtableconfig/actionform/index.scss +++ b/src/templates/comtableconfig/actionform/index.scss @@ -4,4 +4,12 @@ color: #1890ff; cursor: pointer; } + .textarea { + .ant-col-sm-7 { + width: 14%; + } + .ant-col-sm-17 { + width: 86%; + } + } } \ No newline at end of file diff --git a/src/templates/comtableconfig/dragelement/index.jsx b/src/templates/comtableconfig/dragelement/index.jsx index 71e0022..9e0c293 100644 --- a/src/templates/comtableconfig/dragelement/index.jsx +++ b/src/templates/comtableconfig/dragelement/index.jsx @@ -7,7 +7,7 @@ import ItemTypes from './itemtypes' import './index.scss' -const Container = ({list, setting, type, placeholder, handleList, handleMenu }) => { +const Container = ({list, setting, type, placeholder, handleList, handleMenu, copyElement }) => { let target = null const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { @@ -35,16 +35,16 @@ let copycard = JSON.parse(JSON.stringify(card)) copycard.uuid = Utils.getuuid() copycard.origin = false - let names = cards.map(car => { return car.label }) - let index = 1 - let origin = copycard.label.split('(copy')[0] || 'button' - let label = origin + '(copy)' - while (names.includes(label)) { - label = origin + `(copy${index})` - index++ - } + // let names = cards.map(car => { return car.label }) + // let index = 1 + // let origin = copycard.label.split('(copy')[0] || 'button' + // let label = origin + '(copy)' + // while (names.includes(label)) { + // label = origin + `(copy${index})` + // index++ + // } - copycard.label = label + copycard.label = copycard.label + '(copy)' let indexes = cards.map(car => { return car.id }) let newid = 0 @@ -53,11 +53,13 @@ } copycard.id = newid - const { index: overIndex } = findCard(`${card.id}`) + // const { index: overIndex } = findCard(`${card.id}`) - const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] }) - setCards(_cards) - handleList({action: _cards}) + // const _cards = update(cards, { $splice: [[overIndex + 1, 0, copycard]] }) + // setCards(_cards) + // handleList({action: _cards}) + + copyElement(copycard) } const hasDrop = (item) => { @@ -102,12 +104,14 @@ newcard.label = 'button' newcard.innerFunc = '' newcard.outerFunc = '' + newcard.sql = '' newcard.Ot = 'requiredSgl' newcard.OpenType = item.subType newcard.icon = '' newcard.class = 'default' newcard.intertype = 'inner' newcard.interface = '' + newcard.method = 'POST' newcard.position = 'toolbar' newcard.execSuccess = 'grid' newcard.execError = 'never' diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 7129967..ada6e79 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -600,6 +600,20 @@ }, { 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', label: this.state.dict['header.form.icon'], initVal: card.icon, @@ -613,6 +627,13 @@ initVal: card.class, required: false, options: [] + }, + { + type: 'textarea', + key: 'sql', + label: this.state.dict['header.form.datasource'], + initVal: card.sql || '', + required: false } ] }) @@ -713,6 +734,7 @@ handleSubmit = () => { this.formRef.handleConfirm().then(res => { let _config = this.state.config + let isupdate = false if (res.type === 'search') { if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { @@ -727,6 +749,7 @@ if (this.state.operaType === 'add') { _config[res.type] = _config[res.type].map(item => { if (item.uuid === res.values.uuid) { + isupdate = true return res.values } else { return item @@ -736,11 +759,16 @@ } else { _config[res.type] = _config[res.type].map(item => { if (item.uuid === res.values.uuid) { + isupdate = true return res.values } else { return item } }) + } + + if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃 + _config[res.type].push(res.values) } this.setState({ @@ -1443,6 +1471,7 @@ placeholder={this.state.dict['header.form.action.placeholder']} handleList={this.handleList} handleMenu={this.handleAction} + copyElement={this.handleAction} /> : null } </div> diff --git a/src/templates/comtableconfig/settingform/index.jsx b/src/templates/comtableconfig/settingform/index.jsx index 1975255..da4b682 100644 --- a/src/templates/comtableconfig/settingform/index.jsx +++ b/src/templates/comtableconfig/settingform/index.jsx @@ -51,30 +51,6 @@ <Form {...formItemLayout} className="ant-advanced-search-form commontable-setting-form" id="commontable-setting-form"> <Row gutter={24}> <Col span={12}> - <Form.Item label="鍥哄畾鎸夐挳"> - {getFieldDecorator('actionfixed', { - initialValue: data.actionfixed - })( - <Radio.Group> - <Radio value={true}>鏄�</Radio> - <Radio value={false}>鍚�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={12}> - <Form.Item label="鍥哄畾鍒�"> - {getFieldDecorator('columnfixed', { - initialValue: data.columnfixed - })( - <Radio.Group> - <Radio value={true}>鏄�</Radio> - <Radio value={false}>鍚�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - <Col span={12}> <Form.Item label="琛ㄥ悕"> {getFieldDecorator('tableName', { initialValue: data.tableName, @@ -116,6 +92,30 @@ </Form.Item> </Col> <Col span={12}> + <Form.Item label="鍥哄畾鎸夐挳"> + {getFieldDecorator('actionfixed', { + initialValue: data.actionfixed + })( + <Radio.Group> + <Radio value={true}>鏄�</Radio> + <Radio value={false}>鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鍥哄畾鍒�"> + {getFieldDecorator('columnfixed', { + initialValue: data.columnfixed + })( + <Radio.Group> + <Radio value={true}>鏄�</Radio> + <Radio value={false}>鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + <Col span={12}> <Form.Item label="涓婚敭"> {getFieldDecorator('primaryKey', { initialValue: primaryKey diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index 9fd5ba0..d52cb61 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -85,7 +85,9 @@ intertype: 'inner', innerFunc: '', interface: '', + method: 'POST', outerFunc: '', + sql: '', callbackFunc: '', Ot: 'notRequired', position: 'toolbar', @@ -104,7 +106,9 @@ intertype: 'inner', innerFunc: '', interface: '', + method: 'POST', outerFunc: '', + sql: '', callbackFunc: '', Ot: 'requiredSgl', position: 'grid', @@ -123,7 +127,9 @@ intertype: 'inner', innerFunc: '', interface: '', + method: 'POST', outerFunc: '', + sql: '', callbackFunc: '', Ot: 'required', position: 'toolbar', @@ -142,7 +148,9 @@ intertype: 'inner', innerFunc: '', interface: '', + method: 'POST', outerFunc: '', + sql: '', callbackFunc: '', Ot: 'requiredOnce', position: 'toolbar', -- Gitblit v1.8.0