From 3ca91a731665962918a026f521c556f4745ebf35 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 16 十一月 2020 19:20:19 +0800
Subject: [PATCH] 2020-11-16

---
 src/utils/utils.js |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 952b283..8df4de7 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -163,6 +163,10 @@
     })
     // 鏇挎崲%绗︼紙鏁版嵁搴撲腑瑙f瀽鍚巗ql鎶ラ敊锛�
     value = value.replace(/%/ig, ' mpercent ')
+    // 澶栬仈鏁版嵁搴撴浛鎹�
+    if (window.GLOB.externalDatabase !== null) {
+      value = value.replace(/@db@/ig, `[${window.GLOB.externalDatabase}]..`)
+    }
     // encode缂栫爜锛堜腑鏂囧瓧绗﹁秴鍑篵ase64鍔犲瘑鑼冨洿锛�
     value = window.btoa(window.encodeURIComponent(value))
     // 鎻掑叆瀛楃
@@ -230,6 +234,10 @@
 
     // 1銆佹浛鎹�%绗︼紙鏁版嵁搴撲腑瑙f瀽鍚巗ql鎶ラ敊锛�
     value = value.replace(/%/ig, ' mpercent ')
+    // 澶栬仈鏁版嵁搴撴浛鎹�
+    if (window.GLOB.externalDatabase !== null) {
+      value = value.replace(/@db@/ig, `[${window.GLOB.externalDatabase}]..`)
+    }
 
     let encodesql = (val) => {
       if (!val) return ''
@@ -668,8 +676,11 @@
 
     if (item.type === 'link') {
       arrfield.push(item.linkField)
-    } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) {
+    } else if ((item.type === 'select' || item.type === 'radio') && item.linkSubField && item.linkSubField.length > 0) {
       arrfield.push(...item.linkSubField)
+    } else if (item.type === 'checkcard') {
+      arrfield = item.fields.map(f => f.field)
+      arrfield.push(item.valueField)
     }
 
     arrfield = Array.from(new Set(arrfield))
@@ -684,9 +695,9 @@
     arrfield = arrfield.join(',')
 
     if (item.orderBy) {
-      sql = `select ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
+      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}`
     } else {
-      sql = 'select distinct ' + arrfield + ' from ' + _datasource
+      sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource}) a`
     }
 
     return {
@@ -1026,18 +1037,14 @@
     })
 
     // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-    // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey']
     let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode']
 
     // 涓婚敭瀛楁
     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), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)
-      `
+    // sql璇彞
+    let _sql = ''
 
-    // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦
     let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦
     let _initfields = []
     let _declarefields = []
@@ -1140,10 +1147,11 @@
     // 鍙橀噺澹版槑
     _declarefields = _declarefields.join(',')
     if (_declarefields) {
-      _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),@ModularDetailCode nvarchar(50),${_declarefields}
-      `
+      _declarefields = ',' + _declarefields
     }
+    _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),@ModularDetailCode nvarchar(50)${_declarefields}
+      `
 
     // 鍙橀噺璧嬪��
     _initfields = _initfields.join(',')

--
Gitblit v1.8.0