king
2023-04-27 d52169be5ed98d6846bb07f75e5a305271e374d4
src/menu/components/table/edit-table/columns/editColumn/index.jsx
@@ -16,7 +16,8 @@
  text: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'textFormat', 'editable', 'initval', 'blacklist'],
  number: ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'editable', 'initval', 'sum', 'blacklist'],
  textarea: ['label', 'field', 'type', 'Align', 'Hide', 'Width', 'prefix', 'initval', 'postfix', 'blacklist'],
  custom: ['label', 'type', 'Align', 'Hide', 'Width', 'blacklist'],
  custom: ['label', 'type', 'Align', 'Width', 'blacklist'],
  colspan: ['label', 'type', 'Align', 'Hide', 'blacklist'],
  action: ['label', 'type', 'Align', 'Width'],
  formula: ['label', 'type', 'Align', 'Hide', 'Width', 'prefix', 'postfix', 'eval', 'formula', 'blacklist'],
  index: ['label', 'type', 'Align', 'Width']
@@ -59,6 +60,10 @@
    let _options = fromJS(columnTypeOptions[this.column.type]).toJS()
    if (this.column.editable === 'true') {
      _options.push('ctrlField')
      if (this.column.ctrlField) {
        _options.push('ctrlValue')
      }
      if (this.column.type === 'text') {
        _options.push('editType')
@@ -123,6 +128,11 @@
    if (key === 'type') {
      let _options = this.getOptions()
      let _field = ''
      if (value === 'formula') {
        _field = this.props.form.getFieldValue('field') || ''
      }
      this.setState({
        formlist: this.state.formlist.map(item => {
          item.initVal = this.column[item.key] || item.initVal
@@ -131,8 +141,10 @@
          return item
        })
      }, () => {
        if (value === 'action') {
        if (value === 'action' || value === 'colspan') {
          this.props.form.setFieldsValue({Align: 'center'})
        } else if (value === 'formula' && _field) {
          this.props.form.setFieldsValue({formula: '@' + _field + '@'})
        }
      })
    } else if (key === 'field') {
@@ -169,7 +181,7 @@
      }
    } else if (key === 'format' && value === 'percent') {
      this.props.form.setFieldsValue({postfix: '%'})
    } else if (key === 'editable' || key === 'editType' || key === 'resourceType') {
    } else if (key === 'editable' || key === 'editType' || key === 'resourceType' || key === 'ctrlField') {
      let _options = this.getOptions()
      this.setState({
@@ -214,7 +226,11 @@
    let resource = this.props.form.getFieldValue('dataSource') || ''
    resource = `select '' as ${field},'全部' as ${text} union all \n${resource}`
    if (field === text) {
      resource = `select '' as ${field} union all \n${resource}`
    } else {
      resource = `select '' as ${field},'全部' as ${text} union all \n${resource}`
    }
    this.props.form.setFieldsValue({dataSource: resource})
  }
@@ -345,20 +361,18 @@
  }
  handleSubmit = () => {
    const { columns, column } = this.props
    // 表单提交时检查输入值是否正确
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        values.uuid = column.uuid
        values.marks = column.marks || []
        if (values.field && columns.filter(col => col.field && col.uuid !== values.uuid && col.field === values.field).length > 0) {
          notification.warning({
            top: 92,
            message: '字段已添加!',
            duration: 5
          })
          return
        if (values.type === 'number' && values.editable === 'true') {
          if (typeof(values.max) === 'number' && typeof(values.min) === 'number' && values.max < values.min) {
            notification.warning({
              top: 92,
              message: '最大值不可小于最小值!',
              duration: 5
            })
            return
          }
        }
        this.setState({visible: false, formlist: null})
        this.props.submitCol(values)