From 34f4be5727bf4d0d231e0691a503cf0c9e5d00d3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 27 一月 2021 19:10:56 +0800
Subject: [PATCH] 2021-01-27

---
 src/assets/mobimg/sandbox.png                                                    |    0 
 src/utils/utils-datamanage.js                                                    |   81 +
 src/menu/picturecontroller/index.jsx                                             |   52 +
 src/menu/stylecombcontrolbutton/index.scss                                       |    3 
 src/tabviews/formtab/actionList/index.jsx                                        |    8 
 src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx |    5 
 src/tabviews/verupmanage/actionList/index.jsx                                    |   14 
 src/templates/zshare/verifycard/callbackcustomscript/index.jsx                   |   14 
 src/templates/comtableconfig/index.jsx                                           |    4 
 src/menu/picturecontroller/index.scss                                            |    4 
 src/tabviews/zshare/settingcomponent/index.jsx                                   |    4 
 src/tabviews/zshare/actionList/excelInbutton/index.jsx                           |    4 
 src/views/menudesign/printmenuform/index.jsx                                     |   10 
 src/menu/pastecontroller/index.scss                                              |    4 
 src/views/billprint/index.jsx                                                    |   24 
 src/tabviews/subtable/index.jsx                                                  |   72 -
 src/tabviews/subtabtable/index.jsx                                               |   72 -
 src/tabviews/commontable/index.jsx                                               |   72 -
 src/tabviews/zshare/actionList/normalbutton/index.jsx                            |   85 +
 src/views/menudesign/index.jsx                                                   |   20 
 src/utils/utils.js                                                               | 1791 +++++++++++++++++++-------------------
 src/utils/utils-update.js                                                        |  311 +++---
 src/templates/zshare/verifycard/index.jsx                                        |   10 
 src/menu/pastecontroller/index.jsx                                               |    2 
 src/templates/subtableconfig/index.jsx                                           |    4 
 src/tabviews/zshare/mutilform/index.jsx                                          |   38 
 src/menu/modelsource/option.jsx                                                  |    3 
 src/menu/stylecombcontrolbutton/index.jsx                                        |    2 
 src/menu/popview/index.jsx                                                       |    4 
 29 files changed, 1,390 insertions(+), 1,327 deletions(-)

diff --git a/src/assets/mobimg/sandbox.png b/src/assets/mobimg/sandbox.png
new file mode 100644
index 0000000..b77e217
--- /dev/null
+++ b/src/assets/mobimg/sandbox.png
Binary files differ
diff --git a/src/menu/modelsource/option.jsx b/src/menu/modelsource/option.jsx
index f99e7bc..9c0a333 100644
--- a/src/menu/modelsource/option.jsx
+++ b/src/menu/modelsource/option.jsx
@@ -10,6 +10,7 @@
 import NormalTable from '@/assets/mobimg/normal-table.png'
 import Pie from '@/assets/mobimg/pie.png'
 import Editor from '@/assets/mobimg/editor.png'
+import SandBox from '@/assets/mobimg/sandbox.png'
 import Pie1 from '@/assets/mobimg/ring.png'
 import Pie2 from '@/assets/mobimg/nightingale.png'
 import Mainsearch from '@/assets/mobimg/mainsearch.png'
@@ -29,7 +30,7 @@
   { type: 'menu', url: Pie, component: 'pie', subtype: 'pie', title: '楗煎浘', width: 12 },
   { type: 'menu', url: Pie1, component: 'pie', subtype: 'ring', title: '鐜浘', width: 12 },
   { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '瀵屾枃鏈�', width: 24 },
-  { type: 'menu', url: Editor, component: 'code', subtype: 'sandbox', title: '鑷畾涔�', width: 24 },
+  { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '鑷畾涔�', width: 24 },
   { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '鍗椾竵鏍煎皵鍥�', width: 12 },
   { type: 'menu', url: group, component: 'group', subtype: 'normalgroup', title: '鍒嗙粍', width: 24, forbid: ['billPrint'] },
 ]
diff --git a/src/menu/pastecontroller/index.jsx b/src/menu/pastecontroller/index.jsx
index f8061f3..d7d3dc4 100644
--- a/src/menu/pastecontroller/index.jsx
+++ b/src/menu/pastecontroller/index.jsx
@@ -241,7 +241,7 @@
     return (
       <div style={{display: 'inline-block'}}>
         {type !== 'menu' ? <Icon type="snippets" style={{color: 'purple'}} onClick={() => {this.setState({visible: true})}} /> : null}
-        {type === 'menu' ? <Button type="link" style={{padding: '5px'}} icon="snippets" onClick={() => {this.setState({visible: true})}}>绮樿创</Button> : null}
+        {type === 'menu' ? <Button className="Menu-config-paste" icon="snippets" onClick={() => {this.setState({visible: true})}}>绮樿创</Button> : null}
         <Modal
           title="绮樿创"
           visible={visible}
diff --git a/src/menu/pastecontroller/index.scss b/src/menu/pastecontroller/index.scss
index e69de29..6fbba6f 100644
--- a/src/menu/pastecontroller/index.scss
+++ b/src/menu/pastecontroller/index.scss
@@ -0,0 +1,4 @@
+.Menu-config-paste {
+  border-color: #40a9ff;
+  color: #40a9ff;
+}
\ No newline at end of file
diff --git a/src/menu/picturecontroller/index.jsx b/src/menu/picturecontroller/index.jsx
new file mode 100644
index 0000000..0e6b3b3
--- /dev/null
+++ b/src/menu/picturecontroller/index.jsx
@@ -0,0 +1,52 @@
+import React, {Component} from 'react'
+// import { fromJS } from 'immutable'
+import { Modal, Button } from 'antd'
+
+// import Utils from '@/utils/utils.js'
+// import asyncComponent from '@/utils/asyncComponent'
+import './index.scss'
+
+// const PasteForm = asyncComponent(() => import('@/templates/zshare/pasteform'))
+
+class PasteController extends Component {
+  state = {
+    visible: false
+  }
+  
+  addSource = () => {
+
+  }
+  
+  render() {
+    const { visible } = this.state
+
+    return (
+      <div style={{display: 'inline-block'}}>
+        <Button className="mk-border-purple" icon="picture" onClick={() => {this.setState({visible: true})}}>璧勬簮绠$悊</Button>
+        <Modal
+          title="绮樿创"
+          visible={visible}
+          width={600}
+          maskClosable={false}
+          onOk={this.pasteSubmit}
+          onCancel={() => {this.setState({visible: false})}}
+          footer={[
+            <Button key="back" type="link" icon="plus" onClick={this.addSource}>
+              娣诲姞
+            </Button>,
+            <Button key="colse" onClick={() => {this.setState({visible: false})}}>
+              鍏抽棴
+            </Button>
+          ]}
+          destroyOnClose
+        >
+          <div>
+
+          </div>
+        </Modal>
+      </div>
+    )
+  }
+}
+
+export default PasteController
\ No newline at end of file
diff --git a/src/menu/picturecontroller/index.scss b/src/menu/picturecontroller/index.scss
new file mode 100644
index 0000000..6fbba6f
--- /dev/null
+++ b/src/menu/picturecontroller/index.scss
@@ -0,0 +1,4 @@
+.Menu-config-paste {
+  border-color: #40a9ff;
+  color: #40a9ff;
+}
\ No newline at end of file
diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx
index 83b58a1..93b026c 100644
--- a/src/menu/popview/index.jsx
+++ b/src/menu/popview/index.jsx
@@ -585,10 +585,10 @@
               {customComponents && customComponents.length ? <Panel header="鑷畾涔夌粍浠�" key="cuscomponent">
                 <SourceWrap components={customComponents} MenuType={MenuType} />
               </Panel> : null}
-              <Panel header={'鑳屾櫙'} key="background">
+              <Panel header={'椤甸潰鑳屾櫙'} key="background">
                 {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null}
               </Panel>
-              <Panel header={'鍐呰竟璺�'} key="padding">
+              <Panel header={'椤甸潰鍐呰竟璺�'} key="padding">
                 {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null}
               </Panel>
             </Collapse>
diff --git a/src/menu/stylecombcontrolbutton/index.jsx b/src/menu/stylecombcontrolbutton/index.jsx
index 328487d..19f3454 100644
--- a/src/menu/stylecombcontrolbutton/index.jsx
+++ b/src/menu/stylecombcontrolbutton/index.jsx
@@ -148,7 +148,7 @@
   render() {
     const { label } = this.state
     return (
-      <Button className="style-control-button" type="link" icon="font-colors" title="璋冩暣鏍峰紡" onClick={this.triggerStyleChange}>{label}</Button>
+      <Button className="style-control-button" icon="font-colors" title="璋冩暣鏍峰紡" onClick={this.triggerStyleChange}>{label}</Button>
     )
   }
 }
diff --git a/src/menu/stylecombcontrolbutton/index.scss b/src/menu/stylecombcontrolbutton/index.scss
index 4b518f3..09668c2 100644
--- a/src/menu/stylecombcontrolbutton/index.scss
+++ b/src/menu/stylecombcontrolbutton/index.scss
@@ -1,6 +1,7 @@
 
-.style-control-button.ant-btn-link, .style-control-button.ant-btn-link:hover, .style-control-button.ant-btn-link:focus {
+.style-control-button, .style-control-button:hover, .style-control-button:focus {
   color: orange;
+  border-color: orange;
   position: relative;
   z-index: 13;
   background: #ffffff;
diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 41b2dc9..a400cdd 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -10,7 +10,7 @@
 import Utils from '@/utils/utils.js'
 import options from '@/store/options.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateCommonTable } from '@/utils/utils-update.js'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import MKEmitter from '@/utils/events.js'
@@ -151,7 +151,7 @@
       }
 
       // 鐗堟湰鍏煎
-      config = UtilsUpdate.updateCommonTable(config)
+      config = updateCommonTable(config)
 
       // 鏉冮檺杩囨护
       if (this.props.menuType !== 'HS') {
@@ -565,9 +565,6 @@
 
   customCallbackRequest = (result) => {
     const { setting } = this.state
-    let lines = []
-    let pre = setting.callbackType === 'script' ? '@' : ''
-
     let errSql = ''
     if (result.$ErrCode === 'E') {
       errSql = `
@@ -578,68 +575,11 @@
       delete result.$ErrMesg
     }
 
-    let getDefaultSql = (obj, tb, bid, level) => {
-      let keys = []
-      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) {
-                item.$$key = tb + '_' + key
-                subObjs.push(item)
-              }
-            })
-          } else if (Object.keys(val).length > 0) {
-            val.$$key = tb + '_' + key
-            subObjs.push(val)
-          }
-        } else {
-          keys.push(key)
-          vals.push(`'${val}'`)
-        }
-      })
-
-      lines.push({
-        table: tb,
-        insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`,
-        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
-      })
-
-      subObjs.forEach(item => {
-        getDefaultSql(item, item.$$key, id, level + 1)
-      })
-    }
-    
-    getDefaultSql(result, setting.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]
-        })
-      }
-    })
-
+    let lines = UtilsDM.getCallBackSql(setting, result)
     let param = {}
 
     if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈�
