首页业务处理

This commit is contained in:
13405411873 2024-10-23 23:26:01 +08:00
parent aedaf4e73f
commit d2ae3d87f6
9 changed files with 107 additions and 48 deletions

View File

@ -52,7 +52,7 @@
"core-js": "^3.26.0", "core-js": "^3.26.0",
"crypto-js": "^4.0.0", "crypto-js": "^4.0.0",
"dayjs": "^1.11.12", "dayjs": "^1.11.12",
"echarts": "5.4.0", "echarts": "^5.4.0",
"element-ui": "2.15.12", "element-ui": "2.15.12",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"fuse.js": "6.6.2", "fuse.js": "6.6.2",

View File

@ -21,10 +21,11 @@ export function login(username, password, captchaVerification, socialType, socia
} }
// 获取用户详细信息 // 获取用户详细信息
export function getInfo() { export function getInfo(data) {
return request({ return request({
url: '/system/auth/get-permission-info', url: '/system/auth/get-permission-info',
method: 'get' method: 'get',
params: data
}) })
} }

View File

@ -18,7 +18,14 @@ export function getMyNotifyMessagePage(query) {
params: query params: query
}) })
} }
// 获得我的提醒
export function warnList(query) {
return request({
url: '/warnMsg/warnMsg/pageList',
method: 'get',
params: query
})
}
// 批量标记已读 // 批量标记已读
export function updateNotifyMessageRead(ids) { export function updateNotifyMessageRead(ids) {
return request({ return request({

View File

@ -20,6 +20,7 @@ import { parseTime, resetForm, handleTree, addBeginAndEndTime, divide} from "@/u
import Pagination from "@/components/Pagination"; import Pagination from "@/components/Pagination";
// 自定义表格工具扩展 // 自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar" import RightToolbar from "@/components/RightToolbar"
import { download } from '@/utils/request'
// 图片上传组件 // 图片上传组件
import ImageUpload from "@/components/ImageUpload/index.vue"; import ImageUpload from "@/components/ImageUpload/index.vue";
// 文件上传组件 // 文件上传组件
@ -45,6 +46,7 @@ Vue.prototype.DICT_TYPE = DICT_TYPE
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
Vue.prototype.addBeginAndEndTime = addBeginAndEndTime Vue.prototype.addBeginAndEndTime = addBeginAndEndTime
Vue.prototype.divide = divide Vue.prototype.divide = divide
Vue.prototype.download = download
// 全局组件挂载 // 全局组件挂载
Vue.component('DictTag', DictTag) Vue.component('DictTag', DictTag)

View File

@ -25,7 +25,7 @@ router.beforeEach((to, from, next) => {
// 获取字典数据 add by 芋艿 // 获取字典数据 add by 芋艿
store.dispatch('dict/loadDictDatas') store.dispatch('dict/loadDictDatas')
// 判断当前用户是否已拉取完 user_info 信息 // 判断当前用户是否已拉取完 user_info 信息
store.dispatch('GetInfo').then(userInfo => { store.dispatch('GetInfo',{routeCode:to.query.routeCode}).then(userInfo => {
isRelogin.show = false isRelogin.show = false
// 触发 GenerateRoutes 事件时,将 menus 菜单树传递进去 // 触发 GenerateRoutes 事件时,将 menus 菜单树传递进去
store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => { store.dispatch('GenerateRoutes', userInfo.menus).then(accessRoutes => {

View File

@ -52,11 +52,11 @@ const permission = {
// 遍历后台传来的路由字符串,转换为组件对象 // 遍历后台传来的路由字符串,转换为组件对象
function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) { function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
return asyncRouterMap.filter(route => { return asyncRouterMap.filter(function(route,index) {
// 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处 // 将 ruoyi 后端原有耦合前端的逻辑,迁移到此处
// 处理 meta 属性 // 处理 meta 属性
route.meta = { route.meta = {
title: route.name, title:dealMenuText(index) +' '+ route.name,
icon: route.icon, icon: route.icon,
noCache: !route.keepAlive, noCache: !route.keepAlive,
} }
@ -95,10 +95,18 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
delete route['children'] delete route['children']
delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段 delete route['alwaysShow'] // 如果没有子菜单,就不需要考虑 alwaysShow 字段
} }
console.log(route,989898)
return true return true
}) })
} }
function dealMenuText(num){
let tempData =['(一)','(二)','(三)','(四)','(五)','(六)','(七)','(八)','(九)','(十)'
,'(十一)','(十二)','(十三)','(十四)','(十五)','(十六)','(十七)','(十八)','(十九)','(二十)','(二十一)','(二十二)','(二十三)']
if (num>tempData.length){
return "";
}
return tempData[num]
}
function filterChildren(childrenMap, lastRouter = false) { function filterChildren(childrenMap, lastRouter = false) {
let children = []; let children = [];
childrenMap.forEach((el, index) => { childrenMap.forEach((el, index) => {
@ -115,11 +123,12 @@ function filterChildren(childrenMap, lastRouter = false) {
return return
} }
} }
if (lastRouter) { if (lastRouter) {
el.path = lastRouter.path + '/' + el.path el.path = lastRouter.path + '/' + el.path
} }
children = children.concat(el) children = children.concat(el)
}) })
return children return children
} }

View File

@ -85,9 +85,9 @@ const user = {
}) })
}, },
// 获取用户信息 // 获取用户信息
GetInfo({ commit, state }) { GetInfo({ commit },obj) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo().then(res => { getInfo(obj).then(res => {
// 没有 data 数据,赋予个默认值 // 没有 data 数据,赋予个默认值
if (!res) { if (!res) {
res = { res = {

View File

@ -1,11 +1,11 @@
import axios from 'axios' import axios from 'axios'
import {Message, MessageBox, Notification} from 'element-ui' import {Message, MessageBox, Notification,Loading} from 'element-ui'
import store from '@/store' import store from '@/store'
import {getAccessToken, getRefreshToken, getTenantId, setToken} from '@/utils/auth' import {getAccessToken, getRefreshToken, getTenantId, setToken} from '@/utils/auth'
import errorCode from '@/utils/errorCode' import errorCode from '@/utils/errorCode'
import {getPath, getTenantEnable} from "@/utils/ruoyi"; import {getPath, getTenantEnable} from "@/utils/ruoyi";
import {refreshToken} from "@/api/login"; import {refreshToken} from "@/api/login";
import { saveAs } from 'file-saver'
// 需要忽略的提示。忽略后,自动 Promise.reject('error') // 需要忽略的提示。忽略后,自动 Promise.reject('error')
const ignoreMsgs = [ const ignoreMsgs = [
"无效的刷新令牌", // 刷新令牌被删除时,不用提示 "无效的刷新令牌", // 刷新令牌被删除时,不用提示
@ -210,40 +210,62 @@ function handleAuthorized() {
} }
let downloadLoadingInstance; let downloadLoadingInstance;
// 通用下载方法
// 通用下载方法 // 通用下载方法
export function download(url, params, filename, config) { export function download(url, params, filename, config) {
downloadLoadingInstance = ElLoading.service({text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)",}) downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return axios.post(url, params, { return service.post(url, params, {
transformRequest: [(params) => { transformRequest: [(params) => { return tansParams(params) }],
return tansParams(params) headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
}],
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
responseType: 'blob', responseType: 'blob',
...config ...config
}).then(async (data) => { }).then(async (data) => {
const isBlob = blobValidate(data.data); const isBlob = blobValidate(data);
if (isBlob) { if (isBlob) {
let blob = new Blob([data.data], {type: "application/vnd.ms-excel"}); // 设置文件类型excel const blob = new Blob([data])
let url = window.URL.createObjectURL(blob); // 创建一个临时的url指向blob对象 saveAs(blob, filename)
// 创建url之后可以模拟对此文件对象的一系列操作例如预览、下载
let a = document.createElement("a");
a.href = url;
a.download = filename + ".xlsx";
a.click();
// 释放这个临时的对象url
window.URL.revokeObjectURL(url);
} else { } else {
const resText = await data.data.text(); const resText = await data.text();
const rspObj = JSON.parse(resText); const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'] const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
ElMessage.error(errMsg); Message.error(errMsg);
} }
downloadLoadingInstance.close(); downloadLoadingInstance.close();
}).catch((r) => { }).catch((r) => {
console.error(r) console.error(r)
ElMessage.error('下载文件出现错误,请联系管理员!') Message.error('下载文件出现错误,请联系管理员!')
downloadLoadingInstance.close(); 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 export default service

View File

@ -2,38 +2,41 @@
<div> <div>
<el-row> <el-row>
<el-col v-for="item in serviceList" :span="4"> <el-col v-for="item in serviceList" :span="4">
<image-preview :width="300" :height="300" :src="item.coverImg"></image-preview> <div @click="goRoute(item.id)">
{{ item.name }} <image-preview :width="300" :height="300" :src="item.coverImg"></image-preview>
{{ item.name }}
</div>
</el-col> </el-col>
</el-row> </el-row>
<div style="margin-top: 30px"> <div style="margin-top: 30px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<div> <div>
<div style="font-size: 30px;margin-bottom: 30px">资产临期提醒</div> <div style="font-size: 30px;margin-bottom: 30px">临期提醒</div>
<el-table <el-table
:data="warnList" :data="warnList"
stripe stripe
style="width: 100%"> style="width: 100%">
<el-table-column <el-table-column
prop="date" prop="title"
label="日期" label="标题"
width="180"> width="180">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="name" prop="content"
label="姓名" label="内容"
width="180"> width="180">
</el-table-column> </el-table-column>
<el-table-column <el-table-column
prop="address" prop="warnTime"
label="地址"> label="提醒时间">
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页组件 --> <!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="warnTotal > 0" :total="warnTotal" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getWarnList"
/> />
</div> </div>
</el-col> </el-col>
@ -86,7 +89,7 @@ import RaddarChart from './dashboard/RaddarChart'
import PieChart from './dashboard/PieChart' import PieChart from './dashboard/PieChart'
import BarChart from './dashboard/BarChart' import BarChart from './dashboard/BarChart'
import {getServicePackageList} from "@/api/system/servicePackage"; import {getServicePackageList} from "@/api/system/servicePackage";
import {getMyNotifyMessagePage, getUnreadNotifyMessageList} from "@/api/system/notify/message"; import {warnList,getMyNotifyMessagePage} from "@/api/system/notify/message";
const lineChartData = { const lineChartData = {
newVisitis: { newVisitis: {
@ -130,24 +133,39 @@ export default {
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
}, },
messageTotal: 0 messageTotal: 0,
warnTotal: 0
} }
}, },
created() { created() {
this.getServiceList() this.getServiceList()
this.getNotifyMessage() this.getNotifyMessage()
this.getWarnList()
}, },
methods: { methods: {
handleSetLineChartData(type) { handleSetLineChartData(type) {
this.lineChartData = lineChartData[type] this.lineChartData = lineChartData[type]
}, },
goRoute(code){
console.log(window.location.host,150)
window.open(window.location.origin+"/index?routeCode="+code)
},
getNotifyMessage() { getNotifyMessage() {
// //
getMyNotifyMessagePage(this.messageQueryParams).then(response => { getMyNotifyMessagePage(this.messageQueryParams).then(response => {
this.messageList = response.data.list; this.messageList = response.data.list;
this.messageTotal = response.data.total; 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() { getServiceList() {
getServicePackageList(this.queryParams).then(response => { getServicePackageList(this.queryParams).then(response => {
this.serviceList = response.data; this.serviceList = response.data;