From f07c42a322f41e14ef5b1bf8f2fd66fc5d338cdd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 28 六月 2023 18:17:09 +0800
Subject: [PATCH] 2023-06-28

---
 src/tabviews/custom/popview/index.jsx |  430 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 263 insertions(+), 167 deletions(-)

diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx
index 04863e0..67bdd49 100644
--- a/src/tabviews/custom/popview/index.jsx
+++ b/src/tabviews/custom/popview/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { notification, Spin, Row, Col } from 'antd'
+import { notification, Spin, Row, Col, Modal } from 'antd'
 
 import Api from '@/api'
 import zhCN from '@/locales/zh-CN/main.js'
@@ -20,6 +20,7 @@
 const AntvScatter = asyncComponent(() => import('../components/chart/antv-scatter'))
 const DataCard = asyncComponent(() => import('../components/card/data-card'))
 const PropCard = asyncComponent(() => import('../components/card/prop-card'))
+const DoubleDataCard = asyncComponent(() => import('../components/card/double-data-card'))
 const SimpleForm = asyncComponent(() => import('../components/form/simple-form'))
 const StepForm = asyncComponent(() => import('../components/form/step-form'))
 const TabForm = asyncComponent(() => import('../components/form/tab-form'))
@@ -38,6 +39,9 @@
 const CustomChart = asyncComponent(() => import('../components/chart/custom-chart'))
 const TimeLine = asyncComponent(() => import('../components/timeline/normal-timeline'))
 const Voucher = asyncComponent(() => import('../components/module/voucher'))
+const Iframe = asyncComponent(() => import('../components/iframe'))
+const AntvG6 = asyncComponent(() => import('../components/chart/antv-G6'))
+const AntvX6 = asyncComponent(() => import('../components/chart/antv-X6'))
 
 class CustomPage extends Component {
   static propTpyes = {
@@ -94,7 +98,7 @@
 
     // 鏁版嵁缂撳瓨璁剧疆
     if (config.cacheUseful === 'true') {
-      if (!['day', 'hour'].includes(config.timeUnit)) {
+      if (!['day', 'hour', 'minute'].includes(config.timeUnit)) {
         config.timeUnit = 'day'
       }
       config.cacheTime = config.cacheTime || 1
@@ -127,7 +131,9 @@
       })
     }
 
-    config.components = this.filterComponent(config.components, roleId, balMap, param, Tab)
+    config.$cache = config.cacheLocal === 'true'
+
+    config.components = this.filterComponent(config.components, roleId, balMap, param, Tab, config.$cache)
     
     // 鑾峰彇涓绘悳绱㈡潯浠�
     let mainSearch = []
@@ -173,9 +179,10 @@
     })
   }
 
-  filterComponent = (components, roleId, balMap, urlparam, Tab) => {
+  filterComponent = (components, roleId, balMap, urlparam, Tab, cache) => {
     return components.filter(item => {
       item.$pageId = Tab.uuid
+      item.$cache = cache
       
       if (item.style && item.style.boxShadow) {
         delete item.style.hShadow
@@ -259,7 +266,7 @@
         item.subtabs = item.subtabs.map(tab => {
           tab.$pageId = Tab.uuid
 
-          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab)
+          tab.components = this.filterComponent(tab.components, roleId, balMap, urlparam, Tab, cache)
           return tab
         })
 
@@ -272,7 +279,7 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab)
+        item.components = this.filterComponent(item.components, roleId, balMap, urlparam, Tab, cache)
 
         return true
       } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
@@ -296,6 +303,29 @@
         item.search = Utils.initSearchVal(item.search)
       }
 
+      if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢
+        item.setting.supModule = item.supNodes[0].componentId
+      } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
+        let pid = item.setting.supModule.pop()
+        if (pid && pid !== 'empty') {
+          item.setting.supModule = pid
+        } else {
+          item.setting.supModule = ''
+        }
+      }
+
+      // 鏉冮檺杩囨护
+      if (item.action && item.action.length > 0) {
+        item.action = item.action.filter(cell => {
+          if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
+
+          cell = this.resetButton(item, cell, Tab)
+          cell.$toolbtn = true
+
+          return true
+        })
+      }
+
       if (item.type === 'table') {
         let statFields = []
         let getCols = (cols) => {
@@ -304,6 +334,8 @@
               return false
             } else if (col.Hide === 'true') {
               return false
+            } else if (col.type === 'action') {
+              col.type = 'custom'
             }
             
             if (col.type === 'number') {
@@ -316,26 +348,31 @@
                   col.decimal = col.decimal > 2 ? col.decimal - 2 : 0
                 }
               }
