From a02fc6a77fa1b35c6516b2d37108d80e260c6c85 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 十一月 2024 22:05:08 +0800
Subject: [PATCH] 2024-11-07

---
 src/views/menudesign/menuform/index.jsx |  273 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 172 insertions(+), 101 deletions(-)

diff --git a/src/views/menudesign/menuform/index.jsx b/src/views/menudesign/menuform/index.jsx
index 7c8be79..d8b2366 100644
--- a/src/views/menudesign/menuform/index.jsx
+++ b/src/views/menudesign/menuform/index.jsx
@@ -4,10 +4,13 @@
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
-import options from '@/store/options.js'
+import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
 const { TextArea } = Input
+
+const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
+const SysColorSketch = asyncComponent(() => import('@/menu/stylecontroller/syscolorsketch'))
 
 class CustomMenuForm extends Component {
   static propTpyes = {
@@ -26,11 +29,15 @@
   }
 
   UNSAFE_componentWillMount () {
+    const { config } = this.props
+
     if (sessionStorage.getItem('thdMenuList') && sessionStorage.getItem('fstMenuList')) {
       this.setMenus()
     } else {
       this.getMenus()
     }
+
+    window.GLOB.process = config.process === 'true'
   }
 
   setMenus = () => {
@@ -43,6 +50,7 @@
     thdMenuList = JSON.parse(thdMenuList)
 
     let thdMenu = null
+    let firstId = ''
 
     thdMenuList.forEach(trd => {
       if (MenuId === trd.MenuID) {
@@ -58,17 +66,21 @@
           smenulist = item.children
         }
       })
+
+      firstId = thdMenu.FstId || ''
     }
 
-    this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''})
+    if (firstId !== config.fstMenuId) {
+      this.props.updateConfig({...config, fstMenuId: firstId})
+    }
 
     this.setState({
-      fstMenuId: thdMenu ? thdMenu.FstId : '',
+      fstMenuId: firstId,
       menulist,
       smenulist
     }, () => {
       this.props.form.setFieldsValue({
-        fstMenuId: thdMenu ? thdMenu.FstId : '',
+        fstMenuId: firstId,
         parentId: thdMenu ? thdMenu.ParentId : ''
       })
     })
@@ -77,7 +89,7 @@
   getMenus = () => {
     const { MenuId, config } = this.props
 
-    Api.getSystemConfig({func: 's_get_pc_menus', systemType: options.sysType, debug: 'Y'}).then(result => {
+    Api.getCloudConfig({func: 's_get_pc_menus', systemType: window.GLOB.sysType, debug: 'Y'}).then(result => {
       if (result.status) {
         let thdMenu = null
         let thdMenuList = []
@@ -113,14 +125,14 @@
                     EasyCode: trd.EasyCode,
                     value: trd.MenuID,
                     label: trd.MenuName,
-                    type: 'CommonTable',
+                    type: 'CustomPage',
                     disabled: false
                   }
 
                   if (trd.PageParam) {
                     try {
                       trd.PageParam = JSON.parse(trd.PageParam)
-                      trdItem.type = trd.PageParam.Template || 'CommonTable'
+                      trdItem.type = trd.PageParam.Template || 'CustomPage'
                     } catch (e) {
 
                     }
@@ -142,24 +154,29 @@
         })
 
         let smenulist = []
+        let firstId = ''
         if (thdMenu) {
           menulist.forEach(item => {
             if (item.MenuID === thdMenu.FstId) {
               smenulist = item.children
             }
           })
+          firstId = thdMenu.FstId || ''
         }
         sessionStorage.setItem('fstMenuList', JSON.stringify(menulist))
         sessionStorage.setItem('thdMenuList', JSON.stringify(thdMenuList))
-        this.props.updateConfig({...config, fstMenuId: thdMenu ? thdMenu.FstId : ''})
+
+        if (firstId !== config.fstMenuId) {
+          this.props.updateConfig({...config, fstMenuId: firstId})
+        }
 
         this.setState({
-          fstMenuId: thdMenu ? thdMenu.FstId : '',
+          fstMenuId: firstId,
           menulist,
           smenulist
         }, () => {
           this.props.form.setFieldsValue({
-            fstMenuId: thdMenu ? thdMenu.FstId : '',
+            fstMenuId: firstId,
             parentId: thdMenu ? thdMenu.ParentId : ''
           })
         })
@@ -173,7 +190,6 @@
     })
   }
 
-  // 涓�浜岀骇鑿滃崟鍒囨崲
   selectChange = (key, value) => {
     const { config } = this.props
     const { menulist } = this.state
@@ -193,47 +209,16 @@
         this.props.form.setFieldsValue({parentId: _id})
         this.props.updateConfig({...config, fstMenuId: value, parentId: _id})
       })
