king
2022-04-26 5046d0d13dc6a8563b8e54e31913bc44cfa1072f
src/mob/components/menubar/normal-menubar/index.jsx
@@ -41,7 +41,6 @@
      let _card = {
        uuid: card.uuid,
        type: card.type,
        floor: card.floor,
        tabId: '',
        parentId: '',
        format: 'object',   // 组件属性 - 数据格式
@@ -52,7 +51,7 @@
        name: card.name,
        subtype: card.subtype,
        setting: { interType: 'system' },
        wrap: { name: card.name, width: card.width || 24, title: '' },
        wrap: { name: card.name, width: card.width || 24, title: '', permission: 'true' },
        style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' },
        headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' },
        subMenus: [{
@@ -145,20 +144,27 @@
  /**
   * @description 单个卡片信息更新
   */
  deleteCard = (cell) => {
  deleteCard = (cell, type) => {
    let card = fromJS(this.state.card).toJS()
    let _this = this
    confirm({
      content: '确定删除卡片吗?',
      onOk() {
        card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid)
        _this.setState({card})
        _this.props.updateConfig(card)
      },
      onCancel() {}
    })
    if (type !== 'direct') {
      confirm({
        content: '确定删除卡片吗?',
        onOk() {
          card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid)
          _this.setState({card})
          _this.props.updateConfig(card)
        },
        onCancel() {}
      })
    } else {
      card.subMenus = card.subMenus.filter(item => item.uuid !== cell.uuid)
      this.setState({card})
      this.props.updateConfig(card)
    }
  }
  changeStyle = () => {
@@ -186,7 +192,7 @@
    let newcard = {
      uuid: Utils.getuuid(),
      setting: { type: 'menu', width: 6, sign: 'icon', icon: 'user', name: '客户', url: '', color: '#ffffff', iconFont: 20, padding: 12, background: '#1890ff', imgWidth: '' },
      setting: { type: 'menu', width: 6, sign: 'icon', icon: '', name: '', url: '', color: '#ffffff', iconFont: 20, padding: 12, background: '#1890ff', imgWidth: '' },
      style: {
        paddingTop: '15px', paddingBottom: '15px'
      }
@@ -195,12 +201,28 @@
    if (card.subMenus.length > 0) {
      newcard = fromJS(card.subMenus.slice(-1)[0]).toJS()
      newcard.uuid = Utils.getuuid()
      newcard.setting.clearMenu = 'true'
      newcard.setting.icon = ''
      newcard.setting.name = ''
      newcard.setting.MenuNo = ''
      newcard.setting.type = 'menu'
      newcard.setting.copyMenuId = ''
      newcard.setting.linkMenuId = ''
      newcard.setting.linkurl = ''
      newcard.setting.tip = ''
      newcard.setting.url = ''
    }
    card.subMenus.push(newcard)
    
    this.setState({card})
    this.props.updateConfig(card)
    setTimeout(() => {
      let node = document.getElementById(newcard.uuid)
      node && node.click()
    }, 200)
  }
  move = (item, direction) => {
@@ -252,18 +274,6 @@
  render() {
    const { card } = this.state
    let offset = 0
    if (card.wrap.cardFloat && card.wrap.cardFloat !== 'left') {
      let _width = 0
      card.subMenus.forEach(card => {
        _width += card.setting.width
      })
      offset = _width < 24 ? 24 - _width : 0
      if (card.wrap.cardFloat === 'center') {
        offset = Math.floor(offset / 2)
      }
    }
    let _style = resetStyle(card.style)
    return (
@@ -286,7 +296,9 @@
        } trigger="hover">
          <ToolOutlined />
        </Popover>
        {card.subMenus.map((menu, index) => (<MenuComponent key={menu.uuid} offset={!index ? offset : 0} cards={card} card={menu} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))}
        <div className={(card.wrap.layout || 'grid') + '-layout'}>
          {card.subMenus.map((menu, index) => (<MenuComponent key={menu.uuid} cards={card} card={menu} move={this.move} updateElement={this.updateCard} deleteElement={this.deleteCard}/>))}
        </div>
      </div>
    )
  }