From e41a64966b7832baffe96c21d1ea77ef6adb2905 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 14 十月 2021 18:31:55 +0800
Subject: [PATCH] 2021-10-14

---
 src/tabviews/custom/index.jsx |  156 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 122 insertions(+), 34 deletions(-)

diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx
index 22c148f..420caa2 100644
--- a/src/tabviews/custom/index.jsx
+++ b/src/tabviews/custom/index.jsx
@@ -24,11 +24,13 @@
 const DataCard = asyncComponent(() => import('./components/card/data-card'))
 const PropCard = asyncComponent(() => import('./components/card/prop-card'))
 const NormalForm = asyncComponent(() => import('./components/form/normal-form'))
+const TabForm = asyncComponent(() => import('./components/form/tab-form'))
 const CarouselDataCard = asyncComponent(() => import('./components/carousel/data-card'))
 const CarouselPropCard = asyncComponent(() => import('./components/carousel/prop-card'))
 const TableCard = asyncComponent(() => import('./components/card/table-card'))
 const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
 const NormalTable = asyncComponent(() => import('./components/table/normal-table'))
+const EditTable = asyncComponent(() => import('./components/table/edit-table'))
 const NormalGroup = asyncComponent(() => import('./components/group/normal-group'))
 const BraftEditor = asyncComponent(() => import('./components/editor/braft-editor'))
 const SandBox = asyncComponent(() => import('./components/code/sand-box'))
@@ -36,6 +38,7 @@
 const Balcony = asyncComponent(() => import('./components/card/balcony'))
 const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
 const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage'))
+const CustomChart = asyncComponent(() => import('./components/chart/custom-chart'))
 
 class CustomPage extends Component {
   static propTpyes = {
@@ -130,7 +133,9 @@
 
       // 鏉冮檺杩囨护
       let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID
-      config.components = this.filterComponent(config.components, roleId, permAction, permMenus)
+      let balMap = new Map()
+      let skip = config.permission === 'false' || this.props.menuType === 'HS'
+      config.components = this.filterComponent(config.components, roleId, permAction, permMenus, balMap, skip)
       
       // 鑾峰彇涓绘悳绱㈡潯浠�
       let mainSearch = []
@@ -190,7 +195,11 @@
         })
       }
 
-      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs)
+      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap)
+
+      if ([...balMap.keys()].length > 0) {
+        config.components = this.filterBalcony(config.components, balMap)
+      }
 
       this.setState({
         BID: BID,
@@ -439,7 +448,7 @@
     })
   }
 
-  filterComponent = (components, roleId, permAction, permMenus) => {
+  filterComponent = (components, roleId, permAction, permMenus, balMap, skip) => {
     return components.filter(item => {
       
       if (item.style && item.style.boxShadow) {
@@ -470,7 +479,7 @@
         })
 
         item.subtabs = item.subtabs.map(tab => {
-          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus)
+          tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus, balMap, skip)
           return tab
         })
 
@@ -493,8 +502,8 @@
           return false
         }
 
-        item.components = this.filterComponent(item.components, roleId, permAction, permMenus)
-      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) {
+        item.components = this.filterComponent(item.components, roleId, permAction, permMenus, balMap, skip)
+      } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
         if (
           item.plot.blacklist && item.plot.blacklist.length > 0 &&
           item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
@@ -515,14 +524,18 @@
         item.search = Utils.initSearchVal(item.search)
       }
 
