From a5f99a5f0e2035851997221bc2430f8cfd1dc146 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 04 十二月 2019 23:21:04 +0800 Subject: [PATCH] 2019-12-04 --- src/templates/comtableconfig/index.jsx | 149 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 104 insertions(+), 45 deletions(-) diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 97e9a88..73a64e1 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -12,6 +12,7 @@ import ColumnForm from './columnform' import ColspanForm from './colspanform' import SettingForm from './settingform' +import GridBtnForm from './gridbtnform' import EditCard from './editcard' import MenuForm from './menuform' import zhCN from '@/locales/zh-CN/comtable.js' @@ -753,56 +754,110 @@ } } + handleGridBtn = () => { + this.setState({ + visible: true, + formtemp: 'gridbtn' + }) + } + + /** + * @description 鎼滅储銆佹寜閽�佹樉绀哄垪淇敼鍚庢彁浜や繚瀛� + * 1銆佹悳绱㈡潯浠朵繚瀛橈紝褰撶被鍨嬩负涓嬫媺妗嗕笖瀛樺湪鏁版嵁婧愭椂锛屽皢鏌ヨ鏉′欢鎷兼帴涓簊ql锛屽苟鐢╞ase64杞爜 + * 2銆佹寜閽寘鎷甯哥紪杈戝拰澶嶅埗锛屽鍒舵椂,鎸夐挳鍒楁湯灏炬坊鍔� + * 3銆佹坊鍔犳垨缂栬緫鍒楋紝淇濆瓨鏃讹紝濡傛寜閽綅缃缃负琛ㄦ牸锛屽垯淇敼鎿嶄綔鍒楁樉绀虹姸鎬� + */ handleSubmit = () => { - this.formRef.handleConfirm().then(res => { - let _config = this.state.config - let isupdate = false + let _config = JSON.parse(JSON.stringify(this.state.config)) - if (res.type === 'search') { - if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { - let sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ' from (' + res.values.dataSource + ')' - if (res.values.orderBy) { - sql = sql + ' ld order by ' + res.values.orderBy + ' ' + res.values.orderType + if (this.state.formtemp !== 'gridbtn') { + this.formRef.handleConfirm().then(res => { + let isupdate = false + + if (res.type === 'search') { + if ((res.values.type === 'select' || res.values.type === 'link') && res.values.resourceType === '1') { + let sql = 'select ' + res.values.valueField + ',' + res.values.valueText + ' from (' + res.values.dataSource + ')' + if (res.values.orderBy) { + sql = sql + ' ld order by ' + res.values.orderBy + ' ' + res.values.orderType + } + res.values.dataSourceSql = Utils.formatOptions(sql) } - res.values.dataSourceSql = Utils.formatOptions(sql) } - } - - 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 + + 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 + } + }) + _config[res.type] = _config[res.type].filter(item => !item.origin) + } 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) + } + + if (res.type === 'action') { + let gridbtn = _config.action.filter(act => act.position === 'grid') + let _display = false + + if (gridbtn.length > 0) { + _display = true } - }) - _config[res.type] = _config[res.type].filter(item => !item.origin) - } else { - _config[res.type] = _config[res.type].map(item => { - if (item.uuid === res.values.uuid) { - isupdate = true - return res.values + + if (_config.gridBtn) { + _config.gridBtn.display = _display } else { - return item + _config.gridBtn = { + display: _display, + Align: 'center', + IsSort: 'false', + uuid: Utils.getuuid(), + label: this.state.dict['header.form.column.action'], + type: 'action', + style: 'button', + show: 'horizontal', + Width: 120 + } } - }) - } - - if (!isupdate) { // 鎿嶄綔涓嶆槸淇敼锛屾坊鍔犲厓绱犺嚦鍒楄〃 - _config[res.type].push(res.values) - } - - this.setState({ - config: _config, - [res.type + 'loading']: true, - visible: false - }, () => { + } + this.setState({ - [res.type + 'loading']: false + config: _config, + searchloading: true, + actionloading: true, + columnsloading: true, + visible: false + }, () => { + this.setState({ + searchloading: false, + actionloading: false, + columnsloading: false + }) }) }) - }) + } else { + this.formRef.handleConfirm().then(res => { + _config.gridBtn = res + + this.setState({ + config: _config, + visible: false + }) + }) + } } deleteElement = (element) => { @@ -1529,11 +1584,13 @@ <DragElement list={this.state.config.columns} setting={this.state.config.setting} + gridBtn={this.state.config.gridBtn} type="columns" placeholder={this.state.dict['header.form.column.placeholder']} handleList={this.handleList} handleMenu={this.handleColumn} deleteMenu={this.deleteElement} + handleGridBtn={this.handleGridBtn} /> : null } </div> @@ -1547,11 +1604,6 @@ width={700} onCancel={() => { this.setState({ visible: false }) }} onOk={this.handleSubmit} - // footer={[ - // <Button key="delete" type="danger" onClick={this.deleteElement}>{this.state.dict['header.delete']}</Button>, - // <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['header.cancel']}</Button>, - // <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> - // ]} destroyOnClose > {this.state.formtemp === 'search' ? @@ -1586,6 +1638,13 @@ wrappedComponentRef={(inst) => this.formRef = inst} /> : null } + {this.state.formtemp === 'gridbtn' ? + <GridBtnForm + dict={this.state.dict} + card={this.state.config.gridBtn} + wrappedComponentRef={(inst) => this.formRef = inst} + /> : null + } </Modal> {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */} <Modal -- Gitblit v1.8.0