| | |
| | | import TabForm from './tabform' |
| | | import TabDragElement from './tabdragelement' |
| | | import Api from '@/api' |
| | | import SearchForm from '@/templates/tableshare/searchform' |
| | | import SearchForm from './modalform' |
| | | import DragElement from './dragelement' |
| | | import EditCard from '@/templates/tableshare/editcard' |
| | | import VerifyCard from '@/templates/tableshare/verifycard' |
| | |
| | | card: null, // 编辑元素 |
| | | searchloading: false, // 搜索条件加载中 |
| | | actionloading: false, // 按钮加载中 |
| | | columnsloading: false, // 显示列加载中 |
| | | tabloading: false, // 标签页加载中 |
| | | menuloading: false, // 菜单保存中 |
| | | menucloseloading: false, // 菜单关闭时,选择保存 |
| | |
| | | UNSAFE_componentWillMount () { |
| | | const { menu, editAction, config } = this.props |
| | | |
| | | console.log(menu) |
| | | console.log(editAction) |
| | | console.log(config) |
| | | let _config = '' |
| | | |
| | | if (!config) { |
| | |
| | | } |
| | | } |
| | | |
| | | handleList = (type, list, card, groupId) => { |
| | | const { config } = this.state |
| | | handleList = (type, list, card, groupId, elementId) => { |
| | | let config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | if (type === 'tabs') { // 标签页调整顺序或添加元素 |
| | | if (list.length > config[card.groupId].length) { |
| | |
| | | } else { |
| | | this.setState({config: {...config, action: list}}) |
| | | } |
| | | } else if (type === 'search') { |
| | | let _group = config.groups.filter(group => group.uuid === groupId)[0] |
| | | let isChange = list.length > _group.length |
| | | let isAdd = !elementId && list.length > _group.length |
| | | |
| | | if (isAdd) { |
| | | _group.sublist = list.filter(item => !item.origin) |
| | | this.handleSearch(card) |
| | | } else if (elementId) { |
| | | // 修改已有元素的分组 |
| | | let element = null |
| | | config.groups.forEach(item => { |
| | | item.sublist = item.sublist.filter(cell => { |
| | | if (cell.uuid !== elementId) { |
| | | return true |
| | | } else { |
| | | element = cell |
| | | return false |
| | | } |
| | | }) |
| | | }) |
| | | _group.sublist.push(element) |
| | | } else { |
| | | _group.sublist = list |
| | | } |
| | | |
| | | config.groups = config.groups.map(item => { |
| | | if (item.uuid === _group.uuid) { |
| | | return _group |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | if (isChange) { |
| | | this.setState({ |
| | | searchloading: true, |
| | | config: config |
| | | }, () => { |
| | | // 刷新对应的配置信息 |
| | | this.setState({ |
| | | searchloading: false |
| | | }) |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | | handleSearch = (card) => { |
| | | const { config } = this.state |
| | | let _inputfields = [] |
| | | |
| | | // 设置下拉菜单可关联字段 |
| | | config.groups.forEach(group => { |
| | | let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') |
| | | _inputfields = [..._inputfields, ...sublist] |
| | | }) |
| | | |
| | | if (card.linkSubField && card.linkSubField.length > 0) { |
| | | let fields = _inputfields.map(item => item.field) |
| | | card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) |
| | | } |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | formtemp: 'search', |
| | | modalTitle: '编辑-搜索条件', |
| | | modalTitle: '编辑-表单', |
| | | card: card, |
| | | formlist: [ |
| | | { |
| | |
| | | key: 'field', |
| | | label: this.state.dict['header.form.field'], |
| | | initVal: card.field, |
| | | tooltip: '字段名可以使用逗号分隔,进行多字段综合搜索,注:综合搜索仅在文本类型时有效', |
| | | tooltipClass: 'middle', |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | |
| | | value: 'text', |
| | | text: this.state.dict['header.form.text'] |
| | | }, { |
| | | value: 'number', |
| | | text: this.state.dict['header.form.number'] |
| | | }, { |
| | | value: 'select', |
| | | text: this.state.dict['header.form.select'] |
| | | }, { |
| | |
| | | value: 'link', |
| | | text: this.state.dict['header.form.link'] |
| | | }, { |
| | | value: 'fileupload', |
| | | text: this.state.dict['header.form.fileupload'] |
| | | }, { |
| | | value: 'date', |
| | | text: this.state.dict['header.form.dateday'] |
| | | }, { |
| | | value: 'dateweek', |
| | | text: this.state.dict['header.form.dateweek'] |
| | | }, { |
| | | value: 'datemonth', |
| | | text: this.state.dict['header.form.datemonth'] |
| | | }, { |
| | | value: 'daterange', |
| | | text: this.state.dict['header.form.daterange'] |
| | | value: 'datetime', |
| | | text: this.state.dict['header.form.datetime'] |
| | | }, { |
| | | value: 'textarea', |
| | | text: this.state.dict['header.form.textarea'] |
| | | }] |
| | | }, |
| | | { |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'match', |
| | | label: this.state.dict['header.form.match'], |
| | | initVal: card.match || 'like', |
| | | required: true, |
| | | type: 'number', |
| | | key: 'decimal', |
| | | label: this.state.dict['header.form.decimal'], |
| | | initVal: card.decimal || 0, |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'min', |
| | | label: '最小值', |
| | | initVal: card.min || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'max', |
| | | label: '最大值', |
| | | initVal: card.max || '', |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'readonly', |
| | | label: this.state.dict['header.form.readonly'], |
| | | initVal: card.readonly || 'false', |
| | | options: [{ |
| | | value: 'like', |
| | | text: 'like' |
| | | value: 'true', |
| | | text: this.state.dict['header.form.true'] |
| | | }, { |
| | | value: 'equal', |
| | | text: 'equal' |
| | | }, { |
| | | value: 'greater', |
| | | text: '>' |
| | | }, { |
| | | value: 'less', |
| | | text: '<' |
| | | }, { |
| | | value: 'greaterequal', |
| | | text: '>=' |
| | | value: 'false', |
| | | text: this.state.dict['header.form.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'display', |
| | | label: this.state.dict['header.form.display'], |
| | | initVal: card.display || 'dropdown', |
| | | required: true, |
| | | type: 'radio', |
| | | key: 'required', |
| | | label: this.state.dict['header.form.field.required'], |
| | | initVal: card.required || 'false', |
| | | options: [{ |
| | | value: 'dropdown', |
| | | text: this.state.dict['header.form.dropdown'] |
| | | value: 'true', |
| | | text: this.state.dict['header.form.true'] |
| | | }, { |
| | | value: 'button', |
| | | text: this.state.dict['header.form.button'] |
| | | value: 'false', |
| | | text: this.state.dict['header.form.false'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'multiselect', |
| | | key: 'linkSubField', |
| | | label: this.state.dict['header.form.linkForm'], |
| | | initVal: card.linkSubField || [], |
| | | options: _inputfields |
| | | } |
| | | ] |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | if (res.type !== 'tabs') { |
| | | _config[res.type] = _config[res.type].map(item => { |
| | | |
| | | if (res.type === 'action') { |
| | | _config.action = _config.action.map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | | isupdate = true |
| | | return res.values |
| | |
| | | return item |
| | | } |
| | | }) |
| | | _config[res.type] = _config[res.type].filter(item => !item.origin) |
| | | _config.action = _config.action.filter(item => !item.origin) |
| | | |
| | | if (!isupdate) { // 操作不是修改,添加元素至列表 |
| | | _config[res.type].push(res.values) |
| | | _config.action.push(res.values) |
| | | } |
| | | } else if (res.type === 'search') { |
| | | _config.groups = _config.groups.map(item => { |
| | | item.sublist = item.sublist.map(cell => { |
| | | if (cell.uuid === res.values.uuid) { |
| | | return res.values |
| | | } else { |
| | | return cell |
| | | } |
| | | }) |
| | | if (item.isDefault) { |
| | | item.sublist = item.sublist.filter(cell => !cell.origin) |
| | | } |
| | | return item |
| | | }) |
| | | } else { // 标签页的添加与修改 |
| | | _config[res.values.groupId] = _config[res.values.groupId].map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | |
| | | config: _config, |
| | | searchloading: true, |
| | | actionloading: true, |
| | | columnsloading: true, |
| | | tabloading: true, |
| | | visible: false |
| | | }, () => { |
| | | this.setState({ |
| | | searchloading: false, |
| | | actionloading: false, |
| | | columnsloading: false, |
| | | tabloading: false |
| | | }) |
| | | }) |
| | |
| | | ParentID: res.parentId |
| | | }, |
| | | searchloading: true, |
| | | actionloading: true, |
| | | columnsloading: true |
| | | actionloading: true |
| | | }, () => { |
| | | this.setState({ |
| | | searchloading: false, |
| | | actionloading: false, |
| | | columnsloading: false |
| | | actionloading: false |
| | | }) |
| | | }) |
| | | |
| | |
| | | this.setState({ |
| | | config: {...config, setting: res}, |
| | | settingVisible: false, |
| | | columnsloading: true, |
| | | tabloading: true |
| | | }, () => { |
| | | this.setState({ |
| | | columnsloading: false, |
| | | tabloading: false |
| | | }) |
| | | }) |
| | |
| | | />} |
| | | </Panel> |
| | | {/* 搜索条件添加 */} |
| | | <Panel header={this.state.dict['header.menu.search']} key="1"> |
| | | <Panel header={this.state.dict['header.menu.form']} key="1"> |
| | | <div className="search-element"> |
| | | {Source.searchItems.map((item, index) => { |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.search.add']}</Button> |
| | | <Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.form.add']}</Button> |
| | | </Panel> |
| | | {/* 按钮添加 */} |
| | | <Panel header={this.state.dict['header.menu.action']} key="2"> |