+            } else if (col.type === 'formula') {
+              if (typeof(col.decimal) === 'number') {
+                col.round = Math.pow(10, col.decimal)
+              }
             } else if (col.type === 'colspan') {
               col.subcols = getCols(col.subcols || [])
               if (col.subcols.length === 0) {
                 return false
               }
             } else if (col.type === 'custom') {
-              col.elements = col.elements.map(cell => {
-                if (['text', 'number', 'formula'].includes(cell.eleType)) {
-                  if (!cell.height) {
-                    cell.innerHeight = 'auto'
-                  }
-                  if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                    cell.round = Math.pow(10, cell.decimal)
-                    if (cell.format === 'percent') {
-                      cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                    }
-                  }
+              col.elements = col.elements.filter(cell => {
+                if (cell.eleType === 'button') {
+                  if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
+            
+                  cell = this.resetButton(item, cell, Tab)
+                } else {
+                  cell = this.resetElement(cell)
                 }
-                return cell
+
+                return true
               })
+
+              if (col.elements.length === 0) {
+                return false
+              }
             }
       
             if (col.linkmenu && col.linkmenu.length > 0) {
@@ -351,46 +388,20 @@
         
         item.cols = getCols(item.cols)
         item.statFields = statFields
-      }
 
-      let mutil = false
-      if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢
-        mutil = true
-        item.setting.supModule = item.supNodes[0].componentId
-      } else if (item.setting && item.setting.supModule) {
-        let pid = item.setting.supModule.pop()
-        if (pid && pid !== 'empty') {
-          item.setting.supModule = pid
-        } else {
-          item.setting.supModule = ''
+        if (item.subtype === 'editable') {
+          item.submit.logLabel = item.$menuname + '-鎻愪氦'
+          item.submit.$menuId = item.uuid
+          item.submit.syncComponentId = item.submit.syncComponent ? (item.submit.syncComponent.pop() || '') : ''
+
+          if (item.submit.syncComponentId && item.submit.syncComponentId === item.setting.supModule) {
+            item.submit.syncComponentId = ''
+            if (item.submit.execSuccess === 'grid') {
+              item.submit.execSuccess = 'mainline'
+            }
+          }
         }
-      }
-
-      // 鏉冮檺杩囨护
-      if (item.action && item.action.length > 0) {
-        item.action = item.action.filter(cell => {
-          if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
-
-          cell.logLabel = item.$menuname + '-' + cell.label
-          cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-          cell.$menuId = item.uuid
-          cell.$tabId = Tab.uuid
-          cell.$toolbtn = true
-
-          if (!mutil && cell.syncComponentId === item.setting.supModule) {
-            cell.syncComponentId = ''
-          }
-
-          if (cell.btnstyle) { // 鍏煎
-            cell.style = cell.style || {}
-            cell.style = {...cell.style, ...cell.btnstyle}
-          }
-
-          return true
-        })
-      }
-
-      if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
+      } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
         item.subcards && item.subcards.forEach(card => {
           if (card.style.boxShadow) {
             delete card.style.hShadow
@@ -401,66 +412,49 @@
 
           card.elements = card.elements.filter(cell => {
             if (cell.eleType === 'button') {
-              if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+              if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$tabId = Tab.uuid
-
-              if (!mutil && cell.syncComponentId === item.setting.supModule) {
-                cell.syncComponentId = ''
-              }
-              if (card.btnstyle) { // 鍏煎
-                card.style = card.style || {}
-                card.style = {...card.style, ...card.btnstyle}
-              }
-            } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-              if (!cell.height) {
-                cell.innerHeight = 'auto'
-              }
-              if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                cell.round = Math.pow(10, cell.decimal)
-                if (cell.format === 'percent') {
-                  cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                }
-              }
+              cell = this.resetButton(item, cell, Tab)
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return true
           })
 
+          if (card.setting.click === 'menus') {
+            if (card.menus) {
+              card.menus = card.menus.filter(m => !!m.MenuID)
+              if (card.menus.length === 0) {
+                card.menus = null
+              }
+            }
+            if (!card.menus || item.subtype !== 'datacard' || card.$cardType === 'extendCard') {
+              card.setting.click = ''
+            }
+          } else if (card.setting.click === 'menu') {
+            if (!Array.isArray(card.setting.menu)) {
+              card.setting.click = ''
+            }
+          }
+
+          if (item.subtype === 'dualdatacard' && card.$cardType !== 'extendCard') {
+            if (card.backSetting && card.backSetting.click === 'menu') {
+              if (!Array.isArray(card.backSetting.menu)) {
+                card.backSetting.click = ''
+              }
+            }
+          }
+
           if (!card.backElements || card.backElements.length === 0) return
 
           card.backElements = card.backElements.filter(cell => {
             if (cell.eleType === 'button') {
-              if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+              if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
 
-              cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = cell.Ot || 'requiredSgl'
-              cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-              cell.$menuId = item.uuid
-              cell.$tabId = Tab.uuid
-
-              if (!mutil && cell.syncComponentId === item.setting.supModule) {
-                cell.syncComponentId = ''
-              }
-
-              if (card.btnstyle) { // 鍏煎
-                card.style = card.style || {}
-                card.style = {...card.style, ...card.btnstyle}
-              }
-            } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-              if (!cell.height) {
-                cell.innerHeight = 'auto'
-              }
-              if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-                cell.round = Math.pow(10, cell.decimal)
-                if (cell.format === 'percent') {
-                  cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-                }
-              }
+              cell = this.resetButton(item, cell, Tab)
+            } else {
+              cell = this.resetElement(cell)
             }
 
             return true
@@ -476,64 +470,20 @@
         }
         item.elements = item.elements.filter(cell => {
           if (cell.eleType === 'button') {
-            if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
+            if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
 
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$tabId = Tab.uuid
-
-            if (cell.syncComponentId === item.wrap.supModule) {
-              cell.syncComponentId = ''
-            }
-          } else if (['text', 'number', 'formula'].includes(cell.eleType)) {
-            if (!cell.height) {
-              cell.innerHeight = 'auto'
-            }
-            if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
-              cell.round = Math.pow(10, cell.decimal)
-              if (cell.format === 'percent') {
-                cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
-              }
-            }
+            cell = this.resetButton(item, cell, Tab)
+          } else {
+            cell = this.resetElement(cell)
           }
 
           return true
         })
-      } else if (item.type === 'table') {
-        item.cols = item.cols.filter(col => {
-          if (col.type !== 'action') return true
-          col.elements = col.elements.filter(cell => {
-            if (cell.hidden === 'true' || ['popview', 'funcbutton'].includes(cell.OpenType)) return false
-            
-            cell.logLabel = item.$menuname + '-' + cell.label
-            cell.Ot = cell.Ot || 'requiredSgl'
-            cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
-            cell.$menuId = item.uuid
-            cell.$tabId = Tab.uuid
-
-            if (cell.syncComponentId === item.setting.supModule) {
-              cell.syncComponentId = ''
-            }
-
-            if (cell.btnstyle) { // 鍏煎
-              cell.style = cell.style || {}
-              cell.style = {...cell.style, ...cell.btnstyle}
-            }
-
-            return true
-          })
-          return col.elements.length !== 0
-        })
-
-        if (item.subtype === 'editable') {
-          item.submit.logLabel = item.$menuname + '-鎻愪氦'
-          item.submit.$menuId = item.uuid
-        }
       } else if (item.type === 'form') {
         item.subcards = item.subcards.map(group => {
           group.subButton.uuid = group.uuid
           group.subButton.$menuId = group.uuid
+          group.subButton.$MenuID = Tab.$MenuID
           group.subButton.OpenType = 'formSubmit'
           group.subButton.execError = 'never'
           group.subButton.logLabel = item.$menuname + '-' + group.subButton.label
@@ -542,19 +492,21 @@
             group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
           }
 
-          group.subButton.syncComponentId = group.subButton.syncComponent ? group.subButton.syncComponent.pop() : ''
+          group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
 
-          if (group.subButton.syncComponentId === item.setting.supModule) {
+          if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) {
             group.subButton.syncComponentId = ''
+            if (group.subButton.execSuccess === 'grid') {
+              group.subButton.execSuccess = 'mainline'
+            }
           }
 
           group.fields = group.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.base_sql = _option.sql
               cell.arr_field = _option.field
             }
       
@@ -611,6 +563,93 @@
       
       return true
     })
