From fc8c8d714687a22f711d642d192bd4149f3b7e88 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 22 四月 2024 11:15:14 +0800 Subject: [PATCH] 2024-04-22 --- src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 131 ++++++++++++++++++++++++++++++------------- 1 files changed, 90 insertions(+), 41 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 5dd577b..c58226f 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -19,7 +19,9 @@ const { confirm } = Modal const { Search } = Input const { Paragraph } = Typography + const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) +const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror')) const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts')) class VerifyCard extends Component { @@ -307,17 +309,17 @@ _verify.range = 1 } + _verify.excelHandle = _verify.excelHandle || 'false' + _verify.default = _verify.default || 'true' + _verify.sheet = _verify.sheet || 'Sheet1' + _verify.range = _verify.range || 0 + _verify.columns = _columns + _verify.scripts = _verify.scripts || [] + _verify.uniques = _verify.uniques || [] + this.setState({ searchKey: '', - verify: { - ..._verify, - default: _verify.default || 'true', - sheet: _verify.sheet || 'Sheet1', - range: _verify.range || 0, - columns: _columns, - scripts: _verify.scripts || [], - uniques: _verify.uniques || [] - } + verify: _verify }, () => { this.resetUniqueColumns() }) @@ -519,7 +521,7 @@ }) } - columnChange = (values) => { + columnChange = (values, callback) => { let verify = JSON.parse(JSON.stringify(this.state.verify)) let fields = verify.columns.map(item => item.Column) @@ -530,6 +532,8 @@ duration: 5 }) return + } else { + callback() } values.uuid = Utils.getuuid() @@ -712,33 +716,44 @@ if (!err) { let _verify = {...verify, ...values} + if (_verify.excelHandle !== 'true') { + delete _verify.excel_func + } + if (_verify.default === 'false' && _verify.scripts.length === 0) { + notification.warning({ + top: 92, + message: '涓嶆墽琛岄粯璁ql鏃讹紝蹇呴』璁剧疆鑷畾涔夎剼鏈紒', + duration: 5 + }) + return + } + let cols = _verify.columns.map(col => col.Column.toLowerCase()) cols = Array.from(new Set(cols)) + let error = '' if (_verify.columns.length === 0) { - notification.warning({ - top: 92, - message: '璇疯缃瓻xcel鍒楀瓧娈�!', - duration: 5 - }) - return + error = '璇疯缃瓻xcel鍒楀瓧娈�!' } else if (_verify.columns.length > cols.length) { - notification.warning({ - top: 92, - message: 'Excel鍒楀瓧娈靛悕锛屼笉鍙噸澶�!', - duration: 5 - }) - return + error = 'Excel鍒楀瓧娈靛悕锛屼笉鍙噸澶�!' + } else if (cols.includes('bid')) { + error = 'bid瀛楁涓轰繚鐣欏瓧锛屼笉鍙娇鐢�!' + } else if (cols.includes('jskey')) { + error = 'jskey瀛楁涓轰繚鐣欏瓧锛屼笉鍙娇鐢�!' } else if (_verify.range === 1) { let tEmptys = _verify.columns.filter(op => !op.Text) if (tEmptys.length > 0) { - notification.warning({ - top: 92, - message: '蹇界暐棣栬鏃讹紝浼氫娇鐢═ext鍊兼牎楠孍xcel棣栬鍐呭锛孴ext鍊间笌Excel琛ㄩ琛屽唴瀹圭浉鍚岋紝涓斿潎涓嶅彲涓虹┖锛�', - duration: 5 - }) - return + error = '蹇界暐棣栬鏃讹紝浼氫娇鐢═ext鍊兼牎楠孍xcel棣栬鍐呭锛孴ext鍊间笌Excel琛ㄩ琛屽唴瀹圭浉鍚岋紝涓斿潎涓嶅彲涓虹┖锛�' } + } + + if (error) { + notification.warning({ + top: 92, + message: error, + duration: 5 + }) + return } _verify.columns.sort((a, b) => { @@ -771,22 +786,27 @@ resolve(_verify) } } else { - notification.warning({ - top: 92, - message: '璇疯缃瓻xcel琛ㄥ悕!', - duration: 5 - }) + this.setState({activeKey: 'basemsg'}) } }) }) } - onOptionChange = (e, key) => { + onOptionChange = (e) => { const { verify } = this.state let value = e.target.value this.setState({ verify: {...verify, default: value} + }) + } + + onHandleChange = (e) => { + const { verify } = this.state + let value = e.target.value + + this.setState({ + verify: {...verify, excelHandle: value} }) } @@ -867,7 +887,31 @@ <TabPane tab="鍩虹楠岃瘉" key="basemsg"> <Form {...formItemLayout}> <Row gutter={24}> + {card.intertype === 'system' ? <Col span={8}> + <Form.Item label={'榛樿sql'}> + <Radio.Group value={verify.default} onChange={this.onOptionChange}> + <Radio value="true">鎵ц</Radio> + <Radio value="false">涓嶆墽琛�</Radio> + </Radio.Group> + </Form.Item> + </Col> : null} <Col span={8}> + <Form.Item label={ + <Tooltip placement="topRight" title="鑷畾涔夐獙璇丒xcel鏍煎紡锛屽彲鐢ㄥ弬鏁颁负 XLSX銆亀orkbook銆乥tn銆乧allback銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 瀵煎叆鏍煎紡 + </Tooltip> + }> + {getFieldDecorator('excelHandle', { + initialValue: verify.excelHandle + })( + <Radio.Group onChange={this.onHandleChange}> + <Radio value="false">榛樿</Radio> + <Radio value="true">鑷畾涔�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {verify.excelHandle !== 'true' ? <Col span={8}> <Form.Item label={ <Tooltip placement="bottomLeft" title="瀵煎叆鏃跺伐浣滆〃鍚嶄笌excel涓繀椤讳竴鑷达紝娉細宸ヤ綔琛ㄥ悕涓篠heet1涓攅xcel涓粎鏈変竴涓伐浣滆〃鏃朵笉杩涜琛ㄥ悕楠岃瘉銆�"> <QuestionCircleOutlined className="mk-form-tip" /> @@ -884,7 +928,7 @@ ] })(<Input placeholder="" autoComplete="off" />)} </Form.Item> - </Col> + </Col> : null} <Col span={8}> <Form.Item label={ <Tooltip placement="bottomLeft" title="蹇界暐棣栬鏃讹紝浼氭牎楠宔xcel涓〃澶村悕绉颁笌excel鍒楄缃槸鍚︿竴鑷淬��"> @@ -897,12 +941,17 @@ })(<InputNumber min={0} max={100} precision={0} />)} </Form.Item> </Col> - {card.intertype === 'system' ? <Col span={8}> - <Form.Item label={'榛樿sql'}> - <Radio.Group value={verify.default} onChange={this.onOptionChange}> - <Radio value="true">鎵ц</Radio> - <Radio value="false">涓嶆墽琛�</Radio> - </Radio.Group> + {verify.excelHandle === 'true' ? <Col span={24} style={{paddingLeft: '30px'}}> + <Form.Item wrapperCol={ {xs: { span: 24 }, sm: { span: 24 }} } label=""> + {getFieldDecorator('excel_func', { + initialValue: verify.excel_func || '', + rules: [ + { + required: true, + message: '璇峰~鍐欒嚜瀹氫箟閫昏緫!' + } + ] + })(<CodeMirror mode="text/javascript" theme="cobalt" />)} </Form.Item> </Col> : null} </Row> -- Gitblit v1.8.0