king
2019-11-05 fa80db0a824464cd0cbc46d5207021263211236d
src/components/sidemenu/menuform/index.jsx
@@ -38,12 +38,38 @@
          initVal: 'folder',
          required: true,
          options: [{
            id: 'folder',
            MenuID: 'folder',
            text: 'folder'
          }, {
            id: 'api',
            MenuID: 'api',
            text: 'api'
          }]
        }
      ],
      tlevel: [
        {
          type: 'select',
          key: 'parentId',
          label: this.props.dict['header.menu.supMenu'],
          initVal: '',
          required: true,
          options: []
        },
        {
          type: 'text',
          key: 'menuName',
          label: this.props.dict['header.menu.menuName'],
          initVal: '',
          required: true,
          readonly: false
        },
        {
          type: 'text',
          key: 'menuNo',
          label: this.props.dict['header.menu.menuNo'],
          initVal: '',
          required: true,
          readonly: false
        }
      ]
    }
@@ -55,7 +81,6 @@
  UNSAFE_componentWillReceiveProps (nextProps) {
    if (nextProps.options.visible && !is(fromJS(this.props.options), fromJS(nextProps.options))) {
      console.log(nextProps.options)
      this.resetform(nextProps.options)
    }
  }
@@ -64,8 +89,7 @@
    if (!options.visible) return
    let formlist = JSON.parse(JSON.stringify(this.state.menuform[options.level]))
    if (options.type === 'add') {
    if (options.type === 'add' && options.level === 'slevel') {
      this.setState({
        formlist: formlist.map(item =>{
          if (item.key === 'parentId') {
@@ -75,16 +99,40 @@
          return item
        })
      })
    } else {
    } else if (options.type === 'add' && options.level === 'tlevel') {
      this.setState({
        formlist: formlist.map(item =>{
          if (item.key === 'parentId') {
            item.initVal = options.parentMenu.MenuID
            item.options = options.supMenuList
          }
          return item
        })
      })
    } else if (options.type === 'edit' && options.level === 'slevel') {
      this.setState({
        formlist: formlist.map(item => {
          if (item.key === 'parentId') {
            item.initVal = options.parentMenu.MenuID
            item.options = options.supMenuList
          } else if (item.key === 'menuName') {
            item.initVal = options.menu.MenuNameP
            item.initVal = options.menu.text
          } else if (item.key === 'icon') {
            item.initVal = options.menu.PageParam.Icon
          }
          return item
        })
      })
    } else if (options.type === 'edit' && options.level === 'tlevel') {
      this.setState({
        formlist: formlist.map(item => {
          if (item.key === 'parentId') {
            item.initVal = options.parentMenu.MenuID
            item.options = options.supMenuList
          } else if (item.key === 'menuName') {
            item.initVal = options.menu.text
          } else if (item.key === 'menuNo') {
            item.initVal = options.menu.MenuNo
          }
          return item
        })
@@ -150,12 +198,12 @@
              })(
                <Select
                  showSearch
                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0}
                  onChange={(value) => {this.openTypeChange(item.key, value)}}
                  getPopupContainer={() => document.getElementById('form-box')}
                >
                  {item.options.map(option =>
                    <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>
                    <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>
                      {item.key === 'icon' && <Icon type={option.text} />} {option.text}
                    </Select.Option>
                  )}
@@ -185,15 +233,34 @@
                Icon: values.icon
              })
            })
          } else {
          } else if (this.props.options.type === 'edit' && this.props.options.level === 'slevel') {
            resolve({
              ParentID: values.parentId,
              MenuID: this.props.options.menu.ParentID,
              MenuID: this.props.options.menu.MenuID,
              MenuName: values.menuName,
              PageParam: JSON.stringify({
                Icon: values.icon
              })
            })
          } else if (this.props.options.type === 'add' && this.props.options.level === 'tlevel') {
            resolve({
              ParentID: values.parentId,
              MenuID: this.props.options.menu.MenuID,
              MenuName: values.menuName,
              PageParam: JSON.stringify({
                Icon: values.icon
              })
            })
          } else if (this.props.options.type === 'edit' && this.props.options.level === 'tlevel') {
            resolve({
              ParentID: values.parentId,
              MenuID: this.props.options.menu.MenuID,
              MenuName: values.menuName,
              MenuNo: values.menuNo,
              PageParam: JSON.stringify({
                Icon: values.icon
              })
            })
          }
        } else {
          reject(err)