From f3167f8371d19d0ea8fe7d0e7af5517ff0b08cd2 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 07 四月 2021 23:25:29 +0800 Subject: [PATCH] 2021-04-07 --- src/menu/components/card/cardcomponent/settingform/index.jsx | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 117 insertions(+), 2 deletions(-) diff --git a/src/menu/components/card/cardcomponent/settingform/index.jsx b/src/menu/components/card/cardcomponent/settingform/index.jsx index 4045ba3..738bd50 100644 --- a/src/menu/components/card/cardcomponent/settingform/index.jsx +++ b/src/menu/components/card/cardcomponent/settingform/index.jsx @@ -1,8 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Radio, Tooltip, Icon, Input, InputNumber, Select } from 'antd' +import { Form, Row, Col, Radio, Tooltip, Icon, Input, InputNumber, Select, Cascader } from 'antd' import './index.scss' + +const { TextArea } = Input class SettingForm extends Component { static propTpyes = { @@ -13,7 +15,32 @@ } state = { - type: this.props.setting.type || 'simple' + type: this.props.setting.type || 'simple', + click: this.props.setting.click || '', + isApp: sessionStorage.getItem('appType') === 'pc', + menulist: [] + } + + UNSAFE_componentWillMount() { + const { isApp } = this.state + let menulist = null + + if (isApp) { + menulist = sessionStorage.getItem('appMenus') + } else { + menulist = sessionStorage.getItem('fstMenuList') + } + + if (menulist) { + try { + menulist = JSON.parse(menulist) + } catch { + menulist = [] + } + } else { + menulist = [] + } + this.setState({menulist}) } handleConfirm = () => { @@ -40,6 +67,7 @@ render() { const { setting, cards } = this.props const { getFieldDecorator } = this.props.form + const { menulist, click, isApp } = this.state const formItemLayout = { labelCol: { @@ -126,6 +154,93 @@ })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit}/>)} </Form.Item> </Col> : null} + <Col span={12}> + <Form.Item label="鐐瑰嚮浜嬩欢"> + {getFieldDecorator('click', { + initialValue: click + })( + <Radio.Group onChange={(e) => this.setState({click: e.target.value})}> + <Radio value="">鏃�</Radio> + <Radio value="menu">鑿滃崟</Radio> + <Radio value="link">閾炬帴</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + {!isApp && click === 'menu' ? <Col span={12}> + <Form.Item label="鑿滃崟"> + {getFieldDecorator('menu', { + initialValue: setting.menu || [], + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '鑿滃崟!' + } + ] + })( + <Cascader options={menulist} placeholder=""/> + )} + </Form.Item> + </Col> : null} + {isApp && click === 'menu' ? <Col span={12}> + <Form.Item label="鍏宠仈鑿滃崟"> + {getFieldDecorator('menu', { + initialValue: setting.menu || '', + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '鍏宠仈鑿滃崟!' + } + ] + })( + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + > + {menulist.map(option => + <Select.Option key={option.MenuID} value={option.MenuID}>{option.MenuName}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> : null} + {click === 'link' ? <Col span={24} className="textarea"> + <Form.Item label="閾炬帴"> + {getFieldDecorator('linkurl', { + initialValue: setting.linkurl || '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '閾炬帴!' + } + ] + })( <TextArea rows={2}/> )} + </Form.Item> + </Col> : null} + {isApp ? <Col span={12}> + <Form.Item label="鎵撳紑鏂瑰紡"> + {getFieldDecorator('open', { + initialValue: setting.open || 'blank' + })( + <Radio.Group> + <Radio value="blank">鏂扮獥鍙�</Radio> + <Radio value="self">褰撳墠绐楀彛</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {click !== '' ? <Col span={12}> + <Form.Item label="鍙傛暟鎷兼帴"> + {getFieldDecorator('joint', { + initialValue: setting.joint || 'true' + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} </Row> </Form> </div> -- Gitblit v1.8.0