| | |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Tabs, Row, Col, Radio, Table, Icon, Select, notification } from 'antd' |
| | | |
| | | // import Utils from '@/utils/utils.js' |
| | | |
| | | import ActionForm from './actionform' |
| | | import ColumnForm from './columnform' |
| | | import PrintForm from './printform' |
| | | import PrintTypeForm from './printtypeform' |
| | | import './index.scss' |
| | |
| | | printbtns: null, |
| | | colColumns: [ |
| | | { |
| | | title: '字段名', |
| | | dataIndex: 'field', |
| | | width: '35%' |
| | | title: '列名', |
| | | dataIndex: 'label', |
| | | width: '20%' |
| | | }, |
| | | { |
| | | title: '列宽', |
| | | dataIndex: 'Width', |
| | | width: '35%' |
| | | width: '20%' |
| | | }, |
| | | { |
| | | title: '字段名', |
| | | dataIndex: 'field', |
| | | width: '35%' |
| | | title: '隐藏', |
| | | dataIndex: 'hidden', |
| | | width: '20%', |
| | | render: (text, record) => { |
| | | if (record.hidden) return '是' |
| | | return '否' |
| | | } |
| | | }, |
| | | { |
| | | title: '固定', |
| | | dataIndex: 'fixed', |
| | | width: '20%', |
| | | render: (text, record) => { |
| | | if (record.fixed) return '是' |
| | | return '否' |
| | | } |
| | | }, |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | width: '25%', |
| | | width: '20%', |
| | | dataIndex: 'operation', |
| | | render: (text, record) => |
| | | (<div> |
| | | <span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'column')} style={{color: '#1890ff'}}><Icon type="edit" /></span> |
| | | <span className="operation-btn" title="上移" onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> |
| | | <span className="operation-btn" title="下移" onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> |
| | | <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> |
| | | </div>) |
| | | } |
| | | ], |
| | |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | let config = JSON.parse(JSON.stringify(this.props.config)) |
| | | |
| | | |
| | | let _subconfig = { |
| | | label: config.label, |
| | | setting: config.setting, |
| | |
| | | |
| | | config.columns.forEach((item, index) => { |
| | | _subconfig.columns[item.uuid] = { |
| | | label: item.label, |
| | | Width: item.Width, |
| | | hidden: item.hidden, |
| | | fixed: item.fixed, |
| | | sort: index |
| | | } |
| | | }) |
| | |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _subconfig = JSON.parse(JSON.stringify(this.state.subconfig)) |
| | | |
| | | _config.action = _config.action.map(item => { |
| | | _config.columns = _config.columns.map((item, index) => { |
| | | if (values.uuid === item.uuid) { |
| | | item = {...item, ...values} |
| | | } |
| | | |
| | | _subconfig.action[item.uuid] = { |
| | | printer: item.printer || '', |
| | | shortcut: item.shortcut |
| | | _subconfig.columns[item.uuid] = { |
| | | label: item.label, |
| | | Width: item.Width, |
| | | hidden: item.hidden, |
| | | fixed: item.fixed, |
| | | sort: index |
| | | } |
| | | |
| | | return item |
| | |
| | | } else if (type === 'printtype') { |
| | | this.printTypeForm.edit(record) |
| | | } else if (type === 'column') { |
| | | this.uniqueForm.edit(record) |
| | | this.columnForm.edit(record) |
| | | } |
| | | |
| | | if (type === 'printtype') return |
| | |
| | | } |
| | | } |
| | | |
| | | handleStatus = (record) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | record.status = record.status === 'false' ? 'true' : 'false' |
| | | |
| | | verify.scripts = verify.scripts.map(item => { |
| | | if (item.uuid === record.uuid) { |
| | | return record |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | |
| | | this.setState({ |
| | | verify: verify |
| | | }) |
| | | } |
| | | |
| | | handleUpDown = (record, type, direction) => { |
| | | let verify = JSON.parse(JSON.stringify(this.state.verify)) |
| | | handleUpDown = (record, direction) => { |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | let _subconfig = JSON.parse(JSON.stringify(this.state.subconfig)) |
| | | let index = 0 |
| | | |
| | | verify.customverifys = verify.customverifys.filter((item, i) => { |
| | | _config.columns = _config.columns.filter((item, i) => { |
| | | if (item.uuid === record.uuid) { |
| | | index = i |
| | | } |
| | | |
| | | return item.uuid !== record.uuid |
| | | }) |
| | | if ((index === 0 && direction === 'up') || (index === verify.customverifys.length && direction === 'down')) { |
| | | if ((index === 0 && direction === 'up') || (index === _config.columns.length && direction === 'down')) { |
| | | return |
| | | } |
| | | |
| | | if (direction === 'up') { |
| | | verify.customverifys.splice(index - 1, 0, record) |
| | | _config.columns.splice(index - 1, 0, record) |
| | | } else { |
| | | verify.customverifys.splice(index + 1, 0, record) |
| | | _config.columns.splice(index + 1, 0, record) |
| | | } |
| | | |
| | | this.setState({ |
| | | verify: verify |
| | | _config.columns = _config.columns.map((item, index) => { |
| | | _subconfig.columns[item.uuid] = { |
| | | label: item.label, |
| | | Width: item.Width, |
| | | hidden: item.hidden, |
| | | fixed: item.fixed, |
| | | sort: index |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | subconfig: _subconfig |
| | | }) |
| | | |
| | | this.props.handleconfig(_config.uuid, _subconfig) |
| | | } |
| | | |
| | | handleConfirm = () => { |
| | |
| | | |
| | | render() { |
| | | const { config } = this.props |
| | | const { actionColumns, printColumns, printTypeColumns, printbtns } = this.state |
| | | const { actionColumns, printColumns, colColumns, printTypeColumns, printbtns } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | pagination={false} |
| | | /> |
| | | </TabPane> |
| | | {/* <TabPane tab="显示列设置" key="column"> |
| | | <ActionForm |
| | | <TabPane tab="显示列设置" key="column"> |
| | | <ColumnForm |
| | | dict={this.props.dict} |
| | | actionChange={this.actionChange} |
| | | wrappedComponentRef={(inst) => this.actionForm = inst} |
| | | columnChange={this.columnChange} |
| | | wrappedComponentRef={(inst) => this.columnForm = inst} |
| | | /> |
| | | <Table |
| | | bordered |
| | | rowKey="uuid" |
| | | className="custom-table" |
| | | dataSource={this.state.config.action} |
| | | columns={actionColumns} |
| | | dataSource={this.state.config.columns} |
| | | columns={colColumns} |
| | | pagination={false} |
| | | /> |
| | | </TabPane> */} |
| | | </TabPane> |
| | | {printbtns && printbtns.length > 0 ? <TabPane tab="打印设置" key="print"> |
| | | <PrintForm |
| | | dict={this.props.dict} |