From f7d1f17bdcb8c3e794a798165737bb7529dbe8ca Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 26 三月 2020 12:15:19 +0800 Subject: [PATCH] 2020-03-26 --- src/tabviews/zshare/verifycard/tabcard/index.jsx | 115 ++++++++++++++++++++++++++++++++------------------------- 1 files changed, 65 insertions(+), 50 deletions(-) diff --git a/src/tabviews/zshare/verifycard/tabcard/index.jsx b/src/tabviews/zshare/verifycard/tabcard/index.jsx index 30801b3..56be2ec 100644 --- a/src/tabviews/zshare/verifycard/tabcard/index.jsx +++ b/src/tabviews/zshare/verifycard/tabcard/index.jsx @@ -2,9 +2,8 @@ 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' @@ -51,31 +50,43 @@ 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>) } ], @@ -160,7 +171,7 @@ UNSAFE_componentWillMount() { let config = JSON.parse(JSON.stringify(this.props.config)) - + let _subconfig = { label: config.label, setting: config.setting, @@ -177,8 +188,10 @@ config.columns.forEach((item, index) => { _subconfig.columns[item.uuid] = { + label: item.label, Width: item.Width, hidden: item.hidden, + fixed: item.fixed, sort: index } }) @@ -271,14 +284,17 @@ 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 @@ -377,7 +393,7 @@ } else if (type === 'printtype') { this.printTypeForm.edit(record) } else if (type === 'column') { - this.uniqueForm.edit(record) + this.columnForm.edit(record) } if (type === 'printtype') return @@ -398,47 +414,46 @@ } } - 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 = () => { @@ -504,7 +519,7 @@ 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 }, @@ -564,21 +579,21 @@ 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} -- Gitblit v1.8.0