| | |
| | | |
| | | class CustomMenuForm extends Component { |
| | | static propTpyes = { |
| | | dict: PropTypes.object, // 字典项 |
| | | config: PropTypes.object, |
| | | MenuId: PropTypes.string, |
| | | MenuName: PropTypes.string, |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | if (sessionStorage.getItem('thdMenuList') && sessionStorage.getItem('fstMenuList')) { |
| | | this.setMenus() |
| | | } else { |
| | | this.getMenus() |
| | | } |
| | | } |
| | | |
| | | setMenus = () => { |
| | | const { MenuId, config } = this.props |
| | | |
| | | let menulist = sessionStorage.getItem('fstMenuList') |
| | | let thdMenuList = sessionStorage.getItem('thdMenuList') |
| | | |
| | | menulist = JSON.parse(menulist) |
| | | thdMenuList = JSON.parse(thdMenuList) |
| | | |
| | | let thdMenu = null |
| | | |
| | | thdMenuList.forEach(trd => { |
| | | if (MenuId === trd.MenuID) { |
| | | thdMenu = trd |
| | | } |
| | | }) |
| | | |
| | | let smenulist = [] |
| | | |
| | | if (thdMenu) { |
| | | menulist.forEach(item => { |
| | | if (item.MenuID === thdMenu.FstId) { |
| | | smenulist = item.children |
| | | } |
| | | }) |
| | | } |
| | | |
| | | this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''}) |
| | | |
| | | this.setState({ |
| | | fstMenuId: thdMenu ? thdMenu.FstId : '', |
| | | menulist, |
| | | smenulist |
| | | }, () => { |
| | | this.props.form.setFieldsValue({ |
| | | fstMenuId: thdMenu ? thdMenu.FstId : '', |
| | | parentId: thdMenu ? thdMenu.ParentId : '' |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | getMenus = () => { |
| | | const { MenuId, config } = this.props |
| | | |
| | | Api.getSystemConfig({func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'}).then(result => { |
| | | if (result.status) { |
| | | let thdMenu = null |
| | |
| | | value: trd.MenuID, |
| | | label: trd.MenuName, |
| | | type: 'CommonTable', |
| | | // disabled: trd.MenuID === MenuId |
| | | disabled: false |
| | | } |
| | | |
| | | if (MenuId === trd.MenuID) { |
| | | thdMenu = trdItem |
| | | } |
| | | |
| | | if (trd.PageParam) { |
| | |
| | | } catch (e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | if (MenuId === trd.MenuID) { |
| | | thdMenu = trdItem |
| | | } |
| | | |
| | | thdMenuList.push(trdItem) |
| | |
| | | }) |
| | | |
| | | let smenulist = [] |
| | | menulist.forEach(item => { |
| | | if (thdMenu && (item.MenuID === thdMenu.FstId)) { |
| | | smenulist = item.children |
| | | } |
| | | }) |
| | | if (thdMenu) { |
| | | menulist.forEach(item => { |
| | | if (item.MenuID === thdMenu.FstId) { |
| | | smenulist = item.children |
| | | } |
| | | }) |
| | | } |
| | | sessionStorage.setItem('fstMenuList', JSON.stringify(menulist)) |
| | | sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList)) |
| | | this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''}) |
| | |
| | | this.props.updateConfig({...config, hidden: value}) |
| | | } else if (key === 'permission') { |
| | | this.props.updateConfig({...config, permission: value}) |
| | | } else if (key === 'cacheLocal') { |
| | | this.props.updateConfig({...config, cacheLocal: value}) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { dict, MenuName, MenuNo, config } = this.props |
| | | const { MenuName, MenuNo, config } = this.props |
| | | const { menulist, smenulist } = this.state |
| | | const { getFieldDecorator } = this.props.form |
| | | const formItemLayout = { |
| | |
| | | <Form {...formItemLayout} className="custom-menu-form"> |
| | | <Row> |
| | | <Col span={24}> |
| | | <Form.Item label={dict['mob.menu.first'] + dict['mob.menu']}> |
| | | <Form.Item label="一级菜单"> |
| | | {getFieldDecorator('fstMenuId', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['mob.required.select'] + dict['mob.menu.first'] + dict['mob.menu'] + '!' |
| | | message: '请选择一级菜单!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={dict['mob.menu.second'] + dict['mob.menu']}> |
| | | <Form.Item label="二级菜单"> |
| | | {getFieldDecorator('parentId', { |
| | | initialValue: '', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['mob.required.select'] + dict['mob.menu.second'] + dict['mob.menu'] + '!' |
| | | message: '请选择二级菜单!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={dict['mob.menu'] + dict['mob.name']}> |
| | | <Form.Item label="菜单名称"> |
| | | {getFieldDecorator('MenuName', { |
| | | initialValue: MenuName, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['mob.required.input'] + dict['mob.menu'] + dict['mob.name'] + '!' |
| | | message: '请输入菜单名称!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={dict['mob.menu'] + dict['mob.param']}> |
| | | <Form.Item label="菜单参数"> |
| | | {getFieldDecorator('MenuNo', { |
| | | initialValue: MenuNo, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['mob.required.input'] + dict['mob.menu'] + dict['mob.param'] + '!' |
| | | message: '请输入菜单参数!' |
| | | } |
| | | ] |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)} |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['form.required.select'] + dict['model.openway'] + '!' |
| | | message: '请选择打开方式!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="数据会缓存到用户本地,方便页面快速呈现。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 本地缓存 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('cacheLocal', { |
| | | initialValue: config.cacheLocal || 'false' |
| | | })( |
| | | <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}> |
| | | <Radio value="true">使用</Radio> |
| | | <Radio value="false">不使用</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="对于不经常性变动的信息,缓存数据有助于提高查询效率。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 缓存数据 |
| | | 后端缓存 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('cacheUseful', { |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: dict['mob.required.input'] + '时长!' |
| | | message: '请输入时长!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | </Form.Item> |
| | | </Col> : null} |
| | | <Col span={24}> |
| | | <Form.Item label={dict['mob.menu.easycode']}> |
| | | <Form.Item label="助记码"> |
| | | {getFieldDecorator('easyCode', { |
| | | initialValue: config.easyCode |
| | | })(<Input placeholder="" autoComplete="off" onChange={this.changeEasyCode}/>)} |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Form.Item label={'隐藏菜单'}> |
| | | <Form.Item label="隐藏菜单"> |
| | | <Switch checkedChildren={'是'} checked={config.hidden === 'true'} unCheckedChildren={'否'} onChange={(value) => { |
| | | this.selectChange('hidden', value + '') |
| | | }} /> |
| | | </Form.Item> |
| | | </Col> |
| | | <Col span={24}> |
| | | <Col span={24} className="red-font"> |
| | | <Form.Item label="备注"> |
| | | {getFieldDecorator('Remark', { |
| | | initialValue: config.Remark || '', |