-      let sql = [...lineMap.values()].map(item => (`
+      let sql = lines.map(item => (`
         ${item.insert}
         ${item.selects.join(` union all
         `)}
@@ -657,7 +597,7 @@
       }
     } else {
       param.func = 's_ex_result_back'
-      param.s_ex_result = [...lineMap.values()].map((item, index) => ({
+      param.s_ex_result = lines.map((item, index) => ({
         MenuID: this.state.config.MenuID,
         MenuName: this.state.config.MenuName,
         TableName: item.table,
@@ -666,7 +606,7 @@
       }))
 
       if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
-        let sql = [...lineMap.values()].map(item => (`
+        let sql = lines.map(item => (`
           ${item.insert}
           ${item.selects.join(` union all
           `)}
diff --git a/src/tabviews/formtab/actionList/index.jsx b/src/tabviews/formtab/actionList/index.jsx
index 3dfab42..698fcf1 100644
--- a/src/tabviews/formtab/actionList/index.jsx
+++ b/src/tabviews/formtab/actionList/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import moment from 'moment'
 import { Button, Modal, notification, message } from 'antd'
-import Utils from '@/utils/utils.js'
+import Utils, { getSysDefaultSql } from '@/utils/utils.js'
 import options from '@/store/options.js'
 import Api from '@/api'
 import './index.scss'
@@ -121,7 +121,7 @@
 
       if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid
         param.ID = Utils.getguid()
-        param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
+        param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
         param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt('', param.timestamp)
         param.LText = Utils.formatOptions(param.LText)
@@ -129,7 +129,7 @@
         _primaryId = param.ID
       } else if (btn.sql && btn.sqlType === 'insertOrUpdate') { // 绯荤粺鍑芥暟娣诲姞鎴栦慨鏀规椂
         param.ID = primaryId || Utils.getguid()
-        param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
+        param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
         param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt('', param.timestamp)
         param.LText = Utils.formatOptions(param.LText)
@@ -137,7 +137,7 @@
         _primaryId = param.ID
       } else if (btn.sql) {
         param.ID = primaryId
-        param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
+        param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧�
         param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
         param.secretkey = Utils.encrypt('', param.timestamp)
         param.LText = Utils.formatOptions(param.LText)
diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx
index d2afecd..bc777f4 100644
--- a/src/tabviews/subtable/index.jsx
+++ b/src/tabviews/subtable/index.jsx
@@ -10,7 +10,7 @@
 import Utils from '@/utils/utils.js'
 import options from '@/store/options.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateSubTable } from '@/utils/utils-update.js'
 import { modifyTabview } from '@/store/action'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
@@ -135,7 +135,7 @@
       let absFields = []     // 缁濆鍊煎瓧娈�
 
       // 鐗堟湰鍏煎
-      config = UtilsUpdate.updateSubTable(config)
+      config = updateSubTable(config)
 
       // 鏉冮檺杩囨护
       if (this.props.menuType !== 'HS') {
@@ -494,9 +494,6 @@
 
   customCallbackRequest = (result) => {
     const { setting } = this.state
-    let lines = []
-    let pre = setting.callbackType === 'script' ? '@' : ''
-
     let errSql = ''
     if (result.$ErrCode === 'E') {
       errSql = `
@@ -507,68 +504,11 @@
       delete result.$ErrMesg
     }
 
-    let getDefaultSql = (obj, tb, bid, level) => {
-      let keys = []
-      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) {
-                item.$$key = tb + '_' + key
-                subObjs.push(item)
-              }
-            })
-          } else if (Object.keys(val).length > 0) {
-            val.$$key = tb + '_' + key
-            subObjs.push(val)
-          }
-        } else {
-          keys.push(key)
-          vals.push(`'${val}'`)
-        }
-      })
-
-      lines.push({
-        table: tb,
-        insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`,
-        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
-      })
-
-      subObjs.forEach(item => {
-        getDefaultSql(item, item.$$key, id, level + 1)
-      })
-    }
-    
-    getDefaultSql(result, setting.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]
-        })
-      }
-    })
-
+    let lines = UtilsDM.getCallBackSql(setting, result)
     let param = {}
 
     if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈�
-      let sql = [...lineMap.values()].map(item => (`
+      let sql = lines.map(item => (`
         ${item.insert}
         ${item.selects.join(` union all
         `)}
@@ -586,7 +526,7 @@
       }
     } else {
       param.func = 's_ex_result_back'
-      param.s_ex_result = [...lineMap.values()].map((item, index) => ({
+      param.s_ex_result = lines.map((item, index) => ({
         MenuID: this.props.MenuID,
         MenuName: this.props.Tab.label,
         TableName: item.table,
@@ -595,7 +535,7 @@
       }))
 
       if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
-        let sql = [...lineMap.values()].map(item => (`
+        let sql = lines.map(item => (`
           ${item.insert}
           ${item.selects.join(` union all
           `)}
diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index 3e98a32..1e7b4bd 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -10,7 +10,7 @@
 import Utils from '@/utils/utils.js'
 import options from '@/store/options.js'
 import UtilsDM from '@/utils/utils-datamanage.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateSubTable } from '@/utils/utils-update.js'
 import asyncComponent from '@/utils/asyncComponent'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
 import NotFount from '@/components/404'
@@ -111,7 +111,7 @@
       let absFields = []     // 缁濆鍊煎瓧娈�
 
       // 鐗堟湰鍏煎
-      config = UtilsUpdate.updateSubTable(config)
+      config = updateSubTable(config)
 
       // 涓嶆敮鎸乫uncbutton銆乸opview 绫诲瀷鎸夐挳
       let labels = []
@@ -455,9 +455,6 @@
 
   customCallbackRequest = (result) => {
     const { setting } = this.state
-    let lines = []
-    let pre = setting.callbackType === 'script' ? '@' : ''
-
     let errSql = ''
     if (result.$ErrCode === 'E') {
       errSql = `
@@ -468,68 +465,11 @@
       delete result.$ErrMesg
     }
 
-    let getDefaultSql = (obj, tb, bid, level) => {
-      let keys = []
-      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) {
-                item.$$key = tb + '_' + key
-                subObjs.push(item)
-              }
-            })
-          } else if (Object.keys(val).length > 0) {
-            val.$$key = tb + '_' + key
-            subObjs.push(val)
-          }
-        } else {
-          keys.push(key)
-          vals.push(`'${val}'`)
-        }
-      })
-
-      lines.push({
-        table: tb,
-        insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`,
-        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
-      })
-
-      subObjs.forEach(item => {
-        getDefaultSql(item, item.$$key, id, level + 1)
-      })
-    }
-    
-    getDefaultSql(result, setting.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]
-        })
-      }
-    })
-
+    let lines = UtilsDM.getCallBackSql(setting, result)
     let param = {}
 
     if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈�
-      let sql = [...lineMap.values()].map(item => (`
+      let sql = lines.map(item => (`
         ${item.insert}
         ${item.selects.join(` union all
         `)}
@@ -548,7 +488,7 @@
     } else {
       let name = this.props.Tab ? (this.props.Tab.label || '') : ''
       param.func = 's_ex_result_back'
-      param.s_ex_result = [...lineMap.values()].map((item, index) => ({
+      param.s_ex_result = lines.map((item, index) => ({
         MenuID: this.props.MenuID,
         MenuName: name,
         TableName: item.table,
@@ -557,7 +497,7 @@
       }))
 
       if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
-        let sql = [...lineMap.values()].map(item => (`
+        let sql = lines.map(item => (`
           ${item.insert}
           ${item.selects.join(` union all
           `)}
diff --git a/src/tabviews/verupmanage/actionList/index.jsx b/src/tabviews/verupmanage/actionList/index.jsx
index 0a20a3d..5671678 100644
--- a/src/tabviews/verupmanage/actionList/index.jsx
+++ b/src/tabviews/verupmanage/actionList/index.jsx
@@ -3,7 +3,7 @@
 import moment from 'moment'
 import { Button, Modal, notification, message } from 'antd'
 import MutilForm from '@/tabviews/zshare/mutilform'
-import Utils from '@/utils/utils.js'
+import Utils, { getSysDefaultSql } from '@/utils/utils.js'
 import options from '@/store/options.js'
 import Api from '@/api'
 import './index.scss'
@@ -171,7 +171,7 @@
             }
           } else if (btn.sql) {
             param.ID = primaryId
-            param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns) // 鏁版嵁婧�
+            param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns) // 鏁版嵁婧�
             
             param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -199,7 +199,7 @@
               }
             }
             param.ID = primaryId || Utils.getguid()
-            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 鏁版嵁婧�
+            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 鏁版嵁婧�
             
             param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -207,7 +207,7 @@
             param.LText = Utils.formatOptions(param.LText)
           } else if (btn.sql) {
             param.ID = primaryId
-            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 鏁版嵁婧�
+            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 鏁版嵁婧�
             
             param.exec_type = 'y' // 鍚庡彴瑙g爜
             param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -253,7 +253,7 @@
               }
             } else if (btn.sql) {
               param.ID = primaryId
-              param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns) // 鏁版嵁婧�
+              param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns) // 鏁版嵁婧�
 
               param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -277,7 +277,7 @@
               }
             } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid
               param.ID = _formPrimaryId || Utils.getguid()
-              param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 鏁版嵁婧�
+              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 鏁版嵁婧�
 
               param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -294,7 +294,7 @@
               }
 
               param.ID = primaryId
-              param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 鏁版嵁婧�
+              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 鏁版嵁婧�
 
               param.exec_type = 'y' // 鍚庡彴瑙g爜
               param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
index 549dd47..1312e0d 100644
--- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -6,7 +6,7 @@
 import { Button, Modal, notification, message } from 'antd'
 
 import ExcelIn from './excelin'
-import Utils from '@/utils/utils.js'
+import Utils, { getExcelInSql } from '@/utils/utils.js'
 import options from '@/store/options.js'
 import Api from '@/api'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -238,7 +238,7 @@
       })
     }
 
-    let result = Utils.getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''))
+    let result = getExcelInSql(btn, data, this.state.dict, (this.props.BID || ''))
 
     if (result.errors) {
       notification.warning({
diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx
index 8e392e3..7eda245 100644
--- a/src/tabviews/zshare/actionList/normalbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -6,7 +6,7 @@
 import { Button, Modal, notification, message } from 'antd'
 
 import Api from '@/api'
-import Utils from '@/utils/utils.js'
+import Utils, { getSysDefaultSql } from '@/utils/utils.js'
 import options from '@/store/options.js'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
@@ -239,7 +239,14 @@
 
       if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛�
         param.ID = primaryId
-        param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+        if (retmsg) {
+          const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+          param.LText = sql
+          param.$callbacksql = callbacksql
+        } else {
+          param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
+        }
 
         if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
           param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -274,7 +281,14 @@
           }
 
           param.ID = primaryId || Utils.getguid()
-          param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+          if (retmsg) {
+            const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+            param.LText = sql
+            param.$callbacksql = callbacksql
+          } else {
+            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
+          }
           
           if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
             param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -299,7 +313,14 @@
           param.LText = Utils.formatOptions(param.LText)
         } else {
           param.ID = primaryId
-          param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+          if (retmsg) {
+            const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+            param.LText = sql
+            param.$callbacksql = callbacksql
+          } else {
+            param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧�
+          }
           
           if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
             param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -354,7 +375,14 @@
 
         if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛�
           param.ID = primaryId
-          param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+          if (retmsg) {
+            const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+            param.LText = sql
+            param.$callbacksql = callbacksql
+          } else {
+            param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 鏁版嵁婧�
+          }
           
           if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
             param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -380,7 +408,14 @@
 
           if (btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid
             param.ID = Utils.getguid()
-            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+            if (retmsg) {
+              const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+              param.LText = sql
+              param.$callbacksql = callbacksql
+            } else {
+              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧�
+            }
             
             if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
               param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -396,7 +431,14 @@
             param.LText = Utils.formatOptions(param.LText)
           } else {
             param.ID = primaryId
-            param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+
+            if (retmsg) {
+              const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 鏁版嵁婧�
+              param.LText = sql
+              param.$callbacksql = callbacksql
+            } else {
+              param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧�
+            }
             
             if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
               param.LText = param.LText.replace(/\$@/ig, '/*')
@@ -638,6 +680,14 @@
       loadingNumber: params.length || ''
     })
 
+    let record = {
+      BID: param.BID || '',
+      ID: param.ID || '',
+      callbacksql: param.$callbacksql || ''
+    }
+
+    delete param.$callbacksql
+
     Api.genericInterface(param).then(res => {
       if (res.status) {
         if (res.mk_ex_invoke === 'false' && params.length === 0) {
@@ -646,7 +696,7 @@
         } else if (res.mk_ex_invoke === 'false' && params.length > 0) {
           this.customLoopRequest(params, _resolve)
         } else {
-          this.customOuterRequest(params, res, _resolve)
+          this.customOuterRequest(params, res, record, _resolve)
         }
       } else if (res.ErrCode === 'C' && this.state.checkParam) {
         const _this = this
@@ -663,7 +713,7 @@
                   } else if (result.mk_ex_invoke === 'false' && params.length > 0) {
                     _this.customLoopRequest(params, _resolve)
                   } else {
-                    _this.customOuterRequest(params, result, _resolve)
+                    _this.customOuterRequest(params, result, record, _resolve)
                   }
                 } else {
                   _this.execError(result)
@@ -696,7 +746,7 @@
   /**
    * @description 鑷畾涔夎姹傚惊鐜墽琛�
    */
-  customOuterRequest = (params, result, _resolve) => {
+  customOuterRequest = (params, result, record, _resolve) => {
     const { btn } = this.props
 
     let url = ''
@@ -736,10 +786,10 @@
           $ErrMesg: error
         }
 
-        this.customCallbackRequest(params, result, _resolve)
+        this.customCallbackRequest(params, result, record, _resolve)
       } else {
         res.mk_api_key = mkey
-        this.customCallbackRequest(params, res, _resolve)
+        this.customCallbackRequest(params, res, record, _resolve)
       }
     }, () => {
       this.updateStatus('over')
@@ -750,7 +800,7 @@
   /**
    * @description 鍥炶皟璇锋眰寰幆鎵ц
    */
-  customCallbackRequest = (params, result, _resolve) => {
+  customCallbackRequest = (params, result, record, _resolve) => {
     const { btn } = this.props
     let lines = []
     let pre = btn.callbackType === 'script' ? '@' : ''
@@ -828,11 +878,14 @@
     if (btn.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈�
       param.func = 'sPC_TableData_InUpDe'
       
-      if (this.props.BID) {
+      if (record.BID) {
         param.BID = this.props.BID
       }
+      if (record.ID) {
+        param.ID = record.ID
+      }
 
-      let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
+      let _prevCustomScript = `${record.callbacksql || 'declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)'}
         Select @ErrorCode='',@retmsg=''
         ${errSql}
       `
@@ -855,7 +908,7 @@
       })
 
       _backCustomScript += `
-      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
 
       let sql = [...lineMap.values()].map(item => (`
         ${item.insert}
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index f55880a..c2ee67c 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -1284,16 +1284,18 @@
 
             if (!_item) return
 
-            if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') {
-              if (_item.value && _item.value.format) {
-                _item.value = _item.value.format(_format[item.type])
-              } else if (!_item.value) {
-                _item.value = ''
-              }
-            }
-
             if (_item.value === undefined) {
               _item.value = ''
+            } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') {
+              if (!_item.value) {
+                _item.value = ''
+              } else if (_item.value.format) {
+                _item.value = _item.value.format(_format[item.type])
+              }
+            } else if (item.type === 'text' && _item.value) { // 鐗规畩瀛楁鏇挎崲
+              _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey)
+              _item.value = _item.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || ''))
+              _item.value = _item.value.replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
             }
 
             search.push(_item)
@@ -1316,19 +1318,20 @@
             }
 
             let _value = ''
