From 316877c1d9e5b6d92334f30b03d97d7e833cd934 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 02 二月 2021 16:01:57 +0800
Subject: [PATCH] 2021-02-02

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

diff --git a/src/views/menudesign/index.jsx b/src/views/menudesign/index.jsx
index b09c3fb..c79828e 100644
--- a/src/views/menudesign/index.jsx
+++ b/src/views/menudesign/index.jsx
@@ -8,6 +8,7 @@
 import html2canvas from 'html2canvas'
 
 import Api from '@/api'
+import options from '@/store/options.js'
 import Utils from '@/utils/utils.js'
 import zhCN from '@/locales/zh-CN/mob.js'
 import enUS from '@/locales/en-US/mob.js'
@@ -26,18 +27,20 @@
 
 const MenuForm = asyncComponent(() => import('./menuform'))
 const HomeForm = asyncComponent(() => import('./homeform'))
-const PrintMenuForm = asyncComponent(() => import('./printmenuform'))
 const Header = asyncComponent(() => import('@/menu/header'))
-const SourceWrap = asyncComponent(() => import('@/menu/modelsource'))
 const MenuShell = asyncComponent(() => import('@/menu/menushell'))
+const PrintMenuForm = asyncComponent(() => import('./printmenuform'))
+const SourceWrap = asyncComponent(() => import('@/menu/modulesource'))
+const PopviewController = asyncComponent(() => import('@/menu/popview'))
 const BgController = asyncComponent(() => import('@/menu/bgcontroller'))
 const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
 const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
 const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
+const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
+const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
+const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
 const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
 const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton'))
-const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
-const PopviewController = asyncComponent(() => import('@/menu/popview'))
 const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent'))
 
 sessionStorage.setItem('isEditState', 'true')
@@ -100,7 +103,10 @@
     MKEmitter.addListener('changePopview', this.initPopview)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
     MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