+  }
+
+  resetButton = (item, cell, Tab) => {
+    cell.logLabel = item.$menuname + '-' + cell.label
+    cell.Ot = cell.Ot || 'requiredSgl'
+    cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
+    cell.$menuId = item.uuid
+    cell.$MenuID = Tab.$MenuID
+    cell.$tabId = Tab.uuid
+
+    if (cell.btnstyle) { // 鍏煎
+      cell.style = cell.style || {}
+      cell.style = {...cell.style, ...cell.btnstyle}
+    }
+
+    if (cell.controlField) {
+      if (/,/ig.test(cell.controlVal)) {
+        cell.controlVals = cell.controlVal.split(',')
+      } else {
+        cell.controlVals = [(cell.controlVal || '')]
+      }
+    }
+
+    if (cell.syncComponentId) {
+      if (cell.syncComponentId === item.setting.supModule) {
+        cell.syncComponentId = ''
+        if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
+          cell.execSuccess = 'mainline'
+        }
+      } else if (cell.syncComponentId === 'multiComponent') {
+        let ids = cell.syncComponents.map(m => {
+          return m.syncComId.pop() || ''
+        })
+
+        if (item.setting.supModule && ids.includes(item.setting.supModule)) {
+          if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
+            cell.execSuccess = 'mainline'
+          }
+          ids = ids.filter(id => id !== item.setting.supModule)
+        }
+        
+        if (ids.length === 0) {
+          cell.syncComponentId = ''
+        } else {
+          cell.syncComponentIds = ids
+        }
+      }
+    }
+
+    return cell
+  }
+
+  resetElement = (cell) => {
+    cell.style = cell.style || {}
+    if (['text', 'number', 'formula'].includes(cell.eleType)) {
+      if (!cell.height) {
+        cell.innerHeight = 'auto'
+      }
+
+      cell.innerHeight = cell.innerHeight || 'auto'
+      cell.alignItems = cell.height > 1 ? cell.alignItems : ''
+
+      if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
+        cell.round = Math.pow(10, cell.decimal)
+        if (cell.format === 'percent') {
+          cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
+        }
+      } else if (cell.type === 'formula' && typeof(cell.decimal) === 'number') {
+        cell.round = Math.pow(10, cell.decimal)
+      }
+    } else if (cell.eleType === 'icon') {
+      if (!cell.innerHeight) { // 鍏煎
+        let fontSize = 14
+        let lineHeight = 1.5
+  
+        if (cell.style.fontSize) {
+          fontSize = parseInt(cell.style.fontSize)
+        }
+        if (cell.style.lineHeight) {
+          lineHeight = parseFloat(cell.style.lineHeight)
+        }
+  
+        cell.innerHeight = fontSize * lineHeight
+      }
+    }
+
+    return cell
   }
 
   getPrinter = (item, parentId) => {
@@ -707,7 +746,7 @@
 
       // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О
       if (component.setting.sync === 'true') {
-        component.dataName = Utils.getdataName()
+        component.dataName = 'mk' + component.uuid.slice(-18)
       }
 
       // floor    缁勪欢鐨勫眰绾�
@@ -752,16 +791,41 @@
    * @description 涓昏〃鏁版嵁鍔犺浇
    */ 
   loadmaindata = (params) => {
-    let param = getStructuredParams(params, this.state.config, this.state.BID || '')
+    const { config } = this.state
+    let param = getStructuredParams(params, config, this.state.BID || '')
 
     this.setState({loading: true})
 
     Api.genericInterface(param).then(result => {
       if (result.status) {
+        if (result.message) {
+          if (result.ErrCode === 'Y') {
+            Modal.success({
+              title: result.message
+            })
+          } else if (result.ErrCode === 'S') {
+            notification.success({
+              top: 92,
+              message: result.message,
+              duration: 2
+            })
+          }
+        }
+
         delete result.status
         delete result.message
         delete result.ErrMesg
         delete result.ErrCode
+
+        if (config.$cache) {
+          params.forEach((item) => {
+            let _data = result[item.name] || ''
+            if (_data && !Array.isArray(_data)) {
+              _data = [_data]
+            }
+            Api.writeCacheConfig(item.uuid, _data)
+          })
+        }
 
         this.setState({
           data: result,
@@ -772,11 +836,19 @@
           data: '',
           loading: false
         })
-        notification.error({
-          top: 92,
-          message: result.message,
-          duration: 10
-        })
+
+        if (!result.message) return
+        if (result.ErrCode === 'N') {
+          Modal.error({
+            title: result.message,
+          })
+        } else if (result.ErrCode !== '-2') {
+          notification.error({
+            top: 92,
+            message: result.message,
+            duration: 10
+          })
+        }
       }
     })
   }
@@ -846,6 +918,12 @@
         return (
           <Col span={item.width} style={style} key={item.uuid}>
             <PropCard config={item} data={data} mainSearch={mainSearch}/>
+          </Col>
+        )
+      } else if (item.type === 'card' && item.subtype === 'dualdatacard') {
+        return (
+          <Col span={item.width} style={style} key={item.uuid}>
+            <DoubleDataCard config={item} mainSearch={mainSearch}/>
           </Col>
         )
       } else if (item.type === 'table' && item.subtype === 'basetable') {
@@ -986,6 +1064,24 @@
             <Voucher config={item}/>
           </Col>
         )
+      } else if (item.type === 'iframe') {
+        return (
+          <Col span={item.width} style={style} key={item.uuid}>
+            <Iframe config={item} data={data} mainSearch={mainSearch}/>
+          </Col>
+        )
+      } else if (item.type === 'antvG6') {
+        return (
+          <Col span={item.width} style={style} key={item.uuid}>
+            <AntvG6 config={item} data={data} mainSearch={mainSearch}/>
+          </Col>
+        )
+      } else if (item.type === 'antvX6') {
+        return (
+          <Col span={item.width} style={style} key={item.uuid}>
+            <AntvX6 config={item}/>
+          </Col>
+        )
       } else {
         return null
       }
@@ -997,7 +1093,7 @@
 
     return (
       <div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}>
-        {loading ? <Spin className="view-spin" size="large" /> : null}
+        {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null}
         <Row className="component-wrap">{this.getComponents()}</Row>
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>

--
Gitblit v1.8.0