-            if (this.state.datatype[key] === 'datetime') {
+            let _type = this.state.datatype[key]
+            if (_type === 'datetime') {
               _value = values[key] ? moment(values[key]).format('YYYY-MM-DD HH:mm:ss') : ''
-            } else if (this.state.datatype[key] === 'datemonth') {
+            } else if (_type === 'datemonth') {
               _value = values[key] ? moment(values[key]).format('YYYY-MM') : ''
-            } else if (this.state.datatype[key] === 'date') {
+            } else if (_type === 'date') {
               _value = values[key] ? moment(values[key]).format('YYYY-MM-DD') : ''
-            } else if (this.state.datatype[key] === 'number') {
+            } else if (_type === 'number') {
               _value = values[key]
 
-            } else if (this.state.datatype[key] === 'multiselect' || this.state.datatype[key] === 'checkbox') {
+            } else if (_type === 'multiselect' || _type === 'checkbox') {
               _value = values[key] ? values[key].join(',') : ''
 
-            } else if (this.state.datatype[key] === 'fileupload') {
+            } else if (_type === 'fileupload') {
               let vals = []
 
               if (values[key] && values[key].length > 0) {
@@ -1342,12 +1345,17 @@
               }
 
               _value = vals.join(',')
-            } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') {
+            } else if (_type === 'text' || _type === 'textarea') {
               _value = values[key].replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗�
 
               if (intercepts.includes(key)) {              // 鍘婚櫎棣栧熬绌烘牸
                 _value = _value.replace(/(^\s*|\s*$)/g, '')
               }
+              if (_type === 'text' && _value) { // 鐗规畩瀛楁鏇挎崲
+                _value = _value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey)
+                _value = _value.replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || ''))
+                _value = _value.replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || ''))
+              }
             } else {
               _value = values[key]
             }
diff --git a/src/tabviews/zshare/settingcomponent/index.jsx b/src/tabviews/zshare/settingcomponent/index.jsx
index e5820fb..a141601 100644
--- a/src/tabviews/zshare/settingcomponent/index.jsx
+++ b/src/tabviews/zshare/settingcomponent/index.jsx
@@ -5,7 +5,7 @@
 
 import Api from '@/api'
 import MKEmitter from '@/utils/events.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateSubTable } from '@/utils/utils-update.js'
 import options from '@/store/options.js'
 import asyncComponent from '@/utils/asyncSpinComponent'
 import './index.scss'
@@ -252,7 +252,7 @@
 
           if (!subconfig || !subconfig.enabled) return
 
-          subconfig = UtilsUpdate.updateSubTable(subconfig)
+          subconfig = updateSubTable(subconfig)
 
           let _comp = {title: res.tab.label, uuid: res.tab.uuid, action: []}
 
diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index 51b223b..2c00e6f 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -9,7 +9,7 @@
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateCommonTable } from '@/utils/utils-update.js'
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
 
@@ -90,7 +90,7 @@
     _config.easyCode = _config.easyCode || ''
 
     // 鐗堟湰鍏煎
-    _config = UtilsUpdate.updateCommonTable(_config)
+    _config = updateCommonTable(_config)
     
     let _oriActions = []
     if (_config.type === 'user') {
diff --git a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
index 177c3bb..3a5c5d5 100644
--- a/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
@@ -430,6 +430,11 @@
                 id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''}
               </Form.Item>
             </Col> : null}
+            {!usefulFields ? <Col span={24} className="sqlfield">
+              <Form.Item label={'鍙敤瀛楁'}>
+                id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id
+              </Form.Item>
+            </Col> : null}
             {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}>
               <Form.Item style={{marginBottom: 0}} label="鎵ц浣嶇疆">
                 {getFieldDecorator('position', {
diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index 62e791d..7676116 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -11,7 +11,7 @@
 import zhCN from '@/locales/zh-CN/model.js'
 import enUS from '@/locales/en-US/model.js'
 import Utils from '@/utils/utils.js'
-import UtilsUpdate from '@/utils/utils-update.js'
+import { updateSubTable } from '@/utils/utils-update.js'
 
 import asyncComponent from '@/utils/asyncComponent'
 import SearchComponent from '@/templates/sharecomponent/searchcomponent'
@@ -106,7 +106,7 @@
     let _activeKey =  editSubTab ? editSubTab.activeKey : editTab.activeKey
 
     // 鐗堟湰鍏煎
-    _config = UtilsUpdate.updateSubTable(_config)
+    _config = updateSubTable(_config)
 
     this.setState({
       openEdition: editSubTab ? (editSubTab.open_edition || '') : (editTab.open_edition || ''),
diff --git a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
index c6a5fc2..aca9271 100644
--- a/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
+++ b/src/templates/zshare/verifycard/callbackcustomscript/index.jsx
@@ -12,6 +12,8 @@
   static propTpyes = {
     dict: PropTypes.object,         // 瀛楀吀椤�
     btn: PropTypes.object,          // 鎸夐挳淇℃伅
+    initsql: PropTypes.string,      // 鍒濆鍖栬剼鏈�
+    usefulfields: PropTypes.string, // 鍙敤瀛楁
     systemScripts: PropTypes.array, // 绯荤粺鑴氭湰
     customScripts: PropTypes.array, // 鑷畾涔夎剼鏈�
     scriptsChange: PropTypes.func   // 琛ㄥ崟
@@ -82,8 +84,6 @@
           return
         }
 
-        let prev = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
-        `
         let tail = `
           aaa:
         `
@@ -110,11 +110,12 @@
         let param = {
           func: 's_debug_sql',
           exec_type: 'y',
-          LText: prev +  _prevCustomScript + _backCustomScript + tail
+          LText: this.props.initsql +  _prevCustomScript + _backCustomScript + tail
         }
 
         // 鏁版嵁鏉冮檺
         param.LText = param.LText.replace(/@\$|\$@/ig, '')
+
         // check
         param.LText = param.LText.replace(/\$check@|@check\$/ig, '')
 
@@ -184,7 +185,7 @@
   }
 
   render() {
-    const { systemScripts, btn } = this.props
+    const { usefulfields, systemScripts, btn } = this.props
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
       labelCol: {
@@ -210,6 +211,11 @@
               ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT锛�, retmsg
             </Form.Item>
           </Col>
+          {usefulfields ? <Col span={24} className="sqlfield">
+            <Form.Item label={'鍙敤瀛楁'}>
+              {usefulfields}
+            </Form.Item>
+          </Col> : null}
           <Col span={8} style={{whiteSpace: 'nowrap'}}>
             <Form.Item style={{marginBottom: 0}} label={
               <Tooltip placement="bottomLeft" title={'鑷畾涔夎剼鏈笌榛樿sql浣嶇疆鍏崇郴銆�'}>
diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx
index b5dd64b..09a4338 100644
--- a/src/templates/zshare/verifycard/index.jsx
+++ b/src/templates/zshare/verifycard/index.jsx
@@ -1570,12 +1570,12 @@
             </span>
           } key="6">
             <CustomScript
-              usefulfields={this.state.usefulfields}
-              initsql={this.state.initsql}
-              dict={this.props.dict}
               btn={this.props.card}
+              dict={this.props.dict}
+              initsql={this.state.initsql}
               customScripts={verify.scripts}
               defaultsql={this.state.defaultsql}
+              usefulfields={this.state.usefulfields}
               systemScripts={this.state.systemScripts}
               scriptsChange={this.scriptsChange}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}
@@ -1589,9 +1589,11 @@
             </span>
           } key="6a">
             <CallBackCustomScript
-              dict={this.props.dict}
               btn={this.props.card}
+              dict={this.props.dict}
+              initsql={this.state.initsql}
               customScripts={verify.cbScripts}
+              usefulfields={this.state.usefulfields}
               systemScripts={this.state.systemScripts}
               scriptsChange={this.cbScriptsChange}
               wrappedComponentRef={(inst) => this.cbscriptsForm = inst}
diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js
index a8e6dbc..95707ed 100644
--- a/src/utils/utils-datamanage.js
+++ b/src/utils/utils-datamanage.js
@@ -441,8 +441,17 @@
       func: 'sPC_TableData_InUpDe',
       exec_type: 'y',
     }
-    let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)
-        Select @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') || ''
+    }
+
+    let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50)
+        Select @ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}'
         ${errSql}
     `
     let _backCustomScript = `
@@ -490,4 +499,72 @@
 
     return param
   }
+
+  /**
+   * @description 鑾峰彇鍥炶皟sql
+   */
+  static getCallBackSql (setting, result) {
+    let lines = []
+    let pre = setting.callbackType === 'script' ? '@' : ''
+
+    let getDefaultSql = (obj, tb, bid, level) => {
+      let keys = []
+      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) {
+                item.$$key = tb + '_' + key
+                subObjs.push(item)
+              }
+            })
+          } else if (Object.keys(val).length > 0) {
+            val.$$key = tb + '_' + key
+            subObjs.push(val)
+          }
+        } else {
+          keys.push(key)
+          vals.push(`'${val}'`)
+        }
+      })
+
+      lines.push({
+        table: tb,
+        insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`,
+        select: `Select ${vals.join(',')},'${level}','${id}','${bid}'`
+      })
+
+      subObjs.forEach(item => {
+        getDefaultSql(item, item.$$key, id, level + 1)
+      })
+    }
+    
+    getDefaultSql(result, setting.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]
+        })
+      }
+    })
+
+    return [...lineMap.values()]
+  }
 }
