| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | if (!sessionStorage.getItem('UserID')) { |
| | | sessionStorage.removeItem('isEditState') |
| | | sessionStorage.removeItem('appType') |
| | | this.props.history.replace('/login') |
| | | return |
| | | } |
| | | |
| | | sessionStorage.setItem('editMenuType', 'menu') // 编辑菜单类型 |
| | | |
| | | window.GLOB.curDate = moment().format('YYYY-MM-DD') |
| | | window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件 |
| | | window.GLOB.TabsMap = new Map() // 缓存用户操作的标签页 |
| | | window.GLOB.urlFields = [] // url变量 |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | if (!sessionStorage.getItem('UserID')) return |
| | | |
| | | MKEmitter.addListener('changePopview', this.initPopview) |
| | | MKEmitter.addListener('triggerMenuSave', this.triggerMenuSave) |
| | | setTimeout(() => { |
| | |
| | | _btn.config.MenuID = _btn.uuid |
| | | _btn.config.ParentId = card.uuid |
| | | _btn.config.MenuName = _btn.label |
| | | _btn.config.components = _btn.config.components || [] |
| | | _btn.config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components[0].cols = tab.components[0].cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | }) |
| | | } else if (item.cols) { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | _btn.config = { |
| | | uuid: _btn.uuid, |
| | |
| | | submitPopConfig = (btnconfig) => { |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | if (cell.OpenType === 'popview' && cell.uuid === btnconfig.uuid) { |
| | | cell.config = btnconfig |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | config.components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | loopCol(tab.components[0].cols) |
| | | |
| | | tab.components[0].$tables = getTables(tab.components[0]) |
| | | }) |
| | |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.OpenType === 'popview' && btn.uuid === btnconfig.uuid) { |
| | | btn.config = btnconfig |
| | | } |
| | | }) |
| | | }) |
| | | |
| | | loopCol(item.cols) |
| | | |
| | | item.$tables = getTables(item) |
| | | } |
| | |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | tab.components[0].name = tab.label |
| | | tab.components[0].cols = tab.components[0].cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | }) |
| | | } else { |
| | | item.cols = item.cols.map(col => { |
| | | if (col.type === 'action') { |
| | | col.type = 'custom' |
| | | } |
| | | return col |
| | | }) |
| | | item.name = '主表' |
| | | } |
| | | }) |
| | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | _s++ |
| | | }) |
| | | tab.components[0].cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | _s++ |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_s * 10}' as Sort, '${tab.components[0].uuid}' as parentid, 60 as Type`) |
| | | _s++ |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | loopCol(tab.components[0].cols) |
| | | }) |
| | | } else { |
| | | if (item.$tables) { |
| | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | }) |
| | | item.cols.forEach(col => { |
| | | if (col.type !== 'action') return |
| | | col.elements.forEach(btn => { |
| | | if (btn.hidden === 'true') return |
| | | |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | let loopCol = (cols) => { |
| | | cols.forEach(col => { |
| | | if (col.type === 'colspan') { |
| | | loopCol(col.subcols) |
| | | } else if (col.type === 'custom') { |
| | | col.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button' || cell.hidden === 'true') return |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${cell.label}' as menuname, '${_sort * 10}' as Sort, '${config.uuid}' as parentid, 40 as Type`) |
| | | _sort++ |
| | | }) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | loopCol(item.cols) |
| | | } |
| | | }) |
| | | |
| | |
| | | menuloading: true |
| | | }) |
| | | |
| | | window.GLOB.saving = true |
| | | |
| | | setTimeout(() => { |
| | | if (config.enabled && this.verifyConfig()) { |
| | | let _pass = this.verifyConfig(config) |
| | | |
| | | if (config.enabled && !_pass) { |
| | | config.enabled = false |
| | | config.force = true |
| | | } else if (!config.enabled && config.force && _pass) { |
| | | config.enabled = true |
| | | delete config.force |
| | | } |
| | | |
| | | let tbs = [] |
| | |
| | | menuloading: false |
| | | }) |
| | | |
| | | window.GLOB.saving = false |
| | | |
| | | if (!res) return |
| | | |
| | | if (res.status) { |
| | |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | |
| | | window.GLOB.saving = false |
| | | |
| | | if (!error) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config || (!config.enabled && this.verifyConfig(true))) { |
| | | return |
| | | } |
| | | let _config = {...config, enabled: !config.enabled} |
| | | |
| | | this.setState({ |
| | | config: {...config, enabled: !config.enabled} |
| | | }) |
| | | delete _config.force |
| | | |
| | | if (!_config.enabled) { |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | } else if (this.verifyConfig(_config)) { |
| | | this.setState({ |
| | | config: _config |
| | | }) |
| | | } |
| | | } |
| | | |
| | | verifyConfig = (show) => { |
| | | const { config } = this.state |
| | | verifyConfig = (config) => { |
| | | let error = '' |
| | | |
| | | config.components.forEach(item => { |
| | |
| | | } |
| | | } |
| | | |
| | | if (show && error) { |
| | | if (config.enabled && error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | |
| | | }) |
| | | } |
| | | |
| | | return error |
| | | return error === '' |
| | | } |
| | | |
| | | // 更新配置信息 |
| | |
| | | <TableNodes config={config} /> |
| | | <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> |
| | | <PasteBaseTable type="page" insert={this.insert}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config && config.enabled} onChange={this.onEnabledChange} /> |
| | | {config ? <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={config.enabled} onChange={this.onEnabledChange} /> : null} |
| | | <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>保存</Button> |
| | | <Button type="default" onClick={this.closeView}>关闭</Button> |
| | | </div> |