From db18f67e6a9ec7be3446ebfb1592809b3c3dcb7d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 06 一月 2020 10:43:42 +0800 Subject: [PATCH] 2020-01-06 --- src/templates/comtableconfig/actionform/index.jsx | 1 src/templates/subtableconfig/source.jsx | 9 src/templates/modalconfig/dragelement/index.jsx | 2 src/templates/tableshare/dragelement/index.jsx | 1 src/templates/comtableconfig/source.jsx | 9 src/templates/tableshare/verifycard/index.jsx | 323 ++++++++++++++++++++++++++++++++ src/templates/comtableconfig/index.jsx | 53 +++- src/templates/modalconfig/dragelement/index.scss | 3 src/templates/subtableconfig/index.jsx | 92 +++++--- src/templates/tableshare/verifycard/index.scss | 29 ++ src/templates/subtableconfig/actionform/index.jsx | 32 --- 11 files changed, 463 insertions(+), 91 deletions(-) diff --git a/src/templates/comtableconfig/actionform/index.jsx b/src/templates/comtableconfig/actionform/index.jsx index cc2b284..cb6f923 100644 --- a/src/templates/comtableconfig/actionform/index.jsx +++ b/src/templates/comtableconfig/actionform/index.jsx @@ -454,6 +454,7 @@ if (!err) { values.id = this.props.card.id values.uuid = this.props.card.uuid + values.verify = this.props.card.verify || null if (values.OpenType === 'excelIn' || values.OpenType === 'excelOut') { values.position = 'toolbar' diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index ae698a1..cc74c33 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -17,6 +17,7 @@ import ColspanForm from '@/templates/tableshare/colspanform' import GridBtnForm from '@/templates/tableshare/gridbtnform' import EditCard from '@/templates/tableshare/editcard' +import VerifyCard from '@/templates/tableshare/verifycard' import MenuForm from '@/templates/tableshare/menuform' import SourceElement from '@/templates/tableshare/dragelement/source' import zhCN from '@/locales/zh-CN/comtable.js' @@ -1839,10 +1840,38 @@ * @description 楠岃瘉淇℃伅閰嶇疆 */ profileAction = (element) => { - // this.setState({ - // profileVisible: true, - // card: element - // }) + this.setState({ + profileVisible: true, + card: element + }) + } + + /** + * @description 楠岃瘉淇℃伅淇濆瓨 + */ + verifySubmit = () => { + const { card } = this.state + let config = JSON.parse(JSON.stringify(this.state.config)) + let _verify = this.verifyRef.state.verify + + config.action = config.action.map(item => { + if (item.uuid === card.uuid) { + item.verify = _verify + } + + return item + }) + + this.setState({ + profileVisible: false, + config: config, + card: '', + actionloading: true + }, () => { + this.setState({ + actionloading: false + }) + }) } /** @@ -3034,21 +3063,13 @@ wrapClassName="common-table-fields-modal" title={'楠岃瘉淇℃伅'} visible={this.state.profileVisible} - width={'65vw'} + width={'75vw'} style={{minWidth: '900px', maxWidth: '1200px'}} - cancelText={this.state.dict['header.close']} - onOk={this.addFieldSubmit} - onCancel={() => { // 鍙栨秷娣诲姞 - this.setState({ - tableVisible: false, - addType: '' - }) - }} + onOk={this.verifySubmit} + onCancel={() => { this.setState({ profileVisible: false }) }} destroyOnClose > - {this.state.addType && this.state.fields.length > 0 ? - <EditCard data={this.state.fields} ref="searchcard" type={this.state.addType} dict={this.state.dict} /> : null - } + <VerifyCard card={this.state.card} wrappedComponentRef={(inst) => this.verifyRef = inst} dict={this.state.dict} /> </Modal> {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} <Modal diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index 4552f1f..c0240de 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -103,7 +103,8 @@ pageTemplate: '', url: '', icon: 'plus', - class: 'green' + class: 'green', + verify: null }, { origin: true, uuid: Utils.getuuid(), @@ -125,7 +126,8 @@ pageTemplate: '', url: '', icon: 'form', - class: 'purple' + class: 'purple', + verify: null }, { origin: true, uuid: Utils.getuuid(), @@ -147,7 +149,8 @@ pageTemplate: '', url: '', icon: 'delete', - class: 'red' + class: 'red', + verify: null } ], columns: [ diff --git a/src/templates/modalconfig/dragelement/index.jsx b/src/templates/modalconfig/dragelement/index.jsx index 14c2773..4b0c581 100644 --- a/src/templates/modalconfig/dragelement/index.jsx +++ b/src/templates/modalconfig/dragelement/index.jsx @@ -110,7 +110,7 @@ let _cols = 24 / (setting.cols || 2) return ( - <div ref={drop} className="ant-row"> + <div ref={drop} className="ant-row modal-fields-row"> {cards.map(card => ( <Col key={card.uuid} span={_cols}> <Card diff --git a/src/templates/modalconfig/dragelement/index.scss b/src/templates/modalconfig/dragelement/index.scss index ac78306..248e718 100644 --- a/src/templates/modalconfig/dragelement/index.scss +++ b/src/templates/modalconfig/dragelement/index.scss @@ -12,4 +12,7 @@ line-height: 65px; text-align: center; color: #bcbcbc; +} +.modal-fields-row { + padding-bottom: 35px; } \ No newline at end of file diff --git a/src/templates/subtableconfig/actionform/index.jsx b/src/templates/subtableconfig/actionform/index.jsx index 080e17b..4bc4b86 100644 --- a/src/templates/subtableconfig/actionform/index.jsx +++ b/src/templates/subtableconfig/actionform/index.jsx @@ -287,37 +287,6 @@ } } - // showError = () => { - // const { errorType } = this.state - - // if (errorType === 'S') { - // notification.success({ - // top: 92, - // message: '鎵ц鎴愬姛锛�', - // duration: 2 - // }) - // } else if (errorType === 'F') { - // notification.error({ - // className: 'notification-custom-error', - // top: 92, - // message: '鎵ц澶辫触锛�', - // duration: 15 - // }) - // } else if (errorType === 'N') { - // notification.error({ - // top: 92, - // message: '鎵ц澶辫触锛�', - // duration: 15 - // }) - // } else if (errorType === 'E') { - // Modal.error({ - // title: '鎵ц澶辫触锛�' - // }) - // } else if (errorType === 'NM') { - // message.error('鎵ц澶辫触锛�') - // } - // } - getFields() { const { getFieldDecorator } = this.props.form const fields = [] @@ -455,6 +424,7 @@ if (!err) { values.id = this.props.card.id values.uuid = this.props.card.uuid + values.verify = this.props.card.verify || null if (values.OpenType === 'excelIn' || values.OpenType === 'excelOut') { values.position = 'toolbar' diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 93775e0..97d8123 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -15,6 +15,7 @@ import ColspanForm from '@/templates/tableshare/colspanform' import GridBtnForm from '@/templates/tableshare/gridbtnform' import EditCard from '@/templates/tableshare/editcard' +import VerifyCard from '@/templates/tableshare/verifycard' import MenuForm from '@/templates/tableshare/menuform' import SourceElement from '@/templates/tableshare/dragelement/source' import zhCN from '@/locales/zh-CN/comtable.js' @@ -65,7 +66,8 @@ delActions: [], // 鍒犻櫎鎸夐挳鍒楄〃 funcLoading: false, // 瀛樺偍杩囩▼鍒涘缓涓� showColumnName: false, // 鏄剧ず鍒楀瓧娈靛悕鎺у埗 - tabviews: [] // 鎵�鏈夋爣绛鹃〉 + tabviews: [], // 鎵�鏈夋爣绛鹃〉 + profileVisible: false // 楠岃瘉淇℃伅妯℃�佹 } /** @@ -678,42 +680,6 @@ text: this.state.dict['header.form.refresh.subgrid'] }] }, - // { - // type: 'select', - // key: 'errorTip', - // label: this.state.dict['header.form.messageTip'], - // initVal: card.errorTip || 'E', - // tooltip: '璇ラ�夐」涓烘彁绀烘晥鏋滃睍绀猴紝閫夋嫨鎻愮ず绫诲瀷鍚庯紝鍙偣鍑绘寜閽煡鐪嬶紝鑷畾涔夊嚱鏁颁腑璁剧疆 ErrCode 涓猴紙S銆�-1銆丒銆丯銆丗銆丯M锛夋椂锛屼細浠ュ搴旀柟寮忓睍绀烘彁绀轰俊鎭��', - // tooltipClass: 'middle', - // required: false, - // options: [{ - // value: 'S', - // text: 'S(鎻愰啋妗�-0)' - // }, { - // value: '-1', - // text: '-1(涓嶆彁绀�)' - // }, { - // value: 'N', - // text: 'N(鎻愰啋妗�-1)' - // }, { - // value: 'F', - // text: 'F(鎻愰啋妗�-2)' - // }, { - // value: 'E', - // text: 'E(纭妗�)' - // }, { - // value: 'NM', - // text: 'NM(椤堕儴鎻愮ず)' - // }] - // }, - // { - // type: 'number', - // key: 'errorTime', - // label: this.state.dict['header.form.errorTime'], - // initVal: card.errorTime || 15, - // tooltip: '鎵ц缁撴灉涓缃� ErrCode 涓� N 鎴� F 鏃舵湁鏁�', - // required: false - // }, { type: 'select', key: 'icon', @@ -1649,6 +1615,44 @@ }) } + /** + * @description 楠岃瘉淇℃伅閰嶇疆 + */ + profileAction = (element) => { + this.setState({ + profileVisible: true, + card: element + }) + } + + /** + * @description 楠岃瘉淇℃伅淇濆瓨 + */ + verifySubmit = () => { + const { card } = this.state + let config = JSON.parse(JSON.stringify(this.state.config)) + let _verify = this.verifyRef.state.verify + + config.action = config.action.map(item => { + if (item.uuid === card.uuid) { + item.verify = _verify + } + + return item + }) + + this.setState({ + profileVisible: false, + config: config, + card: '', + actionloading: true + }, () => { + this.setState({ + actionloading: false + }) + }) + } + // changeTemplate = () => { // this.props.handleConfig('template') // } @@ -2507,6 +2511,7 @@ handleMenu={this.handleAction} copyElement={(val) => this.handleAction(val, 'copy')} deleteMenu={this.deleteElement} + profileMenu={this.profileAction} placeholder={this.state.dict['header.form.action.placeholder']} /> : null } @@ -2613,6 +2618,19 @@ <Empty /> } </Modal> + {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} + <Modal + wrapClassName="common-table-fields-modal" + title={'楠岃瘉淇℃伅'} + visible={this.state.profileVisible} + width={'75vw'} + style={{minWidth: '900px', maxWidth: '1200px'}} + onOk={this.verifySubmit} + onCancel={() => { this.setState({ profileVisible: false }) }} + destroyOnClose + > + <VerifyCard card={this.state.card} wrappedComponentRef={(inst) => this.verifyRef = inst} dict={this.state.dict} /> + </Modal> {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} <Modal title={this.state.dict['header.edit']} diff --git a/src/templates/subtableconfig/source.jsx b/src/templates/subtableconfig/source.jsx index f863ea2..42b9c81 100644 --- a/src/templates/subtableconfig/source.jsx +++ b/src/templates/subtableconfig/source.jsx @@ -102,7 +102,8 @@ errorTime: 15, OpenType: 'pop', icon: 'plus', - class: 'green' + class: 'green', + verify: null }, { origin: true, uuid: Utils.getuuid(), @@ -122,7 +123,8 @@ errorTime: 15, OpenType: 'pop', icon: 'form', - class: 'purple' + class: 'purple', + verify: null }, { origin: true, uuid: Utils.getuuid(), @@ -142,7 +144,8 @@ errorTime: 15, OpenType: 'prompt', icon: 'delete', - class: 'red' + class: 'red', + verify: null } ], columns: [ diff --git a/src/templates/tableshare/dragelement/index.jsx b/src/templates/tableshare/dragelement/index.jsx index 2d7f306..13d1460 100644 --- a/src/templates/tableshare/dragelement/index.jsx +++ b/src/templates/tableshare/dragelement/index.jsx @@ -115,6 +115,7 @@ newcard.callbackFunc = '' newcard.pageTemplate = '' newcard.url = '' + newcard.verify = null if (item.subType === 'excelIn' || item.subType === 'excelOut') { // 瀵煎叆鍜屽鍑篹xcel锛屾寜閽悕绉扮洿鎺ヤ负瀵煎叆銆佸鍑� diff --git a/src/templates/tableshare/verifycard/index.jsx b/src/templates/tableshare/verifycard/index.jsx new file mode 100644 index 0000000..7ec4119 --- /dev/null +++ b/src/templates/tableshare/verifycard/index.jsx @@ -0,0 +1,323 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Tabs, Row, Col, Radio, Input, Button, Select, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd' +import Utils from '@/utils/utils.js' +import './index.scss' + +const { TabPane } = Tabs +const { TextArea } = Input + +class VerifyCard extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + card: PropTypes.object + } + + state = { + verify: {} + } + + UNSAFE_componentWillMount() { + let _verify = this.props.card.verify || {} + + this.setState({ + verify: { + invalid: _verify.invalid || 'false', + unique: _verify.unique || 'false', + accountdate: _verify.accountdate || 'false', + customverifys: _verify.customverifys || [] + } + }) + } + + handleConfirm = () => { + let verify = JSON.parse(JSON.stringify(this.state.verify)) + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + values.uuid = Utils.getuuid() + verify.customverifys.push(values) + + this.setState({ + verify: verify + }) + } + }) + } + + onOptionChange = (e, key) => { + const { verify } = this.state + let value = e.target.value + + this.setState({ + verify: {...verify, [key]: value} + }) + } + + handleDelete = (uuid) => { + const { verify } = this.state + verify.customverifys = verify.customverifys.filter(item => item.uuid !== uuid) + + this.setState({ verify: verify }) + } + + showError = (errorType) => { + if (errorType === 'S') { + notification.success({ + top: 92, + message: '鎵ц鎴愬姛锛�', + duration: 2 + }) + } else if (errorType === 'F') { + notification.error({ + className: 'notification-custom-error', + top: 92, + message: '鎵ц澶辫触锛�', + duration: 15 + }) + } else if (errorType === 'N') { + notification.error({ + top: 92, + message: '鎵ц澶辫触锛�', + duration: 15 + }) + } else if (errorType === 'E') { + Modal.error({ + title: '鎵ц澶辫触锛�' + }) + } else if (errorType === 'NM') { + message.error('鎵ц澶辫触锛�') + } + } + + timeChange = (val, type) => { + const { verify } = this.state + console.log(val) + console.log(type) + this.setState({ + verify: {...verify, [type]: val} + }) + } + + render() { + const { getFieldDecorator } = this.props.form + const { verify } = this.state + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + let columns = [ + { + title: 'SQL', + dataIndex: 'sql', + width: '50%' + }, + { + title: 'ErrorMessage', + dataIndex: 'errmsg', + width: '25%' + }, + { + title: 'ErrorCode', + dataIndex: 'errorCode', + width: '10%' + }, + { + title: '鎿嶄綔', + align: 'center', + width: '15%', + dataIndex: 'operation', + render: (text, record) => + ( + <Popconfirm title="纭畾鍒犻櫎鍚�?" onConfirm={() => this.handleDelete(record.uuid)}> + <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span> + </Popconfirm> + ) + } + ] + + return ( + <Tabs defaultActiveKey="1" className="verify-card-box" onChange={this.tabchange}> + <TabPane tab="鍩虹楠岃瘉" key="1"> + <Form {...formItemLayout}> + <Row gutter={24}> + <Col span={12}> + <Form.Item label={'澶辨晥楠岃瘉'}> + <Radio.Group value={verify.invalid} onChange={(e) => {this.onOptionChange(e, 'invalid')}}> + <Radio value="true">寮�鍚�</Radio> + <Radio value="false">涓嶅紑鍚�</Radio> + </Radio.Group> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={'鍞竴鎬ч獙璇�'}> + <Radio.Group value={verify.unique} onChange={(e) => {this.onOptionChange(e, 'unique')}}> + <Radio value="true">寮�鍚�</Radio> + <Radio value="false">涓嶅紑鍚�</Radio> + </Radio.Group> + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label={'璐︽湡楠岃瘉'}> + <Radio.Group value={verify.accountdate} onChange={(e) => {this.onOptionChange(e, 'accountdate')}}> + <Radio value="true">寮�鍚�</Radio> + <Radio value="false">涓嶅紑鍚�</Radio> + </Radio.Group> + </Form.Item> + </Col> + </Row> + </Form> + </TabPane> + <TabPane tab="鑷畾涔夐獙璇�" key="2"> + <Form {...formItemLayout} className="custom-verify-form" id="verifycard1"> + <Row gutter={24}> + <Col span={10} className="sql"> + <Form.Item label={'sql'}> + {getFieldDecorator('sql', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + 'sql!' + } + ] + })(<TextArea rows={3} />)} + </Form.Item> + </Col> + <Col span={6}> + <Form.Item label={'鎶ラ敊淇℃伅'}> + {getFieldDecorator('errmsg', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '鎶ラ敊淇℃伅!' + } + ] + })(<Input placeholder="" autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={6}> + <Form.Item label={'鎶ラ敊缂栫爜'}> + {getFieldDecorator('errorCode', { + initialValue: 'E', + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!' + } + ] + })( + <Select + getPopupContainer={() => document.getElementById('verifycard1')} + > + <Select.Option value="E"> E </Select.Option> + </Select> + )} + </Form.Item> + </Col> + <Col span={2} className="add"> + <Button onClick={this.handleConfirm} type="primary" className="add-row"> + 娣诲姞 + </Button> + </Col> + </Row> + </Form> + <Table + bordered + rowKey="uuid" + className="custom-table" + dataSource={verify.customverifys} + columns={columns} + pagination={false} + /> + </TabPane> + <TabPane tab="淇℃伅鎻愮ず" key="3"> + <Form {...formItemLayout}> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> S </span> + <Button onClick={() => {this.showError('S')}} type="primary" size="small"> + 鏌ョ湅 + </Button> + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label={'鍋滅暀鏃堕棿'}> + <InputNumber defaultValue={2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} /> + </Form.Item> + </Col> + </Row> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> -1 </span> + 涓嶆彁绀� + </Form.Item> + </Col> + </Row> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> N </span> + <Button onClick={() => {this.showError('N')}} type="primary" size="small"> + 鏌ョ湅 + </Button> + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label={'鍋滅暀鏃堕棿'}> + <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} /> + </Form.Item> + </Col> + </Row> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> F </span> + <Button onClick={() => {this.showError('F')}} type="primary" size="small"> + 鏌ョ湅 + </Button> + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label={'鍋滅暀鏃堕棿'}> + <InputNumber defaultValue={15} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} /> + </Form.Item> + </Col> + </Row> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> E </span> + <Button onClick={() => {this.showError('E')}} type="primary" size="small"> + 鏌ョ湅 + </Button> + </Form.Item> + </Col> + </Row> + <Row gutter={24}> + <Col offset={6} span={6}> + <Form.Item label={'鎻愮ず缂栫爜'}> + <span className="errorval"> NM </span> + <Button onClick={() => {this.showError('NM')}} type="primary" size="small"> + 鏌ョ湅 + </Button> + </Form.Item> + </Col> + </Row> + </Form> + </TabPane> + </Tabs> + ) + } +} + +export default Form.create()(VerifyCard) \ No newline at end of file diff --git a/src/templates/tableshare/verifycard/index.scss b/src/templates/tableshare/verifycard/index.scss new file mode 100644 index 0000000..a7a8067 --- /dev/null +++ b/src/templates/tableshare/verifycard/index.scss @@ -0,0 +1,29 @@ +.verify-card-box { + .ant-tabs-nav-scroll { + text-align: center; + } + .ant-tabs-content { + min-height: 40vh; + } + .custom-verify-form { + .sql { + .ant-col-sm-8 { + width: 25%; + } + .ant-col-sm-16 { + width: 75%; + padding-top: 4px; + } + } + .add { + padding-top: 4px; + } + } + .custom-table .ant-empty { + margin: 20px 8px!important; + } + .errorval { + display: inline-block; + width: 30px; + } +} \ No newline at end of file -- Gitblit v1.8.0