首页业务处理

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",
"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",

View File

@ -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
})
}

View File

@ -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({

View File

@ -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)

View File

@ -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 => {

View File

@ -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
}

View File

@ -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 = {

View File

@ -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

View File

@ -2,38 +2,41 @@
<div>
<el-row>
<el-col v-for="item in serviceList" :span="4">
<image-preview :width="300" :height="300" :src="item.coverImg"></image-preview>
{{ item.name }}
<div @click="goRoute(item.id)">
<image-preview :width="300" :height="300" :src="item.coverImg"></image-preview>
{{ item.name }}
</div>
</el-col>
</el-row>
<div style="margin-top: 30px">
<el-row :gutter="20">
<el-col :span="12">
<div>
<div style="font-size: 30px;margin-bottom: 30px">资产临期提醒</div>
<div style="font-size: 30px;margin-bottom: 30px">临期提醒</div>
<el-table
:data="warnList"
stripe
style="width: 100%">
<el-table-column
prop="date"
label="日期"
prop="title"
label="标题"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
prop="content"
label="内容"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
prop="warnTime"
label="提醒时间">
</el-table-column>
</el-table>
<!-- 分页组件 -->
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"
<pagination v-show="warnTotal > 0" :total="warnTotal" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getWarnList"
/>
</div>
</el-col>
@ -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;