From f3167f8371d19d0ea8fe7d0e7af5517ff0b08cd2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 07 四月 2021 23:25:29 +0800
Subject: [PATCH] 2021-04-07

---
 src/tabviews/zshare/actionList/printbutton/index.jsx |  114 ++++++++++++++++++++------------------------------------
 1 files changed, 41 insertions(+), 73 deletions(-)

diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx
index 5557e08..323d5ab 100644
--- a/src/tabviews/zshare/actionList/printbutton/index.jsx
+++ b/src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -11,6 +11,7 @@
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import asyncSpinComponent from '@/utils/asyncSpinComponent'
+import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
@@ -140,9 +141,14 @@
 
     if (btn.execMode === 'pop') {
       this.updateStatus('start')
+      let modal = this.state.btnconfig
+      if (!modal && btn.modal) {
+        modal = this.handleModelConfig(btn.modal)
+      }
+
       this.setState({
         tabledata: data,
-        btnconfig: btn.modal ? btn.modal : this.state.btnconfig
+        btnconfig: modal
       }, () => {
         this.improveAction()
       })
@@ -1022,6 +1028,29 @@
     })
   }
 
+  handleModelConfig = (config) => {
+    let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
+    config.fields = config.fields.map(cell => {
+      // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗�
+      if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
+        let _option = Utils.getSelectQueryOptions(cell)
+
+        cell.data_sql = Utils.formatOptions(_option.sql)
+        cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
+        cell.arr_field = _option.field
+      }
+
+      // 瀛楁鏉冮檺榛戝悕鍗�
+      if (!cell.blacklist || cell.blacklist.length === 0) return cell
+      if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
+        cell.hidden = 'true'
+      }
+
+      return cell
+    })
+    return config
+  }
+
   /**
    * @description 鑾峰彇鎸夐挳閰嶇疆淇℃伅
    */
@@ -1068,66 +1097,8 @@
           })
           this.updateStatus('over')
         } else {
-          let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
-          if (_LongParam.groups.length > 0) {
-            _LongParam.groups.forEach(group => {
-              group.sublist = group.sublist.map(cell => {
-                // 鏁版嵁婧恠ql璇彞锛岄澶勭悊
-                if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
-                  let _option = Utils.getSelectQueryOptions(cell)
-
-                  if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-                    _option.sql = _option.sql.replace(/\$@/ig, '/*')
-                    _option.sql = _option.sql.replace(/@\$/ig, '*/')
-                  } else {
-                    _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
-                  }
-                  // 澶栬仈鏁版嵁搴撴浛鎹�
-                  if (window.GLOB.externalDatabase !== null) {
-                    _option.sql = _option.sql.replace(/@db@/ig, window.GLOB.externalDatabase)
-                  }
-
-                  cell.data_sql = Utils.formatOptions(_option.sql)
-                  cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
-                  cell.arr_field = _option.field
-                }
-
-                // 瀛楁鏉冮檺榛戝悕鍗�
-                if (!cell.blacklist || cell.blacklist.length === 0) return cell
-                if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
-                  cell.hidden = 'true'
-                }
-
-                return cell
-              })
-            })
-          } else {
-            _LongParam.fields = _LongParam.fields.map(cell => {
-              // 鏁版嵁婧恠ql璇彞锛岄澶勭悊
-              if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') {
-                let _option = Utils.getSelectQueryOptions(cell)
-
-                if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺
-                  _option.sql = _option.sql.replace(/\$@/ig, '/*')
-                  _option.sql = _option.sql.replace(/@\$/ig, '*/')
-                } else {
-                  _option.sql = _option.sql.replace(/@\$|\$@/ig, '')
-                }
-
-                cell.data_sql = Utils.formatOptions(_option.sql)
-                cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
-                cell.arr_field = _option.field
-              }
-
-              // 瀛楁鏉冮檺榛戝悕鍗�
-              if (!cell.blacklist || cell.blacklist.length === 0) return cell
-              if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
-                cell.hidden = 'true'
-              }
-
-              return cell
-            })
-          }
+          _LongParam = updateForm(_LongParam)
+          _LongParam = this.handleModelConfig(_LongParam)
 
           this.setState({
             btnconfig: _LongParam
@@ -1171,17 +1142,10 @@
     const { BData } = this.props
     const { btnconfig, tabledata } = this.state
     let _this = this
-    let _fields = []
+    let result = []
     
-    if (btnconfig.groups.length > 0) {
-      btnconfig.groups.forEach(group => {
-        _fields = [..._fields, ...group.sublist]
-      })
-    } else {
-      _fields = btnconfig.fields
-    }
-
-    let result = _fields.map(item => {
+    btnconfig.fields.forEach(item => {
+      if (!item.field) return
       let _readin = item.readin !== 'false'
       let _initval = item.initval
 
@@ -1208,14 +1172,18 @@
         _fieldlen = item.decimal ? item.decimal : 0
       }
 
-      return {
+      if (_initval === undefined) {
+        _initval = ''
+      }
+
+      result.push({
         key: item.field,
         readonly: item.readonly === 'true',
         readin: _readin,
         fieldlen: _fieldlen,
         type: item.type,
         value: _initval
-      }
+      })
     })
 
     confirm({

--
Gitblit v1.8.0