king
2023-05-09 7b0dbecd1d6155d26ec67be0a47a16264c738c85
src/tabviews/zshare/mutilform/index.jsx
@@ -19,6 +19,7 @@
const MKCheckCard = asyncComponent(() => import('./mkCheckCard'))
const MKSwitch = asyncComponent(() => import('./mkSwitch'))
const MKCheck = asyncComponent(() => import('./mkCheck'))
const MKCheckbox = asyncComponent(() => import('./mkCheckbox'))
const MKRadio = asyncComponent(() => import('./mkRadio'))
const MKDatePicker = asyncComponent(() => import('./mkDatePicker'))
@@ -104,6 +105,12 @@
        delete item.style.marginRight
      }
      if (item.type === 'split' && item.splitctrl) {
        if (data.hasOwnProperty(item.splitctrl.toLowerCase()) && data[item.splitctrl.toLowerCase()] === '') {
          return false
        }
      }
      if (item.type === 'split' || item.type === 'formula') return true
      if (item.type === 'hint') {
        if (item.field && data[item.field.toLowerCase()]) {
@@ -111,18 +118,20 @@
        }
        delete item.field
        return true
      } else if (item.type === 'date') { // 时间搜索
      } else if (item.type === 'date') {
        item.precision = item.precision || 'day'
      } else if (item.type === 'datetime') {
        item.type = 'date'
        item.precision = 'second'
      }
      if (!item.field || !['text', 'number', 'switch', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color', 'vercode'].includes(item.type)) return false
      if (!item.field || !['text', 'number', 'switch', 'check', 'rate', 'select', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color', 'vercode'].includes(item.type)) return false
      if (/^\s+$/.test(item.label)) {
        item.style = item.style || {}
        item.style.color = 'transparent'
        item.style.opacity = 0
        item.style.width = 1
        item.style.display = 'inline-block'
      }
      // 数据自动填充
@@ -165,6 +174,23 @@
          })
        }
        item.oriOptions = fromJS(item.options).toJS()
        if (item.empty === 'hidden' && item.oriOptions.length === 0) {
          item.hidden = true
        }
        if (item.type === 'checkcard' && item.readonly && item.unchecked === 'hidden') {
          let selectKeys = item.initval
          if (item.multiple === 'true') {
            selectKeys = selectKeys ? selectKeys.split(',') : []
            item.options = item.options.filter(item => selectKeys.includes(item.$value))
          } else {
            item.options = item.options.filter(item => selectKeys === item.$value)
          }
          item.oriOptions = fromJS(item.options).toJS()
          if (item.options.length === 0) {
            item.hidden = true
          }
        }
      }
      let newval = '$empty'
@@ -195,7 +221,7 @@
        if (newval === '$empty' && item.initval) {
          newval = moment().subtract(item.initval, 'month').format('YYYY-MM')
        }
      } else if (item.type === 'switch') { // 开关只接收固定值
      } else if (item.type === 'switch' || item.type === 'check') { // 开关勾选框只接收固定值
        if (newval !== '$empty' && (newval === item.closeVal || newval === item.openVal)) {
        } else if (item.initval === true) {
@@ -387,10 +413,13 @@
        let cell = fieldMap.get(item.field)
        if (cell.hidden) return
        // if (cell.hidden) return
        if (supItem.hidden || !item.values.includes(supItem.initval)) {
          cell.hidden = true
          if (cell.empty === 'hidden') {
            cell.$hidden = true
          }
          fieldMap.set(item.field, cell)
        }
@@ -454,7 +483,7 @@
      }
      if (['select', 'link', 'radio'].includes(item.type)) { // 选中第一项
        if (typeof(item.initval) === 'string' && item.initval.indexOf('$first') > -1) {
        if (/^\s*\$first\s*$/.test(item.initval)) {
          item.$first = true
          item.initval = ''
        }
@@ -544,7 +573,7 @@
    let cache = action.setting.cache !== 'false'
    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
    let _sql = `Declare @mk_organization nvarchar(512)  select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n`
    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
    deForms.forEach(item => {
@@ -666,7 +695,7 @@
  improveSimpleActionForm = (deForms) => {
    let cache = this.props.action.setting.cache !== 'false'
    let debug = window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')
    let _sql = `Declare @mk_organization nvarchar(512)  select @mk_organization='${sessionStorage.getItem('organization') || ''}'\n`
    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) => {
      let param = {
@@ -810,6 +839,25 @@
            })
          }
        }
        if (item.empty === 'hidden' && item.oriOptions.length > 0 && !item.$hidden) {
          item.hidden = false
        }
        if (item.type === 'checkcard' && item.readonly && item.unchecked === 'hidden') {
          let selectKeys = item.initval
          if (item.multiple === 'true') {
            selectKeys = selectKeys ? selectKeys.split(',') : []
            item.options = item.options.filter(item => selectKeys.includes(item.$value))
          } else {
            item.options = item.options.filter(item => selectKeys === item.$value)
          }
          item.oriOptions = fromJS(item.options).toJS()
          if (item.options.length === 0) {
            item.hidden = true
          } else {
            item.hidden = false
          }
        }
      }
      
      return item
@@ -869,6 +917,10 @@
        let m = map.get(cell.field)
        m.hidden = current.hidden || !cell.values.includes(val)
        if (m.empty === 'hidden' && m.oriOptions.length === 0) {
          m.hidden = true
        }
        if (m.hidden) {
          m.initval = this.record[m.field]
        }
@@ -901,7 +953,6 @@
    formlist.forEach((item, index) => {
      if (item.hidden) return
      if (item.empty === 'hidden' && item.options.length === 0) return
      if (item.type === 'split') {
        fields.push(
@@ -947,6 +998,8 @@
          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)}/>)
        } else if (item.type === 'check') {
          content = (<MKCheck config={item} onChange={(val) => this.recordChange({[item.field]: val}, item)}/>)
        } else if (item.type === 'checkbox') {
          content = (<MKCheckbox config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>)
        } else if (item.type === 'radio') {
@@ -1041,10 +1094,10 @@
                _item.value = _item.value.slice(-item.fieldlength)
              }
            }
          } else if (item.type.indexOf('date') > -1) {
            if (item.declareType === 'nvarchar(50)') {
              _item.type = 'text'
            }
          } else if (item.type === 'datemonth') {
            _item.type = 'text'
          } else  if (item.type === 'date') {
            _item.type = item.declareType === 'nvarchar(50)' ? 'text' : 'date'
          } else if (item.type === 'vercode') {
            _item.type = 'text'
            forms.push({