\ No newline at end of file
diff --git a/src/utils/utils-update.js b/src/utils/utils-update.js
index 7db6fb5..8c06998 100644
--- a/src/utils/utils-update.js
+++ b/src/utils/utils-update.js
@@ -1,169 +1,164 @@
-import { fromJS } from 'immutable'
-import Utils from './utils.js'
+/**
+ * @description 鍗囩骇涓昏〃淇℃伅
+ * @param {Object}   config      椤甸潰閰嶇疆淇℃伅
+ * @return {Object}  config
+ */
+export function updateCommonTable (config) {
+  if (!config.version || config.version < '1.0') {
+    config.version = '1.0'
+    // 鍏煎鏍囩
+    if (!config.tabgroups) {
+      config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
+    } else if (typeof(config.tabgroups[0]) === 'string') {
+      let _tabgroups = []
+      config.tabgroups.forEach(groupId => {
+        let _group = {
+          uuid: groupId,
+          sublist: config[groupId]
+        }
 
-export default class UpdateUtils {
-  /**
-   * @description 鍗囩骇涓昏〃淇℃伅
-   * @param {Object}   config      椤甸潰閰嶇疆淇℃伅
-   * @return {Object}  config
-   */
-  static updateCommonTable (config) {
-    if (!config.version || config.version < '1.0') {
-      config.version = '1.0'
-      // 鍏煎鏍囩
-      if (!config.tabgroups) {
-        config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
-      } else if (typeof(config.tabgroups[0]) === 'string') {
-        let _tabgroups = []
-        config.tabgroups.forEach(groupId => {
-          let _group = {
-            uuid: groupId,
-            sublist: fromJS(config[groupId]).toJS()
-          }
-  
-          delete config[groupId]
-  
-          _tabgroups.push(_group)
-        })
-  
-        config.tabgroups = _tabgroups
-      }
-  
-      // 鍏煎鍥捐〃
-      if (!config.charts) {
-        config.expand = true
-        config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
-      } else {
-        config.charts.forEach(card => {
-          if (card.chartType === 'card') {
-            card.details = card.details.map(_cell => {
-              _cell.fontSize = _cell.fontSize || 14
-              if (!_cell.width) {
-                _cell.width = 100
-              } else if (_cell.width === 'helf') {
-                _cell.width = 50
-              } else if (_cell.width === 'third') {
-                _cell.width = 33
-              }
-              if (!_cell.fontWeight && _cell.bold === 'true') {
-                _cell.fontWeight = 'normal'
-              }
-              _cell.height = _cell.height || 1
-  
-              return _cell
-            })
-          }
-        })
-      }
+        delete config[groupId]
+
+        _tabgroups.push(_group)
+      })
+
+      config.tabgroups = _tabgroups
     }
 
-    if (config.version < '1.1') {
-      config.version = '1.1'
-      if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
-        config.setting.interType = 'system'
-      }
-      // 鍏煎鎺ュ彛绫诲瀷
-      config.action = config.action.map(item => {
-        if (item.intertype === 'inner' && !item.innerFunc) {
-          item.intertype = 'system'
+    // 鍏煎鍥捐〃
+    if (!config.charts) {
+      config.expand = true
+      config.charts = [{ uuid: '$$normaltable', label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
+    } else {
+      config.charts.forEach(card => {
+        if (card.chartType === 'card') {
+          card.details = card.details.map(_cell => {
+            _cell.fontSize = _cell.fontSize || 14
+            if (!_cell.width) {
+              _cell.width = 100
+            } else if (_cell.width === 'helf') {
+              _cell.width = 50
+            } else if (_cell.width === 'third') {
+              _cell.width = 33
+            }
+            if (!_cell.fontWeight && _cell.bold === 'true') {
+              _cell.fontWeight = 'normal'
+            }
+            _cell.height = _cell.height || 1
+
+            return _cell
+          })
         }
-        return item
       })
     }
-
-    if (config.version < '1.2') {
-      config.version = '1.2'
-      // 鍏煎鍔熻兘鎸夐挳
-      config.action = config.action.map(item => {
-        if (item.execMode) {
-          item.OpenType = 'funcbutton'
-        }
-        return item
-      })
-    }
-
-    config.Template = 'CommonTable'
-
-    return config
   }
 
-  /**
-   * @description 鍗囩骇瀛愯〃淇℃伅
-   * @param {Object}   config      椤甸潰閰嶇疆淇℃伅
-   * @return {Object}  config
-   */
-  static updateSubTable (config) {
-    if (!config.version || config.version < '1.0') {
-      config.version = '1.0'
-      // 鍏煎鍥捐〃
-      if (!config.charts) {
-        config.expand = false
-        config.charts = [{
-          uuid: Utils.getuuid(),
-          label: '',
-          title: '',
-          chartType: 'table',
-          icon: 'table',
-          Hide: 'false',
-          blacklist: []
-        }]
-      } else {
-        config.charts.forEach(card => {
-          if (card.chartType === 'card') {
-            card.details = card.details.map(_cell => {
-              if (!_cell.fontSize) {
-                _cell.fontSize = 14
-              }
-              if (!_cell.width) {
-                _cell.width = 100
-              } else if (_cell.width === 'helf') {
-                _cell.width = 50
-              } else if (_cell.width === 'third') {
-                _cell.width = 33
-              }
-        
-              if (_cell.bold === 'true') {
-                _cell.fontWeight = 'normal'
-              }
-
-              if (!_cell.height) {
-                _cell.height = 1
-              }
-
-              return _cell
-            })
-          }
-        })
+  if (config.version < '1.1') {
+    config.version = '1.1'
+    if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
+      config.setting.interType = 'system'
+    }
+    // 鍏煎鎺ュ彛绫诲瀷
+    config.action = config.action.map(item => {
+      if (item.intertype === 'inner' && !item.innerFunc) {
+        item.intertype = 'system'
       }
-    }
-
-    if (config.version < '1.1') {
-      config.version = '1.1'
-      if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
-        config.setting.interType = 'system'
-      }
-      // 鍏煎鎺ュ彛绫诲瀷
-      config.action = config.action.map(item => {
-        if (item.intertype === 'inner' && !item.innerFunc) {
-          item.intertype = 'system'
-        }
-        return item
-      })
-    }
-
-    if (config.version < '1.2') {
-      config.version = '1.2'
-      // 鍏煎鍔熻兘鎸夐挳
-      config.action = config.action.map(item => {
-        if (item.execMode) {
-          item.OpenType = 'funcbutton'
-        }
-        return item
-      })
-    }
-    
-    config.Template = 'SubTable'
-
-    return config
+      return item
+    })
   }
+
+  if (config.version < '1.2') {
+    config.version = '1.2'
+    // 鍏煎鍔熻兘鎸夐挳
+    config.action = config.action.map(item => {
+      if (item.execMode) {
+        item.OpenType = 'funcbutton'
+      }
+      return item
+    })
+  }
+
+  config.Template = 'CommonTable'
+
+  return config
+}
+
+/**
+ * @description 鍗囩骇瀛愯〃淇℃伅
+ * @param {Object}   config      椤甸潰閰嶇疆淇℃伅
+ * @return {Object}  config
+ */
+export function updateSubTable (config) {
+  if (!config.version || config.version < '1.0') {
+    config.version = '1.0'
+    // 鍏煎鍥捐〃
+    if (!config.charts) {
+      config.expand = false
+      config.charts = [{
+        uuid: '$$normalsubtable',
+        label: '',
+        title: '',
+        chartType: 'table',
+        icon: 'table',
+        Hide: 'false',
+        blacklist: []
+      }]
+    } else {
+      config.charts.forEach(card => {
+        if (card.chartType === 'card') {
+          card.details = card.details.map(_cell => {
+            if (!_cell.fontSize) {
+              _cell.fontSize = 14
+            }
+            if (!_cell.width) {
+              _cell.width = 100
+            } else if (_cell.width === 'helf') {
+              _cell.width = 50
+            } else if (_cell.width === 'third') {
+              _cell.width = 33
+            }
+      
+            if (_cell.bold === 'true') {
+              _cell.fontWeight = 'normal'
+            }
+
+            if (!_cell.height) {
+              _cell.height = 1
+            }
+
+            return _cell
+          })
+        }
+      })
+    }
+  }
+
+  if (config.version < '1.1') {
+    config.version = '1.1'
+    if (config.setting.interType === 'inner' && !config.setting.innerFunc) {
+      config.setting.interType = 'system'
+    }
+    // 鍏煎鎺ュ彛绫诲瀷
+    config.action = config.action.map(item => {
+      if (item.intertype === 'inner' && !item.innerFunc) {
+        item.intertype = 'system'
+      }
+      return item
+    })
+  }
+
+  if (config.version < '1.2') {
+    config.version = '1.2'
+    // 鍏煎鍔熻兘鎸夐挳
+    config.action = config.action.map(item => {
+      if (item.execMode) {
+        item.OpenType = 'funcbutton'
+      }
+      return item
+    })
+  }
+  
+  config.Template = 'SubTable'
+
+  return config
 }
\ No newline at end of file
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 3b1788f..ba6cfde 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -723,947 +723,962 @@
       field: arrfield
     }
   }
+}
 
-  /**
-   * @description 鑾峰彇excel瀵煎叆鍙傛暟
-   * @return {String} btn   鎸夐挳
-   * @return {String} data  excel鏁版嵁
-   */
-  static getExcelInSql (item, data, dict, BID) {
-    let btn = item.verify
-    let keys = ['delete', 'drop', 'insert', 'truncate', 'update']
-    let userName = sessionStorage.getItem('User_Name') || ''
-    let fullName = sessionStorage.getItem('Full_Name') || ''
+/**
+ * @description 鑾峰彇excel瀵煎叆鍙傛暟
+ * @return {String} btn   鎸夐挳
+ * @return {String} data  excel鏁版嵁
+ */
+export function getExcelInSql (item, data, dict, BID) {
+  let btn = item.verify
+  let keys = ['delete', 'drop', 'insert', 'truncate', 'update']
+  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') || ''
-    }
-
-    let database = item.sheet.match(/(.*)\.(.*)\./ig) || ''
-    let sheet = item.sheet.replace(/(.*)\.(.*)\./ig, '')
-
-    let errors = []
-    let _topline = btn.range || 0
-    let upId = this.getuuid()
-
-    let _initCustomScript = '' // 鍒濆鍖栬剼鏈�
-    let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈�
-    let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈�
-
-    if (btn.scripts) {
-      btn.scripts.forEach(script => {
-        if (script.status === 'false') return
-
-        if (script.position === 'init') {
-          _initCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${script.sql}
-        `
-        } else if (script.position === 'front') {
-          _prevCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${script.sql}
-        `
-        } else {
-          _backCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${script.sql}
-        `
-        }
-      })
-    }
-
-    // 鎺у埗鍙版墦鍗版暟鎹�
-    let conLtext = []
-    let _Ltext = data.map((item, lindex) => {
-      let vals = []
-      let convals = []
-      btn.columns.forEach((col, cindex) => {
-        if (col.import === 'false') return
-
-        let val = item[col.Column] !== undefined ? item[col.Column] : ''
-        let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + (cindex + 1) + dict['main.excel.column']  + ' '
-
-        if (/^Nvarchar/ig.test(col.type)) {
-          if (typeof(val) === 'number') {
-            val = val.toString()
-          }
-
-          val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
-
-          if (!val && col.required === 'true') {            // 蹇呭~鏍¢獙
-            errors.push(_position + dict['main.excel.content.emptyerror'])
-          } else if (col.limit && val.length > col.limit) { // 闀垮害鏍¢獙
-            errors.push(_position + dict['main.excel.content.maxlimit'])
-          } else {                                          // 鍏抽敭瀛楁牎楠�
-            keys.forEach(key => {
-              let _patten = new RegExp('(^' + key + '\\s+)|(\\s+' + key + '\\s+)', 'ig')
-              if (_patten.test(val)) {
-                errors.push(_position + dict['main.excel.includekey'] + key)
-              }
-            })
-          }
-        } else if (/^int/ig.test(col.type)) {
-          if (!val && val !== 0) {
-            errors.push(_position + dict['main.excel.content.emptyerror'])
-          } else {
-            let _val = val + ''
-
-            if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) {               // 妫�楠屾槸鍚︿负鏁存暟
-              errors.push(_position + dict['main.excel.content.interror'])
-            } else if ((col.min || col.min === 0) && val < col.min) {          // 鏈�灏忓�兼楠�
-              errors.push(_position + dict['main.excel.content.limitmin'])
-            } else if ((col.max || col.max === 0) && val > col.max) {          // 鏈�澶у�兼楠�
-              errors.push(_position + dict['main.excel.content.limitmax'])
-            }
-          }
-        } else if (/^Decimal/ig.test(col.type)) {
-          if (!val && val !== 0) {
-            errors.push(_position + dict['main.excel.content.emptyerror'])
-          } else {
-            let _val = val + ''
-            let _vals = _val.split('.')
-
-            if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) {                           // 妫�楠屾槸鍚︿负娴偣鏁�
-              errors.push(_position + dict['main.excel.content.floaterror'])
-            } else if (_vals[0].length > 18) {                          // 妫�楠屾暣鏁颁綅
-              errors.push(_position + dict['main.excel.content.floatIntover'])
-            } else if (_vals[1] && _vals[1].length > col.limit) {       // 鏈�灏忓�兼楠�
-              errors.push(_position + dict['main.excel.content.floatPointover'])
-            } else if ((col.min || col.min === 0) && val < col.min) {   // 鏈�灏忓�兼楠�
-              errors.push(_position + dict['main.excel.content.limitmin'])
-            } else if ((col.max || col.max === 0) && val > col.max) {   // 鏈�澶у�兼楠�
-              errors.push(_position + dict['main.excel.content.limitmax'])
-            }
-          }
-        } else if (col.type === 'date') {
-          if (typeof(val) === 'number') {
-            if (val > 2958465 || val <= 0) {                 // 鏃堕棿杩囧ぇ鎴栧皬浜庣瓑浜�0
-              errors.push(_position + dict['main.excel.content.date.over'])
-            } else {                                         // 鏃堕棿鏍煎紡鍖�
-              if (val < 60) {                                // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦�
-                val++
-              }
-              val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD')
-            }
-          } else if (typeof(val) === 'string') {
-            val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
-            if (!val && col.required === 'true') {           // 鏃堕棿蹇呭~鏍¢獙
-              errors.push(_position + dict['main.excel.content.emptyerror'])
-            } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙
-              errors.push(_position + dict['main.excel.content.date.formatError'])
-            }
-          } else {                                           // 鏃堕棿鏍煎紡閿欒
-            errors.push(_position + dict['main.excel.content.date.formatError'])
-          }
-        }
-
-        vals.push(`'${val}'`)
-
-        if (lindex < 40) {
-          convals.push(`'${val}' as ${col.Column}`)
-        }
-      })
-
-      let _lineIndex = '0000' + (lindex + 1) + '0'
-      _lineIndex = _lineIndex.substring(_lineIndex.length - 6)
-
-      vals.push(`'${upId + _lineIndex}'`)
-      vals.push(`'${BID}'`)
-      
-      if (lindex < 40) {
-        convals.push(`'${upId + _lineIndex}' as jskey`)
-        convals.push(`'${BID}' as BID`)
-        conLtext.push(`Select ${convals.join(',')}`)
-      }
-
-      return `Select ${vals.join(',')}`
-    })
-
-    let result = []
-    for(let i = 0; i < _Ltext.length; i += 20) {
-      result.push(_Ltext.slice(i, i + 20))
-    }
-
-    let _sql = ''
-    let _sqlInsert = ''
-    let _sqlBottom = ''
-
-    if (item.intertype === 'system') {
-      let _uniquesql = ''
-      if (btn.uniques && btn.uniques.length > 0) {
-        btn.uniques.forEach(unique => {
-          if (unique.status === 'false') return
-
-          let _fields = unique.field.split(',')
-          let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
-          let _afields = _fields.map(_field => `a.${_field}`)
-          _fields_ = _fields_.join(' and ')
-
-          if (unique.verifyType !== 'physical') {
-            _fields_ += ' and b.deleted=0'
-          }
-
-          _uniquesql += `
-        /* 閲嶅鎬ч獙璇� */
-        Set @tbid=''
-        Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${sheet} ) a group by ${unique.field} having sum(n)>1
-        
-        If @tbid!=''
-        Begin
-          select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 閲嶅'
-          goto aaa
-        end
-        
-        Set @tbid=''
-        Select top 1 @tbid=${_afields.join('+\' \'+')} from  @${sheet} a Inner join ${sheet} b on ${_fields_}
-        
-        If @tbid!=''
-        Begin
-          select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�'
-          goto aaa
-        end
-        `
-        })
-      }
-
-      let declarefields = []
-      let fields = []
-
-      btn.columns.forEach(col => {
-        if (col.import === 'false') return
-        
-        if (col.type === 'date') {
-          declarefields.push(`${col.Column} Nvarchar(50)`)
-        } else {
-          declarefields.push(`${col.Column} ${col.type}`)
-        }
-        fields.push(col.Column)
-      })
-
-      fields = fields.join(',')
-
-      let _insert = ''
-      if (btn.default !== 'false') {
-        _insert = `
-        /* 榛樿sql */
-        Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) 
-        Select ${fields},@userid@,@username,@fullname,@BID@ From @${sheet}
-        `
-      }
-
-      _sql = `
-        /* 绯荤粺鐢熸垚 */
-        declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) )
-        Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)
-        
-        Select  @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}'
-        ${_initCustomScript}
-        `
-      _sqlInsert = `Insert into @${sheet} (${fields},jskey,BID)`
-      _sqlBottom = `
-        /* 榛樿sql */
-        delete tmp_excel_in where upid=@upid@
-        
-        delete tmp_excel_in where datediff(day,createdate,getdate())>15
-        ${_uniquesql}
-        ${_prevCustomScript}
-        ${_insert}
-        ${_backCustomScript}
-        Delete @${sheet}
-        
-        aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
-
-      if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
-        let fsql = `
-        ${_sql}
-        ${_sqlInsert}
-        
-        /* excel鏁版嵁锛堝墠40鏉★級 */
-        ${conLtext.join(' Union all ')}
-        ${_sqlBottom}
-        `
-        fsql = fsql.replace(/\n\s{8}/ig, '\n')
-        console.info(fsql)
-      }
-    } else { // s_sDataDictb_excelIn 浜戠瀵嗛挜楠岃瘉鍙傛暟
-      _sql = `
-        /* 绯荤粺鐢熸垚 */
-        declare @${sheet} table (jskey nvarchar(50))
-        Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)
-        
-        Select  @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}'
-        `
-    }
-
-    return {
-      sql: _sql,
-      lines: result.map((list, index) => {
-        return {
-          Ltext: window.btoa(window.encodeURIComponent(list.join(' Union all '))),
-          Sort: (index + 1) * 10
-        }
-      }),
-      insert: _sqlInsert,
-      bottom: _sqlBottom,
-      errors: errors.join('; ')
-    }
+  if (sessionStorage.getItem('isEditState') === 'true') {
+    userName = sessionStorage.getItem('CloudUserName') || ''
+    fullName = sessionStorage.getItem('CloudFullName') || ''
   }
 
-  /**
-   * @description 浣跨敤绯荤粺鍑芥暟鏃讹紙sPC_TableData_InUpDe 锛夛紝鐢熸垚sql璇彞
-   * @return {String} type   鎵ц绫诲瀷
-   * @return {String} table  琛ㄥ悕
-   */
-  static getSysDefaultSql (btn, setting, formdata, param, data, columns, tab, retmsg) {
-    let primaryId = param.ID
-    let BID = param.BID
-    let verify = btn.verify || {}
-    let datavars = {}                 // 澹版槑鐨勫彉閲忥紝琛ㄥ崟鍙婃樉绀哄垪
-    let _actionType = null
-    let appkey = window.GLOB.appkey || ''
-    let sessionUid = localStorage.getItem('SessionUid') || ''
+  let database = item.sheet.match(/(.*)\.(.*)\./ig) || ''
+  let sheet = item.sheet.replace(/(.*)\.(.*)\./ig, '')
 
-    if (verify.default !== 'false') { // 鍒ゆ柇鏄惁浣跨敤榛樿sql
-      _actionType = btn.sqlType
+  let getuuid = () => {
+    let uuid = []
+    let timestamp = new Date().getTime()
+    let _options = '0123456789abcdefghigklmnopqrstuv'
+    for (let i = 0; i < 19; i++) {
+      uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
     }
+    uuid = timestamp + uuid.join('')
+    return uuid
+  }
 
-    let _initCustomScript = '' // 鍒濆鍖栬剼鏈�
-    let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈�
-    let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈�
+  let errors = []
+  let _topline = btn.range || 0
+  let upId = getuuid()
 
-    verify.scripts && verify.scripts.forEach(item => {
-      if (item.status === 'false') return
+  let _initCustomScript = '' // 鍒濆鍖栬剼鏈�
+  let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈�
+  let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈�
 
-      if (item.position === 'init') {
+  if (btn.scripts) {
+    btn.scripts.forEach(script => {
+      if (script.status === 'false') return
+
+      if (script.position === 'init') {
         _initCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${item.sql}
-        `
-      } else if (item.position === 'front') {
+      /* 鑷畾涔夎剼鏈� */
+      ${script.sql}
+      `
+      } else if (script.position === 'front') {
         _prevCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${item.sql}
-        `
+      /* 鑷畾涔夎剼鏈� */
+      ${script.sql}
+      `
       } else {
         _backCustomScript += `
-        /* 鑷畾涔夎剼鏈� */
-        ${item.sql}
-        `
+      /* 鑷畾涔夎剼鏈� */
+      ${script.sql}
+      `
+      }
+    })
+  }
+
+  // 鎺у埗鍙版墦鍗版暟鎹�
+  let conLtext = []
+  let _Ltext = data.map((item, lindex) => {
+    let vals = []
+    let convals = []
+    btn.columns.forEach((col, cindex) => {
+      if (col.import === 'false') return
+
+      let val = item[col.Column] !== undefined ? item[col.Column] : ''
+      let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + (cindex + 1) + dict['main.excel.column']  + ' '
+
+      if (/^Nvarchar/ig.test(col.type)) {
+        if (typeof(val) === 'number') {
+          val = val.toString()
+        }
+
+        val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
+
+        if (!val && col.required === 'true') {            // 蹇呭~鏍¢獙
+          errors.push(_position + dict['main.excel.content.emptyerror'])
+        } else if (col.limit && val.length > col.limit) { // 闀垮害鏍¢獙
+          errors.push(_position + dict['main.excel.content.maxlimit'])
+        } else {                                          // 鍏抽敭瀛楁牎楠�
+          keys.forEach(key => {
+            let _patten = new RegExp('(^' + key + '\\s+)|(\\s+' + key + '\\s+)', 'ig')
+            if (_patten.test(val)) {
+              errors.push(_position + dict['main.excel.includekey'] + key)
+            }
+          })
+        }
+      } else if (/^int/ig.test(col.type)) {
+        if (!val && val !== 0) {
+          errors.push(_position + dict['main.excel.content.emptyerror'])
+        } else {
+          let _val = val + ''
+
+          if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) {               // 妫�楠屾槸鍚︿负鏁存暟
+            errors.push(_position + dict['main.excel.content.interror'])
+          } else if ((col.min || col.min === 0) && val < col.min) {          // 鏈�灏忓�兼楠�
+            errors.push(_position + dict['main.excel.content.limitmin'])
+          } else if ((col.max || col.max === 0) && val > col.max) {          // 鏈�澶у�兼楠�
+            errors.push(_position + dict['main.excel.content.limitmax'])
+          }
+        }
+      } else if (/^Decimal/ig.test(col.type)) {
+        if (!val && val !== 0) {
+          errors.push(_position + dict['main.excel.content.emptyerror'])
+        } else {
+          let _val = val + ''
+          let _vals = _val.split('.')
+
+          if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) {                           // 妫�楠屾槸鍚︿负娴偣鏁�
+            errors.push(_position + dict['main.excel.content.floaterror'])
+          } else if (_vals[0].length > 18) {                          // 妫�楠屾暣鏁颁綅
+            errors.push(_position + dict['main.excel.content.floatIntover'])
+          } else if (_vals[1] && _vals[1].length > col.limit) {       // 鏈�灏忓�兼楠�
+            errors.push(_position + dict['main.excel.content.floatPointover'])
+          } else if ((col.min || col.min === 0) && val < col.min) {   // 鏈�灏忓�兼楠�
+            errors.push(_position + dict['main.excel.content.limitmin'])
+          } else if ((col.max || col.max === 0) && val > col.max) {   // 鏈�澶у�兼楠�
+            errors.push(_position + dict['main.excel.content.limitmax'])
+          }
+        }
+      } else if (col.type === 'date') {
+        if (typeof(val) === 'number') {
+          if (val > 2958465 || val <= 0) {                 // 鏃堕棿杩囧ぇ鎴栧皬浜庣瓑浜�0
+            errors.push(_position + dict['main.excel.content.date.over'])
+          } else {                                         // 鏃堕棿鏍煎紡鍖�
+            if (val < 60) {                                // 1900-2-29锛宔xcel涓瓨鍦紝瀹為檯涓嶅瓨鍦�
+              val++
+            }
+            val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD')
+          }
+        } else if (typeof(val) === 'string') {
+          val = val.replace(/(^\s*$)|\t*|\v*/ig, '')
+          if (!val && col.required === 'true') {           // 鏃堕棿蹇呭~鏍¢獙
+            errors.push(_position + dict['main.excel.content.emptyerror'])
+          } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 鏃堕棿姝e垯鏍¢獙
+            errors.push(_position + dict['main.excel.content.date.formatError'])
+          }
+        } else {                                           // 鏃堕棿鏍煎紡閿欒
+          errors.push(_position + dict['main.excel.content.date.formatError'])
+        }
+      }
+
+      vals.push(`'${val}'`)
+
+      if (lindex < 40) {
+        convals.push(`'${val}' as ${col.Column}`)
       }
     })
 
-    // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-    let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode']
+    let _lineIndex = '0000' + (lindex + 1) + '0'
+    _lineIndex = _lineIndex.substring(_lineIndex.length - 6)
 
-    // 涓婚敭瀛楁
-    let primaryKey = setting.primaryKey || 'id'
+    vals.push(`'${upId + _lineIndex}'`)
+    vals.push(`'${BID}'`)
+    
+    if (lindex < 40) {
+      convals.push(`'${upId + _lineIndex}' as jskey`)
+      convals.push(`'${BID}' as BID`)
+      conLtext.push(`Select ${convals.join(',')}`)
+    }
 
-    // sql璇彞
-    let _sql = ''
+    return `Select ${vals.join(',')}`
+  })
 
-    let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦
-    let _initFormfields = []
-    let _initColfields = []
-    let _declarefields = []
+  let result = []
+  for(let i = 0; i < _Ltext.length; i += 20) {
+    result.push(_Ltext.slice(i, i + 20))
+  }
 
-    // 鑾峰彇瀛楁閿�煎
-    formdata && formdata.forEach(form => {
-      if (form.type === 'text' && form.value) { // 鐗规畩瀛楁鏇挎崲
-        form.value = form.value.replace(/^(\s*)@appkey@(\s*)$/ig, appkey)
-        form.value = form.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, sessionUid)
-        form.value = form.value.replace(/^(\s*)@bid@(\s*)$/ig, BID)
+  let _sql = ''
+  let _sqlInsert = ''
+  let _sqlBottom = ''
+
+  if (item.intertype === 'system') {
+    let _uniquesql = ''
+    if (btn.uniques && btn.uniques.length > 0) {
+      btn.uniques.forEach(unique => {
+        if (unique.status === 'false') return
+
+        let _fields = unique.field.split(',')
+        let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
+        let _afields = _fields.map(_field => `a.${_field}`)
+        _fields_ = _fields_.join(' and ')
+
+        if (unique.verifyType !== 'physical') {
+          _fields_ += ' and b.deleted=0'
+        }
+
+        _uniquesql += `
+      /* 閲嶅鎬ч獙璇� */
+      Set @tbid=''
+      Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${sheet} ) a group by ${unique.field} having sum(n)>1
+      
+      If @tbid!=''
+      Begin
+        select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 閲嶅'
+        goto aaa
+      end
+      
+      Set @tbid=''
+      Select top 1 @tbid=${_afields.join('+\' \'+')} from  @${sheet} a Inner join ${sheet} b on ${_fields_}
+      
+      If @tbid!=''
+      Begin
+        select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�'
+        goto aaa
+      end
+      `
+      })
+    }
+
+    let declarefields = []
+    let fields = []
+
+    btn.columns.forEach(col => {
+      if (col.import === 'false') return
+      
+      if (col.type === 'date') {
+        declarefields.push(`${col.Column} Nvarchar(50)`)
+      } else {
+        declarefields.push(`${col.Column} ${col.type}`)
+      }
+      fields.push(col.Column)
+    })
+
+    fields = fields.join(',')
+
+    let _insert = ''
+    if (btn.default !== 'false') {
+      _insert = `
+      /* 榛樿sql */
+      Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) 
+      Select ${fields},@userid@,@username,@fullname,@BID@ From @${sheet}
+      `
+    }
+
+    _sql = `
+      /* 绯荤粺鐢熸垚 */
+      declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) )
+      Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)
+      
+      Select  @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}'
+      ${_initCustomScript}
+      `
+    _sqlInsert = `Insert into @${sheet} (${fields},jskey,BID)`
+    _sqlBottom = `
+      /* 榛樿sql */
+      delete tmp_excel_in where upid=@upid@
+      
+      delete tmp_excel_in where datediff(day,createdate,getdate())>15
+      ${_uniquesql}
+      ${_prevCustomScript}
+      ${_insert}
+      ${_backCustomScript}
+      Delete @${sheet}
+      
+      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+
+    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
+      let fsql = `
+      ${_sql}
+      ${_sqlInsert}
+      
+      /* excel鏁版嵁锛堝墠40鏉★級 */
+      ${conLtext.join(' Union all ')}
+      ${_sqlBottom}
+      `
+      fsql = fsql.replace(/\n\s{8}/ig, '\n')
+      console.info(fsql)
+    }
+  } else { // s_sDataDictb_excelIn 浜戠瀵嗛挜楠岃瘉鍙傛暟
+    _sql = `
+      /* 绯荤粺鐢熸垚 */
+      declare @${sheet} table (jskey nvarchar(50))
+      Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)
+      
+      Select  @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}'
+      `
+  }
+
+  return {
+    sql: _sql,
+    lines: result.map((list, index) => {
+      return {
+        Ltext: window.btoa(window.encodeURIComponent(list.join(' Union all '))),
+        Sort: (index + 1) * 10
+      }
+    }),
+    insert: _sqlInsert,
+    bottom: _sqlBottom,
+    errors: errors.join('; ')
+  }
+}
+
+/**
+ * @description 浣跨敤绯荤粺鍑芥暟鏃讹紙sPC_TableData_InUpDe 锛夛紝鐢熸垚sql璇彞
+ * @return {String} type   鎵ц绫诲瀷
+ * @return {String} table  琛ㄥ悕
+ */
+export function getSysDefaultSql (btn, setting, formdata, param, data, columns, tab, retmsg = false) {
+  let primaryId = param.ID
+  let BID = param.BID
+  let verify = btn.verify || {}
+  let datavars = {}                 // 澹版槑鐨勫彉閲忥紝琛ㄥ崟鍙婃樉绀哄垪
+  let _actionType = null
+  let _callbacksql = ''
+
+  if (verify.default !== 'false') { // 鍒ゆ柇鏄惁浣跨敤榛樿sql
+    _actionType = btn.sqlType
+  }
+
+  let _initCustomScript = '' // 鍒濆鍖栬剼鏈�
+  let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈�
+  let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈�
+
+  verify.scripts && verify.scripts.forEach(item => {
+    if (item.status === 'false') return
+
+    if (item.position === 'init') {
+      _initCustomScript += `
+      /* 鑷畾涔夎剼鏈� */
+      ${item.sql}
+      `
+    } else if (item.position === 'front') {
+      _prevCustomScript += `
+      /* 鑷畾涔夎剼鏈� */
+      ${item.sql}
+      `
+    } else {
+      _backCustomScript += `
+      /* 鑷畾涔夎剼鏈� */
+      ${item.sql}
+      `
+    }
+  })
+
+  // 闇�瑕佸0鏄庣殑鍙橀噺闆�
+  let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode']
+
+  // 涓婚敭瀛楁
+  let primaryKey = setting.primaryKey || 'id'
+
+  // sql璇彞
+  let _sql = ''
+
+  let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦
+  let _initFormfields = []
+  let _initColfields = []
+  let _declarefields = []
+
+  // 鑾峰彇瀛楁閿�煎
+  formdata && formdata.forEach(form => {
+    let _key = form.key.toLowerCase()
+    datavars[_key] = form.value
+
+    if (!_initvars.includes(_key)) {
+      _initvars.push(_key)
+
+      if (form.type === 'number') {
+        let val = form.value
+        if (typeof(val) !== 'number') {
+          val = parseFloat(val)
+          if (isNaN(val)) {
+            val = 0
+          }
+        }
+        _initFormfields.push(`@${_key}=${val}`)
+      } else {
+        _initFormfields.push(`@${_key}='${form.value}'`)
+      }
+    }
+    
+    if (!_vars.includes(_key)) {
+      _vars.push(_key)
+
+      if (form.fieldlen && form.fieldlen > 2048) {
+        form.fieldlen = 'max'
       }
 
-      let _key = form.key.toLowerCase()
-      datavars[_key] = form.value
+      let _type = `nvarchar(${form.fieldlen})`
+
+      if (form.type.match(/date/ig)) {
+        _type = 'datetime'
+      } else if (form.type === 'number') {
+        _type = `decimal(18,${form.fieldlen})`
+      }
+
+      _declarefields.push(`@${_key} ${_type}`)
+    }
+  })
+
+  if (data) {
+    Object.keys(data).forEach(key => {
+      data[key.toLowerCase()] = data[key]
+    })
+  }
+
+  // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃)
+  if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') {
+    datavars = {...data, ...datavars}
+
+    const setField = (col) => {
+      if (!col.field) return
+      let _key = col.field.toLowerCase()
 
       if (!_initvars.includes(_key)) {
-        _initvars.push(_key)
+        let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : ''
 
-        if (form.type === 'number') {
-          let val = form.value
-          if (typeof(val) !== 'number') {
-            val = parseFloat(val)
-            if (isNaN(val)) {
-              val = 0
-            }
-          }
-          _initFormfields.push(`@${_key}=${val}`)
-        } else {
-          _initFormfields.push(`@${_key}='${form.value}'`)
-        }
+        _initvars.push(_key)
+        _initColfields.push(`@${_key}='${_val}'`)
       }
       
       if (!_vars.includes(_key)) {
         _vars.push(_key)
 
-        if (form.fieldlen && form.fieldlen > 2048) {
-          form.fieldlen = 'max'
+        if (col.datatype) {
+          _declarefields.push(`@${_key} ${col.datatype}`)
+        } else {
+          if (col.fieldlength && col.fieldlength > 2048) {
+            col.fieldlength = 'max'
+          }
+
+          let _type = `nvarchar(${col.fieldlength || 50})`
+
+          if (col.type === 'number') {
+            let _length = col.decimal ? col.decimal : 0
+            _type = `decimal(18,${_length})`
+          } else if (col.type === 'picture' || col.type === 'textarea') {
+            _type = `nvarchar(${col.fieldlength || 512})`
+          }
+
+          _declarefields.push(`@${_key} ${_type}`)
         }
-
-        let _type = `nvarchar(${form.fieldlen})`
-
-        if (form.type.match(/date/ig)) {
-          _type = 'datetime'
-        } else if (form.type === 'number') {
-          _type = `decimal(18,${form.fieldlen})`
-        }
-
-        _declarefields.push(`@${_key} ${_type}`)
       }
-    })
+    }
 
-    if (data) {
-      Object.keys(data).forEach(key => {
-        data[key.toLowerCase()] = data[key]
+    if (columns && columns.length > 0) {
+      columns.forEach(col => {
+        if (col.type === 'colspan' || col.type === 'old_colspan') {
+          col.subcols.forEach(cell => {
+            setField(cell)
+          })
+        } else {
+          setField(col)
+        }
       })
     }
+  }
 
-    // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃)
-    if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') {
-      datavars = {...data, ...datavars}
+  // 鍙橀噺澹版槑
+  _declarefields = _declarefields.join(',')
+  if (_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}
+    `
 
-      const setField = (col) => {
-        if (!col.field) return
-        let _key = col.field.toLowerCase()
-
-        if (!_initvars.includes(_key)) {
-          let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : ''
-
-          _initvars.push(_key)
-          _initColfields.push(`@${_key}='${_val}'`)
-        }
-        
-        if (!_vars.includes(_key)) {
-          _vars.push(_key)
-
-          if (col.datatype) {
-            _declarefields.push(`@${_key} ${col.datatype}`)
-          } else {
-            if (col.fieldlength && col.fieldlength > 2048) {
-              col.fieldlength = 'max'
-            }
-  
-            let _type = `nvarchar(${col.fieldlength || 50})`
-  
-            if (col.type === 'number') {
-              let _length = col.decimal ? col.decimal : 0
-              _type = `decimal(18,${_length})`
-            } else if (col.type === 'picture' || col.type === 'textarea') {
-              _type = `nvarchar(${col.fieldlength || 512})`
-            }
-  
-            _declarefields.push(`@${_key} ${_type}`)
-          }
-        }
-      }
-
-      if (columns && columns.length > 0) {
-        columns.forEach(col => {
-          if (col.type === 'colspan' || col.type === 'old_colspan') {
-            col.subcols.forEach(cell => {
-              setField(cell)
-            })
-          } else {
-            setField(col)
-          }
-        })
-      }
-    }
-
-    // 鍙橀噺澹版槑
-    _declarefields = _declarefields.join(',')
-    if (_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}
-      `
-
-    // 琛ㄥ崟鍙橀噺璧嬪��
-    if (_initFormfields.length > 0) {
-      _sql += `
-        /* 琛ㄥ崟鍙橀噺璧嬪�� */
-        select ${_initFormfields.join(',')}
-        `
-    }
-    // 鏄剧ず鍒楀彉閲忚祴鍊�
-    if (_initColfields.length > 0) {
-      _sql += `
-        /* 鏄剧ず鍒楀彉閲忚祴鍊� */
-        select ${_initColfields.join(',')}
-        `
-    }
-
-    // 鍘婚櫎绂佺敤鐨勯獙璇�
-    if (verify.contrasts) {
-      verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
-    }
-    if (verify.uniques) {
-      verify.uniques = verify.uniques.filter(item => item.status !== 'false')
-    }
-    if (verify.customverifys) {
-      verify.customverifys = verify.customverifys.filter(item => item.status !== 'false')
-    }
-    if (verify.billcodes) {
-      verify.billcodes = verify.billcodes.filter(item => item.status !== 'false')
-    }
-
-    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') || ''
-    }
-
-    // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁
+  // 琛ㄥ崟鍙橀噺璧嬪��
+  if (_initFormfields.length > 0) {
     _sql += `
-        /* 鍑瘉鍙婄敤鎴蜂俊鎭垵濮嬪寲璧嬪�� */
-        select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @BillCode='', @ModularDetailCode=''
-        `
+      /* 琛ㄥ崟鍙橀噺璧嬪�� */
+      select ${_initFormfields.join(',')}
+      `
+  }
+  // 鏄剧ず鍒楀彉閲忚祴鍊�
+  if (_initColfields.length > 0) {
+    _sql += `
+      /* 鏄剧ず鍒楀彉閲忚祴鍊� */
+      select ${_initColfields.join(',')}
+      `
+  }
 
-    if (_initCustomScript) {
-      _sql += _initCustomScript
+  if (retmsg) {
+    _callbacksql = _sql
+  }
+
+  // 鍘婚櫎绂佺敤鐨勯獙璇�
+  if (verify.contrasts) {
+    verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
+  }
+  if (verify.uniques) {
+    verify.uniques = verify.uniques.filter(item => item.status !== 'false')
+  }
+  if (verify.customverifys) {
+    verify.customverifys = verify.customverifys.filter(item => item.status !== 'false')
+  }
+  if (verify.billcodes) {
+    verify.billcodes = verify.billcodes.filter(item => item.status !== 'false')
+  }
+
+  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}', @BillCode='', @ModularDetailCode=''
+      `
+
+  if (_initCustomScript) {
+    _sql += _initCustomScript
+  }
+
+  // 鍚敤璐︽湡楠岃瘉
+  if (verify.accountdate === 'true') {
+    let orgcode = `''`
+    let date = `''`
+    if (verify.accountfield && _initvars.includes(verify.accountfield.toLowerCase())) {
+      orgcode = '@' + verify.accountfield
+    }
+    if (verify.voucherdate && _initvars.includes(verify.voucherdate.toLowerCase())) {
+      date = '@' + verify.voucherdate
     }
 
-    // 鍚敤璐︽湡楠岃瘉
-    if (verify.accountdate === 'true') {
-      let orgcode = `''`
-      let date = `''`
-      if (verify.accountfield && _initvars.includes(verify.accountfield.toLowerCase())) {
-        orgcode = '@' + verify.accountfield
-      }
-      if (verify.voucherdate && _initvars.includes(verify.voucherdate.toLowerCase())) {
-        date = '@' + verify.voucherdate
-      }
+    _sql += `
+      /* 璐︽湡楠岃瘉 */
+      exec s_FIBVoucherDateCheck @OrgCode=${orgcode},@FIBVoucherDate=${date},@ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT
+      if @ErrorCode!=''
+        GOTO aaa
+      `
+  }
 
+  // 澶辨晥楠岃瘉锛屾坊鍔犳暟鎹椂涓嶇敤
+  if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) {
+    let datasource = setting.dataresource
+    if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 鎷兼帴鍒悕
+      datasource = '(' + datasource + ') tb'
+    }
+
+    if (setting.customScript) {
       _sql += `
-        /* 璐︽湡楠岃瘉 */
-        exec s_FIBVoucherDateCheck @OrgCode=${orgcode},@FIBVoucherDate=${date},@ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT
-        if @ErrorCode!=''
-          GOTO aaa
-        `
-    }
-
-    // 澶辨晥楠岃瘉锛屾坊鍔犳暟鎹椂涓嶇敤
-    if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) {
-      let datasource = setting.dataresource
-      if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 鎷兼帴鍒悕
-        datasource = '(' + datasource + ') tb'
-      }
-
-      if (setting.customScript) {
-        _sql += `
-        /* 鏁版嵁婧愯嚜瀹氫箟鑴氭湰锛岃娉ㄦ剰鍙橀噺瀹氫箟鏄惁閲嶅 */
-        ${setting.customScript}
-        `
-      }
-
-      if (btn.Ot === 'requiredOnce') {
-        _sql += `
-        /* 澶辨晥楠岃瘉 */
-        select @tbid='', @ErrorCode='',@retmsg=''
-        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
-        `
-      }
-    }
-
-    // 姣旇緝楠岃瘉
-    if (verify.contrasts && verify.contrasts.length > 0) {
-      verify.contrasts.forEach(item => {
-        _sql += `
-        /* 姣旇緝楠岃瘉 */
-        If ${item.frontfield} ${item.operator} ${item.backfield}
-        Begin
-          select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
-            goto aaa
-        end
-        `
-      })
-    }
-    
-    // 鑷畾涔夐獙璇�
-    verify.customverifys && verify.customverifys.forEach(item => {        
-      _sql += `
-        /* 鑷畾涔夐獙璇� */
-        select @tbid='', @ErrorCode='',@retmsg=''
-        select top 1 @tbid='X' from (${item.sql}) a
-        If @tbid ${item.result === 'true' ? '!=' : '='}''
-        Begin
-          select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
-          goto aaa
-        end
-        `
-    })
-
-    // 鍗曞彿鐢熸垚锛屼娇鐢ㄤ笂绾d锛圔ID锛夋垨鍒楄〃鏁版嵁锛屽0鏄庡彉閲忥紙妫�楠岋級
-    let _billcodesSql  = ''
-    if (formdata && verify.billcodes && verify.billcodes.length > 0) {
-      let keys = formdata.map(item => item.key.toLowerCase()) // 琛ㄥ崟瀛楁
-
-      verify.billcodes.forEach(item => {
-        let _key = item.field.toLowerCase()
-        let _linkKey = item.linkField ? item.linkField.toLowerCase() : ''
-
-        if (!keys.includes(_key)) return // 琛ㄥ崟涓笉鍚崟鍙风敓鎴愬瓧娈�
-
-        let _ModularDetailCode = ''
-        let _lpline = ''
-        if (item.TypeCharOne === 'Lp') {
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
-            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
-          } else {
-            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)`
-          }
-          _ModularDetailCode = '@ModularDetailCode'
-        } else if (item.TypeCharOne === 'BN') {
-          let _val = ''
-          if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
-            _val = BID
-          } else if (data && data.hasOwnProperty(_linkKey)) {
-            _val = data[_linkKey]
-          }
-          _ModularDetailCode = `'${item.TypeCharOne + _val}'`
-        } else {
-          _ModularDetailCode = `'${item.ModularDetailCode}'`
-        }
-
-        let _declare = ''
-
-        if (!_vars.includes(_key)) {
-          _declare = `Declare @${_key} nvarchar(50)`
-          _vars.push(_key)
-        }
-
-        _billcodesSql += `
-        /* 鍗曞彿鐢熸垚 */
-        ${_declare}
-        select @BillCode='', @${_key}='', @ModularDetailCode=''
-        ${_lpline}
-        exec s_get_BillCode
-          @ModularDetailCode=${_ModularDetailCode},
-          @Type=${item.Type},
-          @TypeCharOne='${item.TypeCharOne}',
-          @TypeCharTwo ='${item.TypeCharTwo}',
-          @BillCode =@BillCode output,
-          @ErrorCode =@ErrorCode output, 
-          @retmsg=@retmsg output
-        if @ErrorCode!=''
-          goto aaa
-        set @${_key}=@BillCode
-        `
-      })
-
-      if (_actionType !== 'insertOrUpdate') {
-        _sql += _billcodesSql
-      }
-    }
-
-    // 鍞竴鎬ч獙璇侊紝蹇呴』瀛樺湪琛ㄥ崟锛堣〃鍗曞瓨鍦ㄦ椂锛屼富閿潎涓哄崟鍊硷級,蹇呴』濉啓鏁版嵁婧愶紝澶氳鎷兼帴鏃朵笉鍙敤
-    if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') {
-      verify.uniques.forEach(item => {
-        let _fieldValue = []                     // 琛ㄥ崟閿�煎field=value
-        let _value = []                          // 琛ㄥ崟鍊硷紝鐢ㄤ簬閿欒鎻愮ず
-        let _labels = item.fieldlabel.split(',') // 琛ㄥ崟鎻愮ず鏂囧瓧
-        let arr = [] // 楠岃瘉涓婚敭
-
-        item.field.split(',').forEach((_field, index) => {
-          let _key = _field.toLowerCase()
-          let _val = datavars[_key] !== undefined ? datavars[_key] : ''
-          let _fval = `'${_val}'`
-
-          if (_key === 'bid' && !datavars.bid) { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺
-            _fval = '@BID@'
-          }
-          if (_key === 'bid' && tab && tab.foreignKey) {
-            arr.push(tab.foreignKey.toLowerCase())
-            _fieldValue.push(`${tab.foreignKey}=${_fval}`)
-          } else {
-            arr.push(_key)
-            _fieldValue.push(`${_key}=${_fval}`)
-          }
-          
-          _value.push(`${_labels[index] || ''}锛�${_val || ''}`)
-        })
-
-        let _verifyType = ''
-        if (item.verifyType === 'logic') {
-          _verifyType = ' and deleted=0'
-        }
-
-        if (!arr.includes(primaryKey.toLowerCase())) {
-          _fieldValue.push(`${primaryKey} !='${primaryId}'`)
-        }
-
-        _sql += `
-        /* 鍞竴鎬ч獙璇� */
-        select @tbid='', @ErrorCode='',@retmsg=''
-        select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType}
-        If @tbid!=''
-        Begin
-          select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 宸插瓨鍦�'
-          goto aaa
-        end
-        `
-      })
-    } else if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce' && setting.dataresource) {
-      let datasource = setting.dataresource
-      if (/\s/.test(datasource)) { // 鎷兼帴鍒悕
-        if (!/tb$/.test(datasource)) {
-          datasource = '(' + datasource + ') tb'
-        }
-      } else {
-        datasource = datasource + ' tb'
-      }
-
-      if (setting.customScript) {
-        _sql += `
-        /* 鏁版嵁婧愯嚜瀹氫箟鑴氭湰锛岃娉ㄦ剰鍙橀噺瀹氫箟鏄惁閲嶅 */
-        ${setting.customScript}
-        `
-      }
-
-      verify.uniques.forEach(item => {
-        _sql += `
-        /* 鍚岀被鏁版嵁楠岃瘉 */
-        Set @tbid=''
-
-        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
-          Set @ErrorCode='E' Set @retmsg='${item.fieldlabel} 鍊间笉鍞竴'
-          goto aaa
-        end
-        `
-      })
-    }
-
-    let hasvoucher = false
-
-    // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
-    if (verify.voucher && verify.voucher.enabled && data) {
-      let _voucher = verify.voucher
-
-      hasvoucher = true
-
-      _sql += `
-        /* 鍒涘缓鍑瘉 */
-        exec s_BVoucher_Create
-          @Bill ='${data[_voucher.linkField.toLowerCase()]}',
-          @BVoucherType ='${_voucher.BVoucherType}',
-          @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
-          @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
-          @Type =${_voucher.Type},
-          @UserID=@UserID@,
-          @Username=@Username,
-          @FullName=@FullName,
-          @BVoucher =@BVoucher OUTPUT ,
-          @FIBVoucherDate =@FIBVoucherDate OUTPUT ,
-          @FiYear =@FiYear OUTPUT ,
-          @ErrorCode =@ErrorCode OUTPUT, 
-          @retmsg=@retmsg OUTPUT
-        if @ErrorCode!=''
-          GOTO aaa
-        `
-    }
-
-    let _insertsql = ''
-    if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 娣诲姞璇彞
-      let keys = []
-      let values = []
-
-      formdata.forEach(item => {
-        if (item.writein === false) return
-        let _key = item.key.toLowerCase()
-
-        keys.push(_key)
-        values.push('@' + _key)
-      })
-
-      if (!keys.includes(primaryKey.toLowerCase())) {
-        keys.push(primaryKey.toLowerCase())
-        values.push('\'' + primaryId + '\'')
-      }
-      if (!keys.includes('createuserid')) {
-        keys.push('createuserid')
-        values.push('@userid@')
-      }
-      if (!keys.includes('createuser')) {
-        keys.push('createuser')
-        values.push('@username')
-      }
-      if (!keys.includes('createstaff')) {
-        keys.push('createstaff')
-        values.push('@fullname')
-      }
-      if (!keys.includes('bid')) {
-        if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) {
-          keys.push(tab.foreignKey.toLowerCase())
-        } else {
-          keys.push('bid')
-        }
-        values.push('@BID@')
-      } else if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) {
-        keys.push(tab.foreignKey.toLowerCase())
-        values.push('@BID@')
-      }
-
-      keys = keys.join(',')
-      values = values.join(',')
-      _insertsql = `insert into ${btn.sql} (${keys}) select ${values};`
-    }
-
-    let _updatesql = ''
-    if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 淇敼璇彞
-      let _form = []
-      let _arr = []
-
-      formdata.forEach(item => {
-        if (item.writein === false) return
-        let _key = item.key.toLowerCase()
-        
-        _arr.push(_key)
-        _form.push(_key + '=@' + _key)
-      })
-
-      if (_actionType === 'audit') {
-        if (!_arr.includes('submitdate')) {
-          _form.push('submitdate=getdate()')
-        }
-        if (!_arr.includes('submituserid')) {
-          _form.push('submituserid=@userid@')
-        }
-      } else {
-        if (!_arr.includes('modifydate')) {
-          _form.push('modifydate=getdate()')
-        }
-        if (!_arr.includes('modifyuserid')) {
-          _form.push('modifyuserid=@userid@')
-        }
-      }
-      
-      if (hasvoucher) {
-        if (!_arr.includes('bvoucher')) {
-          _form.push('BVoucher=@BVoucher')
-        }
-        if (!_arr.includes('fibvoucherdate')) {
-          _form.push('FIBVoucherDate=@FIBVoucherDate')
-        }
-        if (!_arr.includes('fiyear')) {
-          _form.push('FiYear=@FiYear')
-        }
-      }
-      _form = _form.join(',')
-
-      let _ID = '=@ID@'
-      if (btn.Ot === 'requiredOnce') {
-        _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
-      }
-
-      _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};`
-    }
-
-    if (_prevCustomScript) {
-      _sql += _prevCustomScript
-    }
-
-    // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄�
-    if (_actionType === 'insert') {
-      _sql += `
-        /* 榛樿sql */
-        ${_insertsql}`
-    } else if (_actionType === 'update' || _actionType === 'audit') {
-      _sql += `
-        /* 榛樿sql */
-        ${_updatesql}`
-    } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎
-      let _ID = '=@ID@'
-      if (btn.Ot === 'requiredOnce') {
-        _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
-      }
-
-      _sql += `
-        /* 榛樿sql */
-        update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}${_ID};`
-    
-    } else if (_actionType === 'delete') {      // 鐗╃悊鍒犻櫎
-      let _msg = ''
-      if (data && columns && columns.length > 0) {
-        let _index = 0
-        columns.forEach(col => {
-          if (col.Hide !== 'true' && col.type !== 'colspan' && col.type !== 'old_colspan' && _index < 4) {
-            _msg += col.label + '=' + data[col.field] + ','
-            _index++
-          }
-        })
-      }
-
-      let _ID = '=@ID@'
-      if (btn.Ot === 'requiredOnce') {
-        _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
-      }
-
-      _sql += `
-        /* 榛樿sql */
-        insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname
-        delete ${btn.sql} where ${primaryKey}${_ID};`
-    } else if (_actionType === 'insertOrUpdate') {
-      _sql += `
-        /* 榛樿sql */
-        select @tbid=''
-        select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
-        if @tbid=''
-          begin
-          ${_billcodesSql}
-          ${_insertsql}
-          end
-        else
-          begin
-          ${_updatesql}
-          end
+      /* 鏁版嵁婧愯嚜瀹氫箟鑴氭湰锛岃娉ㄦ剰鍙橀噺瀹氫箟鏄惁閲嶅 */
+      ${setting.customScript}
       `
     }
 
-    if (_backCustomScript) {
-      _sql += _backCustomScript
-    }
-
-    if (retmsg) {
+    if (btn.Ot === 'requiredOnce') {
       _sql += `
-          aaa: if @ErrorCode!=''
-          insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@`
+      /* 澶辨晥楠岃瘉 */
+      select @tbid='', @ErrorCode='',@retmsg=''
+      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 += `
-          aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+      /* 澶辨晥楠岃瘉 */
+      select @tbid='', @ErrorCode='',@retmsg=''
+      select @tbid=${primaryKey} from ${datasource} where ${primaryKey}=@ID@
+      If @tbid=''
+      Begin
+        select @ErrorCode='E',@retmsg='鏁版嵁宸插け鏁�'
+        goto aaa
+      end
+      `
+    }
+  }
+
+  // 姣旇緝楠岃瘉
+  if (verify.contrasts && verify.contrasts.length > 0) {
+    verify.contrasts.forEach(item => {
+      _sql += `
+      /* 姣旇緝楠岃瘉 */
+      If ${item.frontfield} ${item.operator} ${item.backfield}
+      Begin
+        select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
+          goto aaa
+      end
+      `
+    })
+  }
+  
+  // 鑷畾涔夐獙璇�
+  verify.customverifys && verify.customverifys.forEach(item => {        
+    _sql += `
+      /* 鑷畾涔夐獙璇� */
+      select @tbid='', @ErrorCode='',@retmsg=''
+      select top 1 @tbid='X' from (${item.sql}) a
+      If @tbid ${item.result === 'true' ? '!=' : '='}''
+      Begin
+        select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
+        goto aaa
+      end
+      `
+  })
+
+  // 鍗曞彿鐢熸垚锛屼娇鐢ㄤ笂绾d锛圔ID锛夋垨鍒楄〃鏁版嵁锛屽0鏄庡彉閲忥紙妫�楠岋級
+  let _billcodesSql  = ''
+  if (formdata && verify.billcodes && verify.billcodes.length > 0) {
+    let keys = formdata.map(item => item.key.toLowerCase()) // 琛ㄥ崟瀛楁
+
+    verify.billcodes.forEach(item => {
+      let _key = item.field.toLowerCase()
+      let _linkKey = item.linkField ? item.linkField.toLowerCase() : ''
+
+      if (!keys.includes(_key)) return // 琛ㄥ崟涓笉鍚崟鍙风敓鎴愬瓧娈�
+
+      let _ModularDetailCode = ''
+      let _lpline = ''
+      if (item.TypeCharOne === 'Lp') {
+        if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
+        } else {
+          _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)`
+        }
+        _ModularDetailCode = '@ModularDetailCode'
+      } else if (item.TypeCharOne === 'BN') {
+        let _val = ''
+        if (_linkKey === 'bid' && BID) { // 鏇挎崲bid
+          _val = BID
+        } else if (data && data.hasOwnProperty(_linkKey)) {
+          _val = data[_linkKey]
+        }
+        _ModularDetailCode = `'${item.TypeCharOne + _val}'`
+      } else {
+        _ModularDetailCode = `'${item.ModularDetailCode}'`
+      }
+
+      let _declare = ''
+
+      if (!_vars.includes(_key)) {
+        _declare = `Declare @${_key} nvarchar(50)`
+        _vars.push(_key)
+      }
+
+      _billcodesSql += `
+      /* 鍗曞彿鐢熸垚 */
+      ${_declare}
+      select @BillCode='', @${_key}='', @ModularDetailCode=''
+      ${_lpline}
+      exec s_get_BillCode
+        @ModularDetailCode=${_ModularDetailCode},
+        @Type=${item.Type},
+        @TypeCharOne='${item.TypeCharOne}',
+        @TypeCharTwo ='${item.TypeCharTwo}',
+        @BillCode =@BillCode output,
+        @ErrorCode =@ErrorCode output, 
+        @retmsg=@retmsg output
+      if @ErrorCode!=''
+        goto aaa
+      set @${_key}=@BillCode
+      `
+    })
+
+    if (_actionType !== 'insertOrUpdate') {
+      _sql += _billcodesSql
+    }
+  }
+
+  // 鍞竴鎬ч獙璇侊紝蹇呴』瀛樺湪琛ㄥ崟锛堣〃鍗曞瓨鍦ㄦ椂锛屼富閿潎涓哄崟鍊硷級,蹇呴』濉啓鏁版嵁婧愶紝澶氳鎷兼帴鏃朵笉鍙敤
+  if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') {
+    verify.uniques.forEach(item => {
+      let _fieldValue = []                     // 琛ㄥ崟閿�煎field=value
+      let _value = []                          // 琛ㄥ崟鍊硷紝鐢ㄤ簬閿欒鎻愮ず
+      let _labels = item.fieldlabel.split(',') // 琛ㄥ崟鎻愮ず鏂囧瓧
+      let arr = [] // 楠岃瘉涓婚敭
+
+      item.field.split(',').forEach((_field, index) => {
+        let _key = _field.toLowerCase()
+        let _val = datavars[_key] !== undefined ? datavars[_key] : ''
+        let _fval = `'${_val}'`
+
+        if (_key === 'bid' && !datavars.bid) { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺
+          _fval = '@BID@'
+        }
+        if (_key === 'bid' && tab && tab.foreignKey) {
+          arr.push(tab.foreignKey.toLowerCase())
+          _fieldValue.push(`${tab.foreignKey}=${_fval}`)
+        } else {
+          arr.push(_key)
+          _fieldValue.push(`${_key}=${_fval}`)
+        }
+        
+        _value.push(`${_labels[index] || ''}锛�${_val || ''}`)
+      })
+
+      let _verifyType = ''
+      if (item.verifyType === 'logic') {
+        _verifyType = ' and deleted=0'
+      }
+
+      if (!arr.includes(primaryKey.toLowerCase())) {
+        _fieldValue.push(`${primaryKey} !='${primaryId}'`)
+      }
+
+      _sql += `
+      /* 鍞竴鎬ч獙璇� */
+      select @tbid='', @ErrorCode='',@retmsg=''
+      select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType}
+      If @tbid!=''
+      Begin
+        select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 宸插瓨鍦�'
+        goto aaa
+      end
+      `
+    })
+  } else if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce' && setting.dataresource) {
+    let datasource = setting.dataresource
+    if (/\s/.test(datasource)) { // 鎷兼帴鍒悕
+      if (!/tb$/.test(datasource)) {
+        datasource = '(' + datasource + ') tb'
+      }
+    } else {
+      datasource = datasource + ' tb'
     }
 
-    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
-      _sql = _sql.replace(/\n\s{8}/ig, '\n')
-      console.info(_sql)
+    if (setting.customScript) {
+      _sql += `
+      /* 鏁版嵁婧愯嚜瀹氫箟鑴氭湰锛岃娉ㄦ剰鍙橀噺瀹氫箟鏄惁閲嶅 */
+      ${setting.customScript}
+      `
     }
 
+    verify.uniques.forEach(item => {
+      _sql += `
+      /* 鍚岀被鏁版嵁楠岃瘉 */
+      Set @tbid=''
+
+      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
+        Set @ErrorCode='E' Set @retmsg='${item.fieldlabel} 鍊间笉鍞竴'
+        goto aaa
+      end
+      `
+    })
+  }
+
+  let hasvoucher = false
+
+  // 鍑瘉-鏄剧ず鍒椾腑閫夊彇,蹇呴』閫夎
+  if (verify.voucher && verify.voucher.enabled && data) {
+    let _voucher = verify.voucher
+
+    hasvoucher = true
+
+    _sql += `
+      /* 鍒涘缓鍑瘉 */
+      exec s_BVoucher_Create
+        @Bill ='${data[_voucher.linkField.toLowerCase()]}',
+        @BVoucherType ='${_voucher.BVoucherType}',
+        @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
+        @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
+        @Type =${_voucher.Type},
+        @UserID=@UserID@,
+        @Username=@Username,
+        @FullName=@FullName,
+        @BVoucher =@BVoucher OUTPUT ,
+        @FIBVoucherDate =@FIBVoucherDate OUTPUT ,
+        @FiYear =@FiYear OUTPUT ,
+        @ErrorCode =@ErrorCode OUTPUT, 
+        @retmsg=@retmsg OUTPUT
+      if @ErrorCode!=''
+        GOTO aaa
+      `
+  }
+
+  let _insertsql = ''
+  if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 娣诲姞璇彞
+    let keys = []
+    let values = []
+
+    formdata.forEach(item => {
+      if (item.writein === false) return
+      let _key = item.key.toLowerCase()
+
+      keys.push(_key)
+      values.push('@' + _key)
+    })
+
+    if (!keys.includes(primaryKey.toLowerCase())) {
+      keys.push(primaryKey.toLowerCase())
+      values.push('\'' + primaryId + '\'')
+    }
+    if (!keys.includes('createuserid')) {
+      keys.push('createuserid')
+      values.push('@userid@')
+    }
+    if (!keys.includes('createuser')) {
+      keys.push('createuser')
+      values.push('@username')
+    }
+    if (!keys.includes('createstaff')) {
+      keys.push('createstaff')
+      values.push('@fullname')
+    }
+    if (!keys.includes('bid')) {
+      if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) {
+        keys.push(tab.foreignKey.toLowerCase())
+      } else {
+        keys.push('bid')
+      }
+      values.push('@BID@')
+    } else if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) {
+      keys.push(tab.foreignKey.toLowerCase())
+      values.push('@BID@')
+    }
+
+    keys = keys.join(',')
+    values = values.join(',')
+    _insertsql = `insert into ${btn.sql} (${keys}) select ${values};`
+  }
+
+  let _updatesql = ''
+  if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 淇敼璇彞
+    let _form = []
+    let _arr = []
+
+    formdata.forEach(item => {
+      if (item.writein === false) return
+      let _key = item.key.toLowerCase()
+      
+      _arr.push(_key)
+      _form.push(_key + '=@' + _key)
+    })
+
+    if (_actionType === 'audit') {
+      if (!_arr.includes('submitdate')) {
+        _form.push('submitdate=getdate()')
+      }
+      if (!_arr.includes('submituserid')) {
+        _form.push('submituserid=@userid@')
+      }
+    } else {
+      if (!_arr.includes('modifydate')) {
+        _form.push('modifydate=getdate()')
+      }
+      if (!_arr.includes('modifyuserid')) {
+        _form.push('modifyuserid=@userid@')
+      }
+    }
+    
+    if (hasvoucher) {
+      if (!_arr.includes('bvoucher')) {
+        _form.push('BVoucher=@BVoucher')
+      }
+      if (!_arr.includes('fibvoucherdate')) {
+        _form.push('FIBVoucherDate=@FIBVoucherDate')
+      }
+      if (!_arr.includes('fiyear')) {
+        _form.push('FiYear=@FiYear')
+      }
+    }
+    _form = _form.join(',')
+
+    let _ID = '=@ID@'
+    if (btn.Ot === 'requiredOnce') {
+      _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
+    }
+
+    _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};`
+  }
+
+  if (_prevCustomScript) {
+    _sql += _prevCustomScript
+  }
+
+  // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄�
+  if (_actionType === 'insert') {
+    _sql += `
+      /* 榛樿sql */
+      ${_insertsql}`
+  } else if (_actionType === 'update' || _actionType === 'audit') {
+    _sql += `
+      /* 榛樿sql */
+      ${_updatesql}`
+  } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎
+    let _ID = '=@ID@'
+    if (btn.Ot === 'requiredOnce') {
+      _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
+    }
+
+    _sql += `
+      /* 榛樿sql */
+      update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}${_ID};`
+  
+  } else if (_actionType === 'delete') {      // 鐗╃悊鍒犻櫎
+    let _msg = ''
+    if (data && columns && columns.length > 0) {
+      let _index = 0
+      columns.forEach(col => {
+        if (col.Hide !== 'true' && col.type !== 'colspan' && col.type !== 'old_colspan' && _index < 4) {
+          _msg += col.label + '=' + data[col.field] + ','
+          _index++
+        }
+      })
+    }
+
+    let _ID = '=@ID@'
+    if (btn.Ot === 'requiredOnce') {
+      _ID = ' in (select ID from  dbo.SplitComma(@ID@))'
+    }
+
+    _sql += `
+      /* 榛樿sql */
+      insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname
+      delete ${btn.sql} where ${primaryKey}${_ID};`
+  } else if (_actionType === 'insertOrUpdate') {
+    _sql += `
+      /* 榛樿sql */
+      select @tbid=''
+      select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@
+      if @tbid=''
+        begin
+        ${_billcodesSql}
+        ${_insertsql}
+        end
+      else
+        begin
+        ${_updatesql}
+        end
+    `
+  }
+
+  if (_backCustomScript) {
+    _sql += _backCustomScript
+  }
+
+  if (retmsg) {
+    _sql += `
+      aaa: if @ErrorCode!=''
+      insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@`
+  } else {
+    _sql += `
+      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
+  }
+
+  if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
+    // _sql = _sql.replace(/\n\s{8}/ig, '\n')
+    console.info(_sql)
+  }
+
+  if (retmsg) {
+    return {
+      sql: _sql,
+      callbacksql: _callbacksql
+    }
+  } else {
     return _sql
   }
 }
\ No newline at end of file
diff --git a/src/views/billprint/index.jsx b/src/views/billprint/index.jsx
index 44841cc..97a31d7 100644
--- a/src/views/billprint/index.jsx
+++ b/src/views/billprint/index.jsx
@@ -121,26 +121,26 @@
           A4: {
             vertical: 980,
             horizontal: 1200,
-            verticaldefault: 1.45789,
-            verticalwithout: 1.41428,
-            horizontaldefault: 0.683,
-            horizontalwithout: 0.705,
+            verticaldefault: 1.455,
+            verticalwithout: 1.411,
+            horizontaldefault: 0.679,
+            horizontalwithout: 0.701,
           },
           A3: {
             vertical: 1200,
             horizontal: 1600,
-            verticaldefault: 1.44404,
-            verticalwithout: 1.41414,
-            horizontaldefault: 0.6923,
-            horizontalwithout: 0.707,
+            verticaldefault: 1.441,
+            verticalwithout: 1.410,
+            horizontaldefault: 0.688,
+            horizontalwithout: 0.703,
           },
           A5: {
             vertical: 700,
             horizontal: 1000,
-            verticaldefault: 1.482,
-            verticalwithout: 1.417,
-            horizontaldefault: 0.6736,
-            horizontalwithout: 0.7047,
+            verticaldefault: 1.478,
+            verticalwithout: 1.413,
+            horizontaldefault: 0.669,
+            horizontalwithout: 0.700,
           }
         }
 
diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index 9cd3d8e..5c9d657 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -34,6 +34,7 @@
 const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
 const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
 const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
+// const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
 const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
 const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
 const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
@@ -101,6 +102,7 @@
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
     MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
     this.updateCustomComponent()
+    // this.getAppPictures()
   }
 
   /**
@@ -117,6 +119,19 @@
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
     MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
   }
+
+  // getAppPictures = () => {
+  //   Api.getSystemConfig({
+  //     func: 's_url_db_adduptdel',
+  //     id: '',
+  //     PageIndex: 0, // 0 浠h〃鍏ㄩ儴
+  //     PageSize: 0,  // 0 浠h〃鍏ㄩ儴
+  //     typecharone: 'image',
+  //     type: 'search'
+  //   }).then(res => {
+
+  //   })
+  // }
 
   updateCustomComponent = () => {
     Api.getSystemConfig({
@@ -900,10 +915,10 @@
                   {customComponents && customComponents.length ? <Panel header="鑷畾涔夌粍浠�" key="cuscomponent">
                     <SourceWrap components={customComponents} MenuType={MenuType} />
                   </Panel> : null}
-                  <Panel header={'鑳屾櫙'} key="background">
+                  <Panel header={'椤甸潰鑳屾櫙'} key="background">
                     {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null}
                   </Panel>
-                  <Panel header={'鍐呰竟璺�'} key="padding">
+                  <Panel header={'椤甸潰鍐呰竟璺�'} key="padding">
                     {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null}
                   </Panel>
                 </Collapse>
@@ -913,6 +928,7 @@
                   <div> {config && config.MenuName} </div>
                 } bordered={false} extra={
                   <div>
+                    {/* <PictureController/> */}
                     <StyleCombControlButton menu={config} />
                     <PasteController type="menu" Tab={null} insert={this.insert} />
                     {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null}
diff --git a/src/views/menudesign/printmenuform/index.jsx b/src/views/menudesign/printmenuform/index.jsx
index 04dab01..a6de29a 100644
--- a/src/views/menudesign/printmenuform/index.jsx
+++ b/src/views/menudesign/printmenuform/index.jsx
@@ -36,8 +36,12 @@
     this.props.updateConfig({...this.props.config, pageSize: val})
   }
 
-  onRadioChange = (val) => {
+  onLayoutChange = (val) => {
     this.props.updateConfig({...this.props.config, pageLayout: val})
+  }
+  
+  onPaddingChange = (val) => {
+    this.props.updateConfig({...this.props.config, pagePadding: val})
   }
 
   render() {
@@ -87,7 +91,7 @@
                   }
                 ]
               })(
-                <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}>
+                <Radio.Group onChange={(e) => {this.onLayoutChange(e.target.value)}}>
                   <Radio value="vertical">绾靛悜</Radio>
                   <Radio value="horizontal">妯悜</Radio>
                 </Radio.Group>
@@ -105,7 +109,7 @@
                   }
                 ]
               })(
-                <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}>
+                <Radio.Group onChange={(e) => {this.onPaddingChange(e.target.value)}}>
                   <Radio value="default">榛樿</Radio>
                   <Radio value="without">鏃�</Radio>
                 </Radio.Group>

--
Gitblit v1.8.0