king
2023-05-15 4587b07918b19e9724439d773b0ba28f388057df
src/templates/zshare/modalform/index.jsx
@@ -29,6 +29,7 @@
  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkField', 'linkSubField', 'span', 'place', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'pickerMode'],
  fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'span', 'labelwidth', 'tooltip', 'extra', 'compress', 'miniSet', 'splitline', 'marginTop', 'marginBottom', 'maxSize'],
  switch: ['initval', 'openVal', 'closeVal', 'openText', 'closeText', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom'],
  check: ['initval', 'openVal', 'closeVal', 'readonly', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'checkTip'],
  date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'place', 'marginTop', 'marginBottom', 'minDate', 'maxDate', 'precision'],
  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'place', 'marginTop', 'marginBottom'],
  datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'],
@@ -236,7 +237,7 @@
    } else if (['date', 'datemonth', 'datetime'].includes(type)) {
      reOptions.initval = dateOptions[type]
      reTypes.initval = 'select'
    } else if (type === 'switch') {
    } else if (type === 'switch' || type === 'check') {
      reOptions.initval = [
        {value: true, text: '开'},
        {value: false, text: '关'}
@@ -370,7 +371,7 @@
      if (value === 'number' || value === 'rate') {
        this.record.initval = 0
        _fieldval.initval = 0
      } else if (value === 'switch') {
      } else if (value === 'switch' || value === 'check') {
        this.record.initval = false
        _fieldval.initval = false
      }
@@ -808,6 +809,52 @@
    return fields
  }
  transfer = (options) => {
    if (options.length === 0) return options
    let isNumber = true
    options.forEach(item => {
      if (!/^([0-9]|[1-9]\d{0,2})$/.test(item.Value)) {
        isNumber = false
      }
    })
    if (isNumber) {
      return options.map(item => {
        item.Value = +item.Value
        return item
      })
    } else {
      return options.map(item => {
        item.Value = item.Value + ''
        return item
      })
    }
  }
  transferCard = (options) => {
    if (options.length === 0) return options
    let isNumber = true
    options.forEach(item => {
      if (!/^([0-9]|[1-9]\d{0,2})$/.test(item.$value)) {
        isNumber = false
      }
    })
    if (isNumber) {
      return options.map(item => {
        item.$value = +item.$value
        return item
      })
    } else {
      return options.map(item => {
        item.$value = item.$value + ''
        return item
      })
    }
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
@@ -823,6 +870,8 @@
              if (values.type === 'radio' && values.linkField) {
                type = 'link'
              }
              values.options = this.transfer(values.options)
              if (values.options.filter(op => op.Text === '').length > 0) {
                notification.warning({
@@ -877,6 +926,8 @@
                return m
              })
              values.options = this.transferCard(values.options)
              let type = values.type
              if (values.linkField) {
                type = 'link'