From 390c5026c78d2be9dca4357041f4a0ec8ac3668f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 04 二月 2020 13:57:31 +0800 Subject: [PATCH] 2020-02-04 --- src/templates/tableshare/verifycard/index.jsx | 94 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 91 insertions(+), 3 deletions(-) diff --git a/src/templates/tableshare/verifycard/index.jsx b/src/templates/tableshare/verifycard/index.jsx index 698b9c3..70059db 100644 --- a/src/templates/tableshare/verifycard/index.jsx +++ b/src/templates/tableshare/verifycard/index.jsx @@ -2,12 +2,15 @@ import PropTypes from 'prop-types' import { Form, Tabs, Row, Col, Radio, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd' import moment from 'moment' + +import Api from '@/api' import Utils from '@/utils/utils.js' + import UniqueForm from './uniqueform' import CustomForm from './customform' +import CustomScript from './customscript' import BillcodeForm from './billcodeform' import VoucherForm from './voucherform' -import Api from '@/api' import './index.scss' const { TabPane } = Tabs @@ -91,6 +94,28 @@ </div>) } ], + scriptsColumns: [ + { + title: 'SQL', + dataIndex: 'sql', + width: '80%' + }, + { + title: '鎿嶄綔', + align: 'center', + width: '20%', + dataIndex: 'operation', + render: (text, record) => + (<div> + <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span> + <Popconfirm title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.handleDelete(record, 'scripts')}> + <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> + </Popconfirm> + <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> + <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> + </div>) + } + ], orderColumns: [ { title: '鍑芥暟鍙橀噺', @@ -153,6 +178,7 @@ customverifys: _verify.customverifys || [], billcodes: _verify.billcodes || [], voucher: _verify.voucher || {enabled: false}, + scripts: _verify.scripts || [] } }) @@ -369,6 +395,27 @@ }) } + scriptsChange = (values) => { + let verify = JSON.parse(JSON.stringify(this.state.verify)) + + if (values.uuid) { + verify.scripts = verify.scripts.map(item => { + if (item.uuid === values.uuid) { + return values + } else { + return item + } + }) + } else { + values.uuid = Utils.getuuid() + verify.scripts.push(values) + } + + this.setState({ + verify: verify + }) + } + orderChange = (values) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) @@ -408,6 +455,8 @@ verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid) } else if (type === 'ordercode') { verify.billcodes = verify.billcodes.filter(item => item.uuid !== record.uuid) + } else if (type === 'scripts') { + verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid) } this.setState({ verify: verify }) @@ -420,6 +469,8 @@ this.uniqueForm.edit(record) } else if (type === 'ordercode') { this.orderForm.edit(record) + } else if (type === 'scripts') { + this.scriptsForm.edit(record) } } @@ -490,6 +541,27 @@ this.setState({ verify: verify }) + } else if (type === 'scripts') { + verify.scripts = verify.scripts.filter((item, i) => { + if (item.uuid === record.uuid) { + index = i + } + + return item.uuid !== record.uuid + }) + if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) { + return + } + + if (direction === 'up') { + verify.scripts.splice(index - 1, 0, record) + } else { + verify.scripts.splice(index + 1, 0, record) + } + + this.setState({ + verify: verify + }) } } @@ -543,7 +615,7 @@ render() { // const { getFieldDecorator } = this.props.form - const { verify, fields, uniqueColumns, customColumns, orderColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state + const { verify, fields, uniqueColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -641,7 +713,23 @@ wrappedComponentRef={(inst) => this.voucherForm = inst} /> </TabPane> - <TabPane tab="淇℃伅鎻愮ず" key="6"> + <TabPane tab="鑷畾涔夎剼鏈�" key="6"> + <CustomScript + fields={fields} + dict={this.props.dict} + scriptsChange={this.scriptsChange} + wrappedComponentRef={(inst) => this.scriptsForm = inst} + /> + <Table + bordered + rowKey="uuid" + className="custom-table" + dataSource={verify.scripts} + columns={scriptsColumns} + pagination={false} + /> + </TabPane> + <TabPane tab="淇℃伅鎻愮ず" key="7"> <Form {...formItemLayout}> <Row gutter={24}> <Col offset={6} span={6}> -- Gitblit v1.8.0