From f36141f3075edf9d41928d64f759ad6bd1b1ac60 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 七月 2020 17:43:34 +0800 Subject: [PATCH] 2020-07-14 --- src/mob/datasource/verifycard/index.jsx | 880 ++++++++-------------------------------------------------- 1 files changed, 129 insertions(+), 751 deletions(-) diff --git a/src/mob/datasource/verifycard/index.jsx b/src/mob/datasource/verifycard/index.jsx index 1731c3c..cb8c091 100644 --- a/src/mob/datasource/verifycard/index.jsx +++ b/src/mob/datasource/verifycard/index.jsx @@ -1,18 +1,15 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' -import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, message, Typography } from 'antd' +import { fromJS } from 'immutable' +import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, Typography } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' -import UniqueForm from './uniqueform' -import ContrastForm from './contrastform' -import CustomForm from './customform' +import ColForm from './columnform' +import CustomScriptsForm from './customscript' import SettingForm from './settingform' -import BillcodeForm from './billcodeform' -import VoucherForm from './voucherform' import './index.scss' const { TabPane } = Tabs @@ -21,60 +18,34 @@ class VerifyCard extends Component { static propTpyes = { - floor: PropTypes.any, // 鏄惁涓哄瓙琛� - btnTab: PropTypes.any, // 琛ㄥ崟鏍囩椤碉紙鎸夐挳锛夊弬鏁� - config: PropTypes.any, // 琛ㄥ崟鏍囩椤靛弬鏁� - dict: PropTypes.object, // 瀛楀吀椤� - card: PropTypes.object, // 鎸夐挳淇℃伅 - columns: PropTypes.array + dict: PropTypes.object, // 瀛楀吀椤� + card: PropTypes.object, // 鏁版嵁婧愪俊鎭� + menuId: PropTypes.string, // 鑿滃崟Id + searches: PropTypes.array, // 鎼滅储鏉′欢 } state = { + columns: [], + activeKey: 'setting', initsql: '', // sql楠岃瘉鏃跺彉閲忓0鏄庡強璧嬪�� - verify: {}, - fields: [], usefulfields: '', defaultsql: '', // 榛樿Sql - orderModular: [], - orderModularDetail: [], - voucher: [], - voucherDetail: [], systemScripts: [], - columnsFields: [], - uniqueColumns: [ + colColumns: [ { - title: '瀛楁鍚�', + title: '鍚嶇О', + dataIndex: 'label', + width: '25%' + }, + { + title: '瀛楁', dataIndex: 'field', - width: '35%' + width: '25%' }, { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '12%' - }, - { - title: '楠岃瘉绫诲瀷', - dataIndex: 'verifyType', - width: '13%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '15%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) + title: '鏁版嵁绫诲瀷', + dataIndex: 'datatype', + width: '25%', }, { title: '鎿嶄綔', @@ -83,191 +54,12 @@ dataIndex: 'operation', render: (text, record) => (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <span className="operation-btn" title={this.props.dict['mob.edit']} onClick={() => this.handleEdit(record, 'columns')} style={{color: '#1890ff'}}><Icon type="edit" /></span> <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - onceUniqueColumns: [ - { - title: '瀛楁鍚�', - dataIndex: 'field', - width: '45%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '30%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '25%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - contrastColumns: [ - { - title: '鍐呭1', - dataIndex: 'frontfield', - width: '13%' - }, - { - title: '杩愮畻绗�', - dataIndex: 'operator', - width: '13%' - }, - { - title: '鍐呭2', - dataIndex: 'backfield', - width: '13%', - }, - { - title: '鎻愮ず淇℃伅', - dataIndex: 'errmsg', - width: '13%' - }, - { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '13%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '15%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'contrast')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'contrast', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'contrast', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'contrast')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'contrast') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - customColumns: [ - { - title: 'SQL', - dataIndex: 'sql', - width: '45%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) - }, - { - title: '缁撴灉澶勭悊', - dataIndex: 'resultName', - width: '9%' - }, - { - title: '鎻愮ず淇℃伅', - dataIndex: 'errmsg', - width: '13%' - }, - { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '9%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '9%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '15%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'customverify')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'customverify', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'customverify', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'customverify')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'customverify') + title={this.props.dict['mob.query.delete']} + okText={this.props.dict['mob.confirm']} + cancelText={this.props.dict['mob.cancel']} + onConfirm={() => this.deleteColumn(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> </Popconfirm> @@ -284,23 +76,9 @@ ) }, { - title: '鎵ц浣嶇疆', - dataIndex: 'position', - width: '10%', - render: (text, record) => { - if (record.position === 'init') { - return '鍒濆鍖�' - } else if (record.position === 'front') { - return 'sql鍓�' - } else { - return 'sql鍚�' - } - } - }, - { title: '鐘舵��', dataIndex: 'status', - width: '10%', + width: '20%', render: (text, record) => record.status === 'false' ? ( <div> @@ -323,118 +101,14 @@ render: (text, record) => (<div> <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> + <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> + <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> <Popconfirm title={this.props.dict['header.form.query.delete']} okText={this.props.dict['model.confirm']} cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'scripts') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - orderColumns: [ - { - title: this.props.dict['header.form.funcvar'], - dataIndex: 'fieldName', - width: '12%', - render: (text, record) => (`${record.fieldName || ''}(${record.field})`) - }, - { - title: '绫诲瀷', - dataIndex: 'billType', - width: '6%', - }, - { - title: '鍑瘉绫诲瀷', - dataIndex: 'ModularCodeName', - width: '11%' - }, - { - title: '鍑瘉鏍囪瘑', - dataIndex: 'ModularDetailCode', - width: '11%' - }, - { - title: '鍏宠仈瀛楁', - dataIndex: 'linkFieldName', - width: '10%', - render: (text, record) => (record.linkField ? `${record.linkFieldName || ''}(${record.linkField})` : '') - }, - { - title: '浣嶆暟', - dataIndex: 'Type', - width: '6%' - }, - { - title: '绀轰緥', - dataIndex: 'example', - width: '13%', - render: (text, record) => { - let _text = '' - - let _type = record.Type - if (_type && typeof(_type) === 'string') { - _type = parseInt(_type) - } else { - _type = 4 - } - - if (record.TypeCharOne === 'n') { - _text = record.ModularDetailCode + Array(_type).join('0') + '1' - } else if (record.TypeCharOne === 'Y') { - _text = record.ModularDetailCode + moment().format('YYYYMMDD') + Array(_type).join('0') + '1' - } else if (record.TypeCharOne === 'Lp') { - _text = Array(_type).join('0') + '10' - } else if (record.TypeCharOne === 'BN') { - _text = moment().format('YYYYMMDD') + Array(_type).join('0') + '1' - } - return _text - } - }, - { - title: '鏍囪瘑', - dataIndex: 'mark', - width: '8%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '8%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '15%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'ordercode')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'ordercode', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'ordercode', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'ordercode')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'ordercode') + onConfirm={() => this.deleteScript(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> </Popconfirm> @@ -444,7 +118,13 @@ } UNSAFE_componentWillMount() { + const { card } = this.props + this.setState({ + columns: fromJS(card.columns).toJS(), + setting: fromJS(card.setting).toJS(), + scripts: fromJS(card.scripts).toJS() + }) } componentDidMount() { @@ -503,11 +183,11 @@ }) } - uniqueChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + columnChange = (values) => { + let columns = fromJS(this.state.columns).toJS() if (values.uuid) { - verify.uniques = verify.uniques.map(item => { + columns = columns.map(item => { if (item.uuid === values.uuid) { return values } else { @@ -516,61 +196,17 @@ }) } else { values.uuid = Utils.getuuid() - verify.uniques.push(values) + columns.push(values) } - this.setState({ - verify: verify - }) - } - - contrastChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - - if (values.uuid) { - verify.contrasts = verify.contrasts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.contrasts.push(values) - } - - this.setState({ - verify: verify - }) - } - - customChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - - if (values.uuid) { - verify.customverifys = verify.customverifys.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.customverifys.push(values) - } - - this.setState({ - verify: verify - }) + this.setState({ columns }) } scriptsChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + let scripts = fromJS(this.state.scripts).toJS() if (values.uuid) { - verify.scripts = verify.scripts.map(item => { + scripts = scripts.map(item => { if (item.uuid === values.uuid) { return values } else { @@ -579,76 +215,29 @@ }) } else { values.uuid = Utils.getuuid() - verify.scripts.push(values) + scripts.push(values) } - this.setState({ - verify: verify - }) + this.setState({ scripts }) } - orderChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - if (values.uuid) { - verify.billcodes = verify.billcodes.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.billcodes.push(values) - } - - this.setState({ - verify: verify - }) + deleteColumn = (record) => { + this.setState({ columns: this.state.columns.filter(item => item.uuid !== record.uuid) }) } - onOptionChange = (e, key) => { - const { verify } = this.state - let value = e.target.value - - this.setState({ - verify: {...verify, [key]: value} - }) - } - - handleDelete = (record, type) => { - const { verify } = this.state - - if (type === 'customverify') { - verify.customverifys = verify.customverifys.filter(item => item.uuid !== record.uuid) - } else if (type === 'unique') { - 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) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid) - } - - this.setState({ verify: verify }) + deleteScript = (record) => { + this.setState({ scripts: this.state.scripts.filter(item => item.uuid !== record.uuid) }) } handleEdit = (record, type) => { - if (type === 'customverify') { - this.customForm.edit(record) - } else if (type === 'unique') { - this.uniqueForm.edit(record) - } else if (type === 'ordercode') { - this.orderForm.edit(record) - } else if (type === 'scripts') { + if (type === 'scripts') { this.scriptsForm.edit(record) - } else if (type === 'contrast') { + } else if (type === 'columns') { this.contrastForm.edit(record) } - let node = document.getElementById('verify-card-box-tab').parentNode + let node = document.getElementById('mob-verify-card-box-tab').parentNode if (node && node.scrollTop) { let inter = Math.ceil(node.scrollTop / 10) @@ -664,211 +253,52 @@ } } - handleStatus = (record, type) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + handleStatus = (record) => { + let scripts = fromJS(this.state.scripts).toJS() record.status = record.status === 'false' ? 'true' : 'false' - if (type === 'customverify') { - verify.customverifys = verify.customverifys.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'unique') { - verify.uniques = verify.uniques.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'ordercode') { - verify.billcodes = verify.billcodes.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'scripts') { - verify.scripts = verify.scripts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } - - this.setState({ - verify: verify + scripts = scripts.map(item => { + if (item.uuid === record.uuid) { + return record + } else { + return item + } }) + + this.setState({ scripts }) } - handleUpDown = (record, type, direction) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + handleUpDown = (record, direction) => { + let scripts = fromJS(this.state.scripts).toJS() let index = 0 - if (type === 'customverify') { - verify.customverifys = verify.customverifys.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')) { - return + scripts = scripts.filter((item, i) => { + if (item.uuid === record.uuid) { + index = i } - if (direction === 'up') { - verify.customverifys.splice(index - 1, 0, record) - } else { - verify.customverifys.splice(index + 1, 0, record) - } - } else if (type === 'unique') { - verify.uniques = verify.uniques.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.uniques.splice(index - 1, 0, record) - } else { - verify.uniques.splice(index + 1, 0, record) - } - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.contrasts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.contrasts.splice(index - 1, 0, record) - } else { - verify.contrasts.splice(index + 1, 0, record) - } - } else if (type === 'ordercode') { - verify.billcodes = verify.billcodes.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.billcodes.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.billcodes.splice(index - 1, 0, record) - } else { - verify.billcodes.splice(index + 1, 0, record) - } - } 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) - } + return item.uuid !== record.uuid + }) + if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { + return } - this.setState({ - verify: verify - }) - } - - voucherChange = (voucher) => { - const { verify } = this.state - - this.setState({ - verify: { - ...verify, - voucher: voucher - } - }) - } - - showError = (errorType) => { - if (errorType === 'S') { - notification.success({ - top: 92, - message: '鎵ц鎴愬姛锛�', - duration: 2 - }) - } else if (errorType === 'Y') { - Modal.success({ - title: '鎵ц鎴愬姛锛�' - }) - } else if (errorType === 'F') { - notification.error({ - className: 'notification-custom-error', - top: 92, - message: '鎵ц澶辫触锛�', - duration: 10 - }) - } else if (errorType === 'N') { - notification.error({ - top: 92, - message: '鎵ц澶辫触锛�', - duration: 10 - }) - } else if (errorType === 'E') { - Modal.error({ - title: '鎵ц澶辫触锛�' - }) - } else if (errorType === 'NM') { - message.error('鎵ц澶辫触锛�') + if (direction === 'up') { + scripts.splice(index - 1, 0, record) + } else { + scripts.splice(index + 1, 0, record) } - } - timeChange = (val, type) => { - const { verify } = this.state - - this.setState({ - verify: {...verify, [type]: val} - }) + this.setState({ scripts }) } handleConfirm = () => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + const { card } = this.props + const { setting, scripts, columns } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { - if (verify.default === 'false' && verify.scripts.length === 0) { + if (setting.default === 'false' && scripts.length === 0) { notification.warning({ top: 92, message: '涓嶆墽琛岄粯璁ql鏃讹紝蹇呴』璁剧疆鑷畾涔夎剼鏈紒', @@ -878,38 +308,48 @@ } let _loading = false - if (this.customForm && this.customForm.state.editItem) { - _loading = true - } else if (this.uniqueForm && this.uniqueForm.state.editItem) { - _loading = true - } else if (this.orderForm && this.orderForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.contrastForm && this.contrastForm.state.editItem) { + if (this.scriptsForm && this.scriptsForm.state.editItem) { _loading = true } if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } else if (this.customForm && this.customForm.props.form.getFieldValue('sql')) { _loading = true } if (_loading) { confirm({ content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氭彁浜ゅ悧锛焋, - okText: this.props.dict['model.confirm'], - cancelText: this.props.dict['header.cancel'], + okText: this.props.dict['mob.confirm'], + cancelText: this.props.dict['mob.cancel'], onOk() { - resolve(verify) + resolve({ + uuid: card.uuid, + setting: setting, + columns: columns, + scripts: scripts + }) }, onCancel() {} }) } else { - resolve(verify) + resolve({ + uuid: card.uuid, + setting: setting, + columns: columns, + scripts: scripts + }) } }) + } + + changeTab = (val) => { + const { activeKey } = this.state + + if (activeKey === 'setting') { + this.settingForm.handleConfirm().then(res => { + console.log(res) + }) + } } /** @@ -922,113 +362,51 @@ } render() { - const { card } = this.props - const { verify, fields, uniqueColumns, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state + const { columns, setting, scripts, colColumns, scriptsColumns, activeKey } = this.state return ( - <div id="verify-card-box-tab"> - <Tabs defaultActiveKey="1" className="verify-card-box"> - <TabPane tab="鏁版嵁婧�" key="1"> - <SettingForm dict={this.props.dict} /> - </TabPane> - <TabPane tab="姣旇緝楠岃瘉" key="2x"> - <ContrastForm + <div id="mob-verify-card-box-tab"> + <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> + <TabPane tab="鏁版嵁婧�" key="setting"> + <SettingForm + menuId={this.props.menuId} dict={this.props.dict} - contrastChange={this.contrastChange} + columns={columns} + setting={setting} + wrappedComponentRef={(inst) => this.settingForm = inst} + /> + </TabPane> + <TabPane tab="瀛楁闆�" key="columns"> + <ColForm + dict={this.props.dict} + columnChange={this.columnChange} wrappedComponentRef={(inst) => this.contrastForm = inst} /> <Table bordered rowKey="uuid" className="custom-table" - dataSource={verify.contrasts} - columns={contrastColumns} + dataSource={columns} + columns={colColumns} pagination={false} /> </TabPane> - <TabPane tab={card.Ot !== 'requiredOnce' ? '鍞竴鎬ч獙璇�' : '鍚岀被鏁版嵁楠岃瘉'} key="2"> - <UniqueForm - btn={card} - fields={card.Ot !== 'requiredOnce' ? fields : columnsFields} - dict={this.props.dict} - uniqueChange={this.uniqueChange} - wrappedComponentRef={(inst) => this.uniqueForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.uniques} - columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鑷畾涔夐獙璇�" key="3"> - <CustomForm - dict={this.props.dict} - btn={this.props.card} - initsql={this.state.initsql} - usefulfields={this.state.usefulfields} - customChange={this.customChange} - wrappedComponentRef={(inst) => this.customForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.customverifys} - columns={customColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鍗曞彿鐢熸垚" key="4"> - <BillcodeForm - fields={fields} - btn={this.props.card} - billcodes={verify.billcodes} - columns={this.props.columns} - dict={this.props.dict} - modular={orderModular} - modularDetail={orderModularDetail} - orderChange={this.orderChange} - wrappedComponentRef={(inst) => this.orderForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.billcodes} - columns={orderColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鍒涘缓鍑瘉" key="5"> - <VoucherForm - dict={this.props.dict} - voucher={voucher} - columns={this.props.columns} - voucherobj={verify.voucher} - voucherDetail={voucherDetail} - voucherChange={this.voucherChange} - wrappedComponentRef={(inst) => this.voucherForm = inst} - /> - </TabPane> - <TabPane tab="鑷畾涔夎剼鏈�" key="6"> - {/* <CustomScript - usefulfields={this.state.usefulfields} + <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> + <CustomScriptsForm + setting={setting} + searches={this.props.searches} initsql={this.state.initsql} dict={this.props.dict} - btn={this.props.card} - customScripts={verify.scripts} + customScripts={scripts} systemScripts={this.state.systemScripts} scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> */} + /> <Table bordered rowKey="uuid" className="custom-table" - dataSource={verify.scripts} + dataSource={scripts} columns={scriptsColumns} pagination={false} /> -- Gitblit v1.8.0