| | |
| | | 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' |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | |
| | |
| | | originActions: _oriActions, |
| | | config: _config, |
| | | operaType: _type, |
| | | originMenu: JSON.parse(JSON.stringify({...menu})), |
| | | originMenu: JSON.parse(JSON.stringify(menu)), |
| | | selectedTables: _config.tables || [], |
| | | menuformlist: [ |
| | | { |
| | |
| | | }) |
| | | } |
| | | |
| | | 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}}) |
| | | } |
| | | } |
| | | |
| | |
| | | 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', |
| | |
| | | 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'] |
| | | }] |
| | | } |
| | | ] |
| | | }) |
| | |
| | | }, { |
| | | 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'] |
| | | }] |
| | | }, |
| | | { |
| | |
| | | }] |
| | | }, |
| | | { |
| | | type: 'select', |
| | | type: 'radio', |
| | | key: 'IsSort', |
| | | label: this.state.dict['header.form.IsSort'], |
| | | initVal: card.IsSort, |
| | |
| | | { |
| | | 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 |
| | | } |
| | | ] |
| | | }) |
| | |
| | | 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) { |
| | |
| | | this.submitAction(btnParam) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | 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) { |
| | |
| | | this.submitAction(btnParam) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false |
| | | menuloading: false, |
| | | menucloseloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | 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, |
| | |
| | | } |
| | | } |
| | | |
| | | 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') |
| | |
| | | <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> |
| | |
| | | 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> |
| | | ]} |