From 4d6b9f8a2d7b316633e43b489eae9ada949c07b5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 九月 2024 10:18:08 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/views/rolemanage/index.jsx |  248 ++++++++++++++++++++++++++++--------------------
 1 files changed, 144 insertions(+), 104 deletions(-)

diff --git a/src/views/rolemanage/index.jsx b/src/views/rolemanage/index.jsx
index 1b0eda4..2fdc6e4 100644
--- a/src/views/rolemanage/index.jsx
+++ b/src/views/rolemanage/index.jsx
@@ -1,10 +1,9 @@
 import React, {Component} from 'react'
 import { fromJS } from 'immutable'
-import { Spin, notification, Button, Table, Modal, ConfigProvider, Tree, Input, Empty } from 'antd'
+import { Spin, notification, Button, Table, Modal, Tree, Input, Empty } from 'antd'
 import moment from 'moment'
 import md5 from 'md5'
-import enUS from 'antd/es/locale/en_US'
-import zhCN from 'antd/es/locale/zh_CN'
+import { ApiOutlined, SoundOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
 import Utils from '@/utils/utils.js'
@@ -15,25 +14,43 @@
 const { TreeNode } = Tree
 const { Search } = Input
 
-const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
 const Header = asyncComponent(() => import('./header'))
 const TransferForm = asyncComponent(() => import('@/templates/zshare/basetransferform'))
-
-sessionStorage.setItem('isEditState', 'true')
 
 class RoleManage extends Component {
   state = {
     app: null,
     loading: false,
     menulist: [],
+    sortType: '',
     columns: [
-      { title: '鑿滃崟鍚嶇О', dataIndex: 'MenuName', key: 'MenuName', align: 'center' },
+      {
+        title: '鑿滃崟鍚嶇О', dataIndex: 'MenuName', key: 'MenuName', align: 'center', render: (text, record) => {
+          if (record.extra || this.state.appKeys.includes(record.MenuID)) {
+            return <span style={{color: '#1890ff'}}>{text}</span>
+          } else if (record.interfaces === 'true' || record.msg === 'true') {
+            return <span>{record.interfaces === 'true' ? <ApiOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓娇鐢ㄤ簡澶栭儴鎺ュ彛" /> : null}{record.msg === 'true' ? <SoundOutlined style={{color: 'orange', marginRight: '5px'}} title="鑿滃崟涓彂閫佷簡娑堟伅" /> : null}{text}</span>
+          }
+          return text
+        }
+      },
+      {
+        title: '鑿滃崟鍙傛暟', dataIndex: 'MenuNo', key: 'MenuNo', align: 'center'
+      },
+      {
+        title: '淇敼鏃堕棿', dataIndex: 'modifydate', key: 'modifydate', align: 'center', sorter: true, render: (text, record) => {
+          if (window.GLOB.upStatus && record.up_action === 'Y') {
+            return <span style={{color: 'orange'}}>{text}</span>
+          }
+          return text
+        }
+      },
       {
         title: '鎿嶄綔',
         key: 'action',
         align: 'center',
         render: (text, record) => (
-          <div>
+          <div style={{minWidth: '125px'}}>
             {record.type !== 'none' ?
               <Button type="link" onClick={() => this.deleteMenu(record)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button> :
               <Button type="link" onClick={() => {
@@ -57,7 +74,8 @@
     trees: null,
     expandedKeys: [],
     searchkey: '',
-    appViewList: []
+    appViewList: [],
+    appKeys: []
   }
 
   oriTrees = null
@@ -65,6 +83,10 @@
   UNSAFE_componentWillMount() {
     document.body.className = ''
     let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
+
+    if (param.lang) {
+      sessionStorage.setItem('lang', param.lang)
+    }
 
     this.setState({app: param}, () => {
       this.getTreeList()
@@ -85,7 +107,7 @@
   getAppViewList = () => {
     const { app } = this.state
 
-    Api.getSystemConfig({
+    Api.getCloudConfig({
       func: 's_get_keyids',
       bid: app.ID
     }).then(result => {
@@ -97,7 +119,9 @@
         })
         return
       }
-      this.setState({appViewList: result.data || []})
+
+      let data = result.data || []
+      this.setState({appViewList: data, appKeys: data.map(item => item.keys_id)})
     })
   }
 
@@ -132,15 +156,18 @@
             try {
               let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist)))
               item.nodes = pageParam
+              item.interfaces = pageParam.interfaces || 'false'
+              item.msg = pageParam.msg || 'false'
               
+              if (pageParam.type) {
+                item.type = pageParam.type
+              }
+
               if (pageParam.version !== '1.0') {
                 item.nodes = ''
               } else if (pageParam.login || pageParam.pass) {
                 item.nodes = ''
-              } else if (pageParam.type === 'navbar') {
-                item.type = 'navbar'
               } else if (pageParam.type === 'im') {
-                item.type = 'im'
                 item.nodes = ''
               }
             } catch (e) {
@@ -150,10 +177,12 @@
             delete item.menus_rolelist
           }
 
-          if (!ub && app.userbind === item.MenuID) {
+          if (app.userbind === item.MenuID) {
+            item.extra = true
             ub = true
           }
-          if (!im && app.instantMessage === item.MenuID) {
+          if (app.instantMessage === item.MenuID) {
+            item.extra = true
             im = true
           }
           
@@ -161,10 +190,10 @@
         })
 
         if (!im) {
-          menus.push({nodes: '', type: 'none', MenuID: app.instantMessage, MenuName: '鍗虫椂閫氫俊'})
+          menus.push({nodes: '', type: 'none', extra: true, MenuID: app.instantMessage, MenuName: '鍗虫椂閫氫俊'})
         }
         if (!ub) {
-          menus.push({nodes: '', type: 'none', MenuID: app.userbind, MenuName: '鐢ㄦ埛缁戝畾'})
+          menus.push({nodes: '', type: 'none', extra: true, MenuID: app.userbind, MenuName: '鐢ㄦ埛缁戝畾'})
         }
 
         this.setState({
@@ -357,7 +386,8 @@
       ParentID: 'mk_app',
       TypeCharOne: app.kei_no,
       typename: app.typename,
-      lang: app.lang
+      lang: app.lang,
+      TYPE: 30
     }).then(res => {
       if (res.status) {
         this.setState({
@@ -380,7 +410,7 @@
 
   deleteMenu = (record) => {
     const { app, appViewList } = this.state
-    const _this = this
+    const that = this
 
     let param = {
       func: 'sPC_MainMenu_Del',
@@ -390,14 +420,10 @@
       lang: app.lang
     }
 
-    if (app.typename === 'pc' && record.nodes && record.nodes.popviews && record.nodes.popviews.length > 0) {
-      param.MenuID = param.MenuID + ',' + record.nodes.popviews.join(',')
-    }
-
     let _param = {
       func: 's_kei_link_keyids_addupt',
       BID: app.ID,
-      exec_type: 'y',
+      exec_type: 'x',
       LText: ''
     }
 
@@ -406,7 +432,7 @@
     if (appViewList.length !== _appViewList.length) {
       _param.LText = _appViewList.map(item => `select '${item.keys_id}','${item.keys_type}','${item.kei_no}','${item.appkey}','${item.bid}','${sessionStorage.getItem('CloudUserID')}','${item.remark}'`)
       _param.LText = _param.LText.join(' union all ')
-      _param.LText = Utils.formatOptions(_param.LText)
+      _param.LText = Utils.formatOptions(_param.LText, 'x')
   
       _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       _param.secretkey = Utils.encrypt('', _param.timestamp)
@@ -425,7 +451,7 @@
                 message: '鎿嶄綔鎴愬姛锛�',
                 duration: 3
               })
-              _this.getMenuList(true)
+              that.getMenuList(true)
 
               if (_param) {
                 Api.getCloudConfig(_param).then(res => {
@@ -436,7 +462,7 @@
                       duration: 5
                     })
                   } else {
-                    _this.setState({appViewList: _appViewList})
+                    that.setState({appViewList: _appViewList})
                   }
                 })
               }
@@ -473,7 +499,7 @@
       confirmLoading: true
     })
 
-    Api.getSystemConfig({
+    Api.getCloudConfig({
       func: 'sPC_MainMenu_ReDel',
       MenuID: targetKeys.join(','),
       TypeCharOne: app.kei_no,
@@ -513,14 +539,15 @@
                     let pageParam = JSON.parse(window.decodeURIComponent(window.atob(item.menus_rolelist)))
                     item.nodes = pageParam
 
+                    if (pageParam.type) {
+                      item.type = pageParam.type
+                    }
+
                     if (pageParam.version !== '1.0') {
                       item.nodes = ''
                     } else if (pageParam.login || pageParam.pass) {
                       item.nodes = ''
-                    } else if (pageParam.type === 'navbar') {
-                      item.type = 'navbar'
                     } else if (pageParam.type === 'im') {
-                      item.type = 'im'
                       item.nodes = ''
                     }
                   } catch (e) {
@@ -528,10 +555,6 @@
                   }
 
                   delete item.menus_rolelist
-                }
-
-                if (targetKeys.includes(item.MenuID) && item.nodes && item.nodes.popviews && item.nodes.popviews.length > 0) {
-                  list = [...list, ...item.nodes.popviews]
                 }
                 
                 return item
@@ -543,7 +566,7 @@
             })
 
             if (app.typename === 'pc' && list.length > 0) {
-              Api.getSystemConfig({
+              Api.getCloudConfig({
                 func: 'sPC_MainMenu_ReDel',
                 MenuID: list.join(','),
                 TypeCharOne: app.kei_no,
@@ -660,12 +683,12 @@
   }
 
   initTree = () => {
-    const _this = this
+    const that = this
     confirm({
       content: '鏉冮檺鏍戜細閲嶆柊鐢熸垚锛岀‘瀹氭墽琛屽悧锛�',
       onOk() {
         return new Promise(resolve => {
-          _this.getMenuList(true, resolve)
+          that.getMenuList(true, resolve)
         })
       },
       onCancel() {}
@@ -673,13 +696,13 @@
   }
 
   syncTree = () => {
-    const _this = this
+    const that = this
 
     confirm({
       content: '鍚屾浼氭牴鎹彍鍗曞垹闄ゆ垨鏂板鑺傜偣锛岀‘瀹氭墽琛屽悧锛�',
       onOk() {
         return new Promise(resolve => {
-          _this.syncMenutree(resolve)
+          that.syncMenutree(resolve)
         })
       },
       onCancel() {}
@@ -687,23 +710,23 @@
   }
 
   saveTree = () => {
-    const { trees } = this.state
-    const _this = this
+    // const { trees } = this.state
+    const that = this
 
-    if (!trees || trees.length === 0) {
-      notification.warning({
-        top: 92,
-        message: '鏈幏鍙栧埌鏉冮檺淇℃伅锛�',
-        duration: 5
-      })
-      return
-    }
+    // if (!trees || trees.length === 0) {
+    //   notification.warning({
+    //     top: 92,
+    //     message: '鏈幏鍙栧埌鏉冮檺淇℃伅锛�',
+    //     duration: 5
+    //   })
+    //   return
+    // }
 
     confirm({
       content: '纭畾鎵ц鍚楋紵',
       onOk() {
         return new Promise(resolve => {
-          _this.execSave(resolve)
+          that.execSave(resolve)
         })
       },
       onCancel() {}
@@ -872,70 +895,87 @@
     window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify({...app, MenuID: item.MenuID, type: 'app'})))}`))
   }
 
+  changeTable = (pagination, filters, sorter) => {
+    this.setState({sortType: sorter.order || ''})
+  }
+
   render () {
-    const { app, loading, columns, menulist, trees, searchkey } = this.state
-    let _menulist = menulist
+    const { app, loading, columns, menulist, trees, searchkey, sortType } = this.state
+    let _menulist = fromJS(menulist).toJS()
 
     if (searchkey) {
       _menulist = _menulist.filter(item => item.MenuName.toLowerCase().indexOf(searchkey.toLowerCase()) > -1)
     }
 
+    if (sortType === 'ascend') {
+      _menulist.sort((a, b) => {
+        if (a.modifydate > b.modifydate) return 1
+        if (a.modifydate < b.modifydate) return -1
+        return 0
+      })
+    } else if (sortType === 'descend') {
+      _menulist.sort((a, b) => {
+        if (a.modifydate < b.modifydate) return 1
+        if (a.modifydate > b.modifydate) return -1
+        return 0
+      })
+    }
+
     return (
       <div className="mk-role-manage">
-        <ConfigProvider locale={_locale}>
-          <Header app={app} />
-          {loading ?
-            <div className="loading-mask">
-              <Spin size="large" />
-            </div> : null
-          }
-          <div className="view-wrap">
-            <div className="left-view">
-              <div className="app-table">
-                <div className="app-action">
-                  <Button className="mk-green" onClick={this.triggerThaw}>瑙e喕鑿滃崟</Button>
-                  <Search placeholder="缁煎悎鎼滅储" onSearch={value => this.setState({ searchkey: value })} enterButton />
-                </div>
-                <Table
-                  rowKey="MenuID"
-                  columns={columns}
-                  dataSource={_menulist}
-                  pagination={false}
-                />
-              </div>
-            </div>
-            <div className="right-view">
+        <Header app={app} />
+        {loading ?
+          <div className="loading-mask">
+            <Spin size="large" />
+          </div> : null
+        }
+        <div className="view-wrap">
+          <div className="left-view">
+            <div className="app-table">
               <div className="app-action">
-                <Button className="mk-primary" onClick={this.initTree}>閲嶇疆</Button>
-                {/* <Button className="mk-purple" onClick={this.syncTree}>鍚屾</Button> */}
-                <Button className="mk-green save" onClick={this.saveTree}>淇濆瓨</Button>
+                <Button className="mk-green" onClick={this.triggerThaw}>瑙e喕鑿滃崟</Button>
+                <Search placeholder="缁煎悎鎼滅储" onSearch={value => this.setState({ searchkey: value })} enterButton />
               </div>
-              {trees && trees.length ? <Tree
-                className="draggable-tree"
-                defaultExpandedKeys={this.state.expandedKeys}
-                // showLine
-                draggable
-                blockNode
-                onDrop={this.onDrop}
-              >
-                {this.renderNode(trees)}
-              </Tree> : <div className="empty">
-                <Empty />
-              </div>}
+              <Table
+                rowKey="MenuID"
+                columns={columns}
+                dataSource={_menulist}
+                pagination={false}
+                onChange={this.changeTable}
+              />
             </div>
           </div>
-          <Modal
-            title="瑙i櫎鍐荤粨"
-            visible={this.state.visible}
-            width={600}
-            onOk={this.thawSubmit}
-            confirmLoading={this.state.confirmLoading}
-            onCancel={() => this.setState({visible: false, targetKeys: []})}
-            destroyOnClose
-          >
-            <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>
-          </Modal>
-        </ConfigProvider>
+          <div className="right-view">
+            <div className="app-action">
+              <Button className="mk-primary" onClick={this.initTree}>閲嶇疆</Button>
+              {/* <Button className="mk-purple" onClick={this.syncTree}>鍚屾</Button> */}
+              <Button className="mk-green save" onClick={this.saveTree}>淇濆瓨</Button>
+            </div>
+            {trees && trees.length ? <Tree
+              className="draggable-tree"
+              defaultExpandedKeys={this.state.expandedKeys}
+              // showLine
+              draggable
+              blockNode
+              onDrop={this.onDrop}
+            >
+              {this.renderNode(trees)}
+            </Tree> : <div className="empty">
+              <Empty />
+            </div>}
+          </div>
+        </div>
+        <Modal
+          title="瑙i櫎鍐荤粨"
+          visible={this.state.visible}
+          width={600}
+          onOk={this.thawSubmit}
+          confirmLoading={this.state.confirmLoading}
+          onCancel={() => this.setState({visible: false, targetKeys: []})}
+          destroyOnClose
+        >
+          <TransferForm onChange={(vals) => this.setState({targetKeys: vals})} menulist={this.state.thawmenulist}/>
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0