From 7adf0212cd71a8ec604f65ba2c2e9bdfc5dec22d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 13 一月 2023 10:31:38 +0800
Subject: [PATCH] 2023-01-13

---
 src/views/mobdesign/index.jsx |  130 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 127 insertions(+), 3 deletions(-)

diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx
index a3f934b..1091b21 100644
--- a/src/views/mobdesign/index.jsx
+++ b/src/views/mobdesign/index.jsx
@@ -45,6 +45,7 @@
 const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
 const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
 const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
+const PopView = asyncComponent(() => import('./popview'))
 
 sessionStorage.setItem('isEditState', 'true')
 sessionStorage.setItem('editMenuType', 'menu') // 缂栬緫鑿滃崟绫诲瀷
@@ -73,6 +74,7 @@
     comloading: false,
     adapters: [],
     viewType: 'menu',
+    view: '',
     eyeopen: false,
     needUpdate: false
   }
@@ -140,6 +142,7 @@
       document.getElementById('mk-mob-design-view').innerHTML = '<div style="text-align: center; font-size: 30px; margin-top: 40vh; height: 100vh; background: #fff;">鏈簲鐢ㄦ病鏈塒C绔〉闈㈢殑缂栬緫鏉冮檺锛岃鑱旂郴绠$悊鍛橈紒</div>'
       return
     }
+    MKEmitter.addListener('changePopview', this.initPopview)
     MKEmitter.addListener('triggerMenuSave', this.submitConfig)
     MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
     setTimeout(() => {
@@ -210,8 +213,129 @@
     this.setState = () => {
       return
     }
+    MKEmitter.removeListener('changePopview', this.initPopview)
     MKEmitter.removeListener('triggerMenuSave', this.submitConfig)
     MKEmitter.removeListener('changeEditMenu', this.changeEditMenu)
+  }
+
+  initPopview = (card, btn) => {
+    const { config } = this.state
+
+    if (!this.checkBase()) {
+      return
+    }
+
+    let _btn = fromJS(btn).toJS()
+
+    if (_btn.config) {
+      _btn.config.uuid = _btn.uuid
+      _btn.config.MenuID = _btn.uuid
+      _btn.config.ParentId = card.uuid
+      _btn.config.MenuName = _btn.label
+    } else {
+      _btn.config = {
+        uuid: _btn.uuid,
+        MenuID: _btn.uuid,
+        ParentId: card.uuid,
+        enabled: false,
+        MenuName: _btn.label,
+        tables: config.tables || [],
+        Template: 'CustomPage',
+        components: [],
+        viewType: 'popview',
+        style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' }
+      }
+    }
+
+    this.setState({view: 'popview', popConfig: _btn})
+  }
+
+  closePop = () => {
+    const {config} = this.state
+
+    sessionStorage.setItem('editMenuType', 'menu')
+
+    window.GLOB.urlFields = config.urlFields || []
+    window.GLOB.customMenu = config
+
+    this.setState({view: '', popConfig: null})
+  }
+
+  submitPopConfig = (btnconfig) => {
+    let parents = {[btnconfig.ParentId]: true}
+    let popbtns = {[btnconfig.uuid]: fromJS(btnconfig).toJS()}
+    let config = fromJS(this.state.config).toJS()
+
+    config.components = this.setPopView(config.components, parents, popbtns)
+
+    this.setState({ config }, () => {
+      this.submitConfig()
+    })
+  }
+
+  setPopView = (components, parents, popbtns) => {
+    return components.map(item => {
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(tab => {
+          tab.components = this.setPopView(tab.components, parents, popbtns)
+        })
+      } else if (item.type === 'group') {
+        item.components = this.setPopView(item.components, parents, popbtns)
+      } else if (parents[item.uuid]) {
+        this.setpopConfig(item, popbtns)
+      }
+      return item
+    })
+  }
+
+  setpopConfig = (config, popbtns) => {
+    config.subcards && config.subcards.forEach(item => {
+      item.elements.forEach(cell => {
+        if (cell.eleType !== 'button') return
+        if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
+          cell.config = popbtns[cell.uuid]
+        }
+      })
+    })
+
+    config.cols && config.cols.forEach(col => {
+      if (col.type === 'action') {
+        col.elements.forEach(cell => {
+          if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
+            cell.config = popbtns[cell.uuid]
+          }
+        })
+      }
+    })
+
+    config.elements && config.elements.forEach(cell => {
+      if (cell.eleType !== 'button') return
+      if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
+        cell.config = popbtns[cell.uuid]
+      }
+    })
+  
+    config.action && config.action.forEach(cell => {
+      if (cell.OpenType === 'popview' && popbtns[cell.uuid]) {
+        cell.config = popbtns[cell.uuid]
+      }
+    })
+
+    config.$tables = getTables(config)
+  }
+
+  checkBase = () => {
+    const { config } = this.state
+
+    if (!config.MenuName || !config.MenuNo) {
+      notification.warning({
+        top: 92,
+        message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒',
+        duration: 5
+      })
+      return false
+    }
+    return true
   }
 
   getSmStemp = () => {
@@ -1868,7 +1992,7 @@
 
 
   render () {
-    const { viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate } = this.state
+    const { view, viewType, comloading, loading, settingshow, controlshow, activeKey, MenuId, config, menuloading, adapters, eyeopen, needUpdate } = this.state
 
     return (
       <ConfigProvider locale={antdZhCN}>
@@ -1876,7 +2000,7 @@
           <Header/>
           {loading ? <Spin className="view-spin" size="large" /> : null}
           <DndProvider backend={HTML5Backend}>
-            <div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}>
+            {view !== 'popview' ? <><div className={'menu-setting ' + (!settingshow ? 'hidden' : '')}>
               <div className="draw">
                 {settingshow ? <DoubleLeftOutlined onClick={() => {this.setState({settingshow: false})}} /> : null}
                 {!settingshow ? <DoubleRightOutlined onClick={() => {this.setState({settingshow: true})}} /> : null}
@@ -1947,7 +2071,7 @@
               {config && !comloading ? <div className="mob-shell" style={{width: window.GLOB.shellWidth, height: window.GLOB.shellHeight}}>
                 <MobShell menu={config} handleList={this.updateConfig} />
               </div> : null}
-            </div>
+            </div></> : <PopView btn={this.state.popConfig} save={this.submitPopConfig} cancel={this.closePop}/>}
           </DndProvider>
           <StyleController />
           <StyleCombController />

--
Gitblit v1.8.0