update 首页头部统计、任务列表,增加当前角色学科筛选条件
This commit is contained in:
@@ -7,20 +7,24 @@ import { post, get } from './request';
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const queryTaskListApi = (params: any) => {
|
export const queryTaskListApi = (params: any) => {
|
||||||
return post(`/api/simulation/project/task/list`, params);
|
return post(`/api/simulation/project/task/list`, params);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 我执行的 各类状态统计
|
// 我执行的 各类状态统计
|
||||||
export const getTaskCountApi = (params: any) => {
|
export const getTaskCountApi = (params: any) => {
|
||||||
return post(`/api/simulation/project/task/count`, params);
|
return post(`/api/simulation/project/task/count`, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const querySystemParamConfigureApi = (data: any) => {
|
||||||
|
return get(`/api/simulation/system/systemData/querySystemParamConfigure`, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 消息列表
|
// 消息列表
|
||||||
export const getUserMsgPageList = (data: any) => {
|
export const getUserMsgPageList = (data: any) => {
|
||||||
return get(`/spdm-msg/getUserMsgPageList`, data);
|
return get(`/spdm-msg/getUserMsgPageList`, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 修改消息状态
|
// 修改消息状态
|
||||||
export const setMsgReadStatus = (params: any) => {
|
export const setMsgReadStatus = (params: any) => {
|
||||||
return post(`/spdm-msg/setMsgReadStatus`, params);
|
return post(`/spdm-msg/setMsgReadStatus`, params);
|
||||||
};
|
};
|
||||||
@@ -27,10 +27,11 @@ export default {
|
|||||||
|
|
||||||
<script setup lang="ts" name="TaskMessageDashboard">
|
<script setup lang="ts" name="TaskMessageDashboard">
|
||||||
import { queryTaskListApi } from '/@/spdm/api/spdm-task';
|
import { queryTaskListApi } from '/@/spdm/api/spdm-task';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, onBeforeUnmount } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import TableRender from '/@/components/TableRender/index.vue';
|
import TableRender from '/@/components/TableRender/index.vue';
|
||||||
import { ElTag } from 'element-plus';
|
import { ElTag } from 'element-plus';
|
||||||
|
import mittBus from '/@/utils/mitt';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -103,6 +104,7 @@ const currentPageChangeFun = (val: number) => {
|
|||||||
|
|
||||||
// 更多按钮
|
// 更多按钮
|
||||||
const goMoreFun = () => {
|
const goMoreFun = () => {
|
||||||
|
localStorage.setItem('HOME_TASK_PARAMS', 'total');
|
||||||
router.push('spdm/task/execute'); // 跳转到我执行的页面
|
router.push('spdm/task/execute'); // 跳转到我执行的页面
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -125,6 +127,7 @@ const getTableList = () => {
|
|||||||
size: 6,
|
size: 6,
|
||||||
sortOrder: 1,
|
sortOrder: 1,
|
||||||
type: 0,
|
type: 0,
|
||||||
|
filterDiscipline: discipline.value,
|
||||||
};
|
};
|
||||||
queryTaskListApi(params).then((res) => {
|
queryTaskListApi(params).then((res) => {
|
||||||
const list = res.data.data;
|
const list = res.data.data;
|
||||||
@@ -136,8 +139,16 @@ const getTableList = () => {
|
|||||||
total.value = res.data.total;
|
total.value = res.data.total;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const discipline = ref([]);
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getTableList();
|
// getTableList();
|
||||||
|
mittBus.on('current_discipline', (data) => {
|
||||||
|
discipline.value = data;
|
||||||
|
getTableList();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
mittBus.off('current_discipline');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
<script lang="ts" setup name="TopNav">
|
<script lang="ts" setup name="TopNav">
|
||||||
import { queryTaskListApi, getTaskCountApi } from '/@/spdm/api/spdm-task';
|
import { queryTaskListApi, getTaskCountApi, querySystemParamConfigureApi } from '/@/spdm/api/spdm-task';
|
||||||
import { getTenantAssignmentsListByUsername } from '/@/api/admin/user';
|
import { getTenantAssignmentsListByUsername } from '/@/api/admin/user';
|
||||||
import { useUserInfo } from '/@/stores/userInfo';
|
import { useUserInfo } from '/@/stores/userInfo';
|
||||||
|
import Cookies from 'js-cookie';
|
||||||
|
import mittBus from '/@/utils/mitt';
|
||||||
|
|
||||||
|
// 获取当前角色有权限的学科
|
||||||
|
const USER_INFO_DATA = Cookies.get('cid_user_info');
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { userInfos, userId } = useUserInfo();
|
const { userInfos, userId } = useUserInfo();
|
||||||
@@ -49,7 +54,7 @@ const getTenantList = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFocusCount = () => {
|
const getFocusCount = (discipline: any) => {
|
||||||
let idMap = [
|
let idMap = [
|
||||||
{ key: null, value: 'tag1' },
|
{ key: null, value: 'tag1' },
|
||||||
{ key: null, value: 'tag2' },
|
{ key: null, value: 'tag2' },
|
||||||
@@ -68,11 +73,12 @@ const getFocusCount = () => {
|
|||||||
sortOrder: 1,
|
sortOrder: 1,
|
||||||
type: 1,
|
type: 1,
|
||||||
idMap: idMap,
|
idMap: idMap,
|
||||||
|
filterDiscipline: discipline,
|
||||||
};
|
};
|
||||||
queryTaskListApi(params).then((res) => {
|
queryTaskListApi(params).then((res) => {
|
||||||
list.value[0].count = res.data.total;
|
list.value[0].count = res.data.total;
|
||||||
});
|
});
|
||||||
getTaskCountApi({ idMap, type: 0 }).then((res) => {
|
getTaskCountApi({ idMap, type: 0, filterDiscipline: discipline }).then((res) => {
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
list.value[1].count = data.todayTmrTasks || 0;
|
list.value[1].count = data.todayTmrTasks || 0;
|
||||||
list.value[2].count = data.inProgress || 0;
|
list.value[2].count = data.inProgress || 0;
|
||||||
@@ -80,14 +86,52 @@ const getFocusCount = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onActivated(() => {
|
// 获取角色拥有的学科
|
||||||
|
const getDisciplineList = async () => {
|
||||||
|
const roleCodes = JSON.parse(USER_INFO_DATA).roleCodes;
|
||||||
|
if (!roleCodes) return [];
|
||||||
|
// 统一处理为数组
|
||||||
|
const codes = Array.isArray(roleCodes) ? roleCodes : roleCodes.split(',');
|
||||||
|
const params = {
|
||||||
|
paramName: 'ROLE_DISCIPLINE',
|
||||||
|
};
|
||||||
|
const res: any = await querySystemParamConfigureApi(params);
|
||||||
|
if (res.code === 200) {
|
||||||
|
const values = res.data.values || [];
|
||||||
|
const list = values.map((item: any) => JSON.parse(item));
|
||||||
|
const allDisciplines: any[] = [];
|
||||||
|
const allSimulationType: any[] = [];
|
||||||
|
// 收集所有角色的学科、仿真类型
|
||||||
|
codes.forEach((roleCode: any) => {
|
||||||
|
const roleData = list.find((item: any) => item.role === roleCode.trim());
|
||||||
|
if (roleData?.discipline?.length) {
|
||||||
|
allDisciplines.push(...roleData.discipline);
|
||||||
|
}
|
||||||
|
if (roleData?.simulationType) {
|
||||||
|
allSimulationType.push(roleData.simulationType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 去重
|
||||||
|
const uniqueDisciplines = Array.from(new Set(allDisciplines));
|
||||||
|
const uniqueSimulationType = Array.from(new Set(allSimulationType));
|
||||||
|
const result = { simulationType: uniqueSimulationType, discipline: uniqueDisciplines };
|
||||||
|
// 获取关注任务数量
|
||||||
|
getFocusCount(result.discipline);
|
||||||
|
// 传递给其他组件
|
||||||
|
mittBus.emit('current_discipline', result.discipline);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const initData = () => {
|
||||||
getTenantList();
|
getTenantList();
|
||||||
getFocusCount();
|
getDisciplineList();
|
||||||
|
};
|
||||||
|
onActivated(() => {
|
||||||
|
initData();
|
||||||
});
|
});
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
getTenantList();
|
initData();
|
||||||
getFocusCount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
Reference in New Issue
Block a user