| | |
| | | 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' |
| | |
| | | }) |
| | | } |
| | | |
| | | 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') { |
| | |
| | | } |
| | | |
| | | 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 |
| | |
| | | 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 |
| | | }), |