king
2023-02-03 b59af63c6742fa48de8fcdba67c9b8dc2e42bf94
src/templates/zshare/modalform/modaleditable/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Table, Input, Popconfirm, Form, Radio, message } from 'antd'
import { Table, Input, Popconfirm, Form, message } from 'antd'
import { ArrowUpOutlined, ArrowDownOutlined, DeleteOutlined, PlusOutlined, SwapOutlined } from '@ant-design/icons'
import { formRule } from '@/utils/option.js'
@@ -140,27 +140,9 @@
    })
  }
  getColumnSearchProps = column => ({
    filterDropdown: () => (
      <div style={{ padding: 8 }}>
        <Radio.Group onChange={(e) => this.changeDatatype(column, e)} value={column.datatype}>
          <Radio style={{display: 'block', height: '30px', lineHeight: '30px'}} value="string">
            字符串
          </Radio>
          <Radio style={{display: 'block', height: '30px', lineHeight: '30px'}} value="number">
            数字
          </Radio>
        </Radio.Group>
      </div>
    ),
    filterIcon: () => (
      <SwapOutlined style={{ color: column.datatype === 'number' ? '#1890ff' : ''}} />
    )
  })
  changeDatatype = (column, e) => {
  changeDatatype = (column) => {
    const { columns, dataSource } = this.state
    let value = e.target.value
    let value = column.datatype !== 'number' ? 'number' : 'string'
    let _data = dataSource.map(item => {
      let val = item[column.dataIndex]
      if (value === 'number') {
@@ -185,7 +167,16 @@
        }
        if (col.dataIndex !== 'operation') {
          col = {...col, ...this.getColumnSearchProps(col)}
          col.title = <div>
            Value
            <Popconfirm
              title={`确定切换为${col.datatype === 'number' ? '文本' : '数值'}吗?`}
              overlayClassName="popover-confirm"
              onConfirm={() => this.changeDatatype(col)
            }>
              <SwapOutlined style={{ color: col.datatype === 'number' ? '#1890ff' : ''}} />
            </Popconfirm>
          </div>
        }
        return col
@@ -376,7 +367,16 @@
    return {
      columns: columns.map(col => {
        if (col.dataIndex !== 'operation') {
          col = {...col, ...this.getColumnSearchProps(col)}
          col.title = <div>
            Value
            <Popconfirm
              title={`确定切换为${col.datatype === 'number' ? '文本' : '数值'}吗?`}
              overlayClassName="popover-confirm"
              onConfirm={() => this.changeDatatype(col)
            }>
              <SwapOutlined style={{ color: col.datatype === 'number' ? '#1890ff' : ''}} />
            </Popconfirm>
          </div>
        }
        return col
      }),