-    } else if (key === 'parentId') {
-      this.props.updateConfig({...config, parentId: value})
-    } else if (key === 'cacheUseful') {
-      this.props.updateConfig({...config, cacheUseful: value})
-    } else if (key === 'timeUnit') {
-      this.props.updateConfig({...config, timeUnit: value})
-    } else if (key === 'OpenType') {
-      this.props.updateConfig({...config, OpenType: value})
-    } else if (key === 'hidden') {
-      this.props.updateConfig({...config, hidden: value})
-    } else if (key === 'permission') {
-      this.props.updateConfig({...config, permission: value})
-    } else if (key === 'cacheLocal') {
-      this.props.updateConfig({...config, cacheLocal: value})
+    } else {
+      if (key === 'cacheTime' || key === 'minWidth' || key === 'localCacheTime') {
+        if (typeof(value) !== 'number') {
+          value = ''
+        }
+      } else if (key === 'process') {
+        window.GLOB.process = value === 'true'
+      }
+      this.props.updateConfig({...config, [key]: value})
     }
-  }
-
-  // 鑿滃崟鍚嶇О
-  changeName = (e) => {
-    this.props.updateConfig({...this.props.config, MenuName: e.target.value})
-  }
-
-  // 鑿滃崟鍙傛暟
-  changeNo = (e) => {
-    this.props.updateConfig({...this.props.config, MenuNo: e.target.value})
-  }
-
-  // 鍔╄鐮�
-  changeEasyCode = (e) => {
-    this.props.updateConfig({...this.props.config, easyCode: e.target.value})
-  }
-
-  changeRemark = (e) => {
-    this.props.updateConfig({...this.props.config, Remark: e.target.value})
-  }
-
-  changeCacheDay = (val) => {
-    if (typeof(val) !== 'number') {
-      val = ''
-    }
-    this.props.updateConfig({...this.props.config, cacheTime: val})
   }
 
   render() {
@@ -306,7 +291,7 @@
                     message: '璇疯緭鍏ヨ彍鍗曞悕绉�!'
                   }
                 ]
-              })(<Input placeholder="" autoComplete="off" onChange={this.changeName}/>)}
+              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuName', e.target.value)}}/>)}
             </Form.Item>
           </Col>
           <Col span={24}>
@@ -319,58 +304,20 @@
                     message: '璇疯緭鍏ヨ彍鍗曞弬鏁�!'
                   }
                 ]