-      if (item.type === 'table' && item.subtype === 'normaltable') {
+      if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
         let statFields = []
         let getCols = (cols) => {
           return cols.filter(col => {
-            if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
-              return false
-            } else if (col.Hide === 'true') {
-              return false
+            if (item.subtype !== 'editable') {
+              if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
+                return false
+              } else if (col.Hide === 'true') {
+                return false
+              }
+            } else if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
+              col.Hide = 'true'
             }
             if (col.type === 'number' && col.sum === 'true' && !statFields.includes(col.field)) {
               statFields.push(col)
@@ -556,7 +569,6 @@
       }
 
       // 鏉冮檺杩囨护
-      let isHS = this.props.menuType === 'HS'
       let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 寮圭獥鏍囩鎸夐挳Id
       if (item.action && item.action.length > 0) {
         item.action = item.action.filter(cell => {
@@ -564,6 +576,7 @@
           cell.ContainerId = this.state.ContainerId
           cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
           cell.$menuId = item.uuid
+          cell.$MenuID = this.props.MenuID
           cell.$tabId = tabId
           cell.$view = 'CustomPage'
 
@@ -576,7 +589,7 @@
             cell.style = {...cell.style, ...cell.btnstyle}
           }
 
-          return isHS || permAction[cell.uuid]
+          return skip || permAction[cell.uuid]
         })
       }
 
@@ -594,10 +607,11 @@
           card.elements = card.elements.filter(cell => {
             if (cell.eleType === 'button') {
               cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = 'requiredSgl'
+              cell.Ot = cell.Ot || 'requiredSgl'
               cell.ContainerId = this.state.ContainerId
               cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
               cell.$menuId = item.uuid
+              cell.$MenuID = this.props.MenuID
               cell.$tabId = tabId
               cell.$view = 'CustomPage'
 
@@ -612,15 +626,16 @@
               cell.innerHeight = 'auto'
             }
 
-            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
           })
           card.backElements = card.backElements.filter(cell => {
             if (cell.eleType === 'button') {
               cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = 'requiredSgl'
+              cell.Ot = cell.Ot || 'requiredSgl'
               cell.ContainerId = this.state.ContainerId
               cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
               cell.$menuId = item.uuid
+              cell.$MenuID = this.props.MenuID
               cell.$tabId = tabId
               cell.$view = 'CustomPage'
 
@@ -634,16 +649,21 @@
             } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
               cell.innerHeight = 'auto'
             }
-            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
           })
         })
       } else if (item.type === 'balcony') {
+        if (item.wrap.linkType === 'sync') {
+          item.wrap.syncModuleId = item.wrap.syncModule.pop()
+          balMap.set(item.wrap.syncModuleId, true)
+        }
         item.elements = item.elements.filter(cell => {
           if (cell.eleType === 'button') {
             cell.logLabel = item.$menuname + '-' + cell.label
             cell.ContainerId = this.state.ContainerId
             cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
             cell.$menuId = item.uuid
+            cell.$MenuID = this.props.MenuID
             cell.$tabId = tabId
             cell.$view = 'CustomPage'
 
@@ -654,7 +674,7 @@
             cell.innerHeight = 'auto'
           }
 
-          return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+          return cell.eleType !== 'button' || skip || permAction[cell.uuid]
         })
       } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel') {
         item.subcards && item.subcards.forEach(card => {
@@ -662,17 +682,17 @@
           card.elements = card.elements.filter(cell => {
             if (cell.eleType === 'button') {
               cell.logLabel = item.$menuname + '-' + cell.label
-              cell.Ot = 'requiredSgl'
+              cell.Ot = cell.Ot || 'requiredSgl'
               cell.ContainerId = this.state.ContainerId
               cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
               cell.$menuId = item.uuid
+              cell.$MenuID = this.props.MenuID
               cell.$tabId = tabId
               cell.$view = 'CustomPage'
 
               if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃�
                 cell = this.getPrinter(cell, item.uuid)
               }
-
               if (card.btnstyle) { // 鍏煎
                 card.style = card.style || {}
                 card.style = {...card.style, ...card.btnstyle}
@@ -680,18 +700,19 @@
             } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) {
               cell.innerHeight = 'auto'
             }
-            return cell.eleType !== 'button' || isHS || permAction[cell.uuid]
+            return cell.eleType !== 'button' || skip || permAction[cell.uuid]
           })
         })
-      } else if (item.type === 'table' && item.subtype === 'normaltable') {
+      } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
         item.cols = item.cols.filter(col => {
           if (col.type !== 'action') return true
           col.elements = col.elements.filter(cell => {
             cell.logLabel = item.$menuname + '-' + cell.label
-            cell.Ot = 'requiredSgl'
+            cell.Ot = cell.Ot || 'requiredSgl'
             cell.ContainerId = this.state.ContainerId
             cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
             cell.$menuId = item.uuid
+            cell.$MenuID = this.props.MenuID
             cell.$tabId = tabId
             cell.$view = 'CustomPage'
 
@@ -704,10 +725,15 @@
               cell.style = {...cell.style, ...cell.btnstyle}
             }
 
-            return isHS || permAction[cell.uuid]
+            return skip || permAction[cell.uuid]
           })
           return col.elements.length !== 0
         })
+
+        if (item.subtype === 'editable') {
+          item.submit.logLabel = item.$menuname + '-鎻愪氦'
+          item.submit.$menuId = item.uuid
+        }
       } 
 
       if (item.setting && item.setting.supModule) {
@@ -722,6 +748,44 @@
         let index = item.action.findIndex((btn) => btn.uuid === item.wrap.doubleClick)
         if (index === -1) {
           item.wrap.doubleClick = ''
+        }
+      }
+      
+      return true
+    })
+  }
+
+  filterBalcony = (components, balMap) => {
+    return components.filter(item => {
+      if (item.type === 'tabs') {
+        item.subtabs = item.subtabs.map(tab => {
+          tab.components = this.filterBalcony(tab.components, balMap)
+          return tab
+        })
+      } else if (item.type === 'group') {
+        item.components = this.filterBalcony(item.components, balMap)
+      }
+
+      if (item.type === 'balcony' && item.wrap.linkType === 'sync') {
+        let conf = balMap.get(item.wrap.syncModuleId)
+
+        if (!conf || conf === true) {
+          return false
+        }
+        
+        item.syncConfig = {
+          uuid: conf.uuid,
+          wrap: conf.wrap,
+          setting: conf.setting,
+          columns: conf.columns
+        }
+
+        if (item.wrap.checkAll === 'show') {
+          if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') {
+            item.wrap.checkAll = 'hidden'
+          } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') {
+            item.wrap.checkAll = 'hidden'
+          }
         }
       }
       
@@ -748,17 +812,17 @@
   }
 
   // 鏍煎紡鍖栭粯璁よ缃�
