king
2025-02-19 1aa5654a0b51bb82948fff8bed77b166f25f11ea
src/templates/sharecomponent/columncomponent/markcolumn/markform/index.jsx
@@ -1,13 +1,13 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Select, Button, Input, InputNumber, Radio, Icon, Cascader, Tooltip } from 'antd'
import { Form, Row, Col, Select, Button, Input, Radio, Cascader } from 'antd'
import { minkeColorSystem, minkeIconSystem } from '@/utils/option.js'
import MkIcon from '@/components/mk-icon'
import './index.scss'
class UniqueForm extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    card: PropTypes.object,         // 字段信息
    columns: PropTypes.array,       // 列名集合
    markChange: PropTypes.func      // 修改函数
@@ -40,12 +40,25 @@
    const { columns } = this.props
    let item = columns.filter(col => col.field === record.field)[0]
    let _type = 'background '
    if (record.signType === 'icon' || record.signType === 'font') {
      _type = 'font '
    }
    this.setState({
      originField: item || '',
      editItem: record,
      contrastType: record.contrastType || '',
      signType: record.signType || '',
      selectIcon: record.icon || ''
      selectIcon: record.icon || '',
      options: this.state.options.map(option => {
        option.children = option.children.map(cell => {
          cell.label = <div className={_type + cell.value}>{record.icon ? <MkIcon type={record.icon} /> : cell.value}</div>
          return cell
        })
        return option
      })
    }, () => {
      let fieldvalue = {}
      Object.keys(record).forEach(key => {
@@ -132,7 +145,7 @@
      selectIcon: val,
      options: this.state.options.map(option => {
        option.children = option.children.map(cell => {
          cell.label = <div className={'font ' + cell.value}><Icon type={val} /></div>
          cell.label = <div className={'font ' + cell.value}><MkIcon type={val} /></div>
          return cell
        })
@@ -170,19 +183,17 @@
      }
    }
    let contFields = columns.filter(col => originField.field !== col.field && originField.type === col.type)
    return (
      <Form {...formItemLayout} id="model-mark-form-box" className="mingke-table">
        <Row gutter={24}>
          <Col span={6}>
            <Form.Item label={'字段'}>
            <Form.Item label="字段">
              {getFieldDecorator('field', {
                initialValue: originField.field,
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '字段!'
                    message: '请选择字段!'
                  }
                ]
              })(
@@ -199,7 +210,7 @@
            </Form.Item>
          </Col>
          <Col span={6}>
            <Form.Item label={'对比类型'}>
            <Form.Item label="对比类型">
              {getFieldDecorator('contrastType', {
                initialValue: 'static'
              })(
@@ -211,46 +222,41 @@
            </Form.Item>
          </Col>
          <Col span={6}>
            <Form.Item label={'对比方式'}>
            <Form.Item label="对比方式">
              {getFieldDecorator('match', {
                initialValue: '=',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '对比方式!'
                    message: '请选择对比方式!'
                  }
                ]
              })(
                <Select>
                  <Select.Option value="="> = </Select.Option>
                  {originField.type === 'number' ? <Select.Option value=">"> > </Select.Option> : null}
                  {originField.type === 'number' ? <Select.Option value="<"> &lt; </Select.Option> : null}
                  {originField.type === 'text' ? <Select.Option value="like"> like </Select.Option> : null}
                  <Select.Option value="!="> != </Select.Option>
                  <Select.Option value=">"> &gt; </Select.Option>
                  <Select.Option value="<"> &lt; </Select.Option>
                  <Select.Option value="like"> like </Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col>
          {contrastType === 'static' ? <Col span={6}>
            <Form.Item label={'对比值'}>
            <Form.Item label="对比值">
              {getFieldDecorator('contrastValue', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '对比值!'
                  }
                ]
              })(originField.type === 'number' ? <InputNumber /> : <Input placeholder="" autoComplete="off" />)}
                initialValue: ''
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col> : null}
          {contrastType === 'dynamic' ? <Col span={6}>
            <Form.Item label={'对比字段'}>
            <Form.Item label="对比字段">
              {getFieldDecorator('contrastField', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '对比字段!'
                    message: '请选择对比字段!'
                  }
                ]
              })(
@@ -258,7 +264,7 @@
                  showSearch
                  filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                >
                  {contFields.map(item => (
                  {columns.map(item => (
                    <Select.Option key={item.uuid} title={item.label + '(' + item.field + ')'} value={item.field}>{item.label + '(' + item.field + ')'}</Select.Option>
                  ))}
                </Select>
@@ -266,18 +272,13 @@
            </Form.Item>
          </Col> : null}
          <Col span={6}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="卡片类型,在卡片图表中起效">
                <Icon type="question-circle" />
                {'标记'}
              </Tooltip>
            }>
            <Form.Item label="标记方式">
              {getFieldDecorator('signType', {
                initialValue: 'background',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '标记方式!'
                    message: '请选择标记方式!'
                  }
                ]
              })(
@@ -313,25 +314,24 @@
                  <Select.Option value="hint">提示建议性图标</Select.Option>
                  <Select.Option value="edit">编辑类图标</Select.Option>
                  <Select.Option value="data">数据类图标</Select.Option>
                  <Select.Option value="trademark">品牌和标识</Select.Option>
                  <Select.Option value="normal">网站通用图标</Select.Option>
                </Select>
              )}
            </Form.Item>
          </Col> : null}
          {signType === 'icon' ? <Col span={6}>
            <Form.Item label={'图标'}>
            <Form.Item label="图标">
              {getFieldDecorator('icon', {
                initialValue: '',
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '图标!'
                    message: '请选择图标!'
                  }
                ]
              })(
                <Select onChange={this.changeIcon} getPopupContainer={() => document.getElementById('model-mark-form-box')}>
                  {icons.map(icon => <Select.Option key={icon} value={icon}><Icon type={icon} /></Select.Option>)}
                  {icons.map(icon => <Select.Option key={icon} value={icon}><MkIcon type={icon} /></Select.Option>)}
                </Select>
              )}
            </Form.Item>
@@ -343,14 +343,14 @@
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.select'] + '颜色!'
                    message: '请选择颜色!'
                  }
                ]
              })(
                <Cascader
                  options={options}
                  placeholder=""
                  displayRender={(label, selectedOptions) => selectedOptions[0] ? selectedOptions[0].label + ' / ' + selectedOptions[1].value : ''}
                  displayRender={(label, selectedOptions) => selectedOptions[0] ? selectedOptions[0].label + (selectedOptions[1] ? ' / ' + selectedOptions[1].value : '') : ''}
                  getPopupContainer={() => document.getElementById('model-mark-form-box')}
                />
              )}