king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/templates/sharecomponent/actioncomponent/index.jsx
@@ -5,23 +5,24 @@
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import DevUtils from '@/utils/devutils.js'
import Utils, { FuncUtils } from '@/utils/utils.js'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import { getActionForm } from '@/templates/zshare/formconfig'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import ActionForm from './actionform'
import VerifyCard from '@/templates/zshare/verifycard'
import CreateFunc from '@/templates/zshare/createfunc'
import CreateInterface from '@/templates/zshare/createinterface'
import VerifyPrint from './verifyprint'
import VerifyExcelIn from './verifyexcelin'
import VerifyExcelOut from './verifyexcelout'
import { updateForm } from '@/utils/utils-update.js'
import DragElement from './dragaction'
import './index.scss'
const { confirm } = Modal
const VerifyCard = asyncSpinComponent(() => import('@/templates/zshare/verifycard'))
const VerifyPrint = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyprint'))
const VerifyExcelIn = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelin'))
const VerifyExcelOut = asyncSpinComponent(() => import('@/templates/sharecomponent/actioncomponent/verifyexcelout'))
class ActionComponent extends Component {
  static propTpyes = {
@@ -34,7 +35,7 @@
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    card: null,          // 编辑中元素
    formlist: null,      // 表单信息
    actionlist: null,    // 按钮组
@@ -62,7 +63,7 @@
    if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
      let len = nextProps.config.action.length
      let item = nextProps.config.action[len - 1]
      if (item.copyType && item.focus) {
      if (item && item.focus) {
        this.handleAction(item)
      }
      this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
@@ -143,7 +144,7 @@
    if (usefulFields) {
      try {
        usefulFields = JSON.parse(usefulFields)
      } catch {
      } catch (e) {
        usefulFields = []
      }
    } else {
@@ -153,7 +154,6 @@
    let ableField = usefulFields.join(', ')
    let functip = <div>
      <p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
      <p>{this.state.dict['model.tooltip.func.outface']}</p>
    </div>
    let menulist = []
@@ -243,7 +243,7 @@
      if (labelrepet) {
        notification.warning({
          top: 92,
          message: this.state.dict['model.name.exist'] + ' !',
          message: '名称已存在!',
          duration: 5
        })
        return
@@ -263,12 +263,12 @@
      new Promise(resolve => {
        if (
          !card.originCard ||
          (btn.OpenType === 'pop' && card.originCard.OpenType !== 'pop') ||
          (['tab', 'blank'].includes(btn.OpenType) && !['tab', 'blank'].includes(card.originCard.OpenType)) ||
          (btn.OpenType === 'popview' && (!btn.createTab || card.originCard.OpenType !== 'popview' || !card.originCard.linkTab))
          (btn.OpenType !== card.originCard.OpenType) ||
          (btn.OpenType === 'tab' && btn.tabTemplate !== 'FormTab') ||
          (btn.OpenType === 'funcbutton' && btn.execMode !== 'pop')
        ) { // 按钮不是复制,或按钮前后类型不一致时,直接保存
          resolve('save')
        } else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.OpenType === 'blank') {
        } else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.execMode === 'pop') {
          resolve('subconf')
        } else if (btn.OpenType === 'popview') {
          resolve('subtab')
@@ -298,20 +298,21 @@
            }
          }
          if (!_LongParam) return 'save'
          let _temp = '' // 配置信息类型
          // 修改模态框标题名称
          if (btn.OpenType === 'pop' && _LongParam && _LongParam.type === 'Modal') {
          if ((btn.OpenType === 'pop' || btn.execMode === 'pop') && _LongParam.type === 'Modal') {
            try {
              _LongParam.setting.title = btn.label
              _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
              _temp = 'Modal'
            } catch {
            } catch (e) {
              console.warn('Stringify Failure')
              _LongParam = ''
              _temp = ''
            }
          } else if (['tab', 'blank'].includes(btn.OpenType) && _LongParam && _LongParam.type === 'FormTab') {
          } else if (btn.OpenType === 'tab' && _LongParam.type === 'FormTab') {
            try {
              _LongParam.action = _LongParam.action.map(_btn => {
                _btn.uuid = Utils.getuuid()
@@ -327,9 +328,8 @@
              })
              _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
              _temp = 'FormTab'
            } catch {
            } catch (e) {
              console.warn('Stringify Failure')
              _LongParam = ''
              _temp = ''
            }
          }
@@ -485,7 +485,7 @@
      _tab.action = _tab.action.map((item, index) => {
        let uuid = Utils.getuuid()
        if (item.OpenType === 'pop') {
        if (item.OpenType === 'pop' || item.execMode === 'pop') {
          _oriActions.push({
            prebtn: JSON.parse(JSON.stringify(item)),
            curuuid: uuid,
@@ -522,7 +522,7 @@
      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
      _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab)))
    } catch {
    } catch (e) {
      console.warn('Stringify Failure')
      _LongParam = ''
      _resolve('save')
@@ -745,23 +745,16 @@
            }
            if (_LongParam) {
              let fields = []
              if (_LongParam.groups.length > 0) {
                _LongParam.groups.forEach(group => {
                  fields = [...fields, ...group.sublist]
                })
              } else {
                fields = _LongParam.fields
              }
              _LongParam = updateForm(_LongParam)
              let _param = {
                funcName: btn.innerFunc,
                name: _config.setting.tableName || '',
                fields: fields,
                fields: _LongParam.fields,
                menuNo: menu.MenuNo
              }
              newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
              DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
              newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config))
              DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
              resolve(true)
            } else {
              notification.warning({
@@ -778,8 +771,8 @@
              funcName: btn.innerFunc,
              menuNo: menu.MenuNo
            }
            newLText = Utils.formatOptions(DevUtils.getexcelInfunc(_param, btn, menu))
            DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
            newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu))
            DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
            resolve(true)
          } else {
            notification.warning({
@@ -794,8 +787,8 @@
            innerFunc: btn.innerFunc
          }
          newLText = Utils.formatOptions(DevUtils.getTableFunc(_param, menu, _config)) // 创建存储过程sql
          DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
          newLText = Utils.formatOptions(FuncUtils.getTableFunc(_param, menu, _config)) // 创建存储过程sql
          DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
          resolve(true)
        } else {
@@ -805,8 +798,8 @@
            fields: '',
            menuNo: menu.MenuNo
          }
          newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
          DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
          newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config))
          DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
          resolve(true)
        }
      }).then(res => {
@@ -838,15 +831,12 @@
  /**
   * @description 按钮双击触发子配置
   */
  btnDoubleClick = (element) => {
    if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank')) {
      this.props.setSubConfig(element)
  btnDoubleClick = (el) => {
    // execMode === 'pop' 为 OpenType === 'funcbutton'
    if (!el.origin && (el.OpenType === 'pop' || el.execMode === 'pop' || el.OpenType === 'popview' || (el.OpenType === 'tab' && el.tabTemplate === 'FormTab'))) {
      this.props.setSubConfig(el)
    } else {
      notification.warning({
        top: 92,
        message: '此按钮无子配置项!',
        duration: 5
      })
      this.handleAction(el)
    }
  }
@@ -885,8 +875,9 @@
        {/* 编辑按钮:复制、编辑 */}
        <Modal
          title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])}
          wrapClassName="model-table-action-edit-modal"
          visible={visible}
          width={800}
          width={850}
          maskClosable={false}
          onCancel={this.editModalCancel}
          footer={[
@@ -914,7 +905,6 @@
          visible={profVisible}
          width={'75vw'}
          maskClosable={false}
          style={{minWidth: '900px', maxWidth: '1200px'}}
          okText={dict['model.submit']}
          onOk={this.verifySubmit}
          onCancel={() => { this.setState({ profVisible: false }) }}