-              })(<Input placeholder="" autoComplete="off" onChange={this.changeNo}/>)}
+              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuNo', e.target.value)}}/>)}
             </Form.Item>
           </Col>
           <Col span={24}>
             <Form.Item label="鎵撳紑鏂瑰紡">
               {getFieldDecorator('OpenType', {
                 initialValue: config.OpenType || 'newtab',
-                rules: [
-                  {
-                    required: true,
-                    message: '璇烽�夋嫨鎵撳紑鏂瑰紡!'
-                  }
-                ]
+                rules: [{ required: true, message: '璇烽�夋嫨鎵撳紑鏂瑰紡!' }]
               })(
-                <Radio.Group onChange={(e) => {this.selectChange('OpenType', e.target.value)}}>
-                  <Radio value="newtab">鏍囩椤�</Radio>
-                  <Radio value="newpage">鏂伴〉闈�</Radio>
-                </Radio.Group>
-              )}
-            </Form.Item>
-          </Col>
-          <Col span={24}>
-            <Form.Item label={
-              <Tooltip placement="topLeft" title="鏁版嵁浼氱紦瀛樺埌鐢ㄦ埛鏈湴锛屾柟渚块〉闈㈠揩閫熷憟鐜般��">
-                <QuestionCircleOutlined className="mk-form-tip" />
-                鏈湴缂撳瓨
-              </Tooltip>
-            }>
-              {getFieldDecorator('cacheLocal', {
-                initialValue: config.cacheLocal || 'false'
-              })(
-                <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}>
-                  <Radio value="true">浣跨敤</Radio>
-                  <Radio value="false">涓嶄娇鐢�</Radio>
-                </Radio.Group>
-              )}
-            </Form.Item>
-          </Col>
-          <Col span={24}>
-            <Form.Item label={
-              <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�">
-                <QuestionCircleOutlined className="mk-form-tip" />
-                鍚庣缂撳瓨
-              </Tooltip>
-            }>
-              {getFieldDecorator('cacheUseful', {
-                initialValue: config.cacheUseful || 'false'
-              })(
-                <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}>
-                  <Radio value="true">浣跨敤</Radio>
-                  <Radio value="false">涓嶄娇鐢�</Radio>
-                </Radio.Group>
+                <Select onChange={(value) => {this.selectChange('OpenType', value)}}>
+                  <Select.Option value="newtab">鏍囩椤�</Select.Option>
+                  <Select.Option value="newpage">鏂伴〉闈紙鏍囩椤碉級</Select.Option>
+                  <Select.Option value="view">鏂伴〉闈紙鍏ㄥ睆锛�</Select.Option>
+                </Select>
               )}
             </Form.Item>
           </Col>
@@ -391,14 +338,80 @@
               )}
             </Form.Item>
           </Col>
+          {config.permission !== 'false' ? <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="鏄惁妫�楠屽悗绔痵ql鐨勬潈闄愶紝浣跨敤鍚庣sql鑴氭湰鏃舵湁鏁堛��">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                sql楠岃瘉
+              </Tooltip>
+            }>
+              {getFieldDecorator('sqlperm', {
+                initialValue: config.sqlperm || 'true'
+              })(
+                <Radio.Group onChange={(e) => {this.selectChange('sqlperm', e.target.value)}}>
+                  <Radio value="true">浣跨敤</Radio>
+                  <Radio value="false">涓嶄娇鐢�</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col> : null}
+          <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="鏁版嵁浼氱紦瀛樺埌鐢ㄦ埛鏈湴锛屾柟渚块〉闈㈠揩閫熷憟鐜般��">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鏈湴缂撳瓨
+              </Tooltip>
+            }>
+              {getFieldDecorator('cacheLocal', {
+                initialValue: config.cacheLocal || 'false'
+              })(
+                <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}>
+                  <Radio value="true">浣跨敤</Radio>
+                  <Radio value="false">涓嶄娇鐢�</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+          {config.cacheLocal === 'true' ? <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="璁剧疆鏈湴缂撳瓨鏃堕暱鍚庯紝鍦ㄧ紦瀛樻湡闄愬唴涓嶅悜鍚庡彴璇锋眰鏁版嵁锛屾椂闀挎渶澶т负5澶╋紙鍗�7200鍒嗛挓锛夈�傛敞锛氭椂闀夸负绌烘椂缂撳瓨鏁版嵁鍙敤浜庨〉闈㈠揩閫熷憟鐜帮紝涓嶅奖鍝嶆帴鍙h姹傘��">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鏃堕暱(鍒�)
+              </Tooltip>
+            }>
+              {getFieldDecorator('localCacheTime', {
+                initialValue: config.localCacheTime
+              })(
+                <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/>
+              )}
+            </Form.Item>
+          </Col> : null}
+          <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="瀵逛簬涓嶇粡甯告�у彉鍔ㄧ殑淇℃伅锛岀紦瀛樻暟鎹湁鍔╀簬鎻愰珮鏌ヨ鏁堢巼銆�">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鍚庣缂撳瓨
+              </Tooltip>
+            }>
+              {getFieldDecorator('cacheUseful', {
+                initialValue: config.cacheUseful || 'false'
+              })(
+                <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}>
+                  <Radio value="true">浣跨敤</Radio>
+                  <Radio value="false">涓嶄娇鐢�</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
           {config.cacheUseful === 'true' ? <Col span={24}>
             <Form.Item label="鍗曚綅">
               {getFieldDecorator('timeUnit', {
                 initialValue: config.timeUnit || 'day'
               })(
-                <Radio.Group onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}>
+                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}>
                   <Radio value="day">澶�</Radio>
                   <Radio value="hour">灏忔椂</Radio>
+                  <Radio value="minute">鍒嗛挓</Radio>
                 </Radio.Group>
               )}
             </Form.Item>