-    this.updateCustomComponent()
+    setTimeout(() => {
+      this.updateCustomComponent()
+      this.getAppPictures()
+    }, 1000)
   }
 
   /**
@@ -116,6 +122,32 @@
     MKEmitter.removeListener('changePopview', this.initPopview)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
     MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
+  }
+
+  getAppPictures = () => {
+    Api.getSystemConfig({
+      func: 's_url_db_adduptdel',
+      PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
+      PageSize: 0,   // 0 浠h〃鍏ㄩ儴
+      typecharone: 'image',
+      type: 'search'
+    }).then(res => {
+      if (res.status) {
+        sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
+      }
+
+      Api.getSystemConfig({
+        func: 's_url_db_adduptdel',
+        PageIndex: 0,  // 0 浠h〃鍏ㄩ儴
+        PageSize: 0,   // 0 浠h〃鍏ㄩ儴
+        typecharone: 'video',
+        type: 'search'
+      }).then(res => {
+        if (res.status) {
+          sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
+        }
+      })
+    })
   }
 
   updateCustomComponent = () => {
@@ -151,6 +183,7 @@
         })
       }
       this.setState({customComponents: coms})
+      this.getRoleFields()
     })
   }
 
@@ -315,7 +348,6 @@
         })
 
         this.props.modifyCustomMenu(config)
-        this.getRoleFields()
       } else {
         notification.warning({
           top: 92,
@@ -341,37 +373,40 @@
           traversal(item.components)
         } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) {
           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++
           })
           item.subcards.forEach(card => {
             card.elements && card.elements.forEach(cell => {
               if (cell.eleType !== 'button') return
-
+              this.checkBtn(cell)
               buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`)
               _sort++
             })
             card.backElements && card.backElements.forEach(cell => {
               if (cell.eleType !== 'button') return
-
+              this.checkBtn(cell)
               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') {
           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') {
           item.action && item.action.forEach(btn => {
-            if (btn.origin) return
+            this.checkBtn(btn)
             buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
             _sort++
           })
           item.cols && item.cols.forEach(col => {
             if (col.type !== 'action') return
             col.elements.forEach(btn => {
+              this.checkBtn(btn)
               buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`)
               _sort++
             })
@@ -383,6 +418,26 @@
     traversal(config.components)
 
     return buttons
+  }
+
+  checkBtn = (btn) => {
+    if (['prompt', 'exec', 'pop'].includes(btn.OpenType) && btn.Ot === 'required' && btn.verify && btn.verify.scripts && btn.verify.scripts.length > 0) {
+      let hascheck = false
+      btn.verify.scripts.forEach(item => {
+        if (item.status === 'false') return
+  
+        if (/\$check@|@check\$/ig.test(item.sql)) {
+          hascheck = true
+        }
+      })
+      if (hascheck) {
+        notification.warning({
+          top: 92,
+          message: `鍙�夋嫨澶氳鐨勬寜閽��${btn.label}銆嬩腑 $check@ 鎴� @check$ 灏嗕笉浼氱敓鏁堬紒`,
+          duration: 5
+        })
+      }
+    }
   }
 
   filterConfig = (components) => {
@@ -429,72 +484,83 @@
       return
     }
 
-    config.components = this.filterConfig(config.components)
-
-    if (config.enabled && this.verifyConfig()) {
-      config.enabled = false
-    }
-
-    let _config = fromJS(config).toJS()
-    delete _config.tableFields
-
-    let param = {
-      func: 'sPC_TrdMenu_AddUpt',
-      FstID: _config.fstMenuId || '',
-      SndID: _config.parentId,
-      ParentID: _config.parentId,
-      MenuID: _config.uuid,
-      MenuNo: _config.MenuNo || '',
-      EasyCode: _config.easyCode || '',
-      Template: 'CustomPage',
-      MenuName: _config.MenuName || '',
-      PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}),
-      LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))),
-      LText: '',
-      LTexttb: ''
-    }
-
-    param.LText = Utils.formatOptions(param.LText)
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-
-    if (openEdition) { // 鐗堟湰绠$悊
-      param.open_edition = openEdition
-    }
-
-    let btnParam = {             // 娣诲姞鑿滃崟鎸夐挳
-      func: 'sPC_Button_AddUpt',
-      Type: 40,                  // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60
-      ParentID: _config.uuid,
-      MenuNo: _config.MenuNo,
-      Template: 'CustomPage',
-      PageParam: '',
-      LongParam: '',
-      LText: []
-    }
-
-    let btnIds = '' // 鐢ㄤ簬澶嶅埗鎸夐挳鐨勮繃婊�
-    if (MenuType !== 'billPrint') {
-      btnParam.LText = this.getMenuMessage()
-      btnParam.LText = btnParam.LText.join(' union all ')
-
-      btnIds = btnParam.LText
-
-      btnParam.LText = Utils.formatOptions(btnParam.LText)
-      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
-    } else {
-      btnParam.LText = ''
-    }
-
     this.setState({
       menuloading: true
-    }, () => {
+    })
+
+    setTimeout(() => {
+      config.components = this.filterConfig(config.components)
+
+      if (config.enabled && this.verifyConfig()) {
+        config.enabled = false
+      }
+
+      let _config = fromJS(config).toJS()
+      delete _config.tableFields
+
+      let param = {
+        func: 'sPC_TrdMenu_AddUpt',
+        FstID: _config.fstMenuId || '',
+        SndID: _config.parentId,
+        ParentID: _config.parentId,
+        MenuID: _config.uuid,
+        MenuNo: _config.MenuNo || '',
+        EasyCode: _config.easyCode || '',
+        Template: 'CustomPage',
+        MenuName: _config.MenuName || '',
+        PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}),
+        LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))),
+        LText: '',
+        LTexttb: ''
+      }
+
+      param.LText = Utils.formatOptions(param.LText)
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+      if (openEdition) { // 鐗堟湰绠$悊
+        param.open_edition = openEdition
+      }
+
+      let btnParam = {             // 娣诲姞鑿滃崟鎸夐挳
+        func: 'sPC_Button_AddUpt',
+        Type: 40,                  // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60
+        ParentID: _config.uuid,
+        MenuNo: _config.MenuNo,
+        Template: 'CustomPage',
+        PageParam: '',
+        LongParam: '',
+        LText: []
+      }
+
+      let btnIds = '' // 鐢ㄤ簬澶嶅埗鎸夐挳鐨勮繃婊�
+      if (MenuType !== 'billPrint') {
+        btnParam.LText = this.getMenuMessage()
+        btnParam.LText = btnParam.LText.join(' union all ')
+
+        btnIds = btnParam.LText
+
+        btnParam.LText = Utils.formatOptions(btnParam.LText)
+        btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+        btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
+      } else {
+        btnParam.LText = ''
+      }
+
       new Promise(resolve => {
         if (MenuType === 'billPrint') { // 鎵撳嵃鐢熸垚椤甸潰鏁堟灉鍥�
           html2canvas(document.getElementById('menu-shell-inner')).then(canvas => {
-            let img = canvas.toDataURL('image/png') // 鑾峰彇鐢熸垚鐨勫浘鐗�
-            Api.fileuploadbase64(img, 'cloud').then(result => {
+            let param = {
+              Base64Img: canvas.toDataURL('image/png') // 鑾峰彇鐢熸垚鐨勫浘鐗�
+            }
+  
+            if (options.cloudServiceApi) {
+              param.rduri = options.cloudServiceApi
+              param.userid = sessionStorage.getItem('CloudUserID') || ''
+              param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
+            }
+  
+            Api.fileuploadbase64(param).then(result => {
               if (result.status) {
                 Api.getSystemConfig({
                   func: 's_PrintTemplateMSub',
@@ -717,7 +783,7 @@
           })
         }
       })
-    })
+    }, 300)
   }
 
   getRoleFields = () => {
@@ -754,7 +820,7 @@
   onEnabledChange = () => {
     const { config } = this.state
 
-    if (!config.enabled && this.verifyConfig(true)) {
+    if (!config || (!config.enabled && this.verifyConfig(true))) {
       return
     }
 
@@ -769,7 +835,7 @@
 
     config.components.forEach(item => {
       if (error) return
-      if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return
+      if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && item.wrap.datatype === 'static') return
 
       if (item.setting) {
         if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) {
@@ -837,7 +903,7 @@
 
     return (
       <ConfigProvider locale={_locale}>
-        <div className="pc-menu-view" id="view">
+        <div className={'pc-menu-view ' + (MenuType || '')} id="mk-menu-design-view">
           <Header />
           {!popBtn && !visible ? <DndProvider backend={HTML5Backend}>
             <div className="menu-body">
@@ -875,10 +941,10 @@
                   {customComponents && customComponents.length ? <Panel header="鑷畾涔夌粍浠�" key="cuscomponent">
                     <SourceWrap components={customComponents} MenuType={MenuType} />
                   </Panel> : null}
-                  <Panel header={'鑳屾櫙'} key="background">
+                  <Panel header={'椤甸潰鑳屾櫙'} key="background">
                     {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null}
                   </Panel>
-                  <Panel header={'鍐呰竟璺�'} key="padding">
+                  <Panel header={'椤甸潰鍐呰竟璺�'} key="padding">
                     {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null}
                   </Panel>
                 </Collapse>
@@ -888,9 +954,11 @@
                   <div> {config && config.MenuName} </div>
                 } bordered={false} extra={
                   <div>
+                    <SysInterface config={config} updateConfig={this.updateConfig}/>
+                    <PictureController/>
                     <StyleCombControlButton menu={config} />
                     <PasteController type="menu" Tab={null} insert={this.insert} />
-                    {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null}
+                    <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="default" onClick={this.closeView}>{dict['mob.return']}</Button>
                   </div>

--
Gitblit v1.8.0