-  formatSetting = (components, params, mainSearch, inherit, regs) => {
+  formatSetting = (components, params, mainSearch, inherit, regs, balMap) => {
     return components.map(component => {
       if (component.type === 'tabs') {
         component.subtabs = component.subtabs.map(tab => {
-          tab.components = this.formatSetting(tab.components, [], [], inherit, regs)
+          tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap)
           tab = {...tab, ...inherit}
           return tab
         })
         return component
       } else if (component.type === 'group') {
-        component.components = this.formatSetting(component.components, [], [], inherit, regs)
+        component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap)
         component = {...component, ...inherit}
         return component
       }
@@ -822,7 +886,7 @@
       // floor    缁勪欢鐨勫眰绾�
       // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О
       // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ
-      if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
+      if (params && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
         let searchlist = []
         if (component.search && component.search.length > 0) {
           searchlist = Utils.initMainSearch(component.search)
@@ -840,10 +904,15 @@
           component.setting.sync = 'false'
           component.setting.onload = 'false'
         } else {
-          params.push(getStructDefaultParam(component, searchlist))
+          params.push(getStructDefaultParam(component, searchlist, params.length === 0))
         }
       } else if (component.floor === 1) {
         component.setting.sync = 'false'
+      }
+
+      if (balMap.has(component.uuid)) {
+        component.setting.$hasSyncModule = true
+        balMap.set(component.uuid, component)
       }
 
       return component
@@ -931,7 +1000,8 @@
       viewlost: false,      // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤
       config: null,         // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑
       loading: false,       // 鍒楄〃鏁版嵁鍔犺浇涓�
-      shortcuts: null
+      shortcuts: null,
+      data: ''
     }, () => {
       this.loadconfig()
     })
@@ -979,10 +1049,16 @@
             <AntvDashboard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
           </Col>
         )
-      } else if (item.type === 'form') {
+      } else if (item.type === 'form' && item.subtype === 'stepform') {
         return (
           <Col span={item.width} key={item.uuid}>
             <NormalForm config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
+          </Col>
+        )
+      } else if (item.type === 'form' && item.subtype === 'tabform') {
+        return (
+          <Col span={item.width} key={item.uuid}>
+            <TabForm config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
           </Col>
         )
       } else if (item.type === 'search') {
@@ -994,7 +1070,7 @@
       } else if (item.type === 'tabs') {
         return (
           <Col span={item.width} key={item.uuid}>
-            <AntvTabs config={item} mainSearch={mainSearch} />
+            <AntvTabs config={item} BID={BID} mainSearch={mainSearch} />
           </Col>
         )
       } else if (item.type === 'card' && item.subtype === 'datacard') {
@@ -1012,7 +1088,7 @@
       } else if (item.type === 'balcony') {
         return (
           <Col span={item.width} key={item.uuid}>
-            <Balcony menu={config} config={item} data={data} BID={_bid} menuType={menuType} />
+            <Balcony config={item} data={data} BID={_bid} menuType={menuType} />
           </Col>
         )
       } else if (item.type === 'carousel' && item.subtype === 'datacard') {
@@ -1039,6 +1115,12 @@
             <NormalTable config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
           </Col>
         )
+      } else if (item.type === 'table' && item.subtype === 'editable') {
+        return (
+          <Col span={item.width} key={item.uuid}>
+            <EditTable config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
+          </Col>
+        )
       } else if (item.type === 'group' && item.subtype === 'normalgroup') {
         return (
           <Col span={item.width} key={item.uuid}>
@@ -1063,6 +1145,12 @@
             <SandBox config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
           </Col>
         )
+      } else if (item.type === 'chart') {
+        return (
+          <Col span={item.width} key={item.uuid}>
+            <CustomChart config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} />
+          </Col>
+        )
       } else {
         return null
       }
@@ -1077,7 +1165,7 @@
       <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}>
         {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null}
         <Row>{this.getComponents()}</Row>
-        {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
+        {menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
         {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null}
         {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
       </div>

--
Gitblit v1.8.0