From 88f02c2c018fb1e5c171bd4975dac534c584c3ba Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 十二月 2019 09:31:37 +0800 Subject: [PATCH] 2019-12-10 --- src/templates/comtableconfig/index.jsx | 299 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 227 insertions(+), 72 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index b97d29d..87a0a7a 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -3,7 +3,7 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty } from 'antd' +import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch } from 'antd' import moment from 'moment' import DragElement from './dragelement' import SourceElement from './dragelement/source' @@ -37,28 +37,29 @@ } state = { - operaType: '', // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫 - dict: CommonDict, // 瀛楀吀 - config: null, // 椤甸潰閰嶇疆 - visible: false, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗 - tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 - addType: '', // 娣诲姞绫诲瀷-鎼滅储鏉′欢鎴栨樉绀哄垪 - tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 - formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - formtemp: '', // 琛ㄥ崟绫诲瀷锛屾樉绀哄垪銆佹寜閽�佹悳绱㈡潯浠� - card: null, // 缂栬緫鍏冪礌 - searchloading: false, // 鎼滅储鏉′欢鍔犺浇涓� - actionloading: false, // 鎸夐挳鍔犺浇涓� - columnsloading: false, // 鏄剧ず鍒楀姞杞戒腑 - menuloading: false, // 鑿滃崟淇濆瓨涓� - loading: false, // 鍔犺浇涓紝椤甸潰spin - settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 - closeVisible: false, // 鍏抽棴妯℃�佹 - tables: [], // 鍙敤琛ㄥ悕 - selectedTables: [], // 宸查�夎〃鍚� - originMenu: null, // 鍘熷鑿滃崟 + operaType: '', // 鎿嶄綔绫诲瀷锛屾柊寤烘垨缂栬緫 + dict: CommonDict, // 瀛楀吀 + config: null, // 椤甸潰閰嶇疆 + visible: false, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗 + tableVisible: false, // 鏁版嵁琛ㄥ瓧娈垫ā鎬佹 + addType: '', // 娣诲姞绫诲瀷-鎼滅储鏉′欢鎴栨樉绀哄垪 + tableColumns: [], // 琛ㄦ牸鏄剧ず鍒� + fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� + menuformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 + formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 + formtemp: '', // 琛ㄥ崟绫诲瀷锛屾樉绀哄垪銆佹寜閽�佹悳绱㈡潯浠� + card: null, // 缂栬緫鍏冪礌 + searchloading: false, // 鎼滅储鏉′欢鍔犺浇涓� + actionloading: false, // 鎸夐挳鍔犺浇涓� + columnsloading: false, // 鏄剧ず鍒楀姞杞戒腑 + menuloading: false, // 鑿滃崟淇濆瓨涓� + menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 + loading: false, // 鍔犺浇涓紝椤甸潰spin + settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 + closeVisible: false, // 鍏抽棴妯℃�佹 + tables: [], // 鍙敤琛ㄥ悕 + selectedTables: [], // 宸查�夎〃鍚� + originMenu: null, // 鍘熷鑿滃崟 originActions: null } @@ -95,7 +96,7 @@ originActions: _oriActions, config: _config, operaType: _type, - originMenu: JSON.parse(JSON.stringify({...menu})), + originMenu: JSON.parse(JSON.stringify(menu)), selectedTables: _config.tables || [], menuformlist: [ { @@ -240,29 +241,31 @@ }) } - handleList = (listObj) => { - let config = this.state.config - if (this.state.operaType === 'add') { - let key = Object.keys(listObj)[0] - let newlength = listObj[key].length - if (newlength > config[key].length) { - listObj[key] = listObj[key].filter(item => !item.origin) - } - if (newlength > listObj[key].length) { + handleList = (type, list, card) => { + const { config } = this.state + + if (list.length > config[type].length) { + list = list.filter(item => !item.origin) + + this.setState({ + [type + 'loading']: true, + config: {...config, [type]: list } + }, () => { + // 鍒锋柊瀵瑰簲鐨勯厤缃俊鎭� this.setState({ - [key + 'loading']: true, - config: {...config, ...listObj} - }, () => { - // 鍒锋柊瀵瑰簲鐨勯厤缃俊鎭� - this.setState({ - [key + 'loading']: false - }) + [type + 'loading']: false }) - } else { - this.setState({config: {...config, ...listObj}}) - } + + if (type === 'search') { + this.handleSearch(card) + } else if (type === 'action') { + this.handleAction(card) + } else if (type === 'columns') { + this.handleColumn(card) + } + }) } else { - this.setState({config: {...config, ...listObj}}) + this.setState({config: {...config, [type]: list}}) } } @@ -622,20 +625,20 @@ 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: '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', @@ -653,11 +656,31 @@ options: [] }, { - type: 'textarea', + type: 'text', key: 'sql', label: this.state.dict['header.form.datasource'], - initVal: card.sql || '', + initVal: card.sql || this.state.config.setting.tableName || '', required: false + }, + { + type: 'select', + key: 'sqlType', + label: this.state.dict['header.form.action.type'], + initVal: card.sqlType || 'insert', + required: false, + options: [{ + 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'] + }] } ] }) @@ -697,6 +720,12 @@ }, { MenuID: 'picture', text: this.state.dict['header.form.picture'] + }, { + MenuID: 'number', + text: this.state.dict['header.form.number'] + }, { + MenuID: 'textarea', + text: this.state.dict['header.form.textarea'] }] }, { @@ -731,7 +760,7 @@ }] }, { - type: 'select', + type: 'radio', key: 'IsSort', label: this.state.dict['header.form.IsSort'], initVal: card.IsSort, @@ -747,10 +776,110 @@ { type: 'number', key: 'Width', + min: 1, + max: 1000, decimal: 0, label: this.state.dict['header.form.columnWidth'], initVal: card.Width, required: true + }, + { + type: 'number', + key: 'decimal', + min: 0, + max: 18, + decimal: 0, + label: this.state.dict['header.form.decimal'], + initVal: card.decimal, + required: false + }, + { + type: 'select', + key: 'format', + label: this.state.dict['header.form.format'], + initVal: card.format || '', + options: [{ + MenuID: '', + text: this.state.dict['header.form.empty'] + }, { + MenuID: 'thdSeparator', + text: this.state.dict['header.form.thdSeparator'] + }], + required: false + }, + { + type: 'text', + key: 'prefix', + label: this.state.dict['header.form.prefix'], + initVal: card.prefix || '', + required: false, + readonly: false + }, + { + type: 'select', + key: 'match', + label: this.state.dict['header.form.match'], + initVal: card.match || '', + options: [{ + MenuID: '', + text: this.state.dict['header.form.empty'] + }, { + MenuID: '>', + text: '>' + }, { + MenuID: '<', + text: '<' + }, { + MenuID: '>=', + text: '>=' + }, { + MenuID: '<=', + text: '<=' + }, { + MenuID: 'between', + text: 'between' + }], + required: false + }, + { + type: 'text', + key: 'matchVal', + min: -Infinity, + max: Infinity, + decimal: 0, + label: this.state.dict['header.form.matchVal'], + initVal: card.matchVal || '', + required: false, + readonly: false + }, + { + type: 'select', + key: 'color', + label: this.state.dict['header.form.color'], + initVal: card.color || '', + options: [{ + MenuID: '', + text: this.state.dict['header.form.empty'] + }, { + MenuID: 'red', + text: '绾㈣壊锛堝唴瀹癸級' + }, { + MenuID: 'redbg', + text: '绾㈣壊锛堣儗鏅級' + }, { + MenuID: 'orange', + text: '姗欒壊锛堝唴瀹癸級' + }, { + MenuID: 'orangebg', + text: '姗欒壊锛堣儗鏅級' + }, { + MenuID: 'green', + text: '缁胯壊锛堝唴瀹癸級' + }, { + MenuID: 'greenbg', + text: '缁胯壊锛堣儗鏅級' + }], + required: false } ] }) @@ -981,9 +1110,15 @@ LongParam: _LongParam } - this.setState({ - menuloading: true - }) + if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� + this.setState({ + menucloseloading: true + }) + } else { + this.setState({ + menuloading: true + }) + } Api.getSystemConfig(param).then(response => { if (response.status) { @@ -1001,7 +1136,8 @@ this.submitAction(btnParam) } else { this.setState({ - menuloading: false + menuloading: false, + menucloseloading: false }) notification.warning({ top: 92, @@ -1021,9 +1157,16 @@ PageParam: JSON.stringify(_pageParam), LongParam: _LongParam } - this.setState({ - menuloading: true - }) + + if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� + this.setState({ + menucloseloading: true + }) + } else { + this.setState({ + menuloading: true + }) + } Api.getSystemConfig(param).then(response => { if (response.status) { @@ -1040,7 +1183,8 @@ this.submitAction(btnParam) } else { this.setState({ - menuloading: false + menuloading: false, + menucloseloading: false }) notification.warning({ top: 92, @@ -1074,12 +1218,14 @@ this.props.handleConfig('') } else { this.setState({ - menuloading: false + menuloading: false, + menucloseloading: false }) } } else { this.setState({ - menuloading: false + menuloading: false, + menucloseloading: false }) notification.warning({ top: 92, @@ -1499,6 +1645,14 @@ } } + onEnabledChange = () => { + const { config } = this.state + + this.setState({ + config: {...config, enabled: !config.enabled} + }) + } + render () { const configAction = this.state.config.action.filter(_action => !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') @@ -1598,6 +1752,7 @@ <div className="setting"> <Card title={this.state.dict['header.menu.page.configurable']} bordered={false} extra={ <div> + <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍏�" defaultChecked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button> <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button> @@ -1745,7 +1900,7 @@ visible={this.state.closeVisible} onCancel={() => { this.setState({closeVisible: false}) }} footer={[ - <Button key="save" className="mk-btn mk-green" onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, + <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, <Button key="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig('')}}>{this.state.dict['header.notsave']}</Button>, <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button> ]} -- Gitblit v1.8.0