king
2023-03-02 d1f19b794216b37417e114b71c1cd7a2ac3d7748
src/templates/zshare/modalform/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox } from 'antd'
import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip, Checkbox, AutoComplete } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { formRule } from '@/utils/option.js'
@@ -19,13 +19,13 @@
const MkEditIcon = asyncComponent(() => import('@/components/mkIcon'))
const modalTypeOptions = {
  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl'],
  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'encryption', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom', 'lenControl', 'inputType'],
  number: ['initval', 'readonly', 'hidden', 'decimal', 'min', 'max', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'splitline', 'place', 'marginTop', 'marginBottom'],
  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'],
  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText', 'splitline', 'arrange', 'marginTop', 'marginBottom'],
  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom'],
  multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'dropdown'],
  select: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom', 'empty'],
  checkbox: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'arrange', 'marginTop', 'marginBottom', 'empty'],
  radio: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'setAll', 'emptyText', 'splitline', 'arrange', 'marginTop', 'marginBottom', 'empty'],
  checkcard: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'span', 'labelwidth', 'display', 'tooltip', 'extra', 'width', 'multiple', 'splitline', 'marginTop', 'marginBottom', 'empty'],
  multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'dropdown', 'empty'],
  link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'declare', 'setAll', 'linkField', 'linkSubField', 'span', 'labelwidth', 'tooltip', 'extra', 'emptyText', 'enter', 'splitline', 'dropdown', 'marginTop', 'marginBottom'],
  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'],
@@ -33,8 +33,8 @@
  datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'splitline', 'marginTop', 'marginBottom'],
  datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'],
  textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'],
  cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'separator'],
  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'],
  cascader: ['readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'extra', 'splitline', 'marginTop', 'marginBottom', 'separator', 'empty'],
  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'colorType', 'extra', 'marginTop', 'marginBottom'],
  rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'color', 'rateCount', 'character', 'place'],
  hint: ['label', 'field', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
  split: ['label', 'type', 'marginTop', 'marginBottom', 'splitline'],
@@ -46,7 +46,6 @@
class MainSearch extends Component {
  static propTpyes = {
    dict: PropTypes.object,    // 字典项
    formlist: PropTypes.any,
    standardform: PropTypes.any,
    card: PropTypes.object,
@@ -67,7 +66,7 @@
      if (item.key === 'linkSubField') {
        item.options.forEach(cell => {
          transfield[cell.field] = cell.label
          transfield[cell.field] = cell.label.replace(/^\d+、/, '')
        })
      }
    })
@@ -142,6 +141,9 @@
      }
      if (this.record.regular !== '') {
        shows.push('regularText')
        if (this.record.regular !== 'phone' && this.record.regular !== 'email') {
          shows.push('regularExtra')
        }
      }
    } else if (type === 'number') {
      reTypes.initval = 'number'
@@ -191,7 +193,7 @@
        if (this.record.resourceType === '0') {        // 自定义资源
          shows.push('options', 'fields')
        } else if (this.record.resourceType === '1') { // 数据源
          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database')
          shows.push('dataSource', 'cardValField', 'colorField', 'fields', 'orderBy', 'orderType', 'database')
        }
      } else {
        reRequired.fields = true
@@ -558,14 +560,23 @@
    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})
  }
  complete = (key, option) => {
    let label = option.props.label
    this.props.form.setFieldsValue({label: label})
  }
  getFields() {
    const { getFieldDecorator } = this.props.form
    const { dict } = this.props
    const { transfield } = this.state
    const fields = []
@@ -581,7 +592,7 @@
      if (item.type === 'text') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' },
          { required: item.required, message: '请输入' + item.label + '!' },
          {
            pattern: /^[^']*$/ig,
            message: '不可使用英文状态的单引号!'
@@ -595,6 +606,11 @@
            max: formRule.field.max,
            message: formRule.field.maxMessage
          })
        } else if (item.key === 'regularExtra') {
          rules.push({
            pattern: /^[~!@#$%^&*()_+:;{}<>,.-]*$/,
            message: '扩展符包括~!@#$%^&*()_+:;{}<>,.-'
          })
        } else if (item.max) {
          rules.push({
            max: item.max,
@@ -607,10 +623,23 @@
          })
        }
        content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
        if (item.key === 'field' && item.options && item.options.length > 0) {
          content = <AutoComplete
            dataSource={item.options.map((cell) => <AutoComplete.Option label={cell.label} value={cell.field} key={cell.uuid}>
              {cell.field}
            </AutoComplete.Option>)}
            filterOption={(input, option) => option.props.children.indexOf(input) > -1}
            onSelect={this.complete}
            placeholder=""
          >
            <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
          </AutoComplete>
        } else {
          content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
        }
      } else if (item.type === 'number') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        initVal = item.initVal
@@ -621,7 +650,7 @@
        }
      } else if (item.type === 'select') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <Select
          showSearch
@@ -649,7 +678,7 @@
        </Select>
      } else if (item.type === 'radio') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        initVal = item.initVal
@@ -662,7 +691,7 @@
        </Radio.Group>
      } else if (item.type === 'checkbox') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        initVal = item.initVal
@@ -671,7 +700,7 @@
        </Checkbox.Group>
      } else if (item.type === 'codemirror') {
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        span = 24
        className = 'text-area'
@@ -685,7 +714,7 @@
        span = 24
        className = 'text-msg'
        rules = [
          { required: item.required, message: dict['form.required.input'] + item.label + '!' }
          { required: item.required, message: '请输入' + item.label + '!' }
        ]
        content = <TextArea rows={item.rows || 4}/>
@@ -716,7 +745,7 @@
          if (this.record.linkField) {
            type = 'link'
          }
          content = <DataTable dict={this.props.dict} type={type} display={this.record.display} linkSubFields={linkSubFields} transfield={transfield} fields={this.record.fields || []} onChange={this.changeOptions}/>
          content = <DataTable type={type} display={this.record.display} linkSubFields={linkSubFields} transfield={transfield} fields={this.record.fields || []} onChange={this.changeOptions}/>
        }
      } else if (item.type === 'fields') {
        span = 24
@@ -729,13 +758,13 @@
      } else if (item.type === 'color') {
        className = 'color-form-item'
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <ColorSketch allowClear={true}/>
      } else if (item.type === 'icon') {
        rules = [
          { required: item.required, message: dict['form.required.select'] + item.label + '!' }
          { required: item.required, message: '请选择' + item.label + '!' }
        ]
        content = <MkEditIcon allowClear />
@@ -877,6 +906,10 @@
            values.initval = ''
          } else if (values.type === 'split') {
            values.span = 24
          } else if (values.type === 'text') {
            if (values.regularExtra) {
              values.regularExtra = Array.from(new Set(values.regularExtra.split(''))).join('')
            }
          }
          ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {