| | |
| | | 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' |
| | |
| | | } |
| | | } |
| | | |
| | | handleGridBtn = () => { |
| | | this.setState({ |
| | | visible: true, |
| | | formtemp: 'gridbtn' |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 搜索、按钮、显示列修改后提交保存 |
| | | * 1、搜索条件保存,当类型为下拉框且存在数据源时,将查询条件拼接为sql,并用base64转码 |
| | | * 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) => { |
| | |
| | | <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> |
| | |
| | | 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' ? |
| | |
| | | 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 |