heli-mes/mes-ui/mini-app/src/pages/index/index.vue

225 lines
6.0 KiB
Vue
Raw Normal View History

2025-01-10 08:50:29 +08:00
<script setup lang="ts">
2025-06-17 20:47:31 +08:00
import { onLoad, onShow } from "@dcloudio/uni-app";
import { useLoginStore } from "@/stores/modules/login";
import { computed, ref, reactive } from "vue";
import CustomNavbar from "./components/CustomNavbar.vue";
import CategoryPanel from "./components/CategoryPanel.vue";
import footRight from "./components/footRight.vue";
import PageSkeleton from "./components/PageSkeleton.vue";
2025-07-12 20:15:57 +08:00
import {
countReview,
getHomeCategoryAPI,
getUnreadMessage,
countUnqualifiedNotification,
2025-08-27 18:07:43 +08:00
countUnqualifiedNotificationConfirm, getReceivingGoodsMessage
2025-07-12 20:15:57 +08:00
} from "@/services/home";
2025-08-27 18:07:43 +08:00
import {getReceivingGoods} from "@/services/productionReport";
2025-01-10 08:50:29 +08:00
// 获取前台分类数据
const categoryList = ref([
{
2025-06-17 20:47:31 +08:00
path: "approveOrder",
name: "订单批准",
2025-01-10 08:50:29 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/approveOrder.png",
defaultImgUrl: "/static/images/approveOrder-default.png",
2025-01-10 08:50:29 +08:00
},
{
2025-06-17 20:47:31 +08:00
path: "unqualifiedNotification",
name: "品质异常通知",
2025-01-10 08:50:29 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/unqualifiedNotification.png",
2025-08-30 15:44:28 +08:00
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-01-10 08:50:29 +08:00
},
{
2025-06-17 20:47:31 +08:00
path: "productionReport",
name: "生产报工",
2025-01-10 08:50:29 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/productionReport.png",
defaultImgUrl: "/static/images/productionReport-default.png",
2025-01-10 08:50:29 +08:00
},
{
2025-06-17 20:47:31 +08:00
path: "assembleReport",
name: "装配报工",
2025-01-10 08:50:29 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/assembleReport.png",
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-01-10 08:50:29 +08:00
},
2025-01-10 17:33:02 +08:00
{
2025-06-17 20:47:31 +08:00
path: "pgMaster",
name: "过程检报工",
2025-07-14 19:07:14 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/guochengjian.png",
defaultImgUrl: "/static/images/assembleReport-default.png",
},
{
path: "zjPgMaster",
name: "终检报工",
2025-07-14 19:07:14 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/zhongjian.png",
defaultImgUrl: "/static/images/assembleReport-default.png",
},
{
path: "moJuSheJiReport",
name: "进度上报",
2025-07-14 19:07:14 +08:00
auth: false,
2025-06-17 20:47:31 +08:00
imgUrl: "/static/images/mojusheji.png",
defaultImgUrl: "/static/images/assembleReport-default.png",
},
2025-06-30 23:28:28 +08:00
{
path: "cgdsp",
name: "采购单审批",
2025-07-14 19:07:14 +08:00
auth: false,
2025-06-30 23:28:28 +08:00
imgUrl: "/static/images/pic_cgdsp.png",
2025-07-11 13:54:22 +08:00
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-06-30 23:28:28 +08:00
},
2025-06-17 20:47:31 +08:00
{
path: "messageNotification",
name: "消息通知",
2025-07-14 19:07:14 +08:00
auth: false,
2025-06-25 22:31:55 +08:00
imgUrl: "/static/images/pic_message.png",
2025-07-11 13:54:22 +08:00
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-06-17 20:47:31 +08:00
unReadCount: 0, // 未读消息数
},
2025-07-12 20:15:57 +08:00
{
path: "unqualifiedNotificationConfirm",
name: "品质异常确认",
2025-07-14 19:07:14 +08:00
auth: false,
2025-07-25 15:06:49 +08:00
imgUrl: "/static/images/unqualifiedNotificationConfirm.png",
2025-08-30 15:44:28 +08:00
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-07-12 20:15:57 +08:00
},
2025-08-27 18:07:43 +08:00
{
path: "receivingGoods",
2025-08-27 23:26:28 +08:00
name: "采购收货",
2025-08-27 18:07:43 +08:00
auth: false,
2025-08-27 23:26:28 +08:00
imgUrl: "/static/images/pic_cgsh.png",
defaultImgUrl: "/static/images/assembleReport-default.png",
2025-08-27 18:07:43 +08:00
},
2025-07-14 19:07:14 +08:00
]);
const categoryList1 = ref([
2025-06-17 20:47:31 +08:00
]);
const loginStore = useLoginStore();
2025-01-10 08:50:29 +08:00
const isLogin = computed(() => {
2025-06-17 20:47:31 +08:00
const accessToken = loginStore.userInfo?.accessToken;
const storage_token = uni.getStorageSync("storage_userInfo")?.accessToken;
return !!accessToken || !!storage_token;
});
2025-01-10 08:50:29 +08:00
// 是否加载中标记
2025-06-17 20:47:31 +08:00
const isLoading = ref(false);
2025-01-10 08:50:29 +08:00
// 页面加载
2025-06-17 20:47:31 +08:00
onShow(async () => {
2025-01-10 08:50:29 +08:00
if (isLogin.value) {
2025-06-17 20:47:31 +08:00
await getHomeCategory();
2025-01-10 08:50:29 +08:00
} else {
categoryList.value.forEach((e) => {
2025-06-17 20:47:31 +08:00
e.auth = true;
});
2025-01-10 08:50:29 +08:00
}
2025-06-17 20:47:31 +08:00
});
2025-01-10 08:50:29 +08:00
const getHomeCategory = async () => {
2025-06-17 20:47:31 +08:00
isLoading.value = true;
const params = {};
const data = await getHomeCategoryAPI(params);
const menus = data?.menus.find((e) => e.path == "/applet")?.children || [];
2025-01-10 08:50:29 +08:00
if (menus.length) {
2025-06-17 20:47:31 +08:00
const arr = [];
2025-01-10 08:50:29 +08:00
categoryList.value.forEach((e) => {
2025-07-11 13:54:22 +08:00
// if (e.path === 'cgdsp') return;
2025-06-17 20:47:31 +08:00
const target = menus.find((q) => q.path == e.path);
e.auth = !!target;
});
2025-07-14 19:07:14 +08:00
console.log()
2025-06-17 20:47:31 +08:00
}
2025-07-14 19:07:14 +08:00
categoryList1.value = categoryList.value.filter(item => item.auth == true);
2025-07-11 13:54:22 +08:00
2025-06-17 20:47:31 +08:00
const unReadCount = await getUnreadMessage();
2025-07-03 18:39:15 +08:00
const count = await countReview();
2025-07-11 14:27:24 +08:00
var query ={
queryType:2,
}
2025-07-12 20:15:57 +08:00
var query1 ={
queryType:1,
}
2025-07-11 13:57:06 +08:00
const unqualifiedNotificationCount = await countUnqualifiedNotification(query);
2025-07-12 20:15:57 +08:00
const unqualifiedNotificationCountConfirm = await countUnqualifiedNotificationConfirm(query1);
2025-08-27 18:07:43 +08:00
const ReceivingGoodsMessage = await getReceivingGoodsMessage();
2025-06-17 20:47:31 +08:00
// 把未读数放到消息通知项
2025-07-14 19:07:14 +08:00
const cgdsp = categoryList1.value.find(
2025-07-03 18:39:15 +08:00
(e) => e.path === "cgdsp"
);
2025-08-27 18:07:43 +08:00
const receivingGoods = categoryList1.value.find(
(e) => e.path === "receivingGoods"
);
2025-07-14 19:07:14 +08:00
const msgItem = categoryList1.value.find(
2025-07-03 18:39:15 +08:00
(e) => e.path === "messageNotification"
2025-06-17 20:47:31 +08:00
);
2025-07-14 19:07:14 +08:00
const unqualifiedNotificationItem = categoryList1.value.find(
2025-07-11 13:57:06 +08:00
(e) => e.path === "unqualifiedNotification"
);
2025-07-14 19:07:14 +08:00
const unqualifiedNotificationConfirm = categoryList1.value.find(
2025-07-12 20:15:57 +08:00
(e) => e.path === "unqualifiedNotificationConfirm"
);
2025-08-27 18:07:43 +08:00
if (receivingGoods){
receivingGoods.unReadCount = ReceivingGoodsMessage;
}
2025-07-03 18:39:15 +08:00
if (cgdsp){
cgdsp.unReadCount = count;
2025-07-11 13:54:22 +08:00
// cgdsp.auth=true
2025-07-03 18:39:15 +08:00
}
2025-06-17 20:47:31 +08:00
if (msgItem) {
msgItem.unReadCount = unReadCount;
2025-07-11 13:54:22 +08:00
// msgItem.auth=true
2025-01-10 08:50:29 +08:00
}
2025-07-11 13:57:06 +08:00
if(unqualifiedNotificationItem){
unqualifiedNotificationItem.unReadCount = unqualifiedNotificationCount
}
2025-07-12 20:15:57 +08:00
if(unqualifiedNotificationConfirm){
unqualifiedNotificationConfirm.unReadCount = unqualifiedNotificationCountConfirm
}
2025-07-11 13:57:06 +08:00
2025-01-10 08:50:29 +08:00
if (loginStore.userInfo.userId) {
const obj = {
...loginStore.userInfo,
2025-06-17 20:47:31 +08:00
nickname: data.user.nickname,
};
loginStore.setInfo(obj);
2025-01-10 08:50:29 +08:00
}
2025-06-17 20:47:31 +08:00
isLoading.value = false;
};
2025-01-10 08:50:29 +08:00
</script>
<template>
<view class="viewport">
<template v-if="isLoading">
<PageSkeleton />
</template>
<template v-else>
<CustomNavbar />
<view class="cont">
2025-07-14 19:07:14 +08:00
<CategoryPanel :list="categoryList1" />
2025-01-10 08:50:29 +08:00
<footRight />
</view>
</template>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
2025-06-17 20:47:31 +08:00
background-color: #f8fafd;
2025-01-10 08:50:29 +08:00
}
.viewport {
width: 100vw;
height: 100vh;
margin-bottom: 300rpx;
.cont {
//margin: 100rpx 0;
}
}
</style>