From d1cd5af5adb53e91efdd278328e1b6f8ad834fb5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 06 二月 2025 21:11:56 +0800
Subject: [PATCH] Merge branch 'positec' into dms
---
src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx | 168 +++++++++++++++++--------------------------------------
1 files changed, 52 insertions(+), 116 deletions(-)
diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
index b76445a..99135ce 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/customscript/index.jsx
@@ -1,13 +1,16 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
-import { Form, Row, Col, Button, notification, Tooltip, Select } from 'antd'
+import { Form, Row, Col, Button, notification, Tooltip, Select, Switch, Radio } from 'antd'
+import { QuestionCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
+import { checkSQL, getSearchFields } from '@/utils/utils-custom.js'
import CodeMirror from '@/templates/zshare/codemirror'
-import './index.scss'
+import MKEmitter from '@/utils/events.js'
+// import './index.scss'
class CustomForm extends Component {
static propTpyes = {
@@ -21,15 +24,20 @@
systemScripts: [],
usefulfields: null,
loading: false,
+ skip: false
}
UNSAFE_componentWillMount () {
- this.resetfield(this.props.searches)
+ this.setState({
+ usefulfields: getSearchFields(this.props.searches)
+ })
}
UNSAFE_componentWillReceiveProps(nextProps) {
if (!is(fromJS(this.props.searches), fromJS(nextProps.searches))) {
- this.resetfield(nextProps.searches)
+ this.setState({
+ usefulfields: getSearchFields(nextProps.searches)
+ })
}
}
@@ -47,20 +55,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 {
@@ -84,30 +93,6 @@
})
}
- resetfield = (searches) => {
- let _usefulFields = []
- searches.forEach(item => {
- if (!item.field) return
-
- if (item.type === 'group') {
- _usefulFields.push(item.field)
- _usefulFields.push(item.datefield)
- _usefulFields.push(item.datefield + '1')
- } else if (['dateweek', 'datemonth', 'daterange'].includes(item.type)) {
- _usefulFields.push(item.field)
- _usefulFields.push(item.field + '1')
- } else if (item.type === 'date' && _usefulFields.includes(item.field)) {
- _usefulFields.push(item.field + '1')
- } else {
- _usefulFields.push(item.field)
- }
- })
-
- this.setState({
- usefulfields: _usefulFields.join(', ')
- })
- }
-
edit = (record) => {
this.setState({
editItem: record
@@ -115,11 +100,12 @@
this.props.form.setFieldsValue({
sql: record.sql,
- position: record.position || 'back'
+ position: record.position || 'front'
})
}
handleConfirm = () => {
+ const { skip } = this.state
// 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
this.props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
@@ -134,54 +120,9 @@
values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
- let _quot = values.sql.match(/'{1}/g)
- let _lparen = values.sql.match(/\({1}/g)
- let _rparen = values.sql.match(/\){1}/g)
+ let pass = checkSQL(values.sql, 'customscript')
- _quot = _quot ? _quot.length : 0
- _lparen = _lparen ? _lparen.length : 0
- _rparen = _rparen ? _rparen.length : 0
-
- if (_quot % 2 !== 0) {
- notification.warning({
- top: 92,
- message: 'sql涓璡'蹇呴』鎴愬鍑虹幇',
- duration: 5
- })
- return
- } else if (_lparen !== _rparen) {
- notification.warning({
- top: 92,
- message: 'sql涓�()蹇呴』鎴愬鍑虹幇',
- duration: 5
- })
- return
- } else if (/--/ig.test(values.sql)) {
- notification.warning({
- top: 92,
- message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/',
- duration: 5
- })
- return
- } else if (/,,/ig.test(values.sql)) {
- notification.warning({
- top: 92,
- message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇杩炵画鐨勮嫳鏂囬�楀彿锛�,,锛�',
- duration: 5
- })
- return
- }
-
- let error = Utils.verifySql(values.sql, 'customscript')
-
- if (error) {
- notification.warning({
- top: 92,
- message: 'sql涓笉鍙娇鐢�' + error,
- duration: 5
- })
- return
- }
+ if (!pass && !skip) return
this.setState({
loading: true
@@ -190,18 +131,22 @@
this.props.scriptsChange(values, (status) => {
if (status) {
this.setState({
+ skip: false,
loading: false,
editItem: null
})
+ if (values.uuid) {
+ MKEmitter.emit('editLineId', values.uuid)
+ }
this.props.form.setFieldsValue({
- sql: ''
+ sql: ' '
})
} else {
this.setState({
loading: false
})
}
- })
+ }, skip)
}
})
}
@@ -212,26 +157,17 @@
})
this.props.form.setFieldsValue({
- sql: ''
+ sql: ' ',
+ position: 'front'
})
}
selectScript = (value, option) => {
- const { usefulfields, sheet } = this.props
-
- let _value = ''
- if (value === 'default') {
- let fields = usefulfields.filter(item => item.import !== 'false')
- fields = fields.map(col => col.Column).join(',')
-
- let _sheet = sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')
-
- _value = `Select ${fields} From ${_sheet}`
- } else {
- _value = value
- }
-
+ let _value = value
let _sql = this.props.form.getFieldValue('sql')
+ if (/^\s+$/.test(_sql)) {
+ _sql = ''
+ }
if (_sql) {
_sql = _sql + `
@@ -251,7 +187,7 @@
render() {
const { sheet, linefields } = this.props
- const { usefulfields, systemScripts } = this.state
+ const { usefulfields, systemScripts, skip } = this.state
const { getFieldDecorator } = this.props.form
const formItemLayout = {
labelCol: {
@@ -268,26 +204,26 @@
<Form {...formItemLayout} className="verify-form" id="verify-excelin-custom-scripts">
<Row gutter={24}>
<Col span={8}>
- <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}>
+ <Form.Item label="琛ㄥ悕" style={{whiteSpace: 'nowrap', margin: 0}}>
{sheet}
</Form.Item>
</Col>
<Col span={10}>
- <Form.Item label={'鎶ラ敊瀛楁'} style={{margin: 0, whiteSpace: 'nowrap'}}>
- ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg
+ <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}>
+ errorcode, retmsg
</Form.Item>
</Col>
<Col span={24} className="sqlfield">
- <Form.Item label={'鍙敤瀛楁'}>
- <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id, typename</span></Tooltip>,
+ <Form.Item label="鍙敤瀛楁">
+ <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, lang, time_id, typename</span></Tooltip>,
<Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>
- {usefulfields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鎼滅储鏉′欢锛岃鎸夌収@xxx@鏍煎紡浣跨敤銆�'}>, {usefulfields}</Tooltip> : null}
+ <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鎺掑簭銆佸垎椤典互鍙婃悳绱㈡潯浠跺彉閲忥紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}>, orderBy, pageSize, pageIndex{usefulfields ? ', ' + usefulfields : ''}</Tooltip>
{linefields ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'琛ㄥ崟鍙婅鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}>, {linefields}</Tooltip> : null}
</Form.Item>
</Col>
- {/* <Col span={8} style={{whiteSpace: 'nowrap'}}>
+ <Col span={8} style={{whiteSpace: 'nowrap'}}>
<Form.Item style={{marginBottom: 0}} label={
- <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌榛樿sql浣嶇疆鍏崇郴銆�'}>
+ <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌鏁版嵁婧愪綅缃叧绯汇��'}>
<QuestionCircleOutlined className="mk-form-tip" />
鎵ц浣嶇疆
</Tooltip>
@@ -296,24 +232,20 @@
initialValue: 'front'
})(
<Radio.Group>
- <Radio value="init">鍒濆鍖�</Radio>
- <Radio value="front">sql鍓�</Radio>
- <Radio value="back">sql鍚�</Radio>
+ <Radio value="front">鍓嶇疆</Radio>
+ <Radio value="back">鍚庣疆</Radio>
</Radio.Group>
)}
</Form.Item>
- </Col> */}
+ </Col>
<Col span={8}>
- <Form.Item style={{marginBottom: 0}} label={'蹇嵎娣诲姞'}>
+ <Form.Item style={{marginBottom: 0}} label="蹇嵎娣诲姞">
<Select
showSearch
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
onSelect={this.selectScript}
getPopupContainer={() => document.getElementById('verify-excelin-custom-scripts')}
>
- <Select.Option key="default" value={'default'}>
- 榛樿sql
- </Select.Option>
<Select.Option key="debugger" value={`z_debug: select @ErrorCode='E',@retmsg='娴嬭瘯鏂偣' goto aaa`}>
娴嬭瘯鏂偣
</Select.Option>
@@ -325,7 +257,7 @@
</Select>
</Form.Item>
</Col>
- <Col span={6} className="add">
+ <Col span={5} className="add" style={{whiteSpace: 'nowrap'}}>
<Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green" style={{marginBottom: 15, marginLeft: 40}}>
淇濆瓨
</Button>
@@ -333,8 +265,12 @@
鍙栨秷
</Button>
</Col>
+ <Col span={3} style={{paddingTop: '15px', fontSize: '12px', whiteSpace: 'nowrap'}}>
+ 寮哄埗淇濆瓨锛�
+ <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/>
+ </Col>
<Col span={24} className="sql">
- <Form.Item label={'sql'}>
+ <Form.Item label="sql">
{getFieldDecorator('sql', {
initialValue: '',
rules: [
--
Gitblit v1.8.0