| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Table, Typography, Modal, Input, InputNumber, Button, notification, message, Select } from 'antd' |
| | | import { EditOutlined } from '@ant-design/icons' |
| | | import { Table, Typography, Modal, Input, InputNumber, Switch, Button, notification, message, Select, DatePicker } from 'antd' |
| | | import { EditOutlined, QuestionCircleOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | import md5 from 'md5' |
| | | |
| | | import Api from '@/api' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Utils, { getEditTableSql, getMark } from '@/utils/utils.js' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import CusSwitch from './cusSwitch' |
| | | import Encrypts from '@/components/encrypts' |
| | | import './index.scss' |
| | | |
| | | const { Paragraph } = Typography |
| | | const MkIcon = asyncComponent(() => import('@/components/mk-icon')) |
| | | const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList')) |
| | | |
| | | class CusSwitch extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | autoFocus: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | status: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { defaultValue, config } = this.props |
| | | |
| | | let status = false |
| | | |
| | | if (defaultValue === config.openVal) { |
| | | status = true |
| | | } |
| | | |
| | | this.setState({status}) |
| | | } |
| | | |
| | | changeStatus = (val) => { |
| | | const { config } = this.props |
| | | this.setState({ status: val }, () => { |
| | | let _val = val ? config.openVal : config.closeVal |
| | | let _text = val ? config.openText : config.closeText |
| | | this.props.onChange(_val, _text) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { config, autoFocus } = this.props |
| | | const { status } = this.state |
| | | return ( |
| | | <Switch checkedChildren={config.openText} autoFocus={autoFocus} onBlur={this.props.onBlur} unCheckedChildren={config.closeText} checked={status} onChange={this.changeStatus} /> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class CusDatePicker extends Component { |
| | | static propTpyes = { |
| | | defaultValue: PropTypes.any, |
| | | config: PropTypes.object, |
| | | onChange: PropTypes.func, |
| | | blur: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | value: null, |
| | | open: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { value, open } = this.props |
| | | |
| | | let _value = value || null |
| | | if (_value) { |
| | | _value = moment(_value, 'YYYY-MM-DD HH:mm:ss') |
| | | } |
| | | |
| | | this.setState({value: _value, open: open === true}) |
| | | } |
| | | |
| | | onOpenChange = (open) => { |
| | | this.setState({open}) |
| | | |
| | | if (open === false) { |
| | | this.props.blur() |
| | | } |
| | | } |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { value, open } = this.state |
| | | |
| | | return ( |
| | | <DatePicker dropdownClassName={'mk-date-picker ' + config.precision} showTime={config.format !== 'YYYY-MM-DD'} format={config.format} open={open} defaultValue={value} onChange={this.props.onChange} onOpenChange={this.onOpenChange}/> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | class BodyRow extends React.Component { |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | |
| | | this.setState({editing: false}) |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | } |
| | | }, 50) |
| | | |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (col.editField) { |
| | | values[col.field] = _option.label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | values[col.field] = val |
| | | } |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onDateChange = (val) => { |
| | | const { col, record } = this.props |
| | | |
| | | let _val = val ? moment(val).format(col.format) : '' |
| | | |
| | | if (col.precision === 'hour') { |
| | | _val = _val + ':00:00' |
| | | } else if (col.precision === 'minute') { |
| | | _val = _val + ':00' |
| | | } |
| | | |
| | | this.setState({editing: false}) |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | let node = document.getElementById(col.enter + record.$$uuid) |
| | | node && node.click() |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: _val}) |
| | | } |
| | | |
| | | switchBlur = () => { |
| | |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.textFormat === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` |
| | |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (col.editable === 'true' && !disabled) { |
| | | if (editing) { |
| | | if (!col.editType || col.editType === 'text') { |
| | | return (<td className="editing_table_cell"> |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <Input className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </td>) |
| | | } else if (col.editType === 'date') { |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <CusDatePicker config={col} value={record[col.field] || null} open={true} onChange={this.onDateChange} blur={() => this.setState({editing: false})}/> |
| | | </td>) |
| | | } else if (col.editType === 'switch') { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/> |
| | | </td>) |
| | | } else { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <Select |
| | | showSearch |
| | | defaultValue={_value} |
| | |
| | | </td>) |
| | | } |
| | | } else { |
| | | return (<td className={className + ' pointer'} style={style}> |
| | | return (<td onClick={(e) => e.stopPropagation()} className={className + ' pointer'} style={style}> |
| | | <div className="mk-mask" id={col.uuid + record.$$uuid} onClick={this.focus}></div>{content} |
| | | </td>) |
| | | } |
| | |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (col.noValue === 'hide' && value === 0) { |
| | | val = '' |
| | | } |
| | | return (<td className="editing_table_cell"> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell"> |
| | | <InputNumber className={err ? 'has-error' : ''} precision={col.decimal || 0} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </td>) |
| | | } else { |
| | | return (<td className={className + ' pointer'} style={style}> |
| | | return (<td onClick={(e) => e.stopPropagation()} className={className + ' pointer'} style={style}> |
| | | <div className="mk-mask" id={col.uuid + record.$$uuid} onClick={this.focus}></div>{content} |
| | | </td>) |
| | | } |
| | |
| | | ) |
| | | } else if (col.type === 'formula') { |
| | | let content = col.formula |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | | }) |
| | | |
| | | if (col.eval !== 'false') { |
| | | if (col.eval === 'func') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | let func = new Function('data', col.formula) |
| | | content = func([record]) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | | } else { |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | | }) |
| | | |
| | | if (col.eval !== 'false') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | console.info(content) |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | content = '' |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.round && typeof(content) === 'number') { |
| | | content = Math.round(content * col.round) / col.round |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | |
| | | if (col.eval === 'func') { |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |
| | | } else if (content !== '') { |
| | | content = `${col.prefix || ''}${content}${col.postfix || ''}` |
| | | content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | style = {...style, ...col.style} |
| | | } |
| | | |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } else if (col.type === 'action') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | |
| | | this.onBlur() |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | const { col, record } = this.props |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | } |
| | | }, 50) |
| | | |
| | | let values = {} |
| | | if (col.editField) { |
| | | values[col.field] = label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | onSelectChange = (val, option) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | if (col.editField) { |
| | | values[col.field] = _option.label |
| | | values[col.editField] = val |
| | | } else { |
| | | values[col.field] = val |
| | | } |
| | | values[col.field] = val |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | if (col.enter === '$next') { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, ...values}) |
| | | } |
| | | |
| | | onDateChange = (val) => { |
| | | const { col, record } = this.props |
| | | |
| | | let _val = val ? moment(val).format(col.format) : '' |
| | | |
| | | if (col.precision === 'hour') { |
| | | _val = _val + ':00:00' |
| | | } else if (col.precision === 'minute') { |
| | | _val = _val + ':00' |
| | | } |
| | | |
| | | setTimeout(() => { |
| | | if (/\$next/.test(col.enter)) { |
| | | MKEmitter.emit('nextLine', col, record.$$uuid) |
| | | } else if (col.enter === '$sub') { |
| | | MKEmitter.emit('subLine', col, record) |
| | | } else if (col.enter !== '$noAct') { |
| | | let node = document.getElementById(col.enter + record.$$uuid) |
| | | node && node.click() |
| | | } |
| | | }, 50) |
| | | |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: _val}) |
| | | } |
| | | |
| | | render() { |
| | | let { col, config, record, style, className, ...resProps } = this.props |
| | | const { err } = this.state |
| | |
| | | if (!col) return (<td {...resProps} className={className} style={style}/>) |
| | | |
| | | let disabled = false |
| | | let editable = false |
| | | if (col.ctrlField) { |
| | | disabled = col.ctrlValue.includes(record[col.ctrlField]) |
| | | } |
| | |
| | | let children = null |
| | | if (col.type === 'text') { |
| | | if (col.editable === 'true' && !disabled) { |
| | | let _value = '' |
| | | if (col.editField) { |
| | | _value = record[col.editField] !== undefined ? record[col.editField] : '' |
| | | } else { |
| | | _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | } |
| | | editable = true |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (!col.editType || col.editType === 'text') { |
| | | children = (<> |
| | |
| | | } else if (col.editType === 'switch') { |
| | | children = ( |
| | | <CusSwitch config={col} autoFocus={false} defaultValue={_value} onChange={this.onSwitchChange} onBlur={() => {}}/> |
| | | ) |
| | | } else if (col.editType === 'date') { |
| | | children = ( |
| | | <CusDatePicker config={col} value={record[col.field] || null} onChange={this.onDateChange} blur={() => {}}/> |
| | | ) |
| | | } else { |
| | | children = (<> |
| | |
| | | content = `${record[col.field]}` |
| | | } |
| | | |
| | | if (col.editType === 'select' && col.options.length > 0) { |
| | | content = col.map.get(content) || content |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.textFormat === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) { |
| | | content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}` |
| | |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (col.editable === 'true' && disabled) { |
| | | content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span> |
| | | } |
| | | |
| | | children = content |
| | | } |
| | | } else if (col.type === 'number') { |
| | | if (col.editable === 'true' && !disabled) { |
| | | editable = true |
| | | let _value = record[col.field] !== undefined ? record[col.field] : '' |
| | | |
| | | if (col.noValue === 'hide' && _value === 0) { |
| | |
| | | } |
| | | |
| | | children = (<> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | <InputNumber className={err ? 'has-error' : ''} title={err} precision={col.decimal || 0} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/> |
| | | </>) |
| | | } else { |
| | | let content = '' |
| | |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (col.editable === 'true' && disabled) { |
| | | content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span> |
| | | } |
| | | |
| | | children = content |
| | | } |
| | | } else if (col.type === 'textarea') { |
| | |
| | | ) |
| | | } else if (col.type === 'formula') { |
| | | let content = col.formula |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | | }) |
| | | |
| | | if (col.eval !== 'false') { |
| | | if (col.eval === 'func') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | let func = new Function('data', col.formula) |
| | | content = func([record]) |
| | | } catch (e) { |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | | } else { |
| | | Object.keys(record).forEach(key => { |
| | | let reg = new RegExp('@' + key + '@', 'ig') |
| | | content = content.replace(reg, record[key]) |
| | | }) |
| | | |
| | | if (col.eval !== 'false') { |
| | | try { |
| | | // eslint-disable-next-line |
| | | content = eval(content) |
| | | } catch (e) { |
| | | console.info(content) |
| | | console.warn(e) |
| | | content = '' |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | content = '' |
| | | } |
| | | |
| | | if (content !== '') { |
| | | if (col.round && typeof(content) === 'number') { |
| | | content = Math.round(content * col.round) / col.round |
| | | content = content.toFixed(col.decimal) |
| | | } |
| | | |
| | | if (col.eval === 'func') { |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |
| | | } else if (content !== '') { |
| | | content = `${col.prefix || ''}${content}${col.postfix || ''}` |
| | | content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, ' ') |
| | | content = <span dangerouslySetInnerHTML={{__html: content}}></span> |
| | | } |
| | | |
| | | if (col.marks) { |
| | | let mark = getMark(col.marks, record, style) |
| | | style = style ? {...style} : {} |
| | | |
| | | style = mark.style |
| | | let mark = getMark(col.marks, record, style) |
| | | |
| | | if (mark.icon) { |
| | | if (mark.position === 'front') { |
| | |
| | | } |
| | | } else if (mark.innerStyle) { |
| | | content = <span style={mark.innerStyle}>{content}</span> |
| | | } else if (mark.space) { |
| | | content = <><span dangerouslySetInnerHTML={{__html: mark.space}}></span>{content}</> |
| | | } else if (mark.point) { |
| | | if (mark.position === 'front') { |
| | | content = <>{mark.point}{content}</> |
| | | } else { |
| | | content = <>{content}{mark.point}</> |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } else if (col.type === 'action') { |
| | | style.padding = '0px' |
| | | if (col.style) { |
| | | style = {...style, ...col.style} |
| | | } |
| | | children = ( |
| | | <CardCellComponent data={record} cards={config} elements={col.elements}/> |
| | | ) |
| | | } |
| | | |
| | | if (editable) { |
| | | return (<td onClick={(e) => e.stopPropagation()} className={'editing_all_table_cell ' + className} style={style}>{children}</td>) |
| | | } |
| | | |
| | | return (<td className={'editing_all_table_cell ' + className} style={style}>{children}</td>) |
| | |
| | | loading: PropTypes.bool, // 表格加载中 |
| | | refreshdata: PropTypes.func, // 表格中排序列、页码的变化时刷新 |
| | | chgSelectData: PropTypes.func, |
| | | allSearch: PropTypes.any, |
| | | colsCtrls: PropTypes.any |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | edData: [], |
| | | selectedRowKeys: [], // 表格中选中行 |
| | | tableId: '', // 表格ID |
| | |
| | | pageSize: 10, // 每页数据条数 |
| | | columns: null, // 显示列 |
| | | forms: [], |
| | | signForms: [], |
| | | orderfields: {}, // 排序id与field转换 |
| | | loading: false, |
| | | pageOptions: [], |
| | | deForms: null |
| | | deForms: null, |
| | | visible: false, |
| | | midData: null, |
| | | allColumns: null, |
| | | reseting: false |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { setting, fields, columns, BID } = this.props |
| | | const { setting, fields, columns, BID, colsCtrls } = this.props |
| | | let orderfields = {} |
| | | |
| | | let _columns = [] |
| | | let deForms = [] |
| | | let _forms = {} |
| | | let hasBid = false |
| | | let signForms = [] |
| | | |
| | | let getColumns = (cols) => { |
| | | return cols.map(item => { |
| | | let cell = null |
| | | |
| | | if (item.type === 'colspan') { |
| | | cell = { title: item.label, align: item.Align } |
| | | cell = { title: item.label, align: item.Align, $key: item.uuid } |
| | | cell.children = getColumns(item.subcols) |
| | | } else { |
| | | if (item.editable === 'true') { |
| | | _forms[item.field] = item |
| | | |
| | | signForms.push(item.field) |
| | | |
| | | if (item.ctrlField) { |
| | | item.ctrlValue = item.ctrlValue.split(',') |
| | | } |
| | | |
| | | if (item.type === 'text' && item.editType === 'select' && item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (/@BID@/ig.test(_option.sql)) { |
| | | hasBid = true |
| | | if (item.type === 'text' && item.editType === 'select') { |
| | | item.map = new Map() |
| | | if (item.resourceType === '1') { |
| | | let _option = Utils.getSelectQueryOptions(item) |
| | | |
| | | if (/@BID@/ig.test(_option.sql)) { |
| | | hasBid = true |
| | | } |
| | | |
| | | item.base_sql = _option.sql |
| | | item.arr_field = _option.field |
| | | |
| | | deForms.push(item) |
| | | } else { |
| | | item.options.forEach(cell => { |
| | | item.map.set(cell.value, cell.label) |
| | | }) |
| | | } |
| | | |
| | | item.base_sql = _option.sql |
| | | item.arr_field = _option.field |
| | | |
| | | deForms.push(item) |
| | | } else if (item.type === 'text' && item.editType === 'date') { |
| | | item.format = 'YYYY-MM-DD' |
| | | |
| | | if (item.precision === 'hour') { |
| | | item.format = 'YYYY-MM-DD HH' |
| | | } else if (item.precision === 'minute') { |
| | | item.format = 'YYYY-MM-DD HH:mm' |
| | | } else if (item.precision === 'second') { |
| | | item.format = 'YYYY-MM-DD HH:mm:ss' |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (item.field) { |
| | | orderfields[item.uuid] = item.field |
| | | } else if (item.sortField) { |
| | | orderfields[item.uuid] = item.sortField |
| | | } |
| | | |
| | | cell = { |
| | | align: item.Align, |
| | | dataIndex: item.uuid, |
| | | title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label, |
| | | sorter: !!(item.field && item.IsSort === 'true'), |
| | | sorter: (item.field || item.sortField) && item.IsSort === 'true', |
| | | width: item.Width || 120, |
| | | $type: item.type, |
| | | // $type: item.type, |
| | | $key: item.uuid, |
| | | onCell: record => ({ |
| | | record, |
| | | col: item, |
| | | config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, |
| | | config: item.type === 'custom' ? {setting, columns: fields} : null, |
| | | }) |
| | | } |
| | | } |
| | |
| | | if (item.field === setting.primaryKey) return |
| | | |
| | | if (_forms[item.field]) { |
| | | forms.push({..._forms[item.field], datatype: item.datatype}) |
| | | let _item = {..._forms[item.field]} |
| | | if (_item.editType === 'date') { |
| | | _item.datatype = _item.declareType || 'datetime' |
| | | } else { |
| | | _item.datatype = item.datatype |
| | | } |
| | | forms.push(_item) |
| | | } else { |
| | | forms.push(item) |
| | | } |
| | |
| | | pageOptions = pageOptions.sort((a, b) => a - b) |
| | | } |
| | | |
| | | let allColumns = null |
| | | if (colsCtrls) { |
| | | allColumns = [..._columns] |
| | | _columns = this.getCurColumns(_columns, this.props.allSearch) |
| | | } |
| | | |
| | | this.setState({ |
| | | forms, |
| | | signForms, |
| | | allColumns, |
| | | pageSize: setting.pageSize || 10, |
| | | pageOptions, |
| | | columns: _columns, |
| | |
| | | MKEmitter.removeListener('changeRecord', this.changeRecord) |
| | | } |
| | | |
| | | getCurColumns = (columns, allSearch) => { |
| | | const { colsCtrls } = this.props |
| | | |
| | | let values = {} |
| | | allSearch.forEach(item => { |
| | | values[item.key] = item.value |
| | | }) |
| | | let cols = null |
| | | colsCtrls.some(item => { |
| | | let originVal = item.field.map(f => values[f] || '').join('') |
| | | let contrastVal = item.contrastValue |
| | | let result = false |
| | | |
| | | if (item.match === '=') { |
| | | result = originVal === contrastVal |
| | | } else if (item.match === '!=') { |
| | | result = originVal !== contrastVal |
| | | } else { |
| | | originVal = isNaN(originVal) ? originVal : +originVal |
| | | contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal |
| | | if (item.match === '>') { |
| | | result = originVal > contrastVal |
| | | } else if (item.match === '<') { |
| | | result = originVal < contrastVal |
| | | } |
| | | } |
| | | |
| | | if (!result) return false |
| | | |
| | | cols = item.cols |
| | | |
| | | return true |
| | | }) |
| | | |
| | | if (cols) { |
| | | return columns.filter(col => cols.includes(col.$key)) |
| | | } |
| | | |
| | | return columns |
| | | } |
| | | |
| | | transferData = (menuid, data, type) => { |
| | | const { MenuID, setting } = this.props |
| | | const { edData, signForms } = this.state |
| | | |
| | | if (menuid !== MenuID) return |
| | | |
| | | if (type !== 'line') { |
| | | this.setState({edData: data}) |
| | | if (setting.commit !== 'all' && setting.standard !== 'change') { |
| | | if (type !== 'line') { |
| | | data.forEach(item => { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += item[field] |
| | | }) |
| | | item.$sign = md5(value) |
| | | }) |
| | | } else { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += data[field] |
| | | }) |
| | | data.$sign = md5(value) |
| | | } |
| | | } |
| | | |
| | | if (setting.addable && data.length === 0) { |
| | | setTimeout(() => { |
| | | this.plusLine(true) |
| | | }, 10) |
| | | if (type !== 'line') { |
| | | let index = edData.findIndex(item => !item.$origin && !item.$forbid) |
| | | |
| | | if (index > -1) { |
| | | this.setState({visible: true, midData: data}) |
| | | } else { |
| | | this.updateMutil(data) |
| | | } |
| | | } else if (type === 'line') { |
| | | let _edData = this.state.edData.map(item => { |
| | |
| | | } |
| | | } |
| | | |
| | | updateMutil = (data) => { |
| | | const { setting, colsCtrls, allSearch } = this.props |
| | | const { allColumns } = this.state |
| | | |
| | | if (colsCtrls) { |
| | | this.setState({ |
| | | columns: this.getCurColumns(allColumns, allSearch), |
| | | reseting: true, |
| | | edData: data, |
| | | visible: false, |
| | | midData: null |
| | | }, () => { |
| | | this.setState({ |
| | | reseting: false |
| | | }) |
| | | }) |
| | | |
| | | return |
| | | } |
| | | |
| | | if (setting.editType === 'multi' && data.length > 0) { |
| | | this.setState({edData: []}, () => { |
| | | this.setState({edData: data, visible: false, midData: null}) |
| | | }) |
| | | } else { |
| | | this.setState({edData: data, visible: false, midData: null}) |
| | | } |
| | | |
| | | if (setting.addable && data.length === 0) { |
| | | setTimeout(() => { |
| | | this.plusLine(true) |
| | | }, 10) |
| | | } |
| | | } |
| | | |
| | | improveActionForm = (deForms, BID) => { |
| | | const { setting } = this.props |
| | | |
| | |
| | | let mainItems = [] // 云端或单点数据 |
| | | let localItems = [] // 本地数据 |
| | | let cache = setting.cache !== 'false' |
| | | let debug = window.GLOB.debugger === true || window.debugger === true |
| | | let debug = window.GLOB.debugger === true |
| | | let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n` |
| | | let _sso = _sql |
| | | |
| | |
| | | } |
| | | |
| | | resetFormList = (result) => { |
| | | const { columns } = this.state |
| | | const { columns, edData } = this.state |
| | | |
| | | let _edColumns = [] |
| | | |
| | |
| | | this.props.columns.forEach(item => { |
| | | if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) { |
| | | let options = [] |
| | | let _map = new Map() |
| | | let all = false |
| | | result[item.uuid].forEach(cell => { |
| | | let _cell = {key: Utils.getuuid()} |
| | |
| | | } |
| | | } |
| | | |
| | | if (_map.has(_cell.value)) return |
| | | _map.set(_cell.value, 0) |
| | | if (item.map.has(_cell.value)) return |
| | | item.map.set(_cell.value, _cell.label) |
| | | |
| | | if (item.linkSubField) { |
| | | item.linkSubField.forEach(m => { |
| | |
| | | |
| | | item.options = options |
| | | |
| | | reCols[item.uuid] = item |
| | | reCols[item.uuid] = fromJS(item).toJS() |
| | | } |
| | | }) |
| | | |
| | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({columns: []}, () => { |
| | | this.setState({columns: _edColumns}) |
| | | let _cols = this.state.allColumns |
| | | if (_cols) { |
| | | _cols = _cols.map(item => { |
| | | if (reCols[item.dataIndex]) { |
| | | item.onCell = record => ({ |
| | | record, |
| | | col: reCols[item.dataIndex] |
| | | }) |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | this.setState({columns: [], edData: [], allColumns: _cols}, () => { |
| | | this.setState({columns: _edColumns, edData: edData}) |
| | | }) |
| | | } |
| | | |
| | |
| | | let next = edData[index + 1] || null |
| | | |
| | | if (next) { |
| | | let node = document.getElementById(setting.initId + next.$$uuid) |
| | | let nextId = setting.initId + next.$$uuid |
| | | if (/^\$next_/.test(col.enter)) { |
| | | nextId = col.enter.split('_')[1] + next.$$uuid |
| | | } |
| | | |
| | | let node = document.getElementById(nextId) |
| | | if (node) { |
| | | if (setting.editType === 'multi') { |
| | | if (setting.triType === 'click') { |
| | |
| | | let _data = edData.filter(item => item.$$uuid !== record.$$uuid) |
| | | this.setState({edData: _data}) |
| | | } else { |
| | | let _data = edData.map(item => { |
| | | let _data = fromJS(edData).toJS().map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | record.$deleted = true |
| | | record.$origin = false |
| | | record.$type = 'del' |
| | | return record |
| | | } else { |
| | | return item |
| | | item.$deleted = true |
| | | item.$origin = false |
| | | item.$type = 'del' |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.commit === 'simple' && record.$deleted) { |
| | | if (setting.commit === 'simple') { |
| | | this.submit() |
| | | } |
| | | }) |
| | |
| | | |
| | | changeRecord = (id, record) => { |
| | | const { setting } = this.props |
| | | const { tableId } = this.state |
| | | const { tableId, signForms } = this.state |
| | | |
| | | if (id !== tableId) return |
| | | |
| | | let lock = record.$lock |
| | | if (!record.$sign) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | delete record.$forbid |
| | | } else { |
| | | let value = '' |
| | | signForms.forEach(field => { |
| | | value += record[field] |
| | | }) |
| | | |
| | | if (record.$sign !== md5(value)) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | } else { |
| | | record.$origin = true |
| | | record.$lock = false |
| | | } |
| | | } |
| | | |
| | | let _data = this.state.edData.map(item => { |
| | | if (item.$$uuid === record.$$uuid) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | |
| | | delete record.$forbid |
| | | |
| | | return record |
| | | } else { |
| | | return item |
| | |
| | | }) |
| | | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.tableType && setting.hasAction && !lock && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | this.selectdata(this.state.selectedRowKeys) |
| | | } |
| | | }) |
| | |
| | | let val = item[col.field] !== undefined ? (item[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | line.push(`${col.label}不可为空`) |
| | | } else if (col.datatype === 'datetime' && !val) { |
| | | val = '1949-10-01' |
| | | } |
| | | item[col.field] = val |
| | | } else if (col.type === 'number') { |
| | |
| | | const { submit, BID, setting } = this.props |
| | | const { forms } = this.state |
| | | |
| | | this.setState({visible: false, midData: null}) |
| | | |
| | | if (setting.supModule && !BID) { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | if (submit.intertype === 'system') { // 系统存储过程 |
| | | param.func = 'sPC_TableData_InUpDe' |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | result.sql = result.sql.replace(/\$@/ig, '/*') |
| | | result.sql = result.sql.replace(/@\$/ig, '*/') |
| | | result.bottom = result.bottom.replace(/\$@/ig, '/*') |
| | | result.bottom = result.bottom.replace(/@\$/ig, '*/') |
| | | } else { |
| | | result.sql = result.sql.replace(/@\$|\$@/ig, '') |
| | | result.bottom = result.bottom.replace(/@\$|\$@/ig, '') |
| | | } |
| | | |
| | | param.excel_in_type = 'true' |
| | | param.LText1 = Utils.formatOptions(result.insert) |
| | | param.LText2 = Utils.formatOptions(result.bottom) |
| | | delete param.excel_in |
| | | |
| | | param.exec_type = 'y' |
| | | param.LText = Utils.formatOptions(result.sql) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | param.menuname = submit.logLabel |
| | | |
| | |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | | }, () => { |
| | | }, (error) => { |
| | | if (error && error.ErrCode === 'LoginError') return |
| | | |
| | | this.execError({}) |
| | | }) |
| | | } else if (submit.intertype === 'inner' && submit.innerFunc) { // 自定义存储过程 |
| | | param.func = submit.innerFunc |
| | | |
| | | if (submit.recordUser === 'true') { |
| | | param.username = sessionStorage.getItem('User_Name') || '' |
| | | param.fullname = sessionStorage.getItem('Full_Name') || '' |
| | | } |
| | | |
| | | Api.genericInterface(param).then((res) => { |
| | | if (res.status) { |
| | |
| | | } else { |
| | | this.execError(res) |
| | | } |
| | | }, () => { |
| | | }, (error) => { |
| | | if (error && error.ErrCode === 'LoginError') return |
| | | |
| | | this.execError({}) |
| | | }) |
| | | } |
| | | } |
| | | |
| | | updataLine = (item) => { |
| | | if (item.$type === 'del') { |
| | | let _data = this.state.edData.filter(m => m.$$uuid !== item.$$uuid) |
| | | |
| | | this.setState({edData: _data}) |
| | | } else { |
| | | let _data = this.state.edData.map(m => { |
| | | if (m.$$uuid === item.$$uuid) { |
| | | item.$origin = true |
| | | return item |
| | | } |
| | | return m |
| | | }) |
| | | |
| | | this.setState({edData: _data}) |
| | | } |
| | | MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid, item) |
| | | } |
| | | |
| | | execSuccess = (res) => { |
| | | const { submit } = this.props |
| | | const { edData } = this.state |
| | | |
| | | if (res && res.ErrCode === 'S') { // 执行成功 |
| | | notification.success({ |
| | | top: 92, |
| | | message: res.ErrMesg || this.state.dict['main.action.confirm.success'], |
| | | message: res.message || '执行成功', |
| | | duration: submit.stime ? submit.stime : 2 |
| | | }) |
| | | } else if (res && res.ErrCode === 'Y') { // 执行成功 |
| | | Modal.success({ |
| | | title: res.ErrMesg || this.state.dict['main.action.confirm.success'] |
| | | title: res.message || '执行成功' |
| | | }) |
| | | } else if (res && res.ErrCode === '-1') { // 完成后不提示 |
| | | |
| | | } |
| | | |
| | | let _edData = fromJS(edData).toJS() |
| | | |
| | | _edData = _edData.map(item => { |
| | | if (!item.$forbid) { |
| | | item.$origin = true |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | loading: false |
| | | loading: false, |
| | | edData: _edData |
| | | }) |
| | | |
| | | if (submit.closetab === 'true') { |
| | |
| | | if (submit.execSuccess !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit) |
| | | } |
| | | |
| | | submit.syncComponentId && MKEmitter.emit('reloadData', submit.syncComponentId) |
| | | } |
| | | |
| | | execError = (res) => { |
| | |
| | | |
| | | if (res.ErrCode === 'E') { |
| | | Modal.error({ |
| | | title: res.message || res.ErrMesg, |
| | | title: res.message || '执行失败!', |
| | | }) |
| | | } else if (res.ErrCode === 'N') { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | message: res.message || '执行失败!', |
| | | duration: submit.ntime ? submit.ntime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'F') { |
| | | notification.error({ |
| | | className: 'notification-custom-error', |
| | | top: 92, |
| | | message: res.message || res.ErrMesg, |
| | | message: res.message || '执行失败!', |
| | | duration: submit.ftime ? submit.ftime : 10 |
| | | }) |
| | | } else if (res.ErrCode === 'NM') { |
| | | message.error(res.message || res.ErrMesg) |
| | | message.error(res.message || '执行失败!') |
| | | } |
| | | |
| | | this.setState({ |
| | |
| | | |
| | | render() { |
| | | const { setting, lineMarks, submit } = this.props |
| | | const { tableId, edData, columns, loading, pageOptions, selectedRowKeys } = this.state |
| | | const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state |
| | | |
| | | if (reseting) return null |
| | | |
| | | const components = { |
| | | body: { |
| | |
| | | } |
| | | } |
| | | |
| | | // 数据收起时,过滤已选数据 |
| | | let _data = edData.filter(item => !item.$deleted) |
| | | |
| | | // 设置表格选择属性:单选、多选、不可选 |
| | |
| | | } |
| | | } |
| | | |
| | | let _footer = '' |
| | | |
| | | let height = setting.height || false |
| | | if (height && height <= 100) { |
| | | height = height + 'vh' |
| | |
| | | |
| | | return ( |
| | | <> |
| | | <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | {setting.hasSubmit ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> |
| | | <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> |
| | | </div> |
| | | </div> : null} |
| | | <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}> |
| | | <Table |
| | | rowKey="$$uuid" |
| | |
| | | onChange={this.changeTable} |
| | | pagination={_pagination} |
| | | /> |
| | | {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null} |
| | | {_data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">提交</Button> : null} |
| | | {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">提交</Button> : null} |
| | | </div> |
| | | <Modal |
| | | className="mk-user-confirm" |
| | | visible={visible} |
| | | width={450} |
| | | maskClosable={false} |
| | | closable={false} |
| | | footer={[ |
| | | <Button key="cancel" onClick={() => { this.setState({ visible: false, midData: null }) }}>取消</Button>, |
| | | <Button key="refresh" className="table-refresh" onClick={() => { midData && this.updateMutil(midData) }}>刷新表格</Button>, |
| | | <Button key="confirm" type="primary" onClick={() => setTimeout(() => {this.submit()}, 10)}>提交数据</Button> |
| | | ]} |
| | | destroyOnClose |
| | | > |
| | | <div><QuestionCircleOutlined />表格中有数据尚未提交</div> |
| | | </Modal> |
| | | </> |
| | | ) |
| | | } |