From 295b93984fd94a11d0337637f76ff91b5a618215 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 24 四月 2023 09:49:26 +0800
Subject: [PATCH] 2023-04-24

---
 src/views/pcdesign/index.jsx |  186 ++++++++++++++++++++++------------------------
 1 files changed, 88 insertions(+), 98 deletions(-)

diff --git a/src/views/pcdesign/index.jsx b/src/views/pcdesign/index.jsx
index 15ac6d8..b6b2760 100644
--- a/src/views/pcdesign/index.jsx
+++ b/src/views/pcdesign/index.jsx
@@ -39,6 +39,7 @@
 const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
 const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
 const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
+const NormalCss = asyncComponent(() => import('@/menu/normalCss'))
 const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
 const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent'))
 const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
@@ -132,7 +133,6 @@
 
     setTimeout(() => {
       this.getAppPictures()
-      this.getSmStemp()
       this.getRoleFields()
       setGLOBFuncs()
     }, 1000)
@@ -312,83 +312,6 @@
         this.props.history.replace('/pcdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: MenuID || homeId, type: 'view'}))))
       }
     })
-  }
-
-  getSmStemp = () => {
-    if (!sessionStorage.getItem('msgTemplate')) {
-      let _sql = `select聽ID,TemplateCode,SignName+'_'+describe as SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a 
-        inner join (select openid from sapp where id='${window.GLOB.appkey}') b 
-        on a.openid=b.openid`
-  
-      _sql = Utils.formatOptions(_sql)
-  
-      let param = {
-        func: 'sPC_Get_SelectedList',
-        LText: _sql,
-        obj_name: 'data',
-        arr_field: 'ID,TemplateCode,SignName'
-      }
-      
-      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉
-      
-      Api.getSystemConfig(param).then(res => {
-        let msgs = []
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-        } else if (res.data) {
-          msgs = res.data
-          sessionStorage.setItem('msgTemplate', JSON.stringify(msgs))
-        }
-      })
-    }
-
-    if (!sessionStorage.getItem('printTemps')) {
-      let _sql = `select ID,Images,PrintTempNO+PrintTempName as PN from sPrintTemplate 
-      where appkey= @appkey@ and Deleted=0 and typechartwo='web_print'
-      union select ID,Images,a.PrintTempNO+PrintTempName as PN 
-      from (select * from sPrintTemplate where appkey= '' and Deleted=0 and typechartwo='web_print') a 
-      left join (select PrintTempNO from sPrintTemplate where appkey= @appkey@ and Deleted=0 ) b 
-      on a.PrintTempNO=b.PrintTempNO 
-      left join (select Srcid from sPrintTemplate_Log where appkey='' and apicode= @appkey@ and Deleted=0 ) c 
-      on a.ID=c.Srcid where b.PrintTempNO is null and c.Srcid is null`
-  
-      let param = {
-        func: 'sPC_Get_SelectedList',
-        LText: Utils.formatOptions(_sql),
-        obj_name: 'data',
-        arr_field: 'PN,ID,Images'
-      }
-  
-      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-  
-      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉
-  
-      Api.getSystemConfig(param).then(res => {
-        if (res.status) {
-          let temps = res.data.map(temp => {
-            return {
-              value: temp.ID,
-              text: temp.PN
-            }
-          })
-  
-          sessionStorage.setItem('printTemps', JSON.stringify(temps))
-        } else {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 5
-          })
-        }
-      })
-    }
   }
 
   getAppPictures = () => {
@@ -775,15 +698,14 @@
           }
         }
       } else {
-        let uuids = {} // 閲嶇疆鍏叡鏁版嵁婧�
+        let commonId = Utils.getuuid()
         if (config.interfaces && config.interfaces.length > 0) {
           config.interfaces = config.interfaces.map(inter => {
-            uuids[inter.uuid] = this.getuuid()
-            inter.uuid = uuids[inter.uuid]
+            inter.uuid = md5(commonId + inter.uuid)
             return inter
           })
         }
-        config.components = MenuUtils.resetConfig(config.components, uuids, urlParam.clearMenu)
+        config.components = MenuUtils.resetConfig(config.components, commonId, urlParam.clearMenu)
 
         if (config.version !== 2.0) {
           config.components = this.collectTB(config.components)
@@ -1082,6 +1004,16 @@
                 menus.push(menuObj[cell.openmenu])
               }
             })
