king
2020-03-13 268be11f39b248920a76568135f8b7b6c4fa9e52
src/templates/subtableconfig/index.jsx
@@ -344,6 +344,14 @@
      tabview: _tabview
    }
    this.state.copyActions.forEach(item => {
      let _param = {
        func: 'sPC_MainMenu_Del',
        MenuID: item
      }
      Api.getSystemConfig(_param)
    })
    this.props.handleView(param)
  }
@@ -1440,15 +1448,33 @@
          Template: 'SubTable',
          PageParam: '',
          LongParam: '',
          LText: config.action.map((item, index) => {
            return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`
          })
          LText: []
        }
        let btntabs = []
        config.action.forEach((item, index) => {
          if (item.OpenType === 'popview') {
            btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`)
          } else {
            btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`)
          }
        })
  
        btnParam.LText = btnParam.LText.join(' union all ')
        btnParam.LText = Utils.formatOptions(btnParam.LText)
        btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
        btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
        let tabParam = { // 添加标签按钮tab页
          func: 'sPC_sMenusTab_AddUpt',
          MenuID: _config.uuid,
          LText: btntabs.join(' union all ')
        }
        tabParam.LText = Utils.formatOptions(tabParam.LText)
        tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
        tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
  
        let param = {
          func: 'sPC_Tab_AddUpt',
@@ -1573,7 +1599,7 @@
                  menuloading: false,
                  menucloseloading: false
                })
                this.submitAction(btnParam)
                this.submitAction(btnParam, tabParam)
              })
            } else {
              this.setState({
@@ -1601,24 +1627,57 @@
  /**
   * @description 保存或修改菜单按钮
   */
  submitAction = (param) => {
  submitAction = (btnParam, tabParam) => {
    const { config } = this.state
    new Promise(resolve => {
      if (param.LText) {
        Api.getSystemConfig(param).then(res => {
          if (res.status) {
            resolve(true)
          } else {
      let deffers = []
      if (tabParam.LText) {
        let defer = new Promise(resolve => {
          Api.getSystemConfig(tabParam).then(result => {
            resolve(result)
          })
        })
        deffers.push(defer)
      }
      if (btnParam.LText) {
        let defer = new Promise(resolve => {
          Api.getSystemConfig(btnParam).then(result => {
            if (result.status) {
              this.setState({ // 保存成功后清空复制列表
                copyActions: []
              })
            }
            resolve(result)
          })
        })
        deffers.push(defer)
      }
      if (deffers.length === 0) {
        resolve(true)
      } else {
        Promise.all(deffers).then(result => {
          let error = false
          result.forEach(res => {
            if (!res.status) {
              error = res
            }
          })
          if (error) {
            notification.warning({
              top: 92,
              message: res.message,
              message: error.message,
              duration: 10
            })
            resolve(false)
          } else {
            resolve(true)
          }
        })
      } else {
        resolve(true)
      }
    }).then(response => {
      if (response === false) return response