king
2021-11-19 53a5b5bea0fb1efae2b1793e6735754e78982d63
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, Icon, Radio, notification, InputNumber, Tooltip } from 'antd'
import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { formRule } from '@/utils/option.js'
@@ -16,6 +16,7 @@
const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
const FieldsTable = asyncComponent(() => import('./fieldtable'))
const DataTable = asyncComponent(() => import('./datatable'))
const MkIcon = asyncComponent(() => import('@/components/mkIcon'))
const modalTypeOptions = {
  text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom'],
@@ -33,6 +34,7 @@
  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'],
  color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'],
  rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'rateCount', 'character', 'place'],
  hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
  split: ['label', 'type', 'marginTop', 'marginBottom'],
  brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'],
@@ -112,20 +114,27 @@
      resourceType: resourceType,
      linkSubFields: linkSubFields,
      formlist: formlist.map(form => {
        if (dateOptions.hasOwnProperty(type) && form.key === 'initval') {
          form.options = dateOptions[type]
          form.type = 'select'
        } else if (type === 'switch' && form.key === 'initval') {
          form.initVal = !!form.initVal
          form.options = [
            {value: true, text: '开'},
            {value: false, text: '关'}
          ]
          form.type = 'radio'
        } else if (type === 'number' && form.key === 'initval') {
          form.type = 'number'
          form.initVal = form.initVal || 0
          form.required = true
        if (form.key === 'initval') {
          if (dateOptions.hasOwnProperty(type)) {
            form.options = dateOptions[type]
            form.type = 'select'
          } else if (type === 'switch') {
            form.initVal = !!form.initVal
            form.options = [
              {value: true, text: '开'},
              {value: false, text: '关'}
            ]
            form.type = 'radio'
          }
          if (type === 'number') {
            form.type = 'number'
            form.initVal = form.initVal || 0
            form.required = true
          } else if (type === 'rate') {
            form.type = 'number'
            form.initVal = form.initVal || 0
            form.required = false
          }
        } else if (form.key === 'label') {
          form.required = true
          if (type === 'hint') {
@@ -243,6 +252,10 @@
            } else if (value === 'number') {
              form.type = 'number'
              form.required = true
              form.initVal = 0
            } else if (value === 'rate') {
              form.type = 'number'
              form.required = false
              form.initVal = 0
            } else {
              form.type = 'text'
@@ -565,7 +578,7 @@
                >
                  {item.options.map((option, i) =>
                    <Select.Option key={`${i}`} value={option.value || option.field || ''}>
                      {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label}
                      {option.text || option.label}
                    </Select.Option>
                  )}
                </Select>
@@ -707,6 +720,27 @@
            </Form.Item>
          </Col>
        )
      } else if (item.type === 'icon') {
        fields.push(
          <Col span={12} key={index}>
            <Form.Item label={item.tooltip ?
              <Tooltip placement="topLeft" title={item.tooltip}>
                <QuestionCircleOutlined className="mk-form-tip" />
                {item.label}
              </Tooltip> : item.label
            }>
              {getFieldDecorator(item.key, {
                initialValue: item.initVal || '',
                rules: [{
                  required: !!item.required,
                  message: this.props.dict['form.required.select'] + item.label + '!'
                }]
              })(
                <MkIcon allowClear />
              )}
            </Form.Item>
          </Col>
        )
      }
    })