king
2020-09-26 ab60d53b67f802878662aaa5a5b52580cca421b8
src/menu/actioncomponent/index.jsx
@@ -13,6 +13,7 @@
import enUS from '@/locales/en-US/model.js'
import { getActionForm } from './formconfig'
import MKEmitter from '@/utils/events.js'
import ActionForm from './actionform'
import VerifyCard from '@/templates/zshare/verifycard'
import CreateFunc from '@/templates/zshare/createfunc'
@@ -27,6 +28,7 @@
class ActionComponent extends Component {
  static propTpyes = {
    type: PropTypes.string,          // 菜单类型,主表或子表
    plus: PropTypes.any,             // 是否存在添加按钮,值为false时隐藏
    config: PropTypes.object,        // 菜单配置信息
    setSubConfig: PropTypes.func,    // 设置子配置信息
    updateaction: PropTypes.func     // 菜单配置更新
@@ -51,6 +53,10 @@
    })
  }
  componentDidMount () {
    MKEmitter.addListener('addButton', this.addButton)
  }
  /**
   * @description 监听到按钮复制时,触发按钮编辑
   */
@@ -60,6 +66,29 @@
    if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState))
  }
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('addButton', this.addButton)
  }
  addButton = (cardId, element) => {
    if (cardId !== this.props.config.uuid) return
    const { actionlist } = this.state
    this.setState({actionlist: [...actionlist, element]})
    this.handleAction(element)
  }
  /**
@@ -76,6 +105,57 @@
        this.props.updateaction({...config, action: list})
      })
    }
  }
  getModules = (components, selfId) => {
    let modules = components.map(item => {
      if (item.uuid === selfId) {
        return {
          children: null
        }
      } else if (item.format) {
        return {
          value: item.uuid,
          label: item.name
        }
      } else if (item.type === 'tabs') {
        let _item = {
          value: item.uuid,
          label: item.name,
          children: item.subtabs.map(f_tab => {
            let subItem = {
              value: f_tab.uuid,
              label: f_tab.label,
              children: this.getModules(f_tab.components, selfId)
            }
            if (!subItem.children || subItem.children.length === 0) {
              return {children: null}
            }
            return subItem
          })
        }
        _item.children = _item.children.filter(t => t.children !== null)
        if (_item.children.length === 0) {
          return {children: null}
        }
        return _item
      } else {
        return {
          children: null
        }
      }
    })
    modules = modules.filter(mod => mod.children !== null)
    if (modules.length === 0) {
      return null
    }
    return modules
  }
  /**
@@ -101,22 +181,7 @@
      })
    }
    // let modules = []
    // menu.components.forEach(item => {
    //   if (item.uuid === config.uuid) return
    //   modules.push({
    //     value: item.uuid,
    //     text: item.setting.name
    //   })
    // })
    // if (supModule && supModule !== 'empty') {
    //   if (modules.filter(item => item.value === supModule).length === 0) {
    //     supModule = ''
    //   }
    // }
    let modules = this.getModules(menu.components, config.uuid)
    if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) {
      let _param = {
@@ -165,14 +230,14 @@
        this.setState({
          visible: true,
          card: card,
          formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist)
          formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules)
        })
      })
    } else {
      this.setState({
        visible: true,
        card: card,
        formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist)
        formlist: getActionForm(card, functip, config.setting, menu.permFuncField, this.props.type, menulist, modules)
      })
    }
  }
@@ -875,27 +940,14 @@
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props.config), fromJS(nextProps.config)) || !is(fromJS(this.state), fromJS(nextState))
  }
  /**
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
  render() {
    const { config, type } = this.props
    const { config, plus } = this.props
    const { actionlist, visible, card, dict, copying, profVisible } = this.state
    return (
      <div className="model-menu-action-list">
        <DragElement
          type={type}
          plus={plus}
          list={actionlist}
          handleList={this.handleList}
          handleMenu={this.handleAction}