| | |
| | | import { fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Input, InputNumber, Popconfirm, Form, Select, Radio, Cascader, notification, Typography, Button } from 'antd' |
| | | import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons' |
| | | import { PlusOutlined, EditOutlined, DeleteOutlined, ArrowRightOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import ColorSketch from '@/mob/colorsketch' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | |
| | | |
| | | class EditableCell extends Component { |
| | | getInput = (form) => { |
| | | const { inputType, options, min, max, unlimit } = this.props |
| | | const { inputType, options, min, max, unlimit, allowClear } = this.props |
| | | |
| | | if (inputType === 'number' && unlimit) { |
| | | return <InputNumber onPressEnter={() => this.getValue(form)} /> |
| | | } else if (inputType === 'number') { |
| | | return <InputNumber min={min} max={max} precision={0} onPressEnter={() => this.getValue(form)} /> |
| | | } else if (inputType === 'color') { |
| | | return <ColorSketch /> |
| | | return <ColorSketch allowClear={allowClear}/> |
| | | } else if (inputType === 'icon') { |
| | | return <MkEditIcon allowClear/> |
| | | } else if (inputType === 'select') { |
| | | return ( |
| | | <Select> |
| | | {options.map((item, i) => (<Select.Option key={i} value={item.field || item.value}> {item.label || item.text} </Select.Option>))} |
| | | <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}> |
| | | {options.map((item, i) => (<Select.Option key={i} value={item.field || item.value}>{item.label || item.text}</Select.Option>))} |
| | | </Select> |
| | | ) |
| | | } else if (inputType === 'multiStr') { |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | let actions = this.props.actions || [] |
| | | let columns = fromJS(this.props.columns).toJS() |
| | | |
| | | let operation = { |
| | |
| | | <span className="danger"><DeleteOutlined /></span> |
| | | </Popconfirm> : null} |
| | | {editingKey !== '' ? <span className="danger"><DeleteOutlined /></span> : null} |
| | | {actions.includes('view') ? <span className="copy" onClick={() => {editingKey === '' && this.changeMenu(record.menu)}}><ArrowRightOutlined /></span> : null} |
| | | </div> |
| | | ) |
| | | } |
| | |
| | | // shouldComponentUpdate (nextProps, nextState) { |
| | | // return !is(fromJS(this.state), fromJS(nextState)) |
| | | // } |
| | | |
| | | changeMenu = (MenuId) => { |
| | | if (MenuId === 'IM') { |
| | | if (!sessionStorage.getItem('instantMessage')) return |
| | | |
| | | let param = { |
| | | MenuID: sessionStorage.getItem('instantMessage'), |
| | | copyMenuId: '', |
| | | type: 'view' |
| | | } |
| | | |
| | | param = window.btoa(window.encodeURIComponent(JSON.stringify(param))) |
| | | |
| | | MKEmitter.emit('changeEditMenu', {routerUrl: '/imdesign/' + param}) |
| | | } else { |
| | | MKEmitter.emit('changeEditMenu', {MenuID: MenuId}) |
| | | } |
| | | } |
| | | |
| | | isEditing = record => record.uuid === this.state.editingKey |
| | | |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { fixed } = this.props |
| | | let components = { |
| | | body: { |
| | | cell: EditableCell |
| | |
| | | unlimit: col.unlimit, |
| | | required: col.required !== false ? true : false, |
| | | title: col.title, |
| | | allowClear: col.allowClear === true, |
| | | editing: this.isEditing(record), |
| | | onSave: this.execSave, |
| | | }), |
| | |
| | | return ( |
| | | <EditableContext.Provider value={this.props.form}> |
| | | <div className="modal-editable-table"> |
| | | <Button disabled={!!this.state.editingKey} type="link" onClick={this.addline}><PlusOutlined style={{}}/></Button> |
| | | {!fixed ? <Button disabled={!!this.state.editingKey} type="link" onClick={this.addline}><PlusOutlined style={{}}/></Button> : null} |
| | | <DndProvider> |
| | | <Table |
| | | bordered |
| | |
| | | })} |
| | | /> |
| | | </DndProvider> |
| | | {this.props.tip ? this.props.tip : null} |
| | | </div> |
| | | </EditableContext.Provider> |
| | | ) |