king
2023-12-14 0eb129a9beddbb86ae74d7106a8e60823206b8d5
src/tabviews/zshare/mutilform/index.jsx
@@ -46,10 +46,12 @@
    ID: '',
    send_type: '',
    timestamp: '',
    n_id: ''
    n_id: '',
    focusId: ''
  }
  record = {}
  submitId = ''
  componentDidMount () {
    const { action, unload } = this.props
@@ -144,6 +146,17 @@
      item.fieldlength = item.fieldlength || 50
      let key = item.field.toLowerCase()
      // positecgroup 表单隐藏
      if (item.tooltip && /@[a-z0-9_]+@/.test(item.tooltip)) {
        let field = item.tooltip.replace(/@|\s/ig, '').toLowerCase()
        if (data[field] === 'N') {
          item.hidden = true
        }
        item.tooltip = ''
      }
      if (item.type === 'funcvar') {
        readin = false
@@ -268,7 +281,7 @@
      }
      if (item.type === 'number') {
        if (isNaN(item.initval)) {
        if (isNaN(item.initval) || item.initval === '') {
          item.initval = 0
        }
      } else if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') {
@@ -308,8 +321,8 @@
          validator: (rule, value, callback) => {
            if (/'/.test(value)) {
              callback('不可使用英文状态的单引号!')
            } else if (/--/.test(value)) {
              callback('不可使用 -- !')
            // } else if (/--/.test(value)) {
            //   callback('不可使用 -- !')
            } else {
              callback()
            }
@@ -423,8 +436,8 @@
          validator: (rule, value, callback) => {
            if (/'/.test(value)) {
              callback('不可使用英文状态的单引号!')
            } else if (/--/.test(value)) {
              callback('不可使用 -- !')
            // } else if (/--/.test(value)) {
            //   callback('不可使用 -- !')
            } else {
              callback()
            }
@@ -623,17 +636,19 @@
      }
      record[item.field] = item.initval
      item.orgval = item.initval
      if (linkFields[item.field]) {
        item.linkFields = linkFields[item.field]
      }
      
      if (item.enter === 'tab' || item.enter === 'sub') {
        if (fieldMap.has(item.tabField)) {
        item.tabUuid = ''
        if (item.tabField && fieldMap.has(item.tabField)) {
          item.tabUuid = fieldMap.get(item.tabField).uuid
        } else if (item.enter === 'tab') {
          item.enter = 'false'
        } else if (item.enter === 'sub') {
        } else if (item.enter === 'sub' && ['text', 'number'].includes(item.type)) {
          item.tabUuid = item.uuid
        }
      }
@@ -670,13 +685,16 @@
    this.record = record
    let ID = this.props.data ? this.props.data.$$uuid || '' : ''
    let focusItem = null
    this.setState({ formlist, ID }, () => {
    if (action.setting.focus && fieldMap.has(action.setting.focus)) {
      focusItem = fieldMap.get(action.setting.focus)
    }
    this.setState({ formlist, ID, focusId: focusItem ? focusItem.uuid : '' }, () => {
      if (unload) return
      
      if (action.setting && action.setting.focus && fieldMap.has(action.setting.focus)) {
        let focusItem = fieldMap.get(action.setting.focus)
      if (focusItem) {
        if (focusItem.type === 'text' || focusItem.type === 'number') {
          setTimeout(() => {
            MKEmitter.emit('mkFC', 'focus', focusItem.uuid)
@@ -702,6 +720,62 @@
        }
      }
    })
    if (action.subButton && action.subButton.resetForms) {
      MKEmitter.addListener('resetForms', this.resetForms)
    }
  }
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('resetForms', this.resetForms)
  }
  resetForms = (id) => {
    const { action } = this.props
    const { focusId } = this.state
    if (id !== action.uuid) return
    let formlist = fromJS(this.state.formlist).toJS()
    let resetForms = action.subButton.resetForms || []
    formlist = formlist.map(item => {
      if (item.type !== 'text' && item.type !== 'number') return item
      if (resetForms.includes(item.field)) {
        item.initval = item.orgval
        this.record[item.field] = item.orgval
      }
      return item
    })
    let _list = fromJS(formlist).toJS().map(item => {
      if (item.type !== 'text' && item.type !== 'number') return item
      if (resetForms.includes(item.field) && !item.hidden) {
        item.hidden = true
      }
      return item
    })
    this.setState({
      formlist: _list
    }, () => {
      this.setState({
        formlist
      })
    })
    if (focusId || this.submitId) {
      setTimeout(() => {
        MKEmitter.emit('mkFC', 'focus', this.submitId || focusId)
      }, 50)
    }
  }
  getFormData = (deForms) => {
@@ -1181,7 +1255,7 @@
        } else if (item.type === 'fileupload') {
          className = item.readonly ? 'readonly' : ''
          className += item.fileType === 'picture-card' ? ' file-upload' : ''
          content = (<MKFileUpload config={item} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />)
          content = (<MKFileUpload config={item} data={this.record} onChange={(val, other = {}) => this.recordChange({[item.field]: val, ...other})} />)
        } else if (item.type === 'textarea') {
          content = (<MKTextArea config={item} onChange={(val, defer) => !defer && this.recordChange({[item.field]: val})}/>)
        } else if (item.type === 'rate') {
@@ -1218,7 +1292,7 @@
    return fields
  }
  handleConfirm = () => {
  handleConfirm = (formId) => {
    const { formlist, send_type, timestamp, n_id } = this.state
    // 表单提交时检查输入值是否正确
@@ -1316,6 +1390,8 @@
          forms.push(_item)
        })
        this.submitId = formId || ''
        resolve(forms)
      })
    })