From d59f518f466274b2caeb2e01c10c92deafe7c93b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 09 二月 2022 11:48:29 +0800 Subject: [PATCH] 2022-02-09 --- src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx | 110 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 82 insertions(+), 28 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx index 391053d..61ac6e4 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx @@ -1,7 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Icon, Button, notification, Select, Popconfirm, Typography, Modal } from 'antd' +import { Form, Row, Col, Button, notification, Select, Popconfirm, Typography, Modal, Radio } from 'antd' +import { StopOutlined, CheckCircleOutlined, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' import moment from 'moment' import Utils from '@/utils/utils.js' @@ -20,6 +21,7 @@ setting: PropTypes.object, // 璁剧疆 scripts: PropTypes.array, // 鑷畾涔夎剼鏈垪琛� searches: PropTypes.array, // 鎼滅储鏉′欢 + urlFields: PropTypes.any, // url鍙橀噺 regoptions: PropTypes.any, // 姝e垯鏇挎崲 scriptsChange: PropTypes.func, // 鑷畾涔夎剼鏈垏鎹㈡椂楠岃瘉 scriptsUpdate: PropTypes.func // 琛ㄥ崟 @@ -34,18 +36,30 @@ { title: 'SQL', dataIndex: 'sql', - width: '73%', + width: '60%', render: (text) => { let title = text.match(/^\s*\/\*.+\*\//) title = title && title[0] ? title[0] : '' - text = title ? text.replace(title, '') : text + let _text = title ? text.replace(title, '') : text return ( <div> - {title ? <span style={{color: '#a50'}}>{title}</span> : null} - <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph> + {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null} + <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph> </div> ) + } + }, + { + title: '鎵ц浣嶇疆', + dataIndex: 'position', + width: '13%', + render: (text, record) => { + if (record.position === 'front') { + return <span style={{color: '#26C281'}}>sql鍓�</span> + } else { + return <span style={{color: '#1890ff'}}>sql鍚�</span> + } } }, { @@ -54,15 +68,15 @@ width: '12%', render: (text, record) => record.status === 'false' ? ( - <div> + <div style={{color: '#ff4d4f'}}> {this.props.dict['model.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> + <StopOutlined style={{marginLeft: '5px'}} /> </div> ) : ( - <div> + <div style={{color: '#26C281'}}> {this.props.dict['model.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> + <CheckCircleOutlined style={{marginLeft: '5px'}}/> </div> ) }, @@ -73,14 +87,14 @@ dataIndex: 'operation', render: (text, record) => (<div style={{textAlign: 'center'}}> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record)} style={{color: '#1890ff'}}><EditOutlined /></span> + <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><SwapOutlined /></span> <Popconfirm overlayClassName="popover-confirm" title={this.props.dict['model.query.delete']} onConfirm={() => this.handleDelete(record) }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> + <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span> </Popconfirm> </div>) } @@ -88,17 +102,16 @@ } UNSAFE_componentWillMount() { - const { searches, scripts } = this.props + const { searches, scripts, urlFields } = this.props let _usefulFields = [] + let scriptsColumns = fromJS(this.state.scriptsColumns).toJS() if (searches) { searches.forEach(item => { if (!item.field) return if (item.type === 'group') { - if (item.transfer === 'true') { - _usefulFields.push(item.field) - } + _usefulFields.push(item.field) _usefulFields.push(item.datefield) _usefulFields.push(item.datefield + '1') } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) { @@ -110,14 +123,26 @@ _usefulFields.push(item.field) } }) + + if (urlFields) { + _usefulFields.push(...urlFields) + } + _usefulFields = _usefulFields.join(', ') + scriptsColumns = scriptsColumns.filter(item => { + if (item.dataIndex === 'sql') { + item.width = '70%' + } + return item.dataIndex !== 'position' + }) } else { _usefulFields = null } this.setState({ usefulFields: _usefulFields, - scripts: fromJS(scripts).toJS() + scripts: fromJS(scripts).toJS(), + scriptsColumns }) } @@ -196,7 +221,11 @@ let values = { uuid: editItem && editItem.uuid ? editItem.uuid : Utils.getuuid(), - sql: _sql + sql: _sql, + } + + if (this.props.form.getFieldValue('position')) { + values.position = this.props.form.getFieldValue('position') } let _quot = values.sql.match(/'{1}/g) @@ -307,13 +336,21 @@ } handleEdit = (record) => { + const { usefulFields } = this.state this.setState({ editItem: record }) - this.props.form.setFieldsValue({ - sql: record.sql - }) + if (usefulFields) { + this.props.form.setFieldsValue({ + sql: record.sql + }) + } else { + this.props.form.setFieldsValue({ + sql: record.sql, + position: record.position || 'back' + }) + } this.scrolltop() } @@ -383,19 +420,36 @@ <div className="modal-menu-setting-script"> <Form {...formItemLayout}> <Row gutter={24}> - <Col span={8}> - <Form.Item label={'鍥炶皟琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> + <Col span={4}> + <Form.Item labelCol={{span: 17}} wrapperCol={{span: 7}} label={'鍥炶皟琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> {setting.cbTable} </Form.Item> </Col> - <Col span={16}> - <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0}}> - ErrorCode, retmsg + <Col span={20}> + <Form.Item labelCol={{span: 4}} wrapperCol={{span: 20}} label={'鎶ラ敊瀛楁'} style={{margin: 0}}> + ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg </Form.Item> </Col> {usefulFields ? <Col span={24} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> - id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} + id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, mk_departmentcode, mk_organization, login_city, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} + </Form.Item> + </Col> : null} + {!usefulFields ? <Col span={24} className="sqlfield"> + <Form.Item label={'鍙敤瀛楁'}> + id, bid, loginuid, sessionuid, userid, username, fullname, RoleID, mk_departmentcode, mk_organization, login_city, appkey, time_id + </Form.Item> + </Col> : null} + {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}> + <Form.Item style={{marginBottom: 0}} label="鎵ц浣嶇疆"> + {getFieldDecorator('position', { + initialValue: 'front' + })( + <Radio.Group> + <Radio value="front">sql鍓�</Radio> + <Radio value="back">sql鍚�</Radio> + </Radio.Group> + )} </Form.Item> </Col> : null} <Col span={10} className="quick-add"> @@ -406,7 +460,7 @@ filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} onChange={this.selectScript} > - {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100))`}>榛樿sql</Select.Option> : null} + {!usefulFields ? <Select.Option key="default" value={`declare @${setting.cbTable} table (mk_api_key nvarchar(100),mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))\n/*@${setting.cbTable}_data table (mk_level nvarchar(10),mk_id nvarchar(50),mk_bid nvarchar(50))*/`}>榛樿sql</Select.Option> : null} {systemScripts.map((option, i) => <Select.Option style={{whiteSpace: 'normal'}} key={i} value={option.value}>{option.name}</Select.Option> )} -- Gitblit v1.8.0