king
2021-07-25 10e2b76a5b403c17da448d8e043c42966b14e657
src/mob/components/menubar/normal-menubar/menucomponent/index.jsx
@@ -6,11 +6,13 @@
import asyncIconComponent from '@/utils/asyncIconComponent'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import Utils from '@/utils/utils.js'
import SettingForm from './settingform'
import { resetStyle } from '@/utils/utils-custom.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
const { confirm } = Modal
const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
class MenuBoxComponent extends Component {
@@ -25,14 +27,11 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    card: null,            // 卡片信息,包括正反面
    formlist: null,        // 设置表单信息
    visible: false,        // 模态框控制
    card: null,
    formlist: null,
    visible: false
  }
  /**
   * @description 搜索条件初始化
   */
  UNSAFE_componentWillMount () {
    const { card } = this.props
@@ -42,7 +41,14 @@
  }
  componentDidMount () {
    const { card } = this.props
    MKEmitter.addListener('submitStyle', this.getStyle)
    if (card.isnew) {
      this.setState({
        visible: true
      })
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -91,13 +97,39 @@
    const { card } = this.state
    this.settingRef.handleConfirm().then(res => {
      this.setState({
        visible: false,
        card: {...card, setting: res}
      })
      let _card = {...card, setting: res}
      this.props.updateElement({...card, setting: res})
      if (!card.isnew && card.setting.type === 'menu' && _card.setting.type !== 'menu') {
        const _this = this
        confirm({
          content: '菜单属性由“菜单”切换至其他类型时,菜单将被重置,即解除之前菜单的绑定关系,确定修改吗?',
          onOk() {
            _card.uuid = Utils.getuuid()
            _this.setState({ visible: false, card: _card })
            _this.props.updateElement(_card)
          },
          onCancel() {}
        })
      } else {
        delete _card.isnew
        this.setState({ visible: false, card: _card })
        this.props.updateElement(_card)
      }
    })
  }
  cancel = () => {
    const { card } = this.state
    if (card.isnew) {
      let _card = fromJS(card).toJS()
      delete _card.isnew
      this.setState({ visible: false, card: _card })
      this.props.updateElement(_card)
    } else {
      this.setState({ visible: false })
    }
  }
  changeMenu = () => {
@@ -167,7 +199,7 @@
          maskClosable={false}
          okText={dict['model.submit']}
          onOk={this.settingSubmit}
          onCancel={() => { this.setState({ visible: false }) }}
          onCancel={this.cancel}
          destroyOnClose
        >
          <SettingForm