From ea2813251609a86a694c4a486f668696ea14b5d4 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 11 十月 2024 17:06:21 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/components/header/index.jsx                          |    4 
 src/views/pcdesign/index.jsx                             |    1 
 src/utils/utils-custom.js                                |  273 ++++++++++++++
 src/tabviews/zshare/actionList/exceloutbutton/index.jsx  |    4 
 src/tabviews/custom/components/module/invoice/index.scss |    2 
 src/tabviews/zshare/mutilform/index.jsx                  |    2 
 src/views/tabledesign/index.jsx                          |    1 
 src/tabviews/home/index.jsx                              |    2 
 src/api/index.js                                         |    2 
 src/tabviews/custom/components/module/invoice/index.jsx  |  687 +++++++++++++++++++++++++++++--------
 src/menu/debug/index.jsx                                 |   57 ++
 src/tabviews/zshare/actionList/normalbutton/index.jsx    |    8 
 src/views/mobdesign/index.jsx                            |    1 
 src/views/interface/index.jsx                            |   14 
 src/views/menudesign/index.jsx                           |    1 
 src/utils/utils.js                                       |    1 
 16 files changed, 870 insertions(+), 190 deletions(-)

diff --git a/src/api/index.js b/src/api/index.js
index 23bfa19..b4b0e42 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -1100,8 +1100,6 @@
    * @description 娓呯┖鍚庣缂撳瓨
    */
   cacheInterface (param) {
-    param.userid = sessionStorage.getItem('UserID') || ''
-    param.LoginUID = sessionStorage.getItem('LoginUID') || ''
     param.appkey = window.GLOB.appkey || ''
 
     let url = '/webapi/excache'
diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx
index 2edc3e1..4ea94db 100644
--- a/src/components/header/index.jsx
+++ b/src/components/header/index.jsx
@@ -56,7 +56,9 @@
   componentDidMount () {
     // 鑾峰彇绯荤粺鐨勭増鏈俊鎭紝寤舵椂鏌ヨ
     setTimeout(() => {
-      Api.getAppVersion()
+      if (!window.GLOB.$error) {
+        Api.getAppVersion()
+      }
     }, 1000)
 
     // sessionStorage 璺ㄩ〉闈㈠叡浜�
diff --git a/src/menu/debug/index.jsx b/src/menu/debug/index.jsx
index ab9eafd..cdbc753 100644
--- a/src/menu/debug/index.jsx
+++ b/src/menu/debug/index.jsx
@@ -385,7 +385,7 @@
           getCols(item.cols)
   
           if (item.subtype === 'editable' && item.submit.intertype === 'system') {
-            let sql = this.getEditTableSql(item.submit, item.cols, item.columns)
+            let sql = this.getEditTableSql(item.submit, item.cols, item.columns, item.setting)
             children.push({label: '鎻愪氦', sql: sql})
           }
         } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
@@ -1131,6 +1131,17 @@
   
     // 鍞竴鎬ч獙璇侊紝蹇呴』瀛樺湪琛ㄥ崟锛堣〃鍗曞瓨鍦ㄦ椂锛屼富閿潎涓哄崟鍊硷級,蹇呴』濉啓鏁版嵁婧愶紝澶氳鎷兼帴鏃朵笉鍙敤
     if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') {
+      let dateForms = []
+      let numForms = []
+      formdata.forEach(form => {
+        let _key = form.key.toLowerCase()
+        if (form.type === 'date') {
+          dateForms.push(_key)
+        } else if (form.type === 'number' || form.type === 'rate') {
+          numForms.push(_key)
+        }
+      })
+
       verify.uniques.forEach(item => {
         let _fieldValue = []                     // 琛ㄥ崟閿�煎field=value
         let _value = []                          // 琛ㄥ崟鍊硷紝鐢ㄤ簬閿欒鎻愮ず
@@ -1144,6 +1155,10 @@
           arr.push(_key)
           if (_key === 'bid') { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺
             _val = BID
+          } else if (numForms.includes(_key)) {
+            _val = '1'
+          } else if (dateForms.includes(_key)) {
+            _val = '1949-10-01'
           }
 
           _fieldValue.push(`${_key}='${_val}'`)
@@ -1759,7 +1774,7 @@
     return sql
   }
 
-  getEditTableSql = (verify, cols, columns) => {
+  getEditTableSql = (verify, cols, columns, setting) => {
     let btn = verify
     let userName = sessionStorage.getItem('User_Name') || ''
     let fullName = sessionStorage.getItem('Full_Name') || ''
@@ -1787,30 +1802,46 @@
   
     let vals = []
     let forms = []
-    let _fields = {}
-
-    columns.forEach(col => {
-      _fields[col.field] = col.datatype
-    })
+    let _forms = {}
+    let index = 0
 
     let getColumns = (cols) => {
       cols.forEach(item => {
         if (item.type === 'colspan') {
           getColumns(item.subcols)
         } else if (item.editable === 'true') {
-          forms.push({
-            field: item.field,
-            type: item.type,
-            datatype: _fields[item.field] || 'nvarchar(50)'
-          })
+          item.$sort = index
+          _forms[item.field] = item
+          index++
         }
       })
     }
 
     getColumns(cols)
 
+    columns.forEach(item => {
+      if (item.field === setting.primaryKey) return
+
+      if (_forms[item.field]) {
+        let _item = {..._forms[item.field]}
+        if (_item.editType === 'date') {
+          _item.datatype = _item.declareType || 'datetime'
+        } else {
+          _item.datatype = item.datatype
+        }
+
+        forms.push(_item)
+      } else {
+        forms.push({...item, $sort: 999})
+      }
+    })
+
+    forms.sort((a, b) => a.$sort - b.$sort)
+
     forms.forEach(col => {
-      if (col.type === 'number') {
+      if (/date/.test(col.datatype)) {
+        vals.push(`'1949-10-01'`)
+      } else if (col.type === 'number') {
         vals.push(`1`)
       } else {
         vals.push(`'mk'`)
diff --git a/src/tabviews/custom/components/module/invoice/index.jsx b/src/tabviews/custom/components/module/invoice/index.jsx
index 5dc2ec4..5f130b2 100644
--- a/src/tabviews/custom/components/module/invoice/index.jsx
+++ b/src/tabviews/custom/components/module/invoice/index.jsx
@@ -85,6 +85,12 @@
     _config.buyer = this.formatSetting(_config.buyer, 'buyer')
     _config.detail = this.formatSetting(_config.detail, 'detail')
     _config.detail.uuid = _config.uuid
+    _config.buyer.setting.uuid = _config.uuid + 'buyer'
+    _config.detail.setting.uuid = _config.uuid + 'detail'
+    _config.billOutBtn.uuid = _config.uuid
+    _config.billSaveBtn.uuid = _config.uuid
+    _config.billOutBtn.logLabel = _config.$menuname + '-' + _config.billOutBtn.label
+    _config.billSaveBtn.logLabel = _config.$menuname + '-' + _config.billSaveBtn.label
 
     let book = null
     let pas = {}
@@ -487,18 +493,23 @@
 
     setTimeout(() => {
       this.getBillMsg().then(() => {
-        let sql = this.getPreSql(config.billSaveBtn)
-  
-        let param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: sql,
-          exec_type: window.GLOB.execType || 'y',
-          timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
-          BID: BID
+        let param = null
+        if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + config.billSaveBtn.type)) {
+          param = this.getBackPreParam(config.billSaveBtn)
+        } else {
+          let sql = this.getPreSql(config.billSaveBtn)
+    
+          param = {
+            func: 'sPC_TableData_InUpDe',
+            LText: sql,
+            exec_type: window.GLOB.execType || 'y',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
+            BID: BID
+          }
+    
+          param.secretkey = Utils.encrypt('', param.timestamp)
+          param.LText = Utils.formatOptions(param.LText, param.exec_type)
         }
-  
-        param.secretkey = Utils.encrypt('', param.timestamp)
-        param.LText = Utils.formatOptions(param.LText, param.exec_type)
 
         this.setState({
           saveType: 'bill'
@@ -570,19 +581,24 @@
 
     setTimeout(() => {
       this.getBillMsg().then(() => {
-        let sql = this.getPreSql(config.billOutBtn)
-  
-        let param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: sql,
-          script_type: 'Y',
-          exec_type: window.GLOB.execType || 'y',
-          timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
-          BID: BID
+        let param = null
+        if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + config.billOutBtn.type)) {
+          param = this.getBackPreParam(config.billOutBtn)
+        } else {
+          let sql = this.getPreSql(config.billOutBtn)
+    
+          param = {
+            func: 'sPC_TableData_InUpDe',
+            LText: sql,
+            script_type: 'Y',
+            exec_type: window.GLOB.execType || 'y',
+            timestamp: moment().format('YYYY-MM-DD HH:mm:ss'),
+            BID: BID
+          }
+    
+          param.secretkey = Utils.encrypt('', param.timestamp)
+          param.LText = Utils.formatOptions(param.LText, param.exec_type)
         }
-  
-        param.secretkey = Utils.encrypt('', param.timestamp)
-        param.LText = Utils.formatOptions(param.LText, param.exec_type)
 
         this.setState({
           saveType: 'out'
@@ -734,6 +750,198 @@
     return sql
   }
 
+  getBackPreParam = (btn) => {
+    const { config, book, ID, BID, io, details, oriDetails, business_type, invoice_type, from_to_name, from_to_tax_no, from_to_addr, from_to_tel, from_to_bank_name, from_to_account_no, from_to_mob, from_to_email, from_to_code, orgname, tax_no, addr, tel, bank_name, account_no, remark, reviewer, drawer, payee } = this.state
+    let ex = window.GLOB.CacheData.get('sql_' + btn.uuid + btn.type)
+    let exps = []
+
+    let values = {
+      time_id: Utils.getguid(),
+      roleid: sessionStorage.getItem('role_id') || '',
+      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+      mk_organization: sessionStorage.getItem('organization') || '',
+      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+      mk_nation: sessionStorage.getItem('nation') || '',
+      mk_province: sessionStorage.getItem('province') || '',
+      mk_city: sessionStorage.getItem('city') || '',
+      mk_district: sessionStorage.getItem('district') || '',
+      mk_address: sessionStorage.getItem('address') || '',
+      id: ID || '',
+      bid: BID || '',
+      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+    }
+
+    if (window.GLOB.externalDatabase !== null) {
+      values.db = window.GLOB.externalDatabase
+    }
+
+    let options = fromJS(oriDetails).toJS()
+    let price = 0
+    let tax = 0
+
+    let lines = []
+    details.forEach(line => {
+      if (!line.productcode) return
+
+      let vals = [line.productcode, line.productname, line.spec, line.unit, line.bill_count, line.unitprice, line.amount_line, line.tax_classify_code, line.tax_classify_name, line.tax_rate, line.tax_amount, line.free_tax_mark || '', line.vat_special_management || '', line.invoice_lp || '', line.tax_item, line.tax_method, line.uuid]
+      let data_type = 'add'
+
+      price += line.amount_line * 100
+      tax += line.tax_amount * 100
+
+      if (options.length) {
+        options = options.filter(option => {
+          if (option.uuid === line.uuid) {
+            data_type = 'upt'
+            return false
+          }
+          return true
+        })
+      }
+
+      vals.push(data_type)
+
+      lines.push(vals)
+    })
+
+    let _total = (price - tax) / 100
+    price = price / 100
+    tax = tax / 100
+
+    if (options.length) {
+      options.forEach(line => {
+        let vals = [line.productcode, line.productname, line.spec, line.unit, line.bill_count, line.unitprice, line.amount_line, line.tax_classify_code, line.tax_classify_name, line.tax_rate, line.tax_amount, line.free_tax_mark || '', line.vat_special_management || '', line.invoice_lp || '', line.tax_item, line.tax_method, line.uuid, 'del']
+        lines.push(vals)
+      })
+    }
+
+    ex.reps.forEach(n => {
+      let key = n.toLowerCase()
+      if (values.hasOwnProperty(key)) {
+        exps.push({
+          key: n,
+          value: values[key]
+        })
+      }
+    })
+
+    exps.push({
+      key: 'account_id',
+      value: book.account_id || ''
+    }, {
+      key: 'account_year_id',
+      value: book.account_year_id || ''
+    }, {
+      key: 'account_code',
+      value: book.account_code || ''
+    }, {
+      key: 'account_year_code',
+      value: book.account_year_code || ''
+    }, {
+      key: 'invoice_type',
+      value: invoice_type
+    }, {
+      key: 'from_to_name',
+      value: from_to_name
+    }, {
+      key: 'from_to_tax_no',
+      value: from_to_tax_no
+    }, {
+      key: 'from_to_addr',
+      value: from_to_addr
+    }, {
+      key: 'from_to_tel',
+      value: from_to_tel
+    }, {
+      key: 'from_to_bank_name',
+      value: from_to_bank_name
+    }, {
+      key: 'from_to_account_no',
+      value: from_to_account_no
+    }, {
+      key: 'from_to_mob',
+      value: from_to_mob
+    }, {
+      key: 'from_to_email',
+      value: from_to_email
+    }, {
+      key: 'from_to_code',
+      value: from_to_code
+    }, {
+      key: 'orgname',
+      value: orgname
+    }, {
+      key: 'tax_no',
+      value: tax_no
+    }, {
+      key: 'addr',
+      value: addr
+    }, {
+      key: 'tel',
+      value: tel
+    }, {
+      key: 'bank_name',
+      value: bank_name
+    }, {
+      key: 'account_no',
+      value: account_no
+    }, {
+      key: 'remark',
+      value: remark
+    }, {
+      key: 'payee',
+      value: payee
+    }, {
+      key: 'reviewer',
+      value: reviewer
+    }, {
+      key: 'drawer',
+      value: drawer
+    }, {
+      key: 'io',
+      value: io
+    }, {
+      key: 'orgcode',
+      value: book.orgcode || ''
+    }, {
+      key: 'total_net_amount',
+      value: _total
+    }, {
+      key: 'total_tax',
+      value: tax
+    }, {
+      key: 'total_amount',
+      value: price
+    }, {
+      key: 'business_type',
+      value: business_type || config.wrap.business_type || ''
+    })
+
+    exps.push({
+      key: 'mk_excel_data',
+      value: lines
+    })
+
+    let md5_id = ''
+    if (window.GLOB.probation) {
+      md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
+      md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
+    }
+
+    return {
+      $backend: true,
+      $type: 's_TableData_InUpDe',
+      data: [{
+        id: ex.id,
+        menuname: btn.logLabel || '',
+        exps: exps,
+        md5_id: md5_id
+      }]
+    }
+  }
+
   getBillMsg = () => {
     const { requireds, invoice_type, details, remark, from_to_addr, addr } = this.state
 
@@ -844,147 +1052,153 @@
   callBackBill = (result) => {
     const { config, BID, ID } = this.state
 
-    let btn = config.billOutBtn
-    let lines = []
-    let pre = '@'
+    let param = null
 
-    let getDefaultSql = (obj, tb, bid, level) => {
-      let keys = []
-      let vals = []
-      let subObjs = []
-      let id = Utils.getuuid()
-      let tbName = pre + tb
-
-      delete obj.$$key
-
-      Object.keys(obj).forEach(key => {
-        let val = obj[key]
-        if (val === null || val === undefined) return
-        if (typeof(val) === 'object') {
-          if (Array.isArray(val)) {
-            val.forEach(item => {
-              if (typeof(item) !== 'object' || Array.isArray(item)) return
-              if (Object.keys(item).length === 0) return
-
-              Object.keys(item).forEach(k => {
-                if (item[k] === null) {
-                  item[k] = ''
-                }
+    if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid + 'billback')) {
+      param = this.getCallBackendParam(config.billOutBtn, result)
+    } else {
+      let btn = config.billOutBtn
+      let lines = []
+      let pre = '@'
+  
+      let getDefaultSql = (obj, tb, bid, level) => {
+        let keys = []
+        let vals = []
+        let subObjs = []
+        let id = Utils.getuuid()
+        let tbName = pre + tb
+  
+        delete obj.$$key
+  
+        Object.keys(obj).forEach(key => {
+          let val = obj[key]
+          if (val === null || val === undefined) return
+          if (typeof(val) === 'object') {
+            if (Array.isArray(val)) {
+              val.forEach(item => {
+                if (typeof(item) !== 'object' || Array.isArray(item)) return
+                if (Object.keys(item).length === 0) return
+  
+                Object.keys(item).forEach(k => {
+                  if (item[k] === null) {
+                    item[k] = ''
+                  }
+                })
+                item.$$key = tb + '_' + key
+                subObjs.push(item)
               })
-              item.$$key = tb + '_' + key
-              subObjs.push(item)
-            })
-          } else if (Object.keys(val).length > 0) {
-            val.$$key = tb + '_' + key
-            subObjs.push(val)
+            } else if (Object.keys(val).length > 0) {
+              val.$$key = tb + '_' + key
+              subObjs.push(val)
+            }
+          } else {
+            if (typeof(val) === 'string') {
+              val = val.replace(/'/ig, '"')
+            }
+            keys.push('[' + key + ']')
+            vals.push(`'${val}'`)
           }
-        } else {
-          if (typeof(val) === 'string') {
-            val = val.replace(/'/ig, '"')
-          }
-          keys.push('[' + key + ']')
-          vals.push(`'${val}'`)
-        }
-      })
-
-      keys = keys.join(',')
-      vals = vals.join(',')
-
-      lines.push({
-        table: md5(tb + keys),
-        insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`,
-        select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'`
-      })
-
-      subObjs.forEach(item => {
-        getDefaultSql(item, item.$$key, id, level + 1)
-      })
-    }
-    
-    getDefaultSql(result, btn.cbTable, '', 1)
-
-    let lineMap = new Map()
-    lines.forEach(line => {
-      if (lineMap.has(line.table)) {
-        let _line = lineMap.get(line.table)
-        _line.selects.push(line.select)
-        lineMap.set(line.table, _line)
-      } else {
-        lineMap.set(line.table, {
-          table: line.table,
-          insert: line.insert,
-          selects: [line.select]
+        })
+  
+        keys = keys.join(',')
+        vals = vals.join(',')
+  
+        lines.push({
+          table: md5(tb + keys),
+          insert: `Insert into ${tbName} (${keys ? keys + ',' : ''}[mk_level],[mk_id],[mk_bid])`,
+          select: `Select ${keys ? vals + ',' : ''}'${level}','${id}','${bid}'`
+        })
+  
+        subObjs.forEach(item => {
+          getDefaultSql(item, item.$$key, id, level + 1)
         })
       }
-    })
-
-    let param = {
-      func: 'sPC_TableData_InUpDe',
-      BID: BID,
-      menuname: config.name + '(鍥炶皟)'
-    }
-
-    let callbacksql = this.getBackSql()
-    let _prevCustomScript = `${callbacksql}
-    `
-    let _backCustomScript = ''
-
-    btn.cbScripts.forEach(script => {
-      if (script.status === 'false') return
-
-      if (script.position === 'front') {
-        _prevCustomScript += `
-      /* 鑷畾涔夎剼鏈� */
-      ${script.sql}
-      `
-      } else {
-        _backCustomScript += `
-      /* 鑷畾涔夎剼鏈� */
-      ${script.sql}
-      `
+      
+      getDefaultSql(result, btn.cbTable, '', 1)
+  
+      let lineMap = new Map()
+      lines.forEach(line => {
+        if (lineMap.has(line.table)) {
+          let _line = lineMap.get(line.table)
+          _line.selects.push(line.select)
+          lineMap.set(line.table, _line)
+        } else {
+          lineMap.set(line.table, {
+            table: line.table,
+            insert: line.insert,
+            selects: [line.select]
+          })
+        }
+      })
+  
+      param = {
+        func: 'sPC_TableData_InUpDe',
+        BID: BID,
+        menuname: config.name + '(鍥炶皟)'
       }
-    })
-
-    _backCustomScript += `
-      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
-
-    let sql = [...lineMap.values()].map(item => (`
-      ${item.insert}
-      ${item.selects.join(` union all
-      `)}
-    `))
-    sql = sql.join('')
-    sql = _prevCustomScript + sql
-    sql = sql + _backCustomScript
-
-    sql = sql.replace(/@ID@/ig, `'${ID || ''}'`)
-    sql = sql.replace(/@BID@/ig, `'${BID || ''}'`)
-    sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
-    sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
-    sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
-    sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
-    sql = sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`)
-    sql = sql.replace(/@typename@/ig, `'admin'`)
-
-    if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-      sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`)
-    } else {
-      sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
-    }
-
-    if (window.GLOB.debugger === true) {
-      window.mkInfo('%c' + config.name + '(鍥炶皟)', 'color: blue')
-      window.mkInfo(sql.replace(/\n\s{8}/ig, '\n'))
-    }
-
-    param.LText = sql
-    param.exec_type = window.GLOB.execType || 'y' // 鍚庡彴瑙g爜
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    param.secretkey = Utils.encrypt('', param.timestamp)
-    param.LText = Utils.formatOptions(param.LText, param.exec_type)
-
-    if (window.GLOB.probation) {
-      param.s_debug_type = 'Y'
+  
+      let callbacksql = this.getBackSql()
+      let _prevCustomScript = `${callbacksql}
+      `
+      let _backCustomScript = ''
+  
+      btn.cbScripts.forEach(script => {
+        if (script.status === 'false') return
+  
+        if (script.position === 'front') {
+          _prevCustomScript += `
+        /* 鑷畾涔夎剼鏈� */
+        ${script.sql}
+        `
+        } else {
+          _backCustomScript += `
+        /* 鑷畾涔夎剼鏈� */
+        ${script.sql}
+        `
+        }
+      })
+  
+      _backCustomScript += `
+        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+  
+      let sql = [...lineMap.values()].map(item => (`
+        ${item.insert}
+        ${item.selects.join(` union all
+        `)}
+      `))
+      sql = sql.join('')
+      sql = _prevCustomScript + sql
+      sql = sql + _backCustomScript
+  
+      sql = sql.replace(/@ID@/ig, `'${ID || ''}'`)
+      sql = sql.replace(/@BID@/ig, `'${BID || ''}'`)
+      sql = sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`)
+      sql = sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`)
+      sql = sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`)
+      sql = sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`)
+      sql = sql.replace(/@lang@/ig, `'${sessionStorage.getItem('lang')}'`)
+      sql = sql.replace(/@typename@/ig, `'admin'`)
+  
+      if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
+        sql = sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, `'Y'`)
+      } else {
+        sql = sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, `''`)
+      }
+  
+      if (window.GLOB.debugger === true) {
+        window.mkInfo('%c' + config.name + '(鍥炶皟)', 'color: blue')
+        window.mkInfo(sql.replace(/\n\s{8}/ig, '\n'))
+      }
+  
+      param.LText = sql
+      param.exec_type = window.GLOB.execType || 'y' // 鍚庡彴瑙g爜
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.secretkey = Utils.encrypt('', param.timestamp)
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
+  
+      if (window.GLOB.probation) {
+        param.s_debug_type = 'Y'
+      }
     }
 
     Api.genericInterface(param).then(res => {
@@ -1015,6 +1229,163 @@
     })
   }
 
+  getCallBackendParam = (btn, result) => {
+    const { book, BID, ID } = this.state
+
+    let lines = []
+    let tables = []
+
+    btn.verify.cbScripts.forEach(script => {
+      if (script.status === 'false') return
+
+      if (/\s#[a-z0-9_]+(\s|\()/ig.test(script.sql)) {
+        tables.push(...script.sql.match(/\s#[a-z0-9_]+(\s|\()/ig))
+      }
+    })
+
+    tables = tables.map(tb => tb.replace(/\s|\(/g, ''))
+
+    if (result.$ErrCode) {
+      delete result.$ErrCode
+      delete result.$ErrMesg
+    }
+
+    let getDefaultSql = (obj, tb, bid, level) => {
+      let vals = {}
+      let subObjs = []
+      let id = Utils.getuuid()
+
+      delete obj.$$key
+
+      Object.keys(obj).forEach(key => {
+        let val = obj[key]
+        if (val === null || val === undefined) return
+        if (typeof(val) === 'object') {
+          if (Array.isArray(val)) {
+            val.forEach(item => {
+              if (typeof(item) !== 'object' || Array.isArray(item)) return
+              if (Object.keys(item).length === 0) return
+
+              Object.keys(item).forEach(k => {
+                if (item[k] === null) {
+                  item[k] = ''
+                }
+              })
+              item.$$key = tb + '_' + key
+              subObjs.push(item)
+            })
+          } else if (Object.keys(val).length > 0) {
+            val.$$key = tb + '_' + key
+            subObjs.push(val)
+          }
+        } else {
+          if (typeof(val) === 'string') {
+            val = val.replace(/'/ig, '"')
+          } else {
+            val = val + ''
+          }
+          vals[key] = val
+        }
+      })
+
+      vals.mk_level = level
+      vals.mk_id = id
+      vals.mk_bid = bid
+
+      let isnew = true
+      lines.forEach(line => {
+        if (line.tb === tb) {
+          line.values.push(vals)
+          isnew = false
+        }
+      })
+      if (isnew) {
+        lines.push({
+          tb: tb,
+          type: tables.includes('#' + tb) ? '01' : '02',
+          values: [vals]
+        })
+      }
+
+      subObjs.forEach(item => {
+        getDefaultSql(item, item.$$key, id, level + 1)
+      })
+    }
+    
+    getDefaultSql(result, btn.cbTable, '', 1)
+
+    let ex = window.GLOB.CacheData.get('sql_' + btn.uuid + 'billback')
+    let exps = []
+
+    let values = {
+      time_id: Utils.getguid(),
+      roleid: sessionStorage.getItem('role_id') || '',
+      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+      mk_organization: sessionStorage.getItem('organization') || '',
+      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+      mk_nation: sessionStorage.getItem('nation') || '',
+      mk_province: sessionStorage.getItem('province') || '',
+      mk_city: sessionStorage.getItem('city') || '',
+      mk_district: sessionStorage.getItem('district') || '',
+      mk_address: sessionStorage.getItem('address') || '',
+      id: ID || '',
+      bid: BID || '',
+      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+    }
+
+    if (window.GLOB.externalDatabase !== null) {
+      values.db = window.GLOB.externalDatabase
+    }
+
+    ex.reps.forEach(n => {
+      let key = n.toLowerCase()
+      if (values.hasOwnProperty(key)) {
+        exps.push({
+          key: n,
+          value: values[key]
+        })
+      }
+    })
+
+    exps.push({
+      key: 'account_id',
+      value: book.account_id || ''
+    }, {
+      key: 'account_year_id',
+      value: book.account_year_id || ''
+    }, {
+      key: 'account_code',
+      value: book.account_code || ''
+    }, {
+      key: 'account_year_code',
+      value: book.account_year_code || ''
+    })
+
+    exps.push({
+      key: 'mk_outer_params',  // 鍥炶皟鑴氭湰鐨勬暟鎹浛鎹�
+      value: lines
+    })
+
+    let md5_id = ''
+    if (window.GLOB.probation) {
+      md5_id = md5('back_' + btn.uuid + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
+      md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
+    }
+
+    return {
+      $backend: true,
+      $type: 's_TableData_InUpDe',
+      data: [{
+        id: ex.id,
+        menuname: btn.logLabel + '(鍥炶皟)',
+        exps: exps,
+        md5_id: md5_id
+      }]
+    }
+  }
+
   getBackSql = () => {
     const { book, BID } = this.state
 
diff --git a/src/tabviews/custom/components/module/invoice/index.scss b/src/tabviews/custom/components/module/invoice/index.scss
index 1ec31ae..dcae8ad 100644
--- a/src/tabviews/custom/components/module/invoice/index.scss
+++ b/src/tabviews/custom/components/module/invoice/index.scss
@@ -23,6 +23,8 @@
       margin-left: 0px;
       padding: 0px;
       box-shadow: none;
+      position: relative;
+      z-index: 1;
     }
     .mk-back::after {
       display: none;
diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx
index d8b8d6c..5dafb3f 100644
--- a/src/tabviews/home/index.jsx
+++ b/src/tabviews/home/index.jsx
@@ -43,7 +43,7 @@
       this.setState({
         waiting: false
       })
-    } else {
+    } else if (!window.GLOB.$error) {
       setTimeout(() => {
         this.check(times)
       }, 200)
diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
index 5bb8a51..3dddc9d 100644
--- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -934,6 +934,10 @@
       _setting.laypage = pagination
       _setting.arr_field = _setting.all_field || _setting.arr_field
 
+      if (setting.sub_field) {
+        _setting.uuid = btn.uuid
+      }
+
       delete _setting.sub_field
     }
 
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 06f0130..ed8e372 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -2771,7 +2771,7 @@
   clearBackCache = () => {
     if (!window.GLOB.backend) return
 
-    Api.cacheInterface({}).then(res => {
+    Api.cacheInterface({userid: sessionStorage.getItem('UserID') || '', LoginUID: sessionStorage.getItem('LoginUID') || ''}).then(res => {
       if (!res.status) {
         notification.warning({
           top: 92,
@@ -2779,7 +2779,11 @@
           duration: 5
         })
       } else if (window.GLOB.localSystemApi) {
-        Api.cacheInterface({rduri: window.GLOB.localSystemApi.replace('dostars', 'excache')}).then(result => {
+        Api.cacheInterface({
+          userid: sessionStorage.getItem('LocalUserID') || sessionStorage.getItem('UserID') || '',
+          LoginUID: sessionStorage.getItem('LocalLoginUID') || sessionStorage.getItem('LoginUID') || '',
+          rduri: window.GLOB.localSystemApi.replace('dostars', 'excache')
+        }).then(result => {
           if (!result.status) {
             notification.warning({
               top: 92,
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index bf3c61e..5d4e1e1 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -141,6 +141,8 @@
       } else if (item.type === 'datetime') {
         item.type = 'date'
         item.precision = 'second'
+      } else if (item.type === 'fileupload') {
+        item.fieldlength = item.fieldlength || 512
       }
 
       if (!item.field || !['text', 'number', 'switch', 'check', 'rate', 'select', 'popSelect', 'link', 'cascader', 'linkMain', 'funcvar', 'date', 'datemonth', 'radio', 'checkbox', 'checkcard', 'fileupload', 'textarea', 'multiselect', 'brafteditor', 'color', 'vercode'].includes(item.type)) return false
diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js
index 0aa4345..3a6e6de 100644
--- a/src/utils/utils-custom.js
+++ b/src/utils/utils-custom.js
@@ -3195,6 +3195,30 @@
 
             resetButton(item, group.subButton)
           })
+        } else if (item.type === 'module' && item.subtype === 'invoice') {
+          if (item.buyer.setting && item.buyer.setting.interType === 'system') {
+            let msg = getDataSource(item.buyer, [])
+            
+            sqls.push({uuid: item.uuid + 'buyer', type: 'datasource', ...msg})
+          }
+
+          if (item.detail.setting && item.detail.setting.interType === 'system') {
+            let _msg = getDataSource(item.detail, [])
+  
+            sqls.push({uuid: item.uuid + 'detail', type: 'datasource', ..._msg})
+          }
+
+          let btnmsg = getInvoicePreSql(item.billSaveBtn, item.$menuname + '-' + item.billSaveBtn.label)
+
+          sqls.push({uuid: item.uuid + item.billSaveBtn.type, type: 'button', ...btnmsg})
+
+          let _btnmsg = getInvoicePreSql(item.billOutBtn, item.$menuname + '-'  + item.billOutBtn.label)
+
+          sqls.push({uuid: item.uuid + item.billOutBtn.type, type: 'button', ..._btnmsg})
+
+          let backmsg = getInvoiceSysBackSql(item.billOutBtn, item.$menuname + '-'  + item.billOutBtn.label + '(鍥炶皟)')
+
+          sqls.push({uuid: item.uuid + 'billback', type: 'btnCallBack', ...backmsg})
         }
       }
     })
@@ -3259,6 +3283,10 @@
     } else if (cell.OpenType === 'excelOut') {
       if (cell.intertype === 'system' && cell.verify && cell.verify.dataType === 'custom') {
         let msg = getExcelOutSql(cell, item)
+
+        sqls.push({uuid: cell.uuid, type: 'excelOut', ...msg})
+      } else if (cell.intertype === 'system' && cell.verify && item.subtype === 'dualdatacard' && item.setting && item.setting.interType === 'system') {
+        let msg = getDoubleExcelOutSql(cell, item)
 
         sqls.push({uuid: cell.uuid, type: 'excelOut', ...msg})
       }
@@ -4642,8 +4670,6 @@
   }
 
   let getDataSource = (item, mainSearch = [], type) => {
-    if (!item.setting || item.setting.interType !== 'system') return
-
     let searches = item.search || []
     if (item.setting.useMSearch === 'true' && mainSearch.length > 0) {
       searches = [...searches, ...mainSearch]
@@ -4694,7 +4720,7 @@
       _search = ''
     }
 
-    if (/\s/.test(_dataresource)) {
+    if (/\s/.test(_dataresource) && !/\)\s+tb$/.test(_dataresource)) {
       _dataresource = '(' + _dataresource + ') tb'
     }
 
@@ -4798,6 +4824,12 @@
     // INSERT INTO s_paas_api_log (appkey,api_name,api_count,menuname,createuserid,createuser,createstaff,cdefine1,cdefine2) 
     // SELECT @appkey@,'sPC_Get_TableData',1,@menuname@,@UserID@,@username@,@fullname@,@SessionUid@,@LoginUID@
     let sql = ''
+    let e_sql = `select ${_columns.map(col => col.field).join(',')} from (select ${_columns.map(col => /date/ig.test(col.datatype) ? `'1949-10-01' as ${col.field}` : `'0' as ${col.field}`).join(',')}) a where ${item.setting.primaryKey || 'ID'} != '0'`
+    if (DateCount) {
+      e_sql += `
+      select 0 as total
+      `
+    }
 
     if (item.setting.transact === 'true' && !/BEGIN\s+TRY\s+begin\s+TRAN/.test(_customScript)) {
       sql = `/* ${item.setting.$name} */
@@ -4807,13 +4839,6 @@
         SELECT obj_name='@mk_obj_name@',prm_field='',str_field='',
         arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}'
       `
-
-      let e_sql = `select ${_columns.map(col => col.field).join(',')} from (select ${_columns.map(col => /date/ig.test(col.datatype) ? `'1949-10-01' as ${col.field}` : `'0' as ${col.field}`).join(',')}) a where ${item.setting.primaryKey || 'ID'} != '0'`
-      if (DateCount) {
-        e_sql += `
-        select 0 as total
-        `
-      }
 
       _tailScript = `${_tailScript}
         select @ErrorCode as ErrorCode,@retmsg as retmsg
@@ -4847,8 +4872,17 @@
         arr_field='${arr_field}',tabid='${tabid}',parid='${parid}',sub_name='${sub_name}',sub_field='${sub_field}'
       `
 
+      let tail = 'aaa:'
+      if (/\sgoto\s+aaa([^0-9a-z_]|$)/ig.test(_customScript) && !/BEGIN\s+TRY\s+begin\s+TRAN/.test(_customScript)) {
+        tail = `if 1=2
+        begin
+          aaa:
+          ${e_sql}
+        end`
+      }
+
       _tailScript = `${_tailScript}
-        aaa:
+        ${tail}
           select @ErrorCode as ErrorCode,@retmsg as retmsg
       `
     }
@@ -5520,6 +5554,20 @@
     return msg
   }
 
+  let getDoubleExcelOutSql = (btn, component) => {
+    let item = fromJS(component).toJS()
+    item.search = item.$searches || []
+    item.subtype = 'datacard'
+    item.columns = [...item.columns, ...item.subColumns]
+
+    item.setting.laypage = btn.pagination
+    item.setting.$name = btn.logLabel || ''
+
+    let msg = getDataSource(item, [])
+
+    return msg
+  }
+
   let getPrintSql = (btn, component) => {
     let item = {setting: {}, columns: btn.verify.columns || [], search: [], useMSearch: 'false'}
 
@@ -5993,6 +6041,209 @@
     return {LText: sql, md5: md5(sql), reps}
   }
 
+  let getInvoicePreSql = (btn, logLabel) => {
+    let reps = []
+    let sysVars = ['loginuid', 'sessionuid', 'userid', 'appkey', 'lang', 'username', 'fullname', 'menuname']
+    let _script = ''
+    btn.scripts.forEach(item => {
+      if (item.status === 'false') return
+      _script += `
+      ${item.sql}
+      `
+    })
+
+    _script = _script.replace(/@typename@/ig, `'admin'`)
+    
+    let regs = ['ID', 'BID', 'time_id', 'datam', ...sysVars]
+
+    regs.forEach(s => {
+      if (new RegExp('@' + s + '@', 'ig').test(_script)) {
+        reps.push(s)
+      }
+    })
+
+    reps.forEach(n => {
+      _script = _script.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`)
+    })
+    if (/\$@/ig.test(_script)) {
+      _script = _script.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@')
+      reps.push('datam_begin', 'datam_end')
+    }
+    if (/@db@/ig.test(_script)) {
+      reps.push('db')
+    }
+
+    let syses = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid']
+    let decSql = []
+    let secSql = []
+  
+    syses.forEach(s => {
+      if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(_script)) {
+        if (['RoleID', 'mk_departmentcode', 'mk_organization'].includes(s)) {
+          decSql.push(`@${s} nvarchar(512)`)
+        } else if (['mk_address'].includes(s)) {
+          decSql.push(`@mk_address nvarchar(100)`)
+        } else {
+          decSql.push(`@${s} nvarchar(50)`)
+        }
+        secSql.push(`@${s}='@${s}@'`)
+        reps.push(s)
+      }
+    })
+    decSql = decSql.join(',')
+    secSql = secSql.join(',')
+
+    let sql = `/* ${logLabel} */
+      BEGIN TRY 
+      begin TRAN
+
+      Declare @ErrorCode nvarchar(50), @retmsg nvarchar(4000), @account_id nvarchar(50), @account_year_id nvarchar(50), @account_code nvarchar(50), @account_year_code nvarchar(50), @tbid nvarchar(50)${decSql ? ',' + decSql : ''}
+
+      Select @ErrorCode='S', @retmsg='', @account_id='@account_id@', @account_year_id='@account_year_id@', @account_code='@account_code@', @account_year_code='@account_year_code@'${secSql ? ',' + secSql : ''}
+
+      /* 鍙戠エ涓昏〃瀛楁 */
+      Declare @invoice_type Nvarchar(50), @from_to_name Nvarchar(50), @from_to_tax_no Nvarchar(50), @from_to_addr Nvarchar(100), @from_to_tel Nvarchar(50), @from_to_bank_name Nvarchar(50), @from_to_account_no Nvarchar(50), @from_to_mob Nvarchar(50), @from_to_email Nvarchar(50), @from_to_code Nvarchar(50), @orgname Nvarchar(50), @tax_no Nvarchar(50), @addr Nvarchar(100), @tel Nvarchar(50), @bank_name Nvarchar(50), @account_no Nvarchar(50), @remark Nvarchar(512), @payee Nvarchar(50), @reviewer Nvarchar(50), @drawer Nvarchar(50), @io Nvarchar(50), @orgcode Nvarchar(50), @total_net_amount Decimal(18,2), @total_tax Decimal(18,2), @total_amount Decimal(18,2), @business_type Nvarchar(20)
+
+      Select @invoice_type='@invoice_type@', @from_to_name='@from_to_name@', @from_to_tax_no='@from_to_tax_no@', @from_to_addr='@from_to_addr@', @from_to_tel='@from_to_tel@', @from_to_bank_name='@from_to_bank_name@', @from_to_account_no='@from_to_account_no@', @from_to_mob='@from_to_mob@', @from_to_email='@from_to_email@', @from_to_code='@from_to_code@', @orgname='@orgname@', @tax_no='@tax_no@', @addr='@addr@', @tel='@tel@', @bank_name='@bank_name@', @account_no='@account_no@', @remark='@remark@', @payee='@payee@', @reviewer='@reviewer@', @drawer='@drawer@', @io='@io@', @orgcode='@orgcode@', @total_net_amount=@total_net_amount@, @total_tax=@total_tax@, @total_amount=@total_amount@, @business_type='@business_type@'
+
+      /* 鍙戠エ鏄庣粏涓存椂琛� */
+
+      Declare @details_list table (productcode Nvarchar(50), productname Nvarchar(50), spec Nvarchar(50), unit Nvarchar(50), bill_count Decimal(18,10), unitprice Decimal(18,10), amount_line Decimal(18,2), tax_classify_code Nvarchar(50), tax_classify_name Nvarchar(50), tax_rate Decimal(18,2), tax_amount Decimal(18,2), free_tax_mark Nvarchar(50), vat_special_management Nvarchar(50), invoice_lp Nvarchar(50), tax_item Nvarchar(50), tax_method Nvarchar(50), jskey Nvarchar(50), data_type Nvarchar(50))
+
+      Insert into @details_list (productcode, productname, spec, unit, bill_count, unitprice, amount_line, tax_classify_code, tax_classify_name, tax_rate, tax_amount, free_tax_mark, vat_special_management, invoice_lp, tax_item, tax_method, jskey, data_type)
+
+      @mk_excel_data@
+
+      /* 鑷畾涔夎剼鏈� */
+      ${_script}
+      `
+
+    if (btn.type === 'billout') {
+      sql += callback
+    } else {
+      sql += `
+        select @ErrorCode as ErrorCode,@retmsg as retmsg
+        ${callback}
+        `
+    }
+
+    reps = reps.filter(n => {
+      if (sysVars.includes(n.toLowerCase())) {
+        return false
+      }
+
+      return true
+    })
+
+    sql = sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '')
+
+    return {LText: sql, md5: md5(sql), reps}
+  }
+
+  let getInvoiceSysBackSql = (btn, logLabel) => {
+    let _prev = ''
+    let _back = ''
+    let tables = []
+    let reps = []
+
+    btn.cbScripts.forEach(script => {
+      if (script.status === 'false') return
+
+      if (/\s#[a-z0-9_]+(\s|\()/ig.test(script.sql)) {
+        tables.push(...script.sql.match(/\s#[a-z0-9_]+(\s|\()/ig))
+      }
+
+      if (script.position === 'front') {
+        _prev += `
+        /* 鑷畾涔夎剼鏈� */
+        ${script.sql}
+        `
+      } else {
+        _back += `
+        /* 鑷畾涔夎剼鏈� */
+        ${script.sql}
+        `
+      }
+    })
+
+    tables = tables.map(tb => tb.replace(/\s|\(/g, ''))
+
+    let syses = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'mk_user_type', 'mk_nation', 'mk_province', 'mk_city', 'mk_district', 'mk_address', 'bid']
+    let decSql = []
+    let secSql = []
+    let testSql = _prev + _back
+
+    _prev = _prev.replace(/@typename@/ig, `'admin'`)
+    _back = _back.replace(/@typename@/ig, `'admin'`)
+
+    let regs = ['ID', 'BID', 'time_id', 'datam', ...sysVars]
+
+    regs.forEach(s => {
+      if (new RegExp('@' + s + '@', 'ig').test(testSql)) {
+        reps.push(s)
+      }
+    })
+
+    reps.forEach(n => {
+      _prev = _prev.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`)
+      _back = _back.replace(new RegExp('@' + n + '@', 'ig'), `'@${n}@'`)
+    })
+    if (/\$@/ig.test(testSql)) {
+      _prev = _prev.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@')
+      _back = _back.replace(/\$@/ig, '@datam_begin@').replace(/@\$/ig, '@datam_end@')
+      reps.push('datam_begin', 'datam_end')
+    }
+    if (/@db@/ig.test(testSql)) {
+      reps.push('db')
+    }
+  
+    syses.forEach(s => {
+      if (new RegExp('@' + s + '[^0-9a-z_]', 'ig').test(testSql)) {
+        if (['RoleID', 'mk_departmentcode', 'mk_organization'].includes(s)) {
+          decSql.push(`@${s} nvarchar(512)`)
+        } else if (['mk_address'].includes(s)) {
+          decSql.push(`@mk_address nvarchar(100)`)
+        } else {
+          decSql.push(`@${s} nvarchar(50)`)
+        }
+        secSql.push(`@${s}='@${s}@'`)
+        reps.push(s)
+      }
+    })
+    decSql = decSql.join(',')
+    secSql = secSql.join(',')
+  
+    // 闇�瑕佸0鏄庣殑鍙橀噺闆�
+
+    let _sql = `/* ${logLabel} */
+      BEGIN TRY 
+      begin TRAN
+
+      Declare @ErrorCode nvarchar(50), @retmsg nvarchar(4000), @account_id nvarchar(50), @account_year_id nvarchar(50), @account_code nvarchar(50), @account_year_code nvarchar(50), @tbid nvarchar(50)${decSql ? ',' + decSql : ''}
+
+      Select @ErrorCode='S', @retmsg='', @account_id='@account_id@', @account_year_id='@account_year_id@', @account_code='@account_code@', @account_year_code='@account_year_code@'${secSql ? ',' + secSql : ''}
+
+      ${_prev}
+      /* 澶栭儴鎺ュ彛鍏ュ弬 */
+      @mk_outer_params@
+      ${_back}
+      select @ErrorCode as ErrorCode,@retmsg as retmsg
+      ${callback}
+      `
+
+    _sql = _sql.replace(/\n\x20{6,8}/g, '\n').replace(/\n{3,}/g, '\n\n').replace(/^\s+|\s+$/g, '').replace(/\t+|\v+/g, '')
+
+    reps = reps.filter(n => {
+      if (sysVars.includes(n.toLowerCase())) {
+        return false
+      }
+
+      return true
+    })
+
+    return { LText: _sql, md5: md5(_sql), reps, tbs: tables }
+  }
+
   let _mainSearch = []
 
   if (appType === 'mob') {
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 47394e2..cc69ca5 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -71,6 +71,7 @@
       uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
     }
     uuid = timestamp + uuid.join('')
+    uuid = uuid.replace(/minke/ig, 'mnkie')
     return uuid
   }
 
diff --git a/src/views/interface/index.jsx b/src/views/interface/index.jsx
index 3d88456..f13789e 100644
--- a/src/views/interface/index.jsx
+++ b/src/views/interface/index.jsx
@@ -1,4 +1,5 @@
-import React, {Component} from 'react'
+import React, { Component } from 'react'
+import { withRouter } from 'react-router'
 
 import Header from './header'
 import History from './history'
@@ -7,7 +8,16 @@
 import './index.scss'
 
 class Interface extends Component {
+  componentDidMount () {
+    if (!sessionStorage.getItem('UserID') || /^visitor/.test(sessionStorage.getItem('UserID'))) {
+      this.props.history.replace('/login')
+      return
+    }
+  }
   render () {
+    if (!sessionStorage.getItem('UserID') || /^visitor/.test(sessionStorage.getItem('UserID'))) {
+      return null
+    }
     return (
       <div className="interface-view">
         <Header key="header"/>
@@ -18,4 +28,4 @@
   }
 }
 
-export default Interface
\ No newline at end of file
+export default withRouter(Interface)
\ No newline at end of file
diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index f85902a..4b91a51 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -817,6 +817,7 @@
           for (let i = 0; i < 18; i++) {
             uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65)
           }
+          uuid = uuid.replace(/minke/ig, 'MNKIE')
           return uuid
         }
 
diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index fff66dd..a87df2d 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -1492,6 +1492,7 @@
           for (let i = 0; i < 18; i++) {
             uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65)
           }
+          uuid = uuid.replace(/minke/ig, 'MNKIE')
           return uuid
         }
 
diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index 978796c..0638e83 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/index.jsx
@@ -1218,6 +1218,7 @@
           for (let i = 0; i < 18; i++) {
             uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65)
           }
+          uuid = uuid.replace(/minke/ig, 'MNKIE')
           return uuid
         }
 
diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx
index 8d46d4a..80aa91e 100644
--- a/src/views/tabledesign/index.jsx
+++ b/src/views/tabledesign/index.jsx
@@ -577,6 +577,7 @@
           for (let i = 0; i < 18; i++) {
             uuid += String.fromCharCode(Math.floor(Math.random() * 26) + 65)
           }
+          uuid = uuid.replace(/minke/ig, 'MNKIE')
           return uuid
         }
 

--
Gitblit v1.8.0