From 58a28e1faa15f638a136fefdcfcd0b3106c1fa16 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 24 六月 2020 10:18:54 +0800 Subject: [PATCH] 2020-06-24 --- src/utils/utils.js | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index de70650..80c6139 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1042,7 +1042,7 @@ // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 _sql += ` /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */ - select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}' + select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @BillCode='', @ModularDetailCode='' ` if (_initCustomScript) { @@ -1066,21 +1066,31 @@ datasource = '(' + datasource + ') tb' } - let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { - _ID = ' in (select ID from dbo.SplitComma(@ID@))' - } - - _sql += ` + _sql += ` /* 澶辨晥楠岃瘉 */ select @tbid='', @ErrorCode='',@retmsg='' - select @tbid=${primaryKey} from ${datasource} where ${primaryKey} ${_ID} + select @tbid='X' from ${datasource} right join (select ID from dbo.SplitComma(@ID@)) sp + on tb.id =sp.id where tb.id is null + + If @tbid!='' + Begin + select @ErrorCode='E',@retmsg='鏁版嵁宸插け鏁�' + goto aaa + end + ` + } else { + _sql += ` + /* 澶辨晥楠岃瘉 */ + select @tbid='', @ErrorCode='',@retmsg='' + select @tbid=${primaryKey} from ${datasource} where ${primaryKey}=@ID@ If @tbid='' Begin select @ErrorCode='E',@retmsg='鏁版嵁宸插け鏁�' goto aaa end ` + } } // 姣旇緝楠岃瘉 @@ -1152,16 +1162,16 @@ let datasource = setting.dataresource if (/\s/.test(datasource)) { // 鎷兼帴鍒悕 datasource = '(' + datasource + ') tb' + } else { + datasource = datasource + ' tb' } verify.uniques.forEach(item => { - let _primaryKey = item.field.split(',').includes(primaryKey) ? '' : ',' + primaryKey - _sql += ` /* 鍚岀被鏁版嵁楠岃瘉 */ Set @tbid='' - Select top 1 @tbid='X' from (select ${item.field}${_primaryKey},1 as n from ${datasource} ) tb inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID group by ${item.field} having sum(n)>1 + Select top 1 @tbid='X' from (select distinct ${item.field},1 as n from ${datasource} inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID ) a having sum(n)>1 If @tbid!='' Begin -- Gitblit v1.8.0