@@ -414,15 +427,63 @@
                   }
                 ]
               })(
-                <InputNumber min={1} max={config.timeUnit !== 'hour' ? 7 : 23} precision={0} onChange={this.changeCacheDay}/>
+                <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/>
               )}
             </Form.Item>
           </Col> : null}
           <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="寮�鍚悗鍙湪鎸夐挳鍙婃暟鎹簮璁剧疆娴佺▼鍙傛暟銆�">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                宸ヤ綔娴�
+              </Tooltip>
+            }>
+              {getFieldDecorator('process', {
+                initialValue: config.process || 'false'
+              })(
+                <Radio.Group onChange={(e) => {this.selectChange('process', e.target.value)}}>
+                  <Radio value="true">浣跨敤</Radio>
+                  <Radio value="false">涓嶄娇鐢�</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="鏁版嵁鍔犺浇鏃剁殑閬僵鏄惁鏄剧ず銆�">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鍔犺浇閬僵
+              </Tooltip>
+            }>
+              {getFieldDecorator('mask', {
+                initialValue: config.mask || 'true'
+              })(
+                <Radio.Group onChange={(e) => {this.selectChange('mask', e.target.value)}}>
+                  <Radio value="true">鏄剧ず</Radio>
+                  <Radio value="false">闅愯棌</Radio>
+                </Radio.Group>
+              )}
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item label={
+              <Tooltip placement="topLeft" title="濡傛灉椤甸潰鍐呭鍦ㄧ獥鍙d腑鏃犳硶瀹屽叏灞曠ず锛屽彲璁剧疆鏈�灏忓搴︼紝瀹炵幇椤甸潰鐨勬í鍚戞粴鍔ㄣ��">
+                <QuestionCircleOutlined className="mk-form-tip" />
+                鏈�灏忓搴�
+              </Tooltip>
+            }>
+              {getFieldDecorator('minWidth', {
+                initialValue: config.minWidth
+              })(
+                <InputNumber min={0} precision={0} onChange={(val) => {this.selectChange('minWidth', val)}}/>
+              )}
+            </Form.Item>
+          </Col>
+          <Col span={24}>
             <Form.Item label="鍔╄鐮�">
               {getFieldDecorator('easyCode', {
                 initialValue: config.easyCode
-              })(<Input placeholder="" autoComplete="off" onChange={this.changeEasyCode}/>)}
+              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('easyCode', e.target.value)}}/>)}
             </Form.Item>
           </Col>
           <Col span={24}>
@@ -442,7 +503,17 @@
                     message: '澶囨敞鏈�澶�512涓瓧绗︼紒'
                   }
                 ]
-              })(<TextArea rows={2} placeholder={''} onChange={this.changeRemark} />)}
+              })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)}
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item style={{marginBottom: '0px'}} label="鑿滃崟棰滆壊">
+              <ColorSketch allowClear={true} value={config.menuColor || ''} onChange={(val) => {this.selectChange('menuColor', val)}} />
+            </Form.Item>
+          </Col>
+          <Col span={24}>
+            <Form.Item style={{marginBottom: '0px'}} label="绯荤粺鑹�">
+              <SysColorSketch onChange={(val) => {this.selectChange('menuColor', val)}} />
             </Form.Item>
           </Col>
         </Row>

--
Gitblit v1.8.0