From d2ae3d87f6bc625b1a264c59316c664e86d2a07f Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Wed, 23 Oct 2024 23:26:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=B8=9A=E5=8A=A1=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/api/login.js | 5 ++- src/api/system/notify/message.js | 9 ++++- src/main.js | 2 + src/permission.js | 2 +- src/store/modules/permission.js | 23 ++++++++---- src/store/modules/user.js | 4 +- src/utils/request.js | 64 +++++++++++++++++++++----------- src/views/index.vue | 44 +++++++++++++++------- 9 files changed, 107 insertions(+), 48 deletions(-) diff --git a/package.json b/package.json index 3a73e45..6bbda10 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "core-js": "^3.26.0", "crypto-js": "^4.0.0", "dayjs": "^1.11.12", - "echarts": "5.4.0", + "echarts": "^5.4.0", "element-ui": "2.15.12", "file-saver": "^2.0.5", "fuse.js": "6.6.2", diff --git a/src/api/login.js b/src/api/login.js index 614a11f..b5bc85c 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -21,10 +21,11 @@ export function login(username, password, captchaVerification, socialType, socia } // 获取用户详细信息 -export function getInfo() { +export function getInfo(data) { return request({ url: '/system/auth/get-permission-info', - method: 'get' + method: 'get', + params: data }) } diff --git a/src/api/system/notify/message.js b/src/api/system/notify/message.js index 5ef63a4..2194cb7 100644 --- a/src/api/system/notify/message.js +++ b/src/api/system/notify/message.js @@ -18,7 +18,14 @@ export function getMyNotifyMessagePage(query) { params: query }) } - +// 获得我的提醒 +export function warnList(query) { + return request({ + url: '/warnMsg/warnMsg/pageList', + method: 'get', + params: query + }) +} // 批量标记已读 export function updateNotifyMessageRead(ids) { return request({ diff --git a/src/main.js b/src/main.js index 18d9258..fee88d6 100644 --- a/src/main.js +++ b/src/main.js @@ -20,6 +20,7 @@ import { parseTime, resetForm, handleTree, addBeginAndEndTime, divide} from "@/u import Pagination from "@/components/Pagination"; // 自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" +import { download } from '@/utils/request' // 图片上传组件 import ImageUpload from "@/components/ImageUpload/index.vue"; // 文件上传组件 @@ -45,6 +46,7 @@ Vue.prototype.DICT_TYPE = DICT_TYPE Vue.prototype.handleTree = handleTree Vue.prototype.addBeginAndEndTime = addBeginAndEndTime Vue.prototype.divide = divide +Vue.prototype.download = download // 全局组件挂载 Vue.component('DictTag', DictTag) diff --git a/src/permission.js b/src/permission.js index 301fee6..3bf25a1 100644 --- a/src/permission.js +++ b/src/permission.js @@ -25,7 +25,7 @@ router.beforeEach((to, from, next) => { // 获取字典数据 add by 芋艿 store.dispatch('dict/loadDictDatas') // 判断当前用户是否已拉取完 user_info 信息 - store.dispatch('GetInfo').then(userInfo => { + store.dispatch('GetInfo',{routeCode:to.query.routeCode}).then(userInfo => { isRelogin.show = false // 触发 GenerateRoutes 事件时,将 menus 菜单树传递进去 store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => { diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index ed61095..3aca219 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -52,11 +52,11 @@ const permission = { // 遍历后台传来的路由字符串,转换为组件对象 function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { - return asyncRouterMap.filter(route => { + return asyncRouterMap.filter(function(route,index) { // 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处 // 处理 meta 属性 route.meta = { - title: route.name, + title:dealMenuText(index) +' '+ route.name, icon: route.icon, noCache: !route.keepAlive, } @@ -95,10 +95,18 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { delete route['children'] delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段 } + console.log(route,989898) return true }) } - +function dealMenuText(num){ + let tempData =['(一)','(二)','(三)','(四)','(五)','(六)','(七)','(八)','(九)','(十)' + ,'(十一)','(十二)','(十三)','(十四)','(十五)','(十六)','(十七)','(十八)','(十九)','(二十)','(二十一)','(二十二)','(二十三)'] + if (num>tempData.length){ + return ""; + } + return tempData[num] +} function filterChildren(childrenMap, lastRouter = false) { let children = []; childrenMap.forEach((el, index) => { @@ -115,11 +123,12 @@ function filterChildren(childrenMap, lastRouter = false) { return } } - if (lastRouter) { - el.path = lastRouter.path + '/' + el.path - } - children = children.concat(el) + if (lastRouter) { + el.path = lastRouter.path + '/' + el.path + } + children = children.concat(el) }) + return children } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2e4ce99..02bff23 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -85,9 +85,9 @@ const user = { }) }, // 获取用户信息 - GetInfo({ commit, state }) { + GetInfo({ commit },obj) { return new Promise((resolve, reject) => { - getInfo().then(res => { + getInfo(obj).then(res => { // 没有 data 数据,赋予个默认值 if (!res) { res = { diff --git a/src/utils/request.js b/src/utils/request.js index a09446c..8d57aca 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,11 +1,11 @@ import axios from 'axios' -import {Message, MessageBox, Notification} from 'element-ui' +import {Message, MessageBox, Notification,Loading} from 'element-ui' import store from '@/store' import {getAccessToken, getRefreshToken, getTenantId, setToken} from '@/utils/auth' import errorCode from '@/utils/errorCode' import {getPath, getTenantEnable} from "@/utils/ruoyi"; import {refreshToken} from "@/api/login"; - +import { saveAs } from 'file-saver' // 需要忽略的提示。忽略后,自动 Promise.reject('error') const ignoreMsgs = [ "无效的刷新令牌", // 刷新令牌被删除时,不用提示 @@ -210,40 +210,62 @@ function handleAuthorized() { } let downloadLoadingInstance; +// 通用下载方法 // 通用下载方法 export function download(url, params, filename, config) { - downloadLoadingInstance = ElLoading.service({text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)",}) - return axios.post(url, params, { - transformRequest: [(params) => { - return tansParams(params) - }], - headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) + return service.post(url, params, { + transformRequest: [(params) => { return tansParams(params) }], + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, responseType: 'blob', ...config }).then(async (data) => { - const isBlob = blobValidate(data.data); + const isBlob = blobValidate(data); if (isBlob) { - let blob = new Blob([data.data], {type: "application/vnd.ms-excel"}); // 设置文件类型excel - let url = window.URL.createObjectURL(blob); // 创建一个临时的url指向blob对象 - // 创建url之后可以模拟对此文件对象的一系列操作,例如:预览、下载 - let a = document.createElement("a"); - a.href = url; - a.download = filename + ".xlsx"; - a.click(); - // 释放这个临时的对象url - window.URL.revokeObjectURL(url); + const blob = new Blob([data]) + saveAs(blob, filename) } else { - const resText = await data.data.text(); + const resText = await data.text(); const rspObj = JSON.parse(resText); const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] - ElMessage.error(errMsg); + Message.error(errMsg); } downloadLoadingInstance.close(); }).catch((r) => { console.error(r) - ElMessage.error('下载文件出现错误,请联系管理员!') + Message.error('下载文件出现错误,请联系管理员!') downloadLoadingInstance.close(); }) } +/** + * 参数处理 + * @param {*} params 参数 + */ +export function tansParams(params) { + let result = '' + for (const propName of Object.keys(params)) { + const value = params[propName]; + var part = encodeURIComponent(propName) + "="; + if (value !== null && value !== "" && typeof (value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') { + let params = propName + '[' + key + ']'; + var subPart = encodeURIComponent(params) + "="; + result += subPart + encodeURIComponent(value[key]) + "&"; + } + } + } else { + result += part + encodeURIComponent(value) + "&"; + } + } + } + return result +} + +// 验证是否为blob格式 +export function blobValidate(data) { + return data.type !== 'application/json' +} export default service diff --git a/src/views/index.vue b/src/views/index.vue index 21d0e3e..21826ca 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -2,38 +2,41 @@
- - {{ item.name }} +
+ + {{ item.name }} +
+
-
资产临期提醒
+
临期提醒
+ prop="warnTime" + label="提醒时间"> -
@@ -86,7 +89,7 @@ import RaddarChart from './dashboard/RaddarChart' import PieChart from './dashboard/PieChart' import BarChart from './dashboard/BarChart' import {getServicePackageList} from "@/api/system/servicePackage"; -import {getMyNotifyMessagePage, getUnreadNotifyMessageList} from "@/api/system/notify/message"; +import {warnList,getMyNotifyMessagePage} from "@/api/system/notify/message"; const lineChartData = { newVisitis: { @@ -130,24 +133,39 @@ export default { pageNo: 1, pageSize: 10 }, - messageTotal: 0 + messageTotal: 0, + warnTotal: 0 } }, created() { this.getServiceList() this.getNotifyMessage() + this.getWarnList() }, methods: { handleSetLineChartData(type) { this.lineChartData = lineChartData[type] }, + goRoute(code){ + console.log(window.location.host,150) + window.open(window.location.origin+"/index?routeCode="+code) + }, getNotifyMessage() { // 执行查询 getMyNotifyMessagePage(this.messageQueryParams).then(response => { + this.messageList = response.data.list; this.messageTotal = response.data.total; }); }, + getWarnList() { + // 执行查询 + warnList(this.queryParams).then(response => { + console.log(response,149) + this.warnList = response.data.records; + this.warnTotal = response.data.total; + }); + }, getServiceList() { getServicePackageList(this.queryParams).then(response => { this.serviceList = response.data;