From f0602b981659c6d1ff18e8dba4ca1ce89c5f5610 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 22 三月 2020 21:18:34 +0800
Subject: [PATCH] 2020-03-22

---
 src/utils/utils.js |   96 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index 2fa05f9..a3abb26 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') : ''
@@ -286,6 +289,12 @@
         newsearches[item.key] = item.value.join(',')
       } else {
         newsearches[item.key] = item.value
+      }
+    })
+
+    Object.keys(newsearches).forEach(key => {
+      if (!newsearches[key]) {
+        delete newsearches[key]
       }
     })
     
@@ -391,6 +400,7 @@
    */
   static getrealurl (url) {
     if (!url) return ''
+
     let baseurl = ''
     if (process.env.NODE_ENV === 'production') {
       baseurl = document.location.origin + '/' + service
@@ -402,6 +412,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
   }
 
   /**
@@ -607,13 +635,13 @@
     // 闇�瑕佸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']
+    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)
+    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)
       `
 
     // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦
@@ -828,16 +856,24 @@
     if (verify.billcodes && verify.billcodes.length > 0) {
       verify.billcodes.forEach(item => {
         let _ModularDetailCode = ''
-        if (item.TypeCharOne === 'Lp' || item.TypeCharOne === 'BN') {
+        let _lpline = ''
+        if (item.TypeCharOne === 'Lp') {
+          if (item.linkField === 'BID' && BID) { // 鏇挎崲bid
+            _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@BID@,48)`
+          } else {
+            _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@${item.linkField},48)`
+          }
+          _ModularDetailCode = '@ModularDetailCode'
+        } else if (item.TypeCharOne === 'BN') {
           let _val = ''
           if (item.linkField === 'BID' && BID) { // 鏇挎崲bid
             _val = BID
           } else if (data && data.hasOwnProperty(item.linkField)) {
             _val = data[item.linkField]
           }
-          _ModularDetailCode = item.TypeCharOne + _val
+          _ModularDetailCode = `'${item.TypeCharOne + _val}'`
         } else {
-          _ModularDetailCode = item.ModularDetailCode
+          _ModularDetailCode = `'${item.ModularDetailCode}'`
         }
 
         let _declare = ''
@@ -849,9 +885,10 @@
         }
 
         _sql += `${_declare}
-          select @BillCode='', @${_key}=''
+          select @BillCode='', @${_key}='', @ModularDetailCode=''
+          ${_lpline}
           exec s_get_BillCode
-            @ModularDetailCode='${_ModularDetailCode}',
+            @ModularDetailCode=${_ModularDetailCode},
             @Type=${item.Type},
             @TypeCharOne='${item.TypeCharOne}',
             @TypeCharTwo ='${item.TypeCharTwo}',
@@ -1029,8 +1066,14 @@
   static getTableFunc (param, menu, config) {
     let form = ''
     let formParam = ''
+    let _vars = ['bid', 'pageindex', 'pagesize', 'ordercol', 'ordertype', 'exceltype', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg']
     let _columns = []
     let primaryKey = config.setting.primaryKey || 'ID'
+
+    if (!_vars.includes(primaryKey.toLowerCase())) {
+      _vars.push(primaryKey.toLowerCase())
+      formParam = `mchr13k@${primaryKey} nvarchar(50)='',`
+    }
 
     if (config.search && config.search.length > 0) {
       let _fields = new Map()
@@ -1051,7 +1094,11 @@
             }
   
             _fields.set(cell, true)
-            formParam = formParam + `mchr13k@${_f} ${type},`
+
+            if (!_vars.includes(_f.toLowerCase())) {
+              _vars.push(_f.toLowerCase())
+              formParam = formParam + `mchr13k@${_f} ${type},`
+            }
           })
         }
       })
@@ -1073,8 +1120,8 @@
 
     let Ltext = `create proc ${param.innerFunc}
     ( /*${menu.MenuName}*/
-    @BID nvarchar(50)='',
-    @${primaryKey} nvarchar(50)='',${formParam}
+    @appkey nvarchar(50)='',
+    @BID nvarchar(50)='',${formParam}
     @PageIndex nvarchar(50)='',
     @PageSize nvarchar(50)='',
     @OrderCol nvarchar(50)='',
@@ -1159,8 +1206,14 @@
   static getfunc (param, btn, menu, config) {
     let form = ''
     let formParam = ''
+    let _vars = ['bid', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg']
     let columns = config.columns
     let primaryKey = config.setting.primaryKey || 'ID'
+
+    if (!_vars.includes(primaryKey.toLowerCase())) {
+      _vars.push(primaryKey.toLowerCase())
+      formParam = `mchr13k@${primaryKey} nvarchar(50)='',`
+    }
 
     if (param.fields && param.fields.length > 0) {
       let _fields = []
@@ -1174,7 +1227,11 @@
           } else {
             type = 'nvarchar(50)=\'\''
           }
-          formParam = formParam + `mchr13k@${item.field} ${type},`
+
+          if (!_vars.includes(item.field.toLowerCase())) {
+            _vars.push(item.field.toLowerCase())
+            formParam = formParam + `mchr13k@${item.field} ${type},`
+          }
 
           _fields.push(item.field)
         }
@@ -1221,10 +1278,16 @@
       `
     }
 
+    // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀�
+    let _printRemark = ''
+    if (btn.funcType === 'print') {
+      _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */'
+    }
+
     let Ltext = `create proc ${param.funcName}
     ( /*${menu.MenuName}  ${btn.label}*/
-    @BID nvarchar(50)='',
-    @${primaryKey} nvarchar(50)='',${formParam}
+    @appkey nvarchar(50)='',
+    @BID nvarchar(50)='',${formParam}
     @sEPTMenuNo nvarchar(50)='${param.menuNo}',
     @lang nvarchar(50)='',
     @debug nvarchar(50)='',
@@ -1244,7 +1307,7 @@
       /*浜嬪姟鎿嶄綔*/
       BEGIN TRAN
         /*鍏蜂綋涓氬姟鎿嶄綔*/
-        
+        ${_printRemark}
         /* 
         select top 10 * from sProcExcep order by id desc
         
@@ -1331,10 +1394,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