From 9a11e62adeb8d435b52a361eb62d5b59e1deef2a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 23 五月 2024 21:14:50 +0800 Subject: [PATCH] 2024-05-23 --- src/menu/components/table/edit-table/columns/tableIn/index.jsx | 336 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 222 insertions(+), 114 deletions(-) diff --git a/src/menu/components/table/edit-table/columns/tableIn/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/index.jsx index 144df97..4bf55dc 100644 --- a/src/menu/components/table/edit-table/columns/tableIn/index.jsx +++ b/src/menu/components/table/edit-table/columns/tableIn/index.jsx @@ -1,13 +1,14 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' -import { StopTwoTone, CheckCircleTwoTone, EditOutlined, ArrowUpOutlined, ArrowDownOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' +import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, Select, Cascader, Tooltip, InputNumber, Radio, Typography } from 'antd' +import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined, QuestionCircleOutlined } from '@ant-design/icons' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' - +import MKEmitter from '@/utils/events.js' +import MenuUtils from '@/utils/utils-custom.js' import UniqueForm from './uniqueform' import CustomScript from './customscript' import asyncComponent from '@/utils/asyncComponent' @@ -17,6 +18,7 @@ const { confirm } = Modal const { Paragraph } = Typography const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) +const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts')) class VerifyTableCard extends Component { static propTpyes = { @@ -27,6 +29,7 @@ state = { verify: {}, fields: [], + modules: [], fieldLabel: {}, systemScripts: [], activeKey: 'basemsg', @@ -47,7 +50,7 @@ { title: '鎶ラ敊缂栫爜', dataIndex: 'errorCode', - width: '12%', + width: '10%', editable: true, inputType: 'select', options: [ @@ -60,13 +63,24 @@ { title: '楠岃瘉绫诲瀷', dataIndex: 'verifyType', - width: '12%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', + width: '14%', + render: (text, record) => { + let names = { + physical: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級', + logic: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級', + physical_temp: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級', + logic_temp: '閫昏緫楠岃瘉锛堜粎涓存椂琛級', + } + + return names[text] || '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級' + }, inputType: 'select', editable: true, options: [ - { value: 'physical', text: '鐗╃悊楠岃瘉' }, - { value: 'logic', text: '閫昏緫楠岃瘉' } + { value: 'physical', text: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級' }, + { value: 'logic', text: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級' }, + { value: 'physical_temp', text: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級' }, + { value: 'logic_temp', text: '閫昏緫楠岃瘉锛堜粎涓存椂琛級' } ] }, { @@ -90,6 +104,92 @@ </div> ) }, + { + dataIndex: 'sqlRender', + render: (record) => { + let columns = this.props.config.columns + + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.datatype)) { + textFields.push(col.field) + } else if (/Decimal|int/ig.test(col.datatype)) { + numberFields.push(col.field) + } else if (/date/ig.test(col.datatype)) { + dateFields.push(col.field) + } + }) + + let _sheet = this.state.verify.sheet + + if (window.GLOB.externalDatabase !== null) { + _sheet = _sheet.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + let database = _sheet.match(/(.*)\.(.*)\./ig) + let sheet = _sheet.replace(/(.*)\.(.*)\./ig, '') + + database = database ? (database[0] || '') : '' + + let _fields = record.field.split(',') + let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) + _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' + + if (record.verifyType === 'logic' || record.verifyType === 'logic_temp') { + _fields_ += ' and b.deleted=0' + } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) + + let sql = ` + /* 閲嶅鎬ч獙璇� */ + Set @tbid='' + Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${record.field} from #${sheet} ) a group by ${record.field} having sum(n)>1 + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 閲嶅' + goto aaa + end + + ${record.verifyType.indexOf('temp') === -1 ? `Set @tbid='' + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_} + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�' + goto aaa + end` : ''} + ` + return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' ')) + } + } ], scriptsColumns: [ { @@ -114,15 +214,13 @@ dataIndex: 'position', width: '10%', render: (text, record) => { - let _text = '' - if (record.position === 'front') { - _text = 'sql鍓�' - } else if (record.position === 'init') { - _text = '鍒濆鍖�' + if (record.position === 'init') { + return <span style={{color: 'orange'}}>鍒濆鍖�</span> + } else if (record.position === 'front') { + return <span style={{color: '#26C281'}}>sql鍓�</span> } else { - _text = 'sql鍚�' + return <span style={{color: '#1890ff'}}>sql鍚�</span> } - return _text } }, { @@ -149,10 +247,8 @@ width: '20%', dataIndex: 'operation', render: (text, record) => - (<div> + (<div style={{textAlign: 'center'}}> <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span> - <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span> - <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span> <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span> <Popconfirm overlayClassName="popover-confirm" @@ -167,27 +263,34 @@ } UNSAFE_componentWillMount() { - const { columns, card, setting } = this.props - let _verify = fromJS(card).toJS() + const { columns, submit, setting, uuid } = this.props.config + let _verify = fromJS(submit).toJS() _verify.sheet = _verify.sheet || setting.tableName let fieldLabel = {} - // let _columns = [] - // let _fields = {} columns.forEach(col => { fieldLabel[col.field] = col.label - // _fields[col.field] = col }) - // cols.forEach(col => { - // if (!col.field || col.type === 'index' || !_fields[col.field]) return - - // _columns.push(_fields[col.field]) - // }) + + let supId = '' + if (setting && setting.supModule) { + let pid = setting.supModule[setting.supModule.length - 1] + if (pid && pid !== 'empty') { + supId = pid + } else { + supId = '' + } + } + + let menu = window.GLOB.customMenu + + let modules = MenuUtils.getSubModules(menu.components, uuid, supId, menu.interfaces || null) this.setState({ fields: fromJS(columns).toJS().filter(item => item.field !== setting.primaryKey), fieldLabel, + modules: modules, verify: _verify }, () => { this.resetUniqueColumns() @@ -208,21 +311,21 @@ 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.getSystemConfig(_sParam).then(res => { + Api.getCloudConfig(_sParam).then(res => { if (res.status) { let _scripts = res.data.map(item => { return { @@ -313,6 +416,8 @@ verify.scripts.push(values) } + MKEmitter.emit('editLineId', values.uuid) + this.setState({ verify: verify }) @@ -371,51 +476,6 @@ return item } }) - } - - this.setState({ - verify: verify - }) - } - - handleUpDown = (record, type, direction) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - let index = 0 - - 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 === '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({ @@ -526,7 +586,8 @@ } render() { - const { verify, scriptsColumns, uniqueColumns, activeKey, fields } = this.state + const { config } = this.props + const { verify, scriptsColumns, uniqueColumns, activeKey, fields, modules } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -563,8 +624,16 @@ <Input value={verify.innerFunc} placeholder="" autoComplete="off" onChange={(e) => this.onOptionChange(e.target.value, 'innerFunc')}/> </Form.Item> </Col> : null} + {verify.intertype === 'inner' ? <Col span={8}> + <Form.Item required label="璁板綍鐢ㄦ埛"> + <Radio.Group value={verify.recordUser || 'false'} onChange={(e) => this.onOptionChange(e.target.value, 'recordUser')}> + <Radio value="false">鍚�</Radio> + <Radio value="true">鏄�</Radio> + </Radio.Group> + </Form.Item> + </Col> : null} {verify.intertype === 'system' ? <Col span={8}> - <Form.Item required label={'榛樿sql'}> + <Form.Item required label="榛樿sql"> <Radio.Group value={verify.default} onChange={(e) => this.onOptionChange(e.target.value, 'default')}> <Radio value="true">鎵ц</Radio> <Radio value="false">涓嶆墽琛�</Radio> @@ -572,31 +641,52 @@ </Form.Item> </Col> : null} <Col span={8}> - <Form.Item label={'鎴愬姛鍚�'}> - <Radio.Group style={{whiteSpace: 'nowrap'}} value={verify.execSuccess} onChange={(e) => this.onOptionChange(e.target.value, 'execSuccess')}> - <Radio value="never">涓嶅埛鏂�</Radio> - <Radio value="grid">鍒锋柊琛ㄦ牸</Radio> - <Radio value="mainline">涓婄骇锛堣锛�</Radio> - </Radio.Group> + <Form.Item label={ + <Tooltip placement="topLeft" title="銆婂埛鏂拌銆嬩笌銆婂埛鏂拌 / 缁勪欢銆嬪彧鍦ㄦ暟鎹彁浜や负 淇敼椤� 鏃舵湁鏁堛��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鎴愬姛鍚� + </Tooltip> + }> + <Select value={verify.execSuccess} onChange={(val) => this.onOptionChange(val, 'execSuccess')}> + <Select.Option value="never">涓嶅埛鏂�</Select.Option> + <Select.Option value="line" disabled={config.wrap.commit !== 'change'}>鍒锋柊琛�</Select.Option> + <Select.Option value="grid">鍒锋柊缁勪欢</Select.Option> + <Select.Option value="line_grid" disabled={config.wrap.commit !== 'change'}>鍒锋柊琛� / 缁勪欢</Select.Option> + <Select.Option value="mainline">鍒锋柊涓婄骇缁勪欢 - 琛�</Select.Option> + <Select.Option value="maingrid">鍒锋柊涓婄骇缁勪欢</Select.Option> + </Select> </Form.Item> </Col> <Col span={8}> - <Form.Item label={'澶辫触鍚�'}> - <Radio.Group style={{whiteSpace: 'nowrap'}} value={verify.execError} onChange={(e) => this.onOptionChange(e.target.value, 'execError')}> - <Radio value="never">涓嶅埛鏂�</Radio> - <Radio value="grid">鍒锋柊琛ㄦ牸</Radio> - <Radio value="mainline">涓婄骇锛堣锛�</Radio> - </Radio.Group> + <Form.Item label="澶辫触鍚�"> + <Select value={verify.execError} onChange={(val) => this.onOptionChange(val, 'execError')}> + <Select.Option value="never">涓嶅埛鏂�</Select.Option> + <Select.Option value="line" disabled={config.wrap.commit !== 'change'}>鍒锋柊琛�</Select.Option> + <Select.Option value="grid">鍒锋柊缁勪欢</Select.Option> + <Select.Option value="line_grid" disabled={config.wrap.commit !== 'change'}>鍒锋柊琛� / 缁勪欢</Select.Option> + <Select.Option value="mainline">鍒锋柊涓婄骇缁勪欢 - 琛�</Select.Option> + <Select.Option value="maingrid">鍒锋柊涓婄骇缁勪欢</Select.Option> + </Select> </Form.Item> </Col> {isPop ? <Col span={8}> - <Form.Item label={'鎴愬姛鍚�'}> + <Form.Item label="鎴愬姛鍚�"> <Radio.Group style={{whiteSpace: 'nowrap'}} value={verify.closetab || 'false'} onChange={(e) => this.onOptionChange(e.target.value, 'closetab')}> <Radio value="false">鏍囩涓嶅叧闂�</Radio> <Radio value="true">鏍囩鍏抽棴</Radio> </Radio.Group> </Form.Item> </Col> : null} + <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title="鎵ц鎴愬姛鍚庯紙鎴栧脊绐楁爣绛惧叧闂椂锛夛紝闇�瑕佸悓姝ュ埛鏂扮殑缁勪欢銆傛敞锛氶�夋嫨褰撳墠缁勪欢鐨勪笂绾х粍浠舵棤鏁堬紝鍒锋柊涓婄骇缁勪欢璇烽�夋嫨鎴愬姛鍚庘�滀笂绾э紙琛岋級鈥濄��"> + <QuestionCircleOutlined className="mk-form-tip" /> + 鍒锋柊缁勪欢 + </Tooltip> + }> + <Cascader options={modules} value={verify.syncComponent || []} expandTrigger="hover" allowClear placeholder="" onChange={(val) => this.onOptionChange(val, 'syncComponent')}/> + </Form.Item> + </Col> </Row> </Form> </TabPane> @@ -607,7 +697,7 @@ </span> } key="unique"> <UniqueForm fields={fields} uniqueChange={this.uniqueChange}/> - <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> + <EditTable actions={['edit', 'move', 'del', 'sql']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> </TabPane> <TabPane disabled={verify.intertype !== 'system'} tab={ <span> @@ -615,6 +705,23 @@ {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null} </span> } key="scripts"> + <FullScripts + scripts={verify.scripts} + getScriptsFullForm={() => this.scriptsFullForm} + getScriptsForm={() => this.scriptsForm} + handleStatus={this.handleStatus} + handleDelete={this.handleDelete} + > + <CustomScript + type="fullscreen" + btn={verify} + usefulfields={fields} + scripts={verify.scripts} + systemScripts={this.state.systemScripts} + scriptsChange={this.scriptsChange} + wrappedComponentRef={(inst) => this.scriptsFullForm = inst} + /> + </FullScripts> <CustomScript btn={verify} usefulfields={fields} @@ -623,20 +730,13 @@ scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.scripts} - columns={scriptsColumns} - pagination={false} - /> + <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/> </TabPane> <TabPane tab="淇℃伅鎻愮ず" key="tip"> <Form {...formItemLayout}> <Row gutter={24}> <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> + <Form.Item label="鎻愮ず缂栫爜"> <span className="errorval"> S </span> <Button onClick={() => {this.showError('S')}} type="primary" size="small"> 鏌ョ湅 @@ -644,14 +744,14 @@ </Form.Item> </Col> <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> + <Form.Item label="鍋滅暀鏃堕棿"> <InputNumber defaultValue={verify.stime || 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={'鎻愮ず缂栫爜'}> + <Form.Item label="鎻愮ず缂栫爜"> <span className="errorval"> Y </span> <Button onClick={() => {this.showError('Y')}} type="primary" size="small"> 鏌ョ湅 @@ -661,7 +761,15 @@ </Row> <Row gutter={24}> <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> + <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"> 鏌ョ湅 @@ -669,14 +777,14 @@ </Form.Item> </Col> <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> + <Form.Item label="鍋滅暀鏃堕棿"> <InputNumber defaultValue={verify.ntime || 10} 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={'鎻愮ず缂栫爜'}> + <Form.Item label="鎻愮ず缂栫爜"> <span className="errorval"> F </span> <Button onClick={() => {this.showError('F')}} type="primary" size="small"> 鏌ョ湅 @@ -684,14 +792,14 @@ </Form.Item> </Col> <Col span={8}> - <Form.Item label={'鍋滅暀鏃堕棿'}> + <Form.Item label="鍋滅暀鏃堕棿"> <InputNumber defaultValue={verify.ftime || 10} 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={'鎻愮ず缂栫爜'}> + <Form.Item label="鎻愮ず缂栫爜"> <span className="errorval"> E </span> <Button onClick={() => {this.showError('E')}} type="primary" size="small"> 鏌ョ湅 @@ -701,7 +809,7 @@ </Row> <Row gutter={24}> <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> + <Form.Item label="鎻愮ず缂栫爜"> <span className="errorval"> NM </span> <Button onClick={() => {this.showError('NM')}} type="primary" size="small"> 鏌ョ湅 @@ -711,9 +819,9 @@ </Row> <Row gutter={24}> <Col offset={6} span={6}> - <Form.Item label={'鎻愮ず缂栫爜'}> - <span className="errorval"> -1 </span> - 涓嶆彁绀� + <Form.Item label="鎻愮ず缂栫爜"> + <span className="errorval"> -2 </span> + 鎵ц澶辫触鏃犳彁绀� </Form.Item> </Col> </Row> -- Gitblit v1.8.0