king
2023-08-14 f078c137d61270d243cd8e03077fa9cf000e276b
src/tabviews/zshare/mutilform/index.jsx
@@ -6,7 +6,6 @@
import moment from 'moment'
import Api from '@/api'
import options from '@/store/options.js'
import { formRule } from '@/utils/option.js'
import Utils from '@/utils/utils.js'
import asyncComponent from '@/utils/asyncComponent'
@@ -31,7 +30,7 @@
const MkVercode = asyncComponent(() => import('./mkVercode'))
const MKEditor = asyncComponent(() => import('@/components/editor'))
class MainSearch extends Component {
class MutilFormComponent extends Component {
  static propTpyes = {
    action: PropTypes.object,    // 按钮信息、表单列表
    data: PropTypes.any,         // 表格数据
@@ -89,6 +88,7 @@
        } else {
          supvals.push('')
        }
        supvals = Array.from(new Set(supvals))
        controlFields[item.supField] = controlFields[item.supField] || []
        controlFields[item.supField].push({field: item.field, values: supvals})
      }
@@ -413,9 +413,24 @@
        let cell = fieldMap.get(item.field)
        // if (cell.hidden) return
        if (supItem.hidden || !item.values.includes(supItem.initval)) {
        let _hidden = false
        if (supItem.hidden) {
          _hidden = true
        } else {
          let box = [...item.values]
          if (supItem.type === 'multiselect' || (supItem.type === 'checkcard' && supItem.multiple === 'true')) {
            box.push(...supItem.initval.split(','))
          } else {
            box.push(supItem.initval)
          }
          if (box.length === Array.from(new Set(box)).length) {
            _hidden = true
          }
        }
        if (_hidden) {
          cell.hidden = true
          if (cell.empty === 'hidden') {
            cell.$hidden = true
@@ -465,6 +480,31 @@
          })
          
          item.options = fromJS(item.oriOptions).toJS()
        }
        item.linkSubField = null
      } else if (item.type === 'switch' && item.linkSubField) {
        item.options = []
        item.subFields = []
        item.linkSubField.forEach(m => {
          let n = fieldMap.get(m)
          if (n && ['text', 'number', 'textarea'].includes(n.type)) {
            item.subFields.push({
              uuid: n.uuid,
              field: m
            })
          }
        })
        if (item.subFields.length === 0) {
          item.subFields = null
        } else {
          reFieldsVal = reFieldsVal || {}
          let val = item.initval === item.openVal ? item.openText : item.closeText
          item.subFields.forEach(n => {
            reFieldsVal[n.field] = val || ''
          })
        }
        item.linkSubField = null
      }
@@ -546,13 +586,21 @@
      if (unload) return
      
      if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) {
        setTimeout(() => {
          MKEmitter.emit('mkFC', 'focus', fieldMap.get(action.setting.focus).uuid)
        }, 500)
        let focusItem = fieldMap.get(action.setting.focus)
        if (focusItem.type === 'text' || focusItem.type === 'number') {
          setTimeout(() => {
            MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
          }, 50)
        } else {
          setTimeout(() => {
            MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
          }, 500)
        }
      }
      if (deForms.length > 0) {
        if (!window.GLOB.mkHS && options.sysType === 'local' && window.GLOB.systemType !== 'production') {
        if (!window.GLOB.mkHS && window.GLOB.sysType === 'local' && window.GLOB.systemType !== 'production') {
          this.improveSimpleActionForm(deForms)
        } else {
          this.improveActionForm(deForms)
@@ -571,7 +619,7 @@
    let mainItems = []  // 云端或单点数据
    let localItems = [] // 本地数据
    let cache = action.setting.cache !== 'false'
    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
    let debug = window.GLOB.debugger === true || (window.debugger === true && window.GLOB.sysType !== 'cloud')
    let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)  select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n`
    let _sso = _sql
@@ -658,8 +706,8 @@
      if (window.GLOB.mkHS) { // 云端数据验证
        mainparam.open_key = Utils.encryptOpenKey(mainparam.secretkey, mainparam.timestamp)
        if (options.cloudServiceApi) {
          mainparam.rduri = options.cloudServiceApi
        if (window.GLOB.cloudServiceApi) {
          mainparam.rduri = window.GLOB.cloudServiceApi
          mainparam.userid = sessionStorage.getItem('CloudUserID') || ''
          mainparam.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
        }
@@ -700,7 +748,7 @@
   */
  improveSimpleActionForm = (deForms) => {
    let cache = this.props.action.setting.cache !== 'false'
    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
    let debug = window.GLOB.debugger === true || (window.debugger === true && window.GLOB.sysType !== 'cloud')
    let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)  select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n`
    let deffers = deForms.map((form, index) => {
@@ -921,7 +969,23 @@
      current.controlFields.forEach(cell => {
        let m = map.get(cell.field)
        m.hidden = current.hidden || !cell.values.includes(val)
        m.hidden = false
        if (current.hidden) {
          m.hidden = true
        } else {
          let box = [...cell.values]
          if (current.type === 'multiselect' || (current.type === 'checkcard' && current.multiple === 'true')) {
            box.push(...val.split(','))
          } else {
            box.push(val)
          }
          if (box.length === Array.from(new Set(box)).length) {
            m.hidden = true
          }
        }
        if (m.empty === 'hidden' && m.oriOptions.length === 0) {
          m.hidden = true
@@ -1003,7 +1067,7 @@
          className = 'checkcard'
          content = (<MKCheckCard config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
        } else if (item.type === 'switch') {
          content = (<MKSwitch config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>)
          content = (<MKSwitch config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)}/>)
        } else if (item.type === 'check') {
          content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>)
        } else if (item.type === 'checkbox') {
@@ -1086,7 +1150,7 @@
            _item.fieldlen = item.decimal || 0
          } else if (['text', 'textarea', 'linkMain'].includes(item.type)) {
            _item.value = _item.value + ''
            _item.value = _item.value.replace(/\t*|\v*/g, '')       // 去除制表符
            _item.value = _item.value.replace(/\t+|\v+/g, '')       // 去除制表符
    
            if (item.interception !== 'false') {                    // 去除首尾空格
              _item.value = _item.value.replace(/(^\s*|\s*$)/g, '')
@@ -1163,4 +1227,4 @@
  }
}
export default Form.create()(MainSearch)
export default Form.create()(MutilFormComponent)