Преглед изворни кода

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-portal into dev

yy пре 1 година
родитељ
комит
4715957043

+ 36 - 86
src/api/layout/index.js

@@ -26,90 +26,40 @@ export async function updatePassword (data) {
  * 查询未读通知
  */
 export async function getUnreadNotice () {
-  return {
-    notice: [
-      {
-        color: '#60B2FC',
-        icon: 'el-icon-s-comment',
-        title: '你收到了一封14份新周报',
-        time: '2020-07-27 18:30:18'
-      },
-      {
-        color: '#F5686F',
-        icon: 'el-icon-s-check',
-        title: '许经理同意了你的请假申请',
-        time: '2020-07-27 09:08:36'
-      },
-      {
-        color: '#7CD734',
-        icon: 'el-icon-video-camera',
-        title: '陈总邀请你参加视频会议',
-        time: '2020-07-26 18:30:01'
-      },
-      {
-        color: '#FAAD14',
-        icon: 'el-icon-s-claim',
-        title: '你推荐的刘诗雨已通过第三轮面试',
-        time: '2020-07-25 16:38:46'
-      },
-      {
-        color: '#2BCACD',
-        icon: 'el-icon-message-solid',
-        title: '你的6月加班奖金已发放',
-        time: '2020-07-25 11:03:31'
-      }
-    ],
-    letter: [
-      {
-        avatar:
-          'https://cdn.eleadmin.com/20200609/c184eef391ae48dba87e3057e70238fb.jpg',
-        title: 'SunSmile 评论了你的日志',
-        content: '写的不错, 以后多多向你学习~',
-        time: '2020-07-27 18:30:18'
-      },
-      {
-        avatar:
-          'https://cdn.eleadmin.com/20200609/948344a2a77c47a7a7b332fe12ff749a.jpg',
-        title: '刘诗雨 点赞了你的日志',
-        content: '写的不错, 以后多多向你学习~',
-        time: '2020-07-27 09:08:36'
-      },
-      {
-        avatar:
-          'https://cdn.eleadmin.com/20200609/2d98970a51b34b6b859339c96b240dcd.jpg',
-        title: '酷酷的大叔 评论了你的周报',
-        content: '写的不错, 以后多多向你学习~',
-        time: '2020-07-26 18:30:01'
-      },
-      {
-        avatar:
-          'https://cdn.eleadmin.com/20200609/f6bc05af944a4f738b54128717952107.jpg',
-        title: 'Jasmine 点赞了你的周报',
-        content: '写的不错, 以后多多向你学习~',
-        time: '2020-07-25 11:03:31'
-      }
-    ],
-    todo: [
-      {
-        status: 0,
-        title: '刘诗雨的请假审批',
-        description: '刘诗雨在 07-27 18:30 提交的请假申请'
-      },
-      {
-        status: 1,
-        title: '第三方代码紧急变更',
-        description: '需要在 2020-07-27 之前完成'
-      },
-      {
-        status: 2,
-        title: '信息安全考试',
-        description: '需要在 2020-07-26 18:30 前完成'
-      },
-      {
-        status: 2,
-        title: 'EleAdmin发布新版本',
-        description: '需要在 2020-07-25 11:03 前完成'
-      }
-    ]
-  };
+  const res = await request.get('/sys/notifymessage/getUnreadNotifyMessageList');
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+/**
+ * 获取某用户的未读消息条数
+ */
+export async function getUnreadNotifyMessageCountAPI () {
+  const res = await request.get('/sys/notifymessage/getUnreadNotifyMessageCount');
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 更新已读-指定消息ID
+ */
+export async function updateNotifyMessageReadByIdAPI (data) {
+  const res = await request.post('/sys/notifymessage/updateNotifyMessageRead',data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+/**
+ * 全部更新已读
+ */
+export async function updateAllNotifyMessageReadAPI () {
+  const res = await request.post('/sys/notifymessage/updateAllNotifyMessageRead');
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
 }

+ 1 - 1
src/config/setting.js

@@ -21,7 +21,7 @@ export const REPEATABLE_TABS = [];
 export const WHITE_LIST = ['/login', '/forget'];
 
 // 开启 KeepAlive 后仍然不需要缓存的路由地址
-export const KEEP_ALIVE_EXCLUDES = [];
+export const KEEP_ALIVE_EXCLUDES = ['/vis-page/index', '/vis-page/page2'];
 
 // 直接指定菜单数据
 export const USER_MENUS = undefined;

+ 152 - 108
src/layout/components/header-notice.vue

@@ -1,12 +1,13 @@
 <!-- 顶栏消息通知 -->
 <template>
   <el-popover
-    :width="330"
+    :width="430"
     trigger="click"
     v-model="visible"
     class="ele-notice-group"
     transition="el-zoom-in-top"
     popper-class="ele-notice-pop"
+    @show="query"
   >
     <template v-slot:reference>
       <div class="ele-notice-group">
@@ -15,98 +16,116 @@
         </el-badge>
       </div>
     </template>
-    <el-tabs v-model="active">
-      <el-tab-pane name="notice" :label="noticeTitle">
-        <div class="ele-notice-list ele-scrollbar-mini">
-          <div
-            v-for="(item, index) in notice"
-            :key="index"
-            class="ele-notice-item"
-          >
-            <div class="ele-cell ele-notice-item-wrapper">
-              <i :class="[item.icon, 'ele-notice-item-icon']"></i>
-              <div class="ele-cell-content">
-                <div class="ele-elip">{{ item.title }}</div>
-                <div class="ele-text-secondary ele-elip">{{ item.time }}</div>
+    <div class="ele-notice-list ele-scrollbar-mini">
+      <div v-for="(item, index) in notice" :key="index" class="ele-notice-item">
+        <div class="ele-cell ele-notice-item-wrapper">
+          <i :class="['el-icon-chat-dot-square', 'ele-notice-item-icon']"></i>
+          <div class="ele-cell-content">
+            <div class="ele-elip">{{ item.templateContent }}</div>
+            <div
+              style="
+                display: flex;
+                justify-content: space-between;
+                align-items: center;
+              "
+            >
+              <div class="ele-text-secondary ele-elip"
+                >{{ item.createTime }}
               </div>
+              <div
+                class="el-icon-view"
+                @click="clearNotice(item, index)"
+                title="已读"
+              ></div>
             </div>
-            <el-divider />
           </div>
         </div>
-        <div v-if="notice.length" class="ele-cell ele-notice-actions">
-          <div class="ele-cell-content" @click="clearNotice">清空通知</div>
-          <el-divider direction="vertical" class="line-color-light" />
-          <router-link to="/user/message?type=notice" class="ele-cell-content">
-            查看更多
-          </router-link>
-        </div>
-        <ele-empty v-if="!notice.length" text="已查看所有通知" />
-      </el-tab-pane>
-      <el-tab-pane name="letter" :label="letterTitle">
-        <div class="ele-notice-list ele-scrollbar-mini">
-          <div
-            v-for="(item, index) in letter"
-            :key="index"
-            class="ele-notice-item"
-          >
-            <div class="ele-cell ele-notice-item-wrapper ele-cell-align-top">
-              <el-avatar :src="item.avatar" size="medium" />
-              <div class="ele-cell-content">
-                <div class="ele-elip">{{ item.title }}</div>
-                <div class="ele-text-secondary ele-elip">
-                  {{ item.content }}
-                </div>
-                <div class="ele-cell-desc ele-elip">{{ item.time }}</div>
-              </div>
-            </div>
-            <el-divider />
-          </div>
-        </div>
-        <div v-if="letter.length" class="ele-cell ele-notice-actions">
-          <div class="ele-cell-content" @click="clearLetter">清空私信</div>
-          <el-divider direction="vertical" class="line-color-light" />
-          <router-link to="/user/message?type=letter" class="ele-cell-content">
-            查看更多
-          </router-link>
-        </div>
-        <ele-empty v-if="!letter.length" text="已读完所有私信" />
-      </el-tab-pane>
-      <el-tab-pane :label="todoTitle" name="todo">
-        <div class="ele-notice-list ele-scrollbar-mini">
-          <div
-            v-for="(item, index) in todo"
-            :key="index"
-            class="ele-notice-item"
-          >
-            <div class="ele-notice-item-wrapper">
-              <div class="ele-cell ele-cell-align-top">
-                <div class="ele-cell-content ele-elip">{{ item.title }}</div>
-                <el-tag size="mini" :type="['info', 'danger', ''][item.status]">
-                  {{ ['未开始', '即将到期', '进行中'][item.status] }}
-                </el-tag>
-              </div>
-              <div class="ele-text-secondary ele-elip">
-                {{ item.description }}
-              </div>
-            </div>
-            <el-divider />
-          </div>
-        </div>
-        <div v-if="todo.length" class="ele-cell ele-notice-actions">
-          <div class="ele-cell-content" @click="clearTodo">清空待办</div>
-          <el-divider direction="vertical" class="line-color-light" />
-          <router-link to="/user/message?type=todo" class="ele-cell-content">
-            查看更多
-          </router-link>
-        </div>
-        <ele-empty v-if="!todo.length" text="已完成所有任务" />
-      </el-tab-pane>
-    </el-tabs>
+        <el-divider />
+      </div>
+    </div>
+    <div v-if="notice.length" class="ele-cell ele-notice-actions">
+      <div class="ele-cell-content" @click="clearNotice">清空通知</div>
+      <el-divider direction="vertical" class="line-color-light" />
+      <router-link to="/page-wt/message" class="ele-cell-content">
+        查看更多
+      </router-link>
+    </div>
+    <ele-empty v-if="!notice.length" text="已查看所有通知" />
+    <!--    <el-tabs v-model="active" type="card">-->
+    <!--      <el-tab-pane name="notice" :label="noticeTitle">-->
+    <!--      -->
+    <!--      </el-tab-pane>-->
+    <!--      <el-tab-pane name="letter" :label="letterTitle">-->
+    <!--        <div class="ele-notice-list ele-scrollbar-mini">-->
+    <!--          <div-->
+    <!--            v-for="(item, index) in letter"-->
+    <!--            :key="index"-->
+    <!--            class="ele-notice-item"-->
+    <!--          >-->
+    <!--            <div class="ele-cell ele-notice-item-wrapper ele-cell-align-top">-->
+    <!--              <el-avatar :src="item.avatar" size="medium" />-->
+    <!--              <div class="ele-cell-content">-->
+    <!--                <div class="ele-elip">{{ item.title }}</div>-->
+    <!--                <div class="ele-text-secondary ele-elip">-->
+    <!--                  {{ item.content }}-->
+    <!--                </div>-->
+    <!--                <div class="ele-cell-desc ele-elip">{{ item.time }}</div>-->
+    <!--              </div>-->
+    <!--            </div>-->
+    <!--            <el-divider />-->
+    <!--          </div>-->
+    <!--        </div>-->
+    <!--        <div v-if="letter.length" class="ele-cell ele-notice-actions">-->
+    <!--          <div class="ele-cell-content" @click="clearLetter">清空私信</div>-->
+    <!--          <el-divider direction="vertical" class="line-color-light" />-->
+    <!--          <router-link to="/user/message?type=letter" class="ele-cell-content">-->
+    <!--            查看更多-->
+    <!--          </router-link>-->
+    <!--        </div>-->
+    <!--        <ele-empty v-if="!letter.length" text="已读完所有私信" />-->
+    <!--      </el-tab-pane>-->
+    <!--      <el-tab-pane :label="todoTitle" name="todo">-->
+    <!--        <div class="ele-notice-list ele-scrollbar-mini">-->
+    <!--          <div-->
+    <!--            v-for="(item, index) in todo"-->
+    <!--            :key="index"-->
+    <!--            class="ele-notice-item"-->
+    <!--          >-->
+    <!--            <div class="ele-notice-item-wrapper">-->
+    <!--              <div class="ele-cell ele-cell-align-top">-->
+    <!--                <div class="ele-cell-content ele-elip">{{ item.title }}</div>-->
+    <!--                <el-tag size="mini" :type="['info', 'danger', ''][item.status]">-->
+    <!--                  {{ ['未开始', '即将到期', '进行中'][item.status] }}-->
+    <!--                </el-tag>-->
+    <!--              </div>-->
+    <!--              <div class="ele-text-secondary ele-elip">-->
+    <!--                {{ item.description }}-->
+    <!--              </div>-->
+    <!--            </div>-->
+    <!--            <el-divider />-->
+    <!--          </div>-->
+    <!--        </div>-->
+    <!--        <div v-if="todo.length" class="ele-cell ele-notice-actions">-->
+    <!--          <div class="ele-cell-content" @click="clearTodo">清空待办</div>-->
+    <!--          <el-divider direction="vertical" class="line-color-light" />-->
+    <!--          <router-link to="/user/message?type=todo" class="ele-cell-content">-->
+    <!--            查看更多-->
+    <!--          </router-link>-->
+    <!--        </div>-->
+    <!--        <ele-empty v-if="!todo.length" text="已完成所有任务" />-->
+    <!--      </el-tab-pane>-->
+    <!--    </el-tabs>-->
   </el-popover>
 </template>
 
 <script>
-  import { getUnreadNotice } from '@/api/layout';
+  import {
+    getUnreadNotice,
+    getUnreadNotifyMessageCountAPI,
+    updateAllNotifyMessageReadAPI,
+    updateNotifyMessageReadByIdAPI
+  } from '@/api/layout';
+  import { getToken } from '@/utils/token-util';
 
   export default {
     data() {
@@ -117,6 +136,8 @@
         active: 'notice',
         // 通知数据
         notice: [],
+        noticeCount: 0,
+        timer: null,
         // 私信数据
         letter: [],
         // 待办数据
@@ -126,40 +147,54 @@
     computed: {
       // 通知标题
       noticeTitle() {
-        return '通知' + (this.notice.length ? `(${this.notice.length})` : '');
-      },
-      // 私信标题
-      letterTitle() {
-        return '私信' + (this.letter.length ? `(${this.letter.length})` : '');
-      },
-      // 待办标题
-      todoTitle() {
-        return '待办' + (this.todo.length ? `(${this.todo.length})` : '');
+        return '通知' + (this.noticeCount > 0 ? `(${this.noticeCount})` : '');
       },
+      // // 私信标题
+      // letterTitle() {
+      //   return '私信' + (this.letter.length ? `(${this.letter.length})` : '');
+      // },
+      // // 待办标题
+      // todoTitle() {
+      //   return '待办' + (this.todo.length ? `(${this.todo.length})` : '');
+      // },
       // 未读数量
       unreadNum() {
-        return this.notice.length + this.letter.length + this.todo.length;
+        return this.noticeCount;
       }
     },
     created() {
-      this.query();
+      if (getToken()) {
+        this.getCount();
+      }
+      console.log('123123');
     },
     methods: {
       /* 查询数据 */
-      query() {
-        getUnreadNotice()
-          .then((result) => {
-            this.notice = result.notice;
-            this.letter = result.letter;
-            this.todo = result.todo;
-          })
-          .catch((e) => {
-            console.log(e.message);
-          });
+      async query() {
+        this.notice = await getUnreadNotice();
+        this.notice = this.notice.slice(0, 15);
+      },
+      /* 查询条数 */
+      async getCount() {
+        clearInterval(this.timer);
+        let count = await getUnreadNotifyMessageCountAPI();
+        this.noticeCount = count * 1 || 0;
+        this.timer = setInterval(() => {
+          this.getCount();
+        }, 5000);
       },
+
       /* 清空通知 */
-      clearNotice() {
-        this.notice = [];
+      async clearNotice(item = {}, index) {
+        if (item.id) {
+          await updateNotifyMessageReadByIdAPI([item.id]);
+          this.notice.splice(index, 1);
+          this.noticeCount = this.noticeCount - 1;
+        } else {
+          await updateAllNotifyMessageReadAPI();
+          this.notice = [];
+          this.noticeCount = 0;
+        }
       },
       /* 清空通知 */
       clearLetter() {
@@ -276,4 +311,13 @@
       background-color: hsla(0, 0%, 60%, 0.05);
     }
   }
+
+  .ele-elip {
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+    -webkit-line-clamp: 3;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: normal !important;
+  }
 </style>

+ 8 - 11
src/layout/components/header-tools.vue

@@ -14,9 +14,9 @@
       <i18n-icon />
     </div> -->
     <!-- 消息通知 -->
-    <!-- <div class="ele-admin-header-tool-item">
+    <div class="ele-admin-header-tool-item">
       <header-notice />
-    </div> -->
+    </div>
     <!-- 用户信息 -->
     <div class="ele-admin-header-tool-item">
       <el-dropdown @command="onUserDropClick">
@@ -30,15 +30,13 @@
           <i class="el-icon-arrow-down"></i>
         </div>
         <template v-slot:dropdown>
-      
           <el-dropdown-menu>
             <!-- <el-dropdown-item command="profile" icon="el-icon-user">
               {{ $t('layout.header.profile') }}
             </el-dropdown-item>-->
             <el-dropdown-item command="password" icon="el-icon-key">
               {{ $t('layout.header.password') }}
-       
-            </el-dropdown-item> 
+            </el-dropdown-item>
             <el-dropdown-item
               command="logout"
               icon="el-icon-switch-button"
@@ -75,7 +73,7 @@
       // 是否是全屏
       fullscreen: Boolean
     },
-    data () {
+    data() {
       return {
         // 是否显示修改密码弹窗
         passwordVisible: false,
@@ -85,13 +83,13 @@
     },
     computed: {
       // 当前用户信息
-      loginUser () {
+      loginUser() {
         return this.$store.state.user.info;
       }
     },
     methods: {
       /* 用户信息下拉点击事件 */
-      onUserDropClick (command) {
+      onUserDropClick(command) {
         if (command === 'password') {
           this.passwordVisible = true;
         } else if (command === 'profile') {
@@ -107,7 +105,6 @@
           )
             .then(() => {
               userLogout().then((res) => {
-              
                 localStorage.removeItem('userId');
                 localStorage.removeItem('LogoName');
                 logout();
@@ -117,11 +114,11 @@
         }
       },
       /* 全屏切换 */
-      toggleFullscreen () {
+      toggleFullscreen() {
         this.$emit('fullscreen');
       },
       /* 打开设置抽屉 */
-      openSetting () {
+      openSetting() {
         this.settingVisible = true;
       }
     }

+ 13 - 6
src/layout/index.vue

@@ -57,12 +57,16 @@
 
     <!-- 顶栏右侧区域 -->
     <template v-slot:right>
-      <header-tools :fullscreen="fullscreen" @fullscreen="onFullscreen" />
+      <header-tools
+        v-if="token"
+        :fullscreen="fullscreen"
+        @fullscreen="onFullscreen"
+      />
     </template>
     <!-- 全局页脚 -->
     <!-- <template v-slot:footer>
-      <page-footer />
-    </template> -->
+        <page-footer />
+      </template> -->
     <!-- 自定义菜单标题增加徽章、小红点 -->
     <template v-slot:title="{ title, item }">
       <span>{{ title }} </span>
@@ -138,7 +142,8 @@
         fullscreen: false,
 
         logoImg: null,
-        projectName: null
+        projectName: null,
+        token: ''
       };
     },
     computed: {
@@ -154,9 +159,9 @@
       ...mapGetters(['theme'])
     },
     created() {
-      if(getToken()){
+      this.token = getToken();
+      if (this.token) {
         this.getLogo();
-
       }
     },
     methods: {
@@ -261,12 +266,14 @@
   .ele-admin-layout {
     .ele-admin-logo {
       font-size: 18px !important;
+
       img {
         width: 50px !important;
         height: auto !important;
       }
     }
   }
+
   // 侧栏菜单徽章样式,定位在右侧垂直居中并调小尺寸
   .ele-menu-badge {
     position: absolute;

+ 9 - 11
src/micro-app.js

@@ -1,4 +1,5 @@
 import store from './store';
+
 const microApps = [
   {
     name: 'wt',
@@ -39,9 +40,9 @@ const microApps = [
   },
 
   {
-    name: 'eom',
-    entry: '/eom/',
-    activeRule: '/page-eom'
+    name: 'eos',
+    entry: '/eos/',
+    activeRule: '/page-eos'
   },
 
   {
@@ -49,14 +50,11 @@ const microApps = [
     entry: '/vis/',
     activeRule: '/page-vis'
   },
-
-
-  
-
-
-
-  
-
+  {
+    name: 'pro',
+    entry: '/pro/',
+    activeRule: '/page-pro'
+  }
 ];
 
 const apps = microApps.map((item) => {

+ 11 - 10
src/store/modules/user.js

@@ -57,25 +57,26 @@ export default {
   },
   mutations: {
     // 设置登录用户的信息
-    setUserInfo (state, info) {
+    setUserInfo(state, info) {
+      localStorage.setItem('info', JSON.stringify(info));
       state.info = info;
     },
     // 设置登录用户的菜单
-    setMenus (state, menus) {
+    setMenus(state, menus) {
       state.menus = menus;
     },
     // 设置登录用户的权限
-    setAuthorities (state, authorities) {
+    setAuthorities(state, authorities) {
       // console.log(authorities,'authorities')
-      state.authorities = authorities
+      state.authorities = authorities;
       // sessionStorage['authorities']=JSON.stringify(authorities.map(item=>item.permissionCode))
     },
     // 设置登录用户的权限路由
-    setAuthoritiesRouter (state, authoritiesRouter) {
+    setAuthoritiesRouter(state, authoritiesRouter) {
       state.authoritiesRouter = authoritiesRouter;
     },
     // 设置登录用户的角色
-    setRoles (state, roles) {
+    setRoles(state, roles) {
       state.roles = roles;
     }
   },
@@ -113,7 +114,7 @@ export default {
     //   return { menus, homePath };
     // },
     //动态路由
-    async fetchUserInfo ({ commit }) {
+    async fetchUserInfo({ commit }) {
       const result = await getResourcesTree().catch(() => {});
       if (!result) {
         return {};
@@ -164,19 +165,19 @@ export default {
     /**
      * 更新用户信息
      */
-    setInfo ({ commit }, value) {
+    setInfo({ commit }, value) {
       commit('setUserInfo', value);
     },
     /**
      * 更新菜单数据
      */
-    setMenus ({ commit }, value) {
+    setMenus({ commit }, value) {
       commit('setMenus', value);
     },
     /**
      * 更新菜单的badge
      */
-    setMenuBadge ({ commit, state }, { path, value, color }) {
+    setMenuBadge({ commit, state }, { path, value, color }) {
       const menus = formatTreeData(state.menus, (m) => {
         if (path === m.path) {
           return {