| | |
| | | card: null, // 编辑元素 |
| | | loading: false, // 表单刷新时使用 |
| | | menuloading: false, // 菜单保存中 |
| | | closeloading: false, // 菜单保存中 |
| | | settingVisible: false, // 全局配置模态框 |
| | | closeVisible: false, // 关闭模态框 |
| | | tables: [], // 可用表名 |
| | | selectedTables: [], // 已选表名 |
| | | originMenu: null, // 原始菜单 |
| | | originConfig: null, // 原始菜单 |
| | | groupVisible: false, // 全局配置模态框 |
| | | curgroup: null // 当前组,新建或编辑 |
| | | } |
| | |
| | | const {menu, editAction} = this.props |
| | | |
| | | let _config = '' |
| | | |
| | | if (editAction.pageParam) { |
| | | _config = editAction.pageParam |
| | | } else { |
| | |
| | | this.setState({ |
| | | config: _config, |
| | | selectedTables: _config.tables || [], |
| | | originConfig: JSON.parse(JSON.stringify(_config)), |
| | | modalformlist: [ |
| | | { |
| | | type: 'text', |
| | |
| | | * @description 表单变化 |
| | | * 1、表单拖拽添加时,检查是否存在示例表单,如存在则去除示例 |
| | | * 2、表单移动后,保存移动后的顺序 |
| | | * 3、新增表单时,直接打开编辑框 |
| | | */ |
| | | handleList = (list, group, elementId) => { |
| | | handleList = (list, group, elementId, newcard) => { |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | if (!group && !elementId) { |
| | | // 没有分组时(拖拽添加) |
| | | if (list.length > _config.fields.length) { |
| | | _config.fields = list.filter(item => !item.origin) |
| | | |
| | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | this.handleForm(newcard) |
| | | }) |
| | | } else { |
| | | _config.fields = list |
| | | this.setState({config: _config}) |
| | | } |
| | | } else if (group && !elementId) { |
| | | // 存在分组时,拖拽添加 |
| | | if (list.length > group.sublist.length) { |
| | | group.sublist = list |
| | | _config.groups = _config.groups.map(item => { |
| | |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | this.handleForm(newcard) |
| | | }) |
| | | } else { |
| | | group.sublist = list |
| | |
| | | this.setState({config: _config}) |
| | | } |
| | | } else if (group && elementId) { |
| | | // 修改已有元素的分组 |
| | | let element = null |
| | | _config.groups.forEach(item => { |
| | | item.sublist = item.sublist.filter(cell => { |
| | |
| | | |
| | | /** |
| | | * @description 表单编辑 |
| | | * 1、显示编辑弹窗 |
| | | * 2、保存编辑项 |
| | | * 3、设置编辑参数项 |
| | | * 1、显示编辑弹窗-visible |
| | | * 2、保存编辑项-card |
| | | * 3、设置编辑参数项-formlist |
| | | */ |
| | | handleForm = (card) => { |
| | | this.setState({ |
| | |
| | | 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: '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: 'desc', |
| | | text: this.state.dict['header.form.desc'] |
| | | }] |
| | | }, |
| | | { |
| | | type: 'number', |
| | | key: 'decimal', |
| | | label: this.state.dict['header.form.decimal'], |
| | | initVal: card.decimal || 0, |
| | | required: false |
| | | }, |
| | | { |
| | | type: 'radio', |
| | | key: 'readonly', |
| | | label: this.state.dict['header.form.readonly'], |
| | | initVal: card.readonly || 'false', |
| | | options: [{ |
| | | value: 'true', |
| | | text: this.state.dict['header.form.true'] |
| | | }, { |
| | | value: 'false', |
| | | text: this.state.dict['header.form.false'] |
| | | }] |
| | | } |
| | | ] |
| | | }) |
| | |
| | | handleSubmit = () => { |
| | | this.formRef.handleConfirm().then(res => { |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | |
| | | if ((res.type === 'select' || res.type === 'link') && res.resourceType === '1') { |
| | | let sql = 'select ' + res.valueField + ',' + res.valueText + ' from (' + res.dataSource + ')' |
| | | if (res.orderBy) { |
| | | sql = sql + ' ld order by ' + res.orderBy + ' ' + res.orderType |
| | | } |
| | | res.dataSourceSql = Utils.formatOptions(sql) |
| | | } |
| | | |
| | | _config.fields = _config.fields.map(item => { |
| | | if (item.uuid === res.uuid) { |
| | |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | const { menu } = this.props |
| | | const { config, originMenu } = this.state |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | const { menu, editAction } = this.props |
| | | const { config } = this.state |
| | | |
| | | if (!config.fields[0] && config.fields[0].origin) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请添加表单', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _LongParam = '' |
| | | let _config = {...config, tables: this.state.selectedTables} |
| | | let _pageParam = {...menu.PageParam, OpenType: res.opentype} |
| | | |
| | | try { |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '编译错误', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 'sPC_ButtonParam_AddUpt', |
| | | ParentID: res.parentId, |
| | | MenuID: menu.MenuID, |
| | | MenuNo: res.menuNo, |
| | | Template: menu.PageParam.Template || '', |
| | | MenuName: res.menuName, |
| | | PageParam: JSON.stringify(_pageParam), |
| | | LongParam: _LongParam |
| | | } |
| | | this.setState({ |
| | | menuloading: true |
| | | }) |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | menuloading: false, |
| | | originMenu: { |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | ParentID: res.parentId |
| | | } |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 10 |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | |
| | | // let param = { |
| | | // func: 'sPC_TrdMenu_Upt', |
| | | // ParentID: res.parentId, |
| | | // MenuID: menu.MenuID, |
| | | // MenuNo: res.menuNo, |
| | | // Template: menu.PageParam.Template || '', |
| | | // MenuName: res.menuName, |
| | | // PageParam: JSON.stringify(_pageParam), |
| | | // LongParam: _LongParam |
| | | // } |
| | | this.setState({ |
| | | menuloading: true |
| | | }) |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 10 |
| | | }) |
| | | if (this.state.closeVisible) { |
| | | this.props.handleConfig('') |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false, |
| | | originMenu: { |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | ParentID: res.parentId |
| | | } |
| | | }) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | }, () => { |
| | | if ((!config.groups[0] && !config.fields[0]) || (config.fields[0] && config.fields[0].origin)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: this.state.dict['header.menu.basemsg'], |
| | | message: '请添加表单', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let _LongParam = '' |
| | | let _config = {...config, tables: this.state.selectedTables} |
| | | |
| | | try { |
| | | _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) |
| | | } catch (e) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '编译错误', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let param = { |
| | | func: 'sPC_ButtonParam_AddUpt', |
| | | ParentID: menu.MenuID, |
| | | MenuID: editAction.uuid, |
| | | MenuNo: menu.MenuNo, |
| | | Template: 'Modal', |
| | | MenuName: editAction.label, |
| | | PageParam: JSON.stringify({Template: 'Modal'}), |
| | | LongParam: _LongParam |
| | | } |
| | | |
| | | if (this.state.closeVisible) { |
| | | this.setState({ |
| | | closeloading: true |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | menuloading: true |
| | | }) |
| | | } |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | menuloading: false, |
| | | closeloading: false, |
| | | originConfig: _config, |
| | | config: _config |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 10 |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | closeloading: false, |
| | | menuloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | cancelConfig = () => { |
| | | const { menu } = this.props |
| | | const { config, originMenu } = this.state |
| | | const { config, originConfig } = this.state |
| | | let _this = this |
| | | |
| | | let isOrigin = config.fields.filter(item => item.origin).length > 0 |
| | | if (isOrigin) { |
| | | confirm({ |
| | | content: '菜单尚未提交,确定放弃保存吗?', |
| | | content: '尚未提交,确定放弃保存吗?', |
| | | okText: this.state.dict['header.confirm'], |
| | | cancelText: this.state.dict['header.cancel'], |
| | | onOk() { |
| | | _this.props.handleConfig('') |
| | | _this.props.handleConfig(menu.type) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } else { |
| | | this.menuformRef.handleConfirm().then(res => { |
| | | let _config = {...config, tables: this.state.selectedTables} |
| | | let _pageParam = {...menu.PageParam, OpenType: res.opentype} |
| | | let _originMenu = { |
| | | ...originMenu, |
| | | LongParam: _config, |
| | | PageParam: _pageParam, |
| | | MenuName: res.menuName, |
| | | MenuNo: res.menuNo, |
| | | ParentID: res.parentId |
| | | } |
| | | |
| | | if (!is(fromJS(originMenu), fromJS(_originMenu))) { |
| | | this.setState({ |
| | | closeVisible: true |
| | | }) |
| | | } else { |
| | | this.props.handleConfig('') |
| | | } |
| | | }, () => { |
| | | if (!is(fromJS(config), fromJS(originConfig))) { |
| | | this.setState({ |
| | | closeVisible: true |
| | | }) |
| | | }) |
| | | } else { |
| | | this.props.handleConfig(menu.type) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | readonly: 'false' |
| | | } |
| | | }) |
| | | _config.groups[_config.groups.length - 1].sublist = [..._config.groups[_config.groups.length - 1].sublist, ..._additems] |
| | |
| | | valueText: '', |
| | | orderBy: '', |
| | | orderType: 'asc', |
| | | readonly: 'false' |
| | | } |
| | | |
| | | items.push(newcard) |
| | |
| | | const {selectedTables, tableColumns} = this.state |
| | | |
| | | this.setState({ |
| | | selectedTables: selectedTables.filter(item => item.name !== table.name), |
| | | tableColumns: tableColumns.filter(item => item.tableName !== table.name) |
| | | selectedTables: selectedTables.filter(item => item.TbName !== table.TbName), |
| | | tableColumns: tableColumns.filter(item => item.tableName !== table.TbName) |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | if (_length === 1) { |
| | | _config.fields = [...group.sublist, ..._config.groups[0].sublist] |
| | | _config.groups[0].sublist = [] |
| | | _config.groups = [] |
| | | } else { |
| | | _config.groups[_length - 1].sublist = [...group.sublist, ..._config.groups[_length - 1].sublist] |
| | | } |
| | |
| | | if (_group.isnew) { |
| | | delete _group.isnew |
| | | config.groups.unshift(_group) |
| | | config.groups = config.groups.map(item => { |
| | | if (item.default) { |
| | | return res.default |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | if (config.groups.length > 1) { |
| | | config.groups = config.groups.map(item => { |
| | | if (item.default) { |
| | | return res.default |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | } else { |
| | | config.groups.push(res.default) |
| | | } |
| | | } else { |
| | | config.groups = config.groups.map(item => { |
| | | if (item.uuid === _group.uuid) { |
| | |
| | | } |
| | | |
| | | render () { |
| | | const { menu } = this.props |
| | | const { config } = this.state |
| | | |
| | | return ( |
| | |
| | | <MenuForm |
| | | dict={this.state.dict} |
| | | formlist={this.state.modalformlist} |
| | | wrappedComponentRef={(inst) => this.menuformRef = inst} |
| | | /> |
| | | <div className="ant-col ant-form-item-label"> |
| | | <label title={this.state.dict['header.menu.table.add']}> |
| | |
| | | </div> |
| | | <div className="ant-modal-body"> |
| | | <div className="modal-form"> |
| | | {!this.state.loading && config.groups.length > 1 && |
| | | {!this.state.loading && config.groups.length > 0 && |
| | | config.groups.map(group => { |
| | | return ( |
| | | <div key={group.uuid}> |
| | |
| | | ) |
| | | }) |
| | | } |
| | | {!this.state.loading && config.groups.length === 1? |
| | | {!this.state.loading && config.groups.length === 0 ? |
| | | <DragElement |
| | | list={config.fields} |
| | | setting={config.setting} |
| | |
| | | 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="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig('')}}>{this.state.dict['header.notsave']}</Button>, |
| | | <Button key="save" className="mk-btn mk-green" loading={this.state.closeloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>, |
| | | <Button key="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig(menu.type)}}>{this.state.dict['header.notsave']}</Button>, |
| | | <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button> |
| | | ]} |
| | | destroyOnClose |