king
2020-02-21 063b983daaf51a7f1e8677bde1e9c0e618866c91
src/templates/subtableconfig/index.jsx
@@ -1227,50 +1227,49 @@
        _config.enabled = false
      }
      // 保存时删除配置类型,system 、user
      delete _config.type
      delete _config.isAdd
      _config.funcs = []
      try {
        _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
      } catch (e) {
        notification.warning({
          top: 92,
          message: '编译错误',
          duration: 10
        })
        return
      }
      _config.funcs.push({
        type: 'view',
        subtype: 'view',
        uuid: _config.uuid,
        intertype: _config.setting.interType || 'inner',
        interface: _config.setting.interface || '',
        tableName: _config.setting.tableName || '',
        innerFunc: _config.setting.innerFunc || '',
        outerFunc: _config.setting.outerFunc || ''
      })
      let btnParam = {
        func: 'sPC_Button_AddUpt',
        Type: 40,
        ParentID: _config.uuid,
        MenuNo: res.tabNo,
        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`
        })
      }
      _config.action.forEach(item => {
        let tablename = item.OpenType === 'excelIn' ? (item.sheet || '') : (item.sql || '')
      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)
        if (item.OpenType === 'excelOut' && item.intertype === 'inner' && !item.innerFunc) {
          tablename = _config.setting.tableName || ''
        }
      let param = {
        func: 'sPC_Tab_AddUpt',
        MenuID: _config.uuid,
        MenuNo: res.tabNo,
        Template: 'SubTable',
        MenuName: res.tabName,
        Remark: res.Remark,
        Sort: 0,
        PageParam: JSON.stringify({Template: 'SubTable'}),
        LongParam: _LongParam
      }
        if (item.OpenType === 'popview') {
          _config.funcs.push({
            type: 'tab',
            subtype: 'btn',
            uuid: item.uuid,
            label: item.label,
            linkTab: item.linkTab
          })
        } else {
          _config.funcs.push({
            type: 'button',
            subtype: 'btn',
            uuid: item.uuid,
            label: item.label,
            tablename: tablename,
            intertype: item.intertype,
            interface: item.interface || '',
            innerFunc: item.innerFunc || '',
            outerFunc: item.outerFunc || '',
            callbackFunc: item.callbackFunc || ''
          })
        }
      })
      if (this.state.closeVisible) { // 显示关闭对话框时,模态框中保存按钮,显示保存中状态
        this.setState({
@@ -1282,77 +1281,170 @@
        })
      }
      // 有按钮或标签删除时,先进行删除操作
      // 删除成功后,保存页面配置
      new Promise(resolve => {
        if (delActions.length > 0) {
          let deffers = delActions.map(item => {
            let _param = {
              func: 'sPC_MainMenu_Del',
              MenuID: item
            }
            return new Promise(resolve => {
              Api.getSystemConfig(_param).then(response => {
                resolve(response)
        let deffers = []
        _config.funcs.forEach(item => {
          if (item.type === 'tab') {
            let deffer = new Promise(resolve => {
              Api.getSystemConfig({
                func: 'sPC_Get_LongParam',
                MenuID: item.linkTab
              }).then(result => {
                if (result.status && result.LongParam) {
                  let _LongParam = ''
                  if (result.LongParam) {
                    try {
                      _LongParam = window.decodeURIComponent(window.atob(result.LongParam))
                      _LongParam = JSON.parse(_LongParam)
                    } catch (e) {
                      _LongParam = ''
                    }
                  }
                  if (_LongParam) {
                    item.menuNo = _LongParam.tabNo
                    item.subfuncs = _LongParam.funcs || []
                  }
                }
                resolve()
              })
            })
            deffers.push(deffer)
          }
        })
        if (deffers.length === 0) {
          resolve()
        } else {
          Promise.all(deffers).then(() => {
            resolve()
          })
          Promise.all(deffers).then(result => {
            let error = null
            result.forEach(response => {
              if (!response.status) {
                error = response
        }
      }).then(() => {
        // 保存时删除配置类型,system 、user
        delete _config.type
        delete _config.isAdd
        try {
          _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
        } catch (e) {
          notification.warning({
            top: 92,
            message: '编译错误',
            duration: 10
          })
          this.setState({
            menucloseloading: false,
            menuloading: false
          })
          return
        }
        let btnParam = {
          func: 'sPC_Button_AddUpt',
          Type: 40,
          ParentID: _config.uuid,
          MenuNo: res.tabNo,
          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`
          })
        }
        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 param = {
          func: 'sPC_Tab_AddUpt',
          MenuID: _config.uuid,
          MenuNo: res.tabNo,
          Template: 'SubTable',
          MenuName: res.tabName,
          Remark: res.Remark,
          Sort: 0,
          PageParam: JSON.stringify({Template: 'SubTable'}),
          LongParam: _LongParam
        }
        // 有按钮或标签删除时,先进行删除操作
        // 删除成功后,保存页面配置
        new Promise(resolve => {
          if (delActions.length > 0) {
            let deffers = delActions.map(item => {
              let _param = {
                func: 'sPC_MainMenu_Del',
                MenuID: item
              }
              return new Promise(resolve => {
                Api.getSystemConfig(_param).then(response => {
                  resolve(response)
                })
              })
            })
            Promise.all(deffers).then(result => {
              let error = null
              result.forEach(response => {
                if (!response.status) {
                  error = response
                }
              })
              if (error) {
                this.setState({
                  menuloading: false,
                  menucloseloading: false
                })
                notification.warning({
                  top: 92,
                  message: error.message,
                  duration: 10
                })
                resolve(false)
              } else {
                this.setState({
                  delActions: []
                })
                resolve(true)
              }
            })
          } else if (delActions.length === 0) {
            resolve(true)
          }
        }).then(resp => {
          if (resp === false) return
  
            if (error) {
          Api.getSystemConfig(param).then(response => {
            if (response.status) {
              this.setState({
                config: _config,
                originConfig: _config
              }, () => {
                this.setState({
                  menuloading: false,
                  menucloseloading: false
                })
                this.submitAction(btnParam)
              })
            } else {
              this.setState({
                menuloading: false,
                menucloseloading: false
              })
              notification.warning({
                top: 92,
                message: error.message,
                message: response.message,
                duration: 10
              })
              resolve(false)
            } else {
              this.setState({
                delActions: []
              })
              resolve(true)
            }
          })
        } else if (delActions.length === 0) {
          resolve(true)
        }
      }).then(resp => {
        if (resp === false) return
        Api.getSystemConfig(param).then(response => {
          if (response.status) {
            this.setState({
              config: _config,
              originConfig: _config
            }, () => {
              this.setState({
                menuloading: false,
                menucloseloading: false
              })
              this.submitAction(btnParam)
            })
          } else {
            this.setState({
              menuloading: false,
              menucloseloading: false
            })
            notification.warning({
              top: 92,
              message: response.message,
              duration: 10
            })
          }
        })
      })
    }, () => {
@@ -2111,6 +2203,7 @@
          title={this.state.dict['header.modal.search.edit']}
          visible={modaltype === 'search'}
          width={700}
          maskClosable={false}
          onOk={this.handleSubmit}
          onCancel={this.editModalCancel}
          destroyOnClose
@@ -2127,6 +2220,7 @@
          title={modaltype === 'actionEdit' ? this.state.dict['header.modal.action.edit'] : this.state.dict['header.modal.action.copy']}
          visible={modaltype === 'actionEdit' || modaltype === 'actionCopy'}
          width={700}
          maskClosable={false}
          onCancel={this.editModalCancel}
          footer={[
            modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null,
@@ -2149,6 +2243,7 @@
          title={this.state.dict['header.modal.column.edit']}
          visible={modaltype === 'columns'}
          width={700}
          maskClosable={false}
          onOk={this.handleSubmit}
          onCancel={this.editModalCancel}
          destroyOnClose
@@ -2165,6 +2260,7 @@
          title={this.state.dict['header.modal.colspan.edit']}
          visible={modaltype === 'colspan'}
          width={700}
          maskClosable={false}
          onOk={this.handleSubmit}
          onCancel={this.editModalCancel}
          destroyOnClose
@@ -2181,6 +2277,7 @@
          title={this.state.dict['header.modal.gridbtn.edit']}
          visible={modaltype === 'gridbtn'}
          width={700}
          maskClosable={false}
          onOk={this.handleSubmit}
          onCancel={this.editModalCancel}
          destroyOnClose
@@ -2197,6 +2294,7 @@
          title={this.state.dict['header.edit']}
          visible={this.state.tableVisible}
          width={'65vw'}
          maskClosable={false}
          style={{minWidth: '900px', maxWidth: '1200px'}}
          cancelText={this.state.dict['header.close']}
          onOk={this.addFieldSubmit}
@@ -2221,6 +2319,7 @@
          title={'验证信息'}
          visible={this.state.profileVisible}
          width={'75vw'}
          maskClosable={false}
          style={{minWidth: '900px', maxWidth: '1200px'}}
          onOk={this.verifySubmit}
          onCancel={() => { this.setState({ profileVisible: false }) }}
@@ -2255,7 +2354,7 @@
          title={this.state.dict['header.edit']}
          visible={this.state.settingVisible}
          width={700}
          // onOk={this.settingSave}
          maskClosable={false}
          onCancel={() => { // 取消修改
            this.setState({
              settingVisible: false
@@ -2280,6 +2379,7 @@
        <Modal
          bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}}
          closable={false}
          maskClosable={false}
          visible={this.state.closeVisible}
          onCancel={() => { this.setState({closeVisible: false}) }}
          footer={[