| | |
| | | // import { is, fromJS } from 'immutable' |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { Button, Card, Modal, Tabs } from 'antd' |
| | | import { Button, Card, Modal, Collapse, Input, notification } from 'antd' |
| | | import DragElement from './dragelement' |
| | | import SourceElement from './dragelement/source' |
| | | import Api from '@/api' |
| | | import SearchForm from './searchform' |
| | | import ActionForm from './actionform' |
| | | import ColumnForm from './columnform' |
| | | import MenuForm from './menuform' |
| | | import zhCN from '@/locales/zh-CN/header.js' |
| | | import enUS from '@/locales/en-US/header.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import './index.scss' |
| | | |
| | | const {TabPane} = Tabs |
| | | const { Panel } = Collapse |
| | | const { Search } = Input |
| | | const HeaderDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS |
| | | |
| | | class ComTableConfig extends Component { |
| | | static propTpyes = { |
| | | menuConfig: PropTypes.any, |
| | | handleConfig: PropTypes.func |
| | | menu: PropTypes.any, |
| | | handleConfig: PropTypes.func, |
| | | supMenuList: PropTypes.array, |
| | | supMenu: PropTypes.object, |
| | | } |
| | | |
| | | state = { |
| | | dict: HeaderDict, |
| | | config: null, |
| | | visible: false, |
| | | tableVisible: false, |
| | | addType: '', |
| | | menuformlist: null, |
| | | formlist: null, |
| | | formtemp: '', |
| | | madalwidth: 520, |
| | | card: null, |
| | | searchloading: false, |
| | | actionloading: false, |
| | |
| | | setAll: 'false', |
| | | options: [], |
| | | dataSource: '', |
| | | linkField: '', |
| | | valueField: '', |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc' |
| | | orderType: 'asc', |
| | | display: 'dropdown' |
| | | }, { |
| | | id: 1, |
| | | uuid: Utils.getuuid(), |
| | |
| | | setAll: 'false', |
| | | options: [], |
| | | dataSource: '', |
| | | linkField: '', |
| | | valueField: '', |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc' |
| | | orderType: 'asc', |
| | | display: 'dropdown' |
| | | }, { |
| | | id: 2, |
| | | uuid: Utils.getuuid(), |
| | |
| | | setAll: 'false', |
| | | options: [], |
| | | dataSource: '', |
| | | linkField: '', |
| | | valueField: '', |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc' |
| | | orderType: 'asc', |
| | | display: 'dropdown' |
| | | }], |
| | | action: [{ |
| | | id: 0, |
| | | uuid: Utils.getuuid(), |
| | | label: 'add', |
| | | intertype: 'inner', |
| | | interface: '', |
| | | func: '', |
| | | callbackFunc: '', |
| | | Ot: 'notRequired', |
| | | OpenType: 'pop', |
| | | pageTemplate: '', |
| | | icon: 'plus', |
| | | class: 'green' |
| | | }, { |
| | | id: 1, |
| | | uuid: Utils.getuuid(), |
| | | label: 'update', |
| | | intertype: 'inner', |
| | | interface: '', |
| | | func: '', |
| | | callbackFunc: '', |
| | | Ot: 'requiredSgl', |
| | | OpenType: 'pop', |
| | | pageTemplate: '', |
| | | icon: 'form', |
| | | class: 'purple' |
| | | }, { |
| | | id: 2, |
| | | uuid: Utils.getuuid(), |
| | | label: 'delete', |
| | | intertype: 'inner', |
| | | interface: '', |
| | | func: '', |
| | | callbackFunc: '', |
| | | Ot: 'required', |
| | | OpenType: 'prompt', |
| | | pageTemplate: '', |
| | | icon: 'delete', |
| | | class: 'red' |
| | | }, { |
| | | id: 3, |
| | | uuid: Utils.getuuid(), |
| | | label: 'freeze', |
| | | intertype: 'inner', |
| | | interface: '', |
| | | func: '', |
| | | callbackFunc: '', |
| | | Ot: 'requiredOnce', |
| | | OpenType: 'exec', |
| | | pageTemplate: '', |
| | | icon: '', |
| | | class: '' |
| | | class: 'default' |
| | | }], |
| | | columns: [{ |
| | | id: 0, |
| | |
| | | } |
| | | |
| | | handleList = (list) => { |
| | | console.log(list) |
| | | let config = this.state.config |
| | | this.setState({config: {...config, ...list}}) |
| | | } |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | formtemp: 'search', |
| | | madalwidth: 700, |
| | | card: card, |
| | | formlist: [ |
| | | { |
| | |
| | | type: 'text', |
| | | key: 'initval', |
| | | label: this.state.dict['header.form.initval'], |
| | | initVal: '', |
| | | initVal: card.initval, |
| | | required: false |
| | | }, |
| | | { |
| | |
| | | MenuID: 'select', |
| | | text: this.state.dict['header.form.select'] |
| | | }, { |
| | | MenuID: 'link', |
| | | text: this.state.dict['header.form.link'] |
| | | }, { |
| | | MenuID: 'dateday', |
| | | text: this.state.dict['header.form.dateday'] |
| | | }, { |
| | |
| | | key: 'resourceType', |
| | | label: this.state.dict['header.form.resourceType'], |
| | | initVal: card.resourceType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: '0', |
| | | text: this.state.dict['header.form.custom'] |
| | |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'linkField', |
| | | label: this.state.dict['header.form.linkField'], |
| | | initVal: card.linkField, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'valueField', |
| | | label: this.state.dict['header.form.valueField'], |
| | | initVal: card.valueField, |
| | |
| | | MenuID: 'desc', |
| | | text: this.state.dict['header.form.desc'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'display', |
| | | label: this.state.dict['header.form.display'], |
| | | initVal: card.display, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'dropdown', |
| | | text: this.state.dict['header.form.dropdown'] |
| | | }, { |
| | | MenuID: 'button', |
| | | text: this.state.dict['header.form.button'] |
| | | }] |
| | | } |
| | | ] |
| | | }) |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | formtemp: 'action', |
| | | madalwidth: 520, |
| | | card: card, |
| | | formlist: [ |
| | | { |
| | |
| | | key: 'label', |
| | | label: this.state.dict['header.form.name'], |
| | | initVal: card.label, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'OpenType', |
| | | label: this.state.dict['header.form.openType'], |
| | | initVal: card.OpenType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'pop', |
| | | text: this.state.dict['header.form.pop'] |
| | | }, { |
| | | MenuID: 'prompt', |
| | | text: this.state.dict['header.form.prompt'] |
| | | }, { |
| | | MenuID: 'exec', |
| | | text: this.state.dict['header.form.exec'] |
| | | }, { |
| | | MenuID: 'tab', |
| | | text: this.state.dict['header.form.tab'] |
| | | }, { |
| | | MenuID: 'blank', |
| | | text: this.state.dict['header.form.blank'] |
| | | }, { |
| | | MenuID: 'newpage', |
| | | text: this.state.dict['header.form.newpage'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'pageTemplate', |
| | | label: this.state.dict['header.form.pageTemplate'], |
| | | initVal: card.pageTemplate, |
| | | required: true, |
| | | options: [] |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'intertype', |
| | | label: this.state.dict['header.form.intertype'], |
| | | initVal: card.intertype, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'inner', |
| | | text: this.state.dict['header.form.interface.inner'] |
| | | }, { |
| | | MenuID: 'outer', |
| | | text: this.state.dict['header.form.interface.outer'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'interface', |
| | | label: this.state.dict['header.form.interface'], |
| | | initVal: card.interface, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'OpenType', |
| | | label: this.state.dict['header.form.openType'], |
| | | initVal: card.OpenType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'pop', |
| | | text: this.state.dict['header.form.pop'] |
| | | }, { |
| | | MenuID: 'prompt', |
| | | text: this.state.dict['header.form.prompt'] |
| | | }, { |
| | | MenuID: 'exec', |
| | | text: this.state.dict['header.form.exec'] |
| | | }, { |
| | | MenuID: 'tab', |
| | | text: this.state.dict['header.form.tab'] |
| | | }, { |
| | | MenuID: 'newpage', |
| | | text: this.state.dict['header.form.newpage'] |
| | | }, { |
| | | MenuID: 'blank', |
| | | text: this.state.dict['header.form.blank'] |
| | | }] |
| | | type: 'text', |
| | | key: 'callbackFunc', |
| | | label: this.state.dict['header.form.callbackFunc'], |
| | | initVal: card.callbackFunc, |
| | | required: false, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | |
| | | key: 'class', |
| | | label: this.state.dict['header.form.class'], |
| | | initVal: card.class, |
| | | required: true, |
| | | required: false, |
| | | options: [] |
| | | } |
| | | ] |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | formtemp: 'columns', |
| | | madalwidth: 520, |
| | | card: card, |
| | | formlist: [ |
| | | { |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'Hide', |
| | | label: this.state.dict['header.form.Hide'], |
| | | initVal: card.Hide, |
| | |
| | | |
| | | handleSubmit = () => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | console.log(res) |
| | | let _config = this.state.config |
| | | _config[res.type] = _config[res.type].map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | |
| | | }, 300) |
| | | } |
| | | |
| | | changeTemplate = () => { |
| | | this.props.handleConfig('template') |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | this.props.handleConfig() |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | console.log(res) |
| | | }) |
| | | // this.props.handleConfig('') |
| | | } |
| | | |
| | | cancelConfig = () => { |
| | | this.props.handleConfig() |
| | | this.props.handleConfig('') |
| | | } |
| | | |
| | | queryField = (type, name) => { |
| | | if (!name) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请输入表名!', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | if (type === 'search') { |
| | | Api.getSystemConfig({func: 'sPC_Get_MainMenu'}).then(res => { |
| | | if (res.status) { |
| | | this.setState({ |
| | | tableVisible: true, |
| | | addType: type |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | addFieldSubmit = () => { |
| | | console.log(13) |
| | | } |
| | | |
| | | cancelFieldSubmit = () => { |
| | | this.setState({ |
| | | tableVisible: false, |
| | | addType: '' |
| | | }) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (!this.props.menuConfig) { |
| | | this.setState({ |
| | | config: JSON.parse(JSON.stringify((this.state.baseconfig))) |
| | | }) |
| | | let _config = '' |
| | | if (!this.props.menu.LongParam) { |
| | | _config = JSON.parse(JSON.stringify((this.state.baseconfig))) |
| | | } else { |
| | | this.setState({ |
| | | config: this.props.menuConfig |
| | | }) |
| | | _config = this.props.menu.LongParam |
| | | } |
| | | this.setState({ |
| | | config: _config, |
| | | menuformlist: [ |
| | | { |
| | | type: 'select', |
| | | key: 'parentId', |
| | | label: this.state.dict['header.menu.supMenu'], |
| | | initVal: this.props.supMenu.MenuID, |
| | | required: true, |
| | | readonly: false, |
| | | options: this.props.supMenuList |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'menuName', |
| | | label: this.state.dict['header.menu.menuName'], |
| | | initVal: this.props.menu.MenuName, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'text', |
| | | key: 'menuNo', |
| | | label: this.state.dict['header.menu.menuNo'], |
| | | initVal: this.props.menu.MenuNo, |
| | | required: true, |
| | | readonly: false |
| | | }, |
| | | { |
| | | type: 'select', |
| | | key: 'opentype', |
| | | label: this.state.dict['header.menu.openType'], |
| | | initVal: this.props.menu.PageParam.OpenType, |
| | | required: true, |
| | | options: [{ |
| | | MenuID: 'newtab', |
| | | text: this.state.dict['header.form.tab'] |
| | | }, { |
| | | MenuID: 'newpage', |
| | | text: this.state.dict['header.form.newpage'] |
| | | }] |
| | | } |
| | | ] |
| | | }) |
| | | } |
| | | |
| | | render () { |
| | |
| | | <div className="common-table-board"> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="tools"> |
| | | <Tabs defaultActiveKey="1"> |
| | | <TabPane tab="搜索" key="1"> |
| | | <ul className="search-element"> |
| | | <Collapse accordion defaultActiveKey="0" bordered={false}> |
| | | <Panel header="基本信息" key="0"> |
| | | <MenuForm |
| | | dict={this.state.dict} |
| | | formlist={this.state.menuformlist} |
| | | wrappedComponentRef={(inst) => this.menuformRef = inst} |
| | | /> |
| | | </Panel> |
| | | <Panel header="搜索" key="1"> |
| | | <Search placeholder="input table name." onSearch={value => this.queryField('search', value)} enterButton /> |
| | | <div className="search-element"> |
| | | {this.state.searchItems.map((item, index) => { |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </ul> |
| | | </TabPane> |
| | | <TabPane tab="按钮" key="2"> |
| | | <ul className="search-element"> |
| | | </div> |
| | | </Panel> |
| | | <Panel header="按钮" key="2"> |
| | | <div className="search-element"> |
| | | {this.state.actionItems.map((item, index) => { |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </ul> |
| | | </TabPane> |
| | | <TabPane tab="显示列" key="3"> |
| | | <ul className="search-element"> |
| | | </div> |
| | | </Panel> |
| | | <Panel header="显示列" key="3"> |
| | | <Search placeholder="input table name." onSearch={value => this.queryField('column', value)} enterButton /> |
| | | <div className="search-element"> |
| | | {this.state.columnItems.map((item, index) => { |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </ul> |
| | | </TabPane> |
| | | </Tabs> |
| | | </div> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | | <div className="setting"> |
| | | <Card title="页面配置" bordered={false} extra={ |
| | | <div> |
| | | <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button> |
| | | <Button type="primary" onClick={this.submitConfig}>{this.state.dict['header.submit']}</Button> |
| | | <Button onClick={this.cancelConfig}>{this.state.dict['header.cancel']}</Button> |
| | | </div> |
| | |
| | | <DragElement |
| | | list={this.state.config.search} |
| | | type="search" |
| | | placeholder={this.state.dict['header.form.search.placeholder']} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleSearch} |
| | | />} |
| | |
| | | <DragElement |
| | | list={this.state.config.action} |
| | | type="action" |
| | | placeholder={this.state.dict['header.form.action.placeholder']} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleAction} |
| | | />} |
| | |
| | | <DragElement |
| | | list={this.state.config.columns} |
| | | type="columns" |
| | | placeholder={this.state.dict['header.form.column.placeholder']} |
| | | handleList={this.handleList} |
| | | handleMenu={this.handleColumn} |
| | | />} |
| | |
| | | <Modal |
| | | title={this.state.dict['header.edit']} |
| | | visible={this.state.visible} |
| | | width={this.state.madalwidth} |
| | | width={700} |
| | | onCancel={this.handleCancel} |
| | | footer={null} |
| | | destroyOnClose |
| | |
| | | <Button type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> |
| | | </div> |
| | | </Modal> |
| | | <Modal |
| | | title={this.state.dict['header.edit']} |
| | | visible={this.state.tableVisible} |
| | | width={'65vw'} |
| | | style={{minWidth: '900px', maxWidth: '1200px'}} |
| | | onOk={this.addFieldSubmit} |
| | | onCancel={this.cancelFieldSubmit} |
| | | destroyOnClose |
| | | > |
| | | {this.state.addType === 'search' && <div>djfiafadf</div>} |
| | | </Modal> |
| | | </div> |
| | | ) |
| | | } |