From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/views/menudesign/index.jsx |  145 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 140 insertions(+), 5 deletions(-)

diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index 3de9a7d..f07b1fe 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -112,8 +112,43 @@
     setTimeout(() => {
       this.updateCustomComponent()
       this.getAppPictures()
+      this.getPrintTemp()
       setGLOBFuncs()
     }, 1000)
+
+    document.onkeydown = (event) => {
+      let e = event || window.event
+      let keyCode = e.keyCode || e.which || e.charCode
+      let preKey = ''
+
+      if (e.ctrlKey) {
+        preKey = 'ctrl'
+      }
+      if (e.shiftKey) {
+        preKey = 'shift'
+      } else if (e.altKey) {
+        preKey = 'alt'
+      }
+      
+      if (!preKey || !keyCode) return
+      
+      let _shortcut = `${preKey}+${keyCode}`
+
+      if (_shortcut === 'ctrl+83') {
+        let node = document.getElementById('save-modal-config')
+        if (!node) {
+          node = document.getElementById('save-pop-config')
+        }
+        if (!node) {
+          node = document.getElementById('save-config')
+        }
+
+        if (node) {
+          node.click()
+        }
+        return false
+      }
+    }
   }
 
   /**
@@ -136,6 +171,50 @@
     if (this.state.visible) return
 
     this.submitConfig()
+  }
+
+  getPrintTemp = () => {
+    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 = () => {
@@ -410,7 +489,7 @@
               _sort++
             })
           })
-        } else if (item.type === 'carousel') {
+        } else if (item.type === 'carousel' || item.type === 'timeline') {
           item.subcards.forEach(card => {
             card.elements && card.elements.forEach(cell => {
               if (cell.eleType !== 'button') return
@@ -426,13 +505,13 @@
             buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`)
             _sort++
           })
-        } else if (item.type === 'line' || item.type === 'bar') {
+        } else if (item.type === 'line' || item.type === 'bar' || item.type === 'chart') {
           item.action && item.action.forEach(btn => {
             this.checkBtn(btn)
             buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
             _sort++
           })
-        } else if (item.type === 'table' && item.subtype === 'normaltable') {
+        } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) {
           item.action && item.action.forEach(btn => {
             this.checkBtn(btn)
             buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
@@ -722,6 +801,7 @@
                       _conf.uuid = item.uuid
                       _conf.MenuID = item.uuid
                       _conf.Template = 'CustomPage'
+                      _conf.enabled = false
                     } else {
                       resolve({
                         status: true
@@ -837,7 +917,7 @@
   }
 
   verifyConfig = (show) => {
-    const { config } = this.state
+    const { config, MenuType } = this.state
     let error = ''
 
     let check = (components) => {
@@ -851,7 +931,12 @@
         } else if (item.type === 'group') {
           check(item.components)
           return
+        } else if (item.subtype === 'propcard' && item.subcards.length === 0) {
+          error = `缁勪欢銆�${item.name}銆嬩腑鍗$墖涓嶅彲涓虹┖锛乣
+          return
         }
+        
+        if (['voucher'].includes(item.subtype)) return
         if (['propcard', 'brafteditor', 'sandbox', 'stepform', 'tabform'].includes(item.subtype) && item.wrap.datatype === 'static') return
         if (['balcony'].includes(item.type) && item.wrap.datatype === 'static') return
   
@@ -862,6 +947,8 @@
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆鏁版嵁婧愶紒`
           } else if (!item.setting.primaryKey) {
             error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婚敭锛乣
+          } else if (!item.setting.supModule && item.type !== 'balcony' && (!item.wrap || item.wrap.supType !== 'multi')) {
+            error = `缁勪欢銆�${item.name}銆嬫湭璁剧疆涓婄骇缁勪欢锛乣
           }
         }
         if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
@@ -874,6 +961,15 @@
           error = `缁勪欢銆�${item.name}銆嬪潗鏍囪酱灏氭湭璁剧疆锛乣
         } else if (item.type === 'tree' && (!item.wrap.valueField || !item.wrap.labelField || !item.wrap.parentField)) {
           error = `缁勪欢銆�${item.name}銆嬪熀鏈俊鎭皻鏈缃紒`
+        } else if (item.type === 'table' && item.wrap.doubleClick) {
+          let _actions = [...item.action]
+          item.cols.forEach(col => {
+            if (col.type !== 'action') return
+            _actions.push(...col.elements)
+          })
+          if (_actions.findIndex((m) => m.uuid === item.wrap.doubleClick) === -1) {
+            error = `缁勪欢銆�${item.name}銆嬬粦瀹氱殑鍙屽嚮鎸夐挳宸插垹闄わ紒`
+          }
         }
       })
     }
@@ -886,6 +982,39 @@
         message: error,
         duration: 5
       })
+    }
+
+    if (MenuType === 'billPrint' && !error) {
+      let forbid = {
+        tabs: '鏍囩椤�',
+        search: '鎼滅储鏉′欢',
+        form: '琛ㄥ崟',
+        carousel: '杞挱',
+        tree: '鏍戝舰鍒楄〃',
+        chart: '鑷畾涔夊浘琛�',
+        editor: '瀵屾枃鏈�',
+        group: '鍒嗙粍'
+      }
+      let subforbid = {
+        editable: '鍙紪杈戣〃鏍�',
+        voucher: '鍑瘉'
+      }
+
+      config.components.forEach(item => {
+        if (!error && forbid[item.type]) {
+          error = '鎵撳嵃妯℃澘涓笉鍙娇鐢�' + forbid[item.type]
+        } else if (!error && subforbid[item.type]) {
+          error = '鎵撳嵃妯℃澘涓笉鍙娇鐢�' + subforbid[item.type]
+        }
+      })
+
+      if (show && error) {
+        notification.warning({
+          top: 92,
+          message: error,
+          duration: 5
+        })
+      }
     }
 
     return error
@@ -918,6 +1047,12 @@
 
     this.setState({config})
     window.GLOB.customMenu = config
+
+    notification.success({
+      top: 92,
+      message: '绮樿创鎴愬姛锛�',
+      duration: 2
+    })
   }
 
   render () {
@@ -988,7 +1123,7 @@
                     <StyleCombControlButton menu={config} />
                     <PasteController insert={this.insert} />
                     <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
-                    <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
+                    <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                     <Button type="default" onClick={this.closeView}>鍏抽棴</Button>
                   </div>
                 } style={{ width: '100%' }}>

--
Gitblit v1.8.0