| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider, DragSource, DropTarget } from 'react-dnd' |
| | | import { Table, Input, InputNumber, Popconfirm, Form, Select, Radio, Cascader, notification, message, Modal, Typography } from 'antd' |
| | | import { CopyOutlined, EditOutlined, DeleteOutlined, SnippetsOutlined } from '@ant-design/icons' |
| | | import { CopyOutlined, EditOutlined, DeleteOutlined, SnippetsOutlined, SwapOutlined } from '@ant-design/icons' |
| | | |
| | | import Utils from '@/utils/utils.js' |
| | | import ColorSketch from '@/mob/colorsketch' |
| | |
| | | import CusSwitch from './cusSwitch' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | |
| | | ) |
| | | } else if (inputType === 'radio') { |
| | | return ( |
| | | <Radio.Group> |
| | | <Radio.Group style={{whiteSpace: 'nowrap'}}> |
| | | {options.map((item, i) => (<Radio key={i} value={item.field || item.value}> {item.label || item.text} </Radio>))} |
| | | </Radio.Group> |
| | | ) |
| | | } else if (inputType === 'textarea') { |
| | | return <Input.TextArea autoSize={true} placeholder=""/> |
| | | } else { |
| | | return <Input onPressEnter={() => this.getValue(form)}/> |
| | | } |
| | |
| | | |
| | | renderCell = (form) => { |
| | | const { getFieldDecorator } = form |
| | | const { editing, dataIndex, title, record, children, className, required, inputType } = this.props |
| | | const { editing, dataIndex, title, record, children, className, required, inputType, rules } = this.props |
| | | |
| | | return ( |
| | | <td className={className}> |
| | |
| | | { |
| | | required: required, |
| | | message: ['number', 'text', 'input'].includes(inputType) ? `${eTDict['form.required.input']} ${title}!` : `${eTDict['form.required.select']} ${title}!`, |
| | | } |
| | | }, |
| | | ...rules |
| | | ], |
| | | initialValue: inputType === 'multiStr' ? (record[dataIndex] ? record[dataIndex].split(',') : []) : record[dataIndex], |
| | | })(this.getInput(form))} |
| | |
| | | data: [], |
| | | editingKey: '', |
| | | visible: false, |
| | | editLineId: '', |
| | | columns: [] |
| | | } |
| | | |
| | |
| | | <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px', whiteSpace: 'nowrap'}}> |
| | | {actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><EditOutlined /></span> : null} |
| | | {actions.includes('copy') ? <span className="copy" onClick={() => {editingKey === '' && this.copy(record)}}><CopyOutlined /></span> : null} |
| | | {actions.includes('status') ? <span className="status" onClick={() => {editingKey === '' && this.handleStatus(record)}}><SwapOutlined /></span> : null} |
| | | {actions.includes('del') && editingKey === '' ? <Popconfirm |
| | | overlayClassName="popover-confirm" |
| | | title={eTDict['model.query.delete']} |
| | |
| | | } |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('editLineId', this.getEditLineId) |
| | | } |
| | | |
| | | componentWillUnmount () { |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('editLineId', this.getEditLineId) |
| | | } |
| | | |
| | | getEditLineId = (id) => { |
| | | this.setState({ editLineId: id }) |
| | | } |
| | | |
| | | isEditing = record => record.uuid === this.state.editingKey |
| | | |
| | | cancel = () => { |
| | |
| | | } |
| | | |
| | | try { |
| | | let srcid = localStorage.getItem(window.location.href.split('#')[0] + 'srcId') |
| | | if (srcid) { |
| | | msg.$srcId = srcid |
| | | } |
| | | |
| | | msg = window.btoa(window.encodeURIComponent(JSON.stringify(msg))) |
| | | } catch (e) { |
| | | console.warn('Stringify Failure') |
| | |
| | | }) |
| | | } |
| | | message.success('粘贴成功。') |
| | | }) |
| | | } |
| | | |
| | | handleStatus = (record) => { |
| | | const { data } = this.state |
| | | |
| | | record.status = record.status === 'false' ? 'true' : 'false' |
| | | |
| | | let newData = data.map(item => { |
| | | if (record.uuid === item.uuid) return record |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ data: newData }, () => { |
| | | this.props.onChange(newData) |
| | | }) |
| | | } |
| | | |
| | |
| | | |
| | | render() { |
| | | const { actions, indexShow } = this.props |
| | | const { editLineId } = this.state |
| | | |
| | | let components = { |
| | | body: { |
| | |
| | | inputType: col.inputType, |
| | | dataIndex: col.dataIndex, |
| | | options: col.options || [], |
| | | rules: col.rules || [], |
| | | min: col.min || 0, |
| | | max: col.max || 500, |
| | | unlimit: col.unlimit, |
| | |
| | | components={components} |
| | | dataSource={data} |
| | | columns={columns} |
| | | rowClassName="editable-row" |
| | | rowClassName={record => !editLineId || editLineId !== record.uuid ? 'editable-row' : 'editable-row active'} |
| | | pagination={false} |
| | | onRow={(record, index) => ({ |
| | | index, |