+
+            card.backElements && card.backElements.forEach(cell => {
+              if (cell.eleType !== 'button') return
+
+              if (cell.linkmenu && menuObj[cell.linkmenu]) {
+                menus.push(menuObj[cell.linkmenu])
+              } else if (cell.openmenu && menuObj[cell.openmenu]) {
+                menus.push(menuObj[cell.openmenu])
+              }
+            })
           })
         } else if (item.type === 'balcony') {
           item.elements && item.elements.forEach(cell => {
@@ -1152,6 +1084,35 @@
     return true
   }
 
+  resetSyncQuery = (components) => {
+    return components.map(item => {
+      if (item.type === 'tabs') {
+        item.subtabs.forEach(tab => {
+          tab.components = this.resetSyncQuery(tab.components)
+        })
+      } else if (item.type === 'group') {
+        item.components = this.resetSyncQuery(item.components)
+      } else if (item.setting && item.setting.interType === 'system' && item.setting.sync === 'true') {
+        let sql = ''
+        if (item.setting.execute !== 'false' && item.setting.dataresource) {
+          sql = item.setting.dataresource
+        }
+
+        item.scripts && item.scripts.forEach(script => {
+          if (script.status === 'false') return
+
+          sql += script.sql
+        })
+       
+        if (sql.length > 8000) {
+          item.setting.sync = 'false'
+        }
+      }
+
+      return item
+    })
+  }
+
   submitConfig = () => {
     let config = fromJS(this.state.config).toJS()
 
@@ -1164,8 +1125,18 @@
     })
 
     setTimeout(() => {
-      if (config.enabled && this.verifyConfig()) {
+      let _pass = this.verifyConfig(config)
+
+      if (config.enabled && !_pass) {
         config.enabled = false
+        config.force = true
+      } else if (!config.enabled && config.force && _pass) {
+        config.enabled = true
+        delete config.force
+      }
+
+      if (config.cacheUseful !== 'true') {
+        config.components = this.resetSyncQuery(config.components)
       }
 
       let tbs = []
@@ -1373,14 +1344,14 @@
                     }
 
                     resolve(result)
-                  })
+                  }, this.netError)
                 } else {
                   resolve(res)
                 }
               } else {
                 resolve(res)
               }
-            })
+            }, this.netError)
           }
         }
       }).then(res => { // 椤甸潰淇濆瓨
@@ -1418,8 +1389,21 @@
             duration: 5
           })
         }
-      })
+      }, this.netError)
     }, 300 + (+sessionStorage.getItem('mkDelay')))
+  }
+
+  netError = (error) => {
+    this.setState({
+      menuloading: false
+    })
+    if (!error) {
+      notification.warning({
+        top: 92,
+        message: '淇濆瓨澶辫触锛岃妫�鏌ョ綉缁滄槸鍚︽甯搞��',
+        duration: 5
+      })
+    }
   }
 
   getRoleFields = () => {
@@ -1457,17 +1441,22 @@
   onEnabledChange = () => {
     const { config } = this.state
 
-    if (!config || (!config.enabled && this.verifyConfig(true))) {
-      return
-    }
+    let _config = {...config, enabled: !config.enabled}
 
-    this.setState({
-      config: {...config, enabled: !config.enabled}
-    })
+    delete _config.force
+
+    if (!_config.enabled) {
+      this.setState({
+        config: _config
+      })
+    } else if (this.verifyConfig(_config)) {
+      this.setState({
+        config: _config
+      })
+    }
   }
 
-  verifyConfig = (show) => {
-    const { config } = this.state
+  verifyConfig = (config) => {
     let error = ''
 
     let check = (components) => {
@@ -1494,7 +1483,7 @@
 
     check(config.components)
 
-    if (show && error) {
+    if (config.enabled && error) {
       notification.warning({
         top: 92,
         message: error,
@@ -1502,7 +1491,7 @@
       })
     }
 
-    return error
+    return error === ''
   }
 
   // 鏇存柊閰嶇疆淇℃伅
@@ -1707,6 +1696,7 @@
                     {/* 琛ㄥ悕娣诲姞 */}
                     {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
                     {config ? <Paragraph style={{padding: '15px 0px 0px 18px'}} copyable={{ text: MenuId }}>鑿滃崟ID</Paragraph> : null}
+                    {config ? <NormalCss config={config} updateConfig={this.updateConfig}/> : null}
                   </Panel>
                   {/* 缁勪欢娣诲姞 */}
                   <Panel header="缁勪欢" key="component">
@@ -1715,7 +1705,7 @@
                   <Panel header="鍏冪礌" key="element">
                     <Modulecell />
                   </Panel>
-                  <Panel header={'椤甸潰鏍峰紡'} key="background">
+                  <Panel header="椤甸潰鏍峰紡" key="background">
                     {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null}
                   </Panel>
                 </Collapse>
@@ -1728,7 +1718,7 @@
               </div>
               <div className="wrap">
                 <Button type="primary" className={needUpdate ? 'update-tip' : ''} id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button>
-                <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config && config.enabled} onChange={this.onEnabledChange} />
+                {config ? <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config.enabled} onChange={this.onEnabledChange} /> : null}
                 <ArrowLeftOutlined title="鍚庨��" className="back-view" onClick={this.backView}/>
                 <Button className="mk-border-purple" onClick={() => this.setState({eyeopen: !eyeopen})}>{!eyeopen ? <EyeOutlined /> : <EyeInvisibleOutlined />} 缁勪欢鍚�</Button>
                 <CreateView resetmenu={this.getAppMenus} />

--
Gitblit v1.8.0