From e0f1f05b7567a7bfd29fd5ad54e4b2222ddfcb94 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 三月 2020 20:19:06 +0800
Subject: [PATCH] 2020-03-26

---
 src/utils/utils.js |   75 ++++++++++++++++++++++++++-----------
 1 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index b5c9245..6a5c97a 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -1,5 +1,6 @@
 import moment from 'moment'
 import md5 from 'md5'
+import options from '@/store/options.js'
 
 const service = window.GLOB.service ? (/\/$/.test(window.GLOB.service) ? window.GLOB.service : window.GLOB.service + '/') : ''
 
@@ -193,7 +194,9 @@
         key: search.field,
         match: search.match,
         type: search.type,
-        value: search.initval
+        label: search.label,
+        value: search.initval,
+        required: search.required === 'true'
       }
       if (item.type === 'date') {
         item.value = item.value ? moment().subtract(item.value, 'days').format('YYYY-MM-DD') : ''
@@ -288,6 +291,12 @@
         newsearches[item.key] = item.value
       }
     })
+
+    Object.keys(newsearches).forEach(key => {
+      if (!newsearches[key]) {
+        delete newsearches[key]
+      }
+    })
     
     return newsearches
   }
@@ -317,12 +326,8 @@
 
         searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\''
       } else if (item.type === 'multiselect') {
-        let str = item.match === '=' ? '' : '%'
-        let options = item.value.map(val => {
-          return item.key + ' ' + item.match + ' \'' + str + val + str + '\''
-        })
 
-        searchText += '(' + options.join(' OR ') + ')'
+        searchText += `'${item.value}' ` + item.match + ' \'%\'+' + item.key + '+\'%\''
       } else if (item.type === 'date') {
         let _val = item.value
         let timetail = ' 00:00:00.000'
@@ -355,6 +360,7 @@
         searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')'
       }
     })
+
     return searchText
   }
 
@@ -391,6 +397,7 @@
    */
   static getrealurl (url) {
     if (!url) return ''
+
     let baseurl = ''
     if (process.env.NODE_ENV === 'production') {
       baseurl = document.location.origin + '/' + service
@@ -402,6 +409,24 @@
     // }
     let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
     return realurl
+  }
+
+  /**
+   * @description 鑾峰彇浜戠鍥剧墖鐪熷疄璺緞
+   * @return {String}    url 鍥剧墖璺緞
+   */
+  static getcloudurl (url) {
+    if (!url) return ''
+    
+    let baseurl = ''
+    
+    if (options.cloudServiceApi) {
+      baseurl = options.cloudServiceApi.replace(/webapi(.*)$/, '')
+    } else {
+      baseurl = document.location.origin + '/' + service
+    }
+
+    return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
   }
 
   /**
@@ -606,7 +631,6 @@
     let _formFieldValue = {}
     // 闇�瑕佸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', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey']
     let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode']
 
     // 涓婚敭瀛楁
@@ -617,7 +641,6 @@
       `
 
     // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦
-    // let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 宸茶祴鍊煎瓧娈甸泦
     let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦
     let _initfields = []
     let _declarefields = []
@@ -706,11 +729,6 @@
         `
     }
 
-    // 娣诲姞鏃朵富閿负绌� 鏀逛负鍓嶅彴鐢熸垚
-    // if (btn.sqlType === 'insert') {
-    //   primaryId = ''
-    // }
-
     // 鍘婚櫎绂佺敤鐨勯獙璇�
     if (verify.contrasts) {
       verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
@@ -728,8 +746,16 @@
       verify.scripts = verify.scripts.filter(item => item.status !== 'false')
     }
 
-    // 鍒濆鍖栧嚟璇佸瓧娈�
-    _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg=''
+    let userName = sessionStorage.getItem('User_Name') || ''
+    let fullName = sessionStorage.getItem('Full_Name') || ''
+
+    if (sessionStorage.getItem('isEditState') === 'true') {
+      userName = sessionStorage.getItem('CloudUserName') || ''
+      fullName = sessionStorage.getItem('CloudFullName') || ''
+    }
+
+    // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁
+    _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}'
       `
 
     // 鍚敤璐︽湡楠岃瘉
@@ -898,10 +924,6 @@
         `
     }
 
-    // 鐢ㄤ簬鍙栫敤鎴蜂俊鎭�
-    let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@
-      `
-
     let primaryKeyName = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(primaryKey.toLowerCase()) ? primaryKey + '@' : primaryKey
 
     let _actionType = null
@@ -951,7 +973,6 @@
 
       keys = keys.join(',')
       values = values.join(',')
-      _sql += _user
       _sql += `insert into ${btn.sql} (${keys}) select ${values};`
     } else if (_actionType === 'update') {
       let _form = []
@@ -1003,7 +1024,6 @@
           }
         })
       }
-      _sql += _user
       _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};`
     }
 
@@ -1092,6 +1112,7 @@
 
     let Ltext = `create proc ${param.innerFunc}
     ( /*${menu.MenuName}*/
+    @appkey nvarchar(50)='',
     @BID nvarchar(50)='',${formParam}
     @PageIndex nvarchar(50)='',
     @PageSize nvarchar(50)='',
@@ -1249,8 +1270,15 @@
       `
     }
 
+    // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀�
+    let _printRemark = ''
+    if (btn.funcType === 'print') {
+      _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */'
+    }
+
     let Ltext = `create proc ${param.funcName}
     ( /*${menu.MenuName}  ${btn.label}*/
+    @appkey nvarchar(50)='',
     @BID nvarchar(50)='',${formParam}
     @sEPTMenuNo nvarchar(50)='${param.menuNo}',
     @lang nvarchar(50)='',
@@ -1271,7 +1299,7 @@
       /*浜嬪姟鎿嶄綔*/
       BEGIN TRAN
         /*鍏蜂綋涓氬姟鎿嶄綔*/
-        
+        ${_printRemark}
         /* 
         select top 10 * from sProcExcep order by id desc
         
@@ -1358,10 +1386,13 @@
 
     let Ltext = `create proc ${param.funcName}
     ( /*${menu.MenuName}  ${btn.label}*/
+      @appkey nvarchar(50)='',
       @ID nvarchar(50)='',
       @BID nvarchar(50)='',
       @Ltext nvarchar(max)='',
       @sEPTMenuNo nvarchar(50)='${param.menuNo}', 
+      @secretkey nvarchar(50)='',
+      @timestamp nvarchar(50)='',
       @lang nvarchar(50)='',
       @LoginUID nvarchar(50)='',
       @SessionUid nvarchar(50)='',

--
Gitblit v1.8.0