From 8d6f1d97f1f9d8c81313a2b27802be6426436518 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 04 二月 2020 20:07:19 +0800 Subject: [PATCH] 2020-02-04 --- src/templates/tableshare/verifycard/customform/index.jsx | 30 +++++++++ src/templates/tableshare/verifycard/customscript/index.jsx | 26 ++++++++ src/templates/subtableconfig/index.jsx | 24 +++++++ src/utils/utils.js | 48 ++++++++++------ 4 files changed, 107 insertions(+), 21 deletions(-) diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 9283033..3c345ab 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -427,6 +427,28 @@ MenuID: card.originCard.uuid }).then(result => { if (result.status && result.LongParam) { + let _LongParam = '' + + // 瑙f瀽閰嶇疆锛屼慨鏀规ā鎬佹鏍囬鍚嶇О + if (result.LongParam) { + try { + _LongParam = window.decodeURIComponent(window.atob(result.LongParam)) + _LongParam = JSON.parse(_LongParam) + } catch (e) { + _LongParam = '' + } + } + if (_LongParam && _LongParam.type === 'Modal') { + try { + _LongParam.setting.title = res.label + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam))) + } catch { + _LongParam = '' + } + } else { + _LongParam = '' + } + let param = { func: 'sPC_ButtonParam_AddUpt', ParentID: config.uuid, @@ -435,7 +457,7 @@ Template: 'Modal', MenuName: res.label, PageParam: JSON.stringify({Template: 'Modal'}), - LongParam: result.LongParam + LongParam: _LongParam } Api.getSystemConfig(param).then(response => { if (!response.status) { diff --git a/src/templates/tableshare/verifycard/customform/index.jsx b/src/templates/tableshare/verifycard/customform/index.jsx index 6ac9c2e..d13eb4c 100644 --- a/src/templates/tableshare/verifycard/customform/index.jsx +++ b/src/templates/tableshare/verifycard/customform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Button } from 'antd' +import { Form, Row, Col, Input, Select, Button, notification } from 'antd' import './index.scss' const { TextArea } = Input @@ -36,6 +36,30 @@ if (!err) { values.uuid = this.state.editItem ? this.state.editItem.uuid : '' values.resultName = values.result === 'false' ? '涓嶅瓨鍦�' : '瀛樺湪' + + let _quot = values.sql.match(/'{1}/g) + let _lparen = values.sql.match(/\({1}/g) + let _rparen = values.sql.match(/\){1}/g) + + _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: 10 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 10 + }) + return + } this.props.customChange(values) this.setState({ @@ -108,6 +132,10 @@ { required: true, message: this.props.dict['form.required.input'] + '鎻愮ず淇℃伅!' + }, + { + pattern: /^[^']*$/ig, + message: '鎻愮ず淇℃伅涓嶅厑璁稿寘鍚玕'' } ] })(<Input placeholder="" autoComplete="off" />)} diff --git a/src/templates/tableshare/verifycard/customscript/index.jsx b/src/templates/tableshare/verifycard/customscript/index.jsx index 9928e47..5379c91 100644 --- a/src/templates/tableshare/verifycard/customscript/index.jsx +++ b/src/templates/tableshare/verifycard/customscript/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Button } from 'antd' +import { Form, Row, Col, Input, Button, notification } from 'antd' import './index.scss' const { TextArea } = Input @@ -33,6 +33,30 @@ if (!err) { 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) + + _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: 10 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 10 + }) + return + } + this.props.scriptsChange(values) this.setState({ editItem: null diff --git a/src/utils/utils.js b/src/utils/utils.js index c8a9f07..231c169 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -457,15 +457,20 @@ }) } + let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName'] + let primaryKey = setting.primaryKey || 'id' // 涓婚敭瀛楁 // 绯荤粺鍙橀噺澹版槑涓庤缃垵濮嬪�� - let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50) + let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50) ` if (verify && verify.scripts && verify.scripts.length > 0 && formdata) { - let _formfields = formdata.filter(form => !['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear'].includes(form.key)) - _formfields = _formfields.map(form => `@${form.key} nvarchar(50)`) + let _formfields = formdata.filter(form => !_vars.includes(form.key)) + _formfields = _formfields.map(form => { + _vars.push(form.key) + return `@${form.key} nvarchar(50)` + }) _formfields = _formfields.join(',') - _sql += `${_formfields} + _sql += `,${_formfields} ` } @@ -572,7 +577,13 @@ _ModularDetailCode = item.ModularDetailCode } - _sql += `Declare @${item.field} nvarchar(50) + let _declare = '' + if (!_vars.includes(item.field)) { + _declare = `Declare @${item.field} nvarchar(50)` + } + _vars.push(item.field) + + _sql += `${_declare} select @BillCode='', @${item.field}='' exec s_get_BillCode @ModularDetailCode='${_ModularDetailCode}', @@ -612,6 +623,9 @@ ` } + let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID + ` + if (btn.OpenType === 'pop' && btn.sqlType === 'insert') { let keys = [] let values = [] @@ -630,10 +644,8 @@ keys = keys.join(',') values = values.join(',') - _sql += `declare @UserName nvarchar(50),@FullName nvarchar(50) - select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID - ` - _sql += `insert into ${btn.sql} (${keys},createuserid,CreateUser,CreateStaff,BID) select ${values},@userid,@username,@fullname,@BID` + _sql += _user + _sql += `insert into ${btn.sql} (${keys},createuserid,CreateUser,CreateStaff,BID) select ${values},@userid,@username,@fullname,@BID;` } else if (btn.OpenType === 'pop' && btn.sqlType === 'update') { let _form = [] formdata.forEach(item => { @@ -646,25 +658,25 @@ } }) _form = _form.join(',') - _sql += `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid${_updateconfig} where ${primaryKey}=@${primaryKey}` + _sql += `update ${btn.sql} set ${_form},modifydate=getdate(),modifyuserid=@userid${_updateconfig} where ${primaryKey}=@${primaryKey};` } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'LogicDelete') { // 閫昏緫鍒犻櫎 - _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid where ${primaryKey}=@${primaryKey}` + _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid where ${primaryKey}=@${primaryKey};` } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete') { // 鐗╃悊鍒犻櫎 - _sql += `insert into snote (remark,createuserid) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${primaryKey}='+@${primaryKey},@userid,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKey}` + _sql += _user + _sql += `insert into snote (remark,createuserid) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${primaryKey}='+@${primaryKey},@userid,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKey};` } if (verify && verify.scripts && verify.scripts.length > 0) { let _scripts = '' verify.scripts.forEach(item => { - _scripts += `${item.sql} - ` + _scripts += ` + ${item.sql}` }) - _sql += ` - ${_scripts}` + _sql += `${_scripts}` } - _sql += `aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg - ` + _sql += ` + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` console.log(_sql) return _sql } -- Gitblit v1.8.0