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 | 193 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 128 insertions(+), 65 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index eaeeb85..c58226f 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -17,8 +17,11 @@ const { TabPane } = Tabs 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 { @@ -31,6 +34,7 @@ verify: {}, systemScripts: [], activeKey: 'basemsg', + searchKey: '', excelColumns: [ { title: '瀛楁', @@ -39,6 +43,8 @@ inputType: 'input', unique: true, strict: true, + searchable: true, + copy: true, editable: true }, { @@ -46,6 +52,7 @@ dataIndex: 'Text', width: '14%', inputType: 'input', + searchable: true, editable: true }, { @@ -54,6 +61,7 @@ width: '15%', editable: true, inputType: 'select', + keyCol: true, options: [ { value: 'Nvarchar(10)', text: 'Nvarchar(10)' }, { value: 'Nvarchar(20)', text: 'Nvarchar(20)' }, @@ -109,7 +117,10 @@ required: false, inputType: 'number', unlimit: true, - editable: true + editable: true, + keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'], + render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : '' + }, { title: '鏈�澶у��', @@ -118,7 +129,9 @@ required: false, inputType: 'number', unlimit: true, - editable: true + editable: true, + keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'], + render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : '' } ], uniqueColumns: [ @@ -296,16 +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({ - verify: { - ..._verify, - default: _verify.default || 'true', - sheet: _verify.sheet || 'Sheet1', - range: _verify.range || 0, - columns: _columns, - scripts: _verify.scripts || [], - uniques: _verify.uniques || [] - } + searchKey: '', + verify: _verify }, () => { this.resetUniqueColumns() }) @@ -325,17 +339,18 @@ let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort` - _scriptSql = Utils.formatOptions(_scriptSql) + _scriptSql = Utils.formatOptions(_scriptSql, 'x') let _sParam = { func: 'sPC_Get_SelectedList', LText: _scriptSql, obj_name: 'data', - arr_field: 'funcname,longparam' + arr_field: 'funcname,longparam', + exec_type: 'x' } _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp) + _sParam.secretkey = Utils.encrypt('', _sParam.timestamp) _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉 Api.getCloudConfig(_sParam).then(res => { @@ -389,7 +404,7 @@ let _columns = JSON.parse(JSON.stringify(verify.columns)) let _names = {} - let _cols = columns.map(item => { + let _cols = _columns.map(item => { let key = item.Column.toLowerCase() _names[key] = item.Text @@ -441,6 +456,8 @@ confirm({ content: '閮ㄥ垎瀛楁鍚嶇О涓庢樉绀哄垪涓嶄竴鑷达紝鏄惁鏇存柊锛�', + okText: '鏇存柊', + cancelText: '涓嶆洿鏂�', onOk() { _columns = _columns.map(item => { let key = item.Column.toLowerCase() @@ -504,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) @@ -515,6 +532,8 @@ duration: 5 }) return + } else { + callback() } values.uuid = Utils.getuuid() @@ -530,7 +549,6 @@ changeColumns = (columns) => { const { verify } = this.state - let reset = false columns = columns.map(col => { col.type = col.type || 'Nvarchar(50)' if (col.type === 'text' || col.type === 'image') { @@ -539,19 +557,18 @@ col.type = 'Decimal(18,2)' } + if (col.import === 'init') { + col.required = 'false' + col.min = '' + col.max = '' + } + if (/^Nvarchar/ig.test(col.type)) { col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000' } else if (/^Decimal/ig.test(col.type)) { col.limit = col.type.match(/\d+/ig)[1] - if (col.required === 'false') { - reset = true - } - col.required = 'true' } else if (/^int/ig.test(col.type)) { - if (col.required === 'false') { - reset = true - } - col.required = 'true' + } else { col.limit = '' } @@ -561,10 +578,6 @@ return col }) - - if (reset) { - message.warning('鏁板�肩被鍨嬪潎涓哄繀濉��') - } this.setState({verify: {...verify, columns}}, () => { this.resetUniqueColumns() @@ -703,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) => { @@ -762,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} }) } @@ -839,7 +868,7 @@ render() { const { card } = this.props const { getFieldDecorator } = this.props.form - const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state + const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey, searchKey } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -858,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" /> @@ -875,7 +928,7 @@ ] })(<Input placeholder="" autoComplete="off" />)} </Form.Item> - </Col> + </Col> : null} <Col span={8}> <Form.Item label={ <Tooltip placement="bottomLeft" title="蹇界暐棣栬鏃讹紝浼氭牎楠宔xcel涓〃澶村悕绉颁笌excel鍒楄缃槸鍚︿竴鑷淬��"> @@ -888,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> @@ -907,13 +965,13 @@ } key="excelcolumn"> <ColumnForm columnChange={this.columnChange}/> <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}> - 鍚屾鏄剧ず鍒� + 鍚屾瀛楁闆� </Button> <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}> 娓呯┖Excel鍒� </Button> <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col> - <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> + <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} searchKey={searchKey} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ <span> @@ -931,7 +989,7 @@ </span> } key="scripts" id="mk-exin-script"> <FullScripts - verify={verify} + scripts={verify.scripts} getScriptsFullForm={() => this.scriptsFullForm} getScriptsForm={() => this.scriptsForm} handleStatus={this.handleStatus} @@ -957,7 +1015,12 @@ /> <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> </TabPane> : null} - <TabPane tab="淇℃伅鎻愮ず" key="tip"> + <TabPane tab={ + <span> + 淇℃伅鎻愮ず + {activeKey === 'excelcolumn' ? <span onClick={(e) => {e.stopPropagation()}}><Search className="mk-search-fields" defaultValue={searchKey} allowClear onSearch={(val, e) => {e.stopPropagation();this.setState({searchKey: val})}} /></span> : null} + </span> + } key="tip"> <Form {...formItemLayout}> <Row gutter={24}> <Col offset={6} span={6}> -- Gitblit v1.8.0