218 lines
4.8 KiB
Vue
Raw Normal View History

2025-10-15 14:07:39 +08:00
<template>
2026-04-02 16:20:33 +08:00
<PageContainer title="愉快政">
<CurrentSite />
2025-10-15 14:07:39 +08:00
<div class="content">
2025-10-16 15:04:54 +08:00
<van-grid :gutter="10" :column-num="3" class="grid">
2025-11-04 17:29:45 +08:00
<van-grid-item
2026-04-02 16:20:33 +08:00
class="grid-item"
v-for="item in gridItems"
:key="item.text"
:to="item.to"
>
<template #icon>
<img :src="item.icon" class="grid-icon" />
</template>
<template #text>
<span class="grid-text">{{ item.text }}</span>
</template>
</van-grid-item>
2025-10-15 14:07:39 +08:00
</van-grid>
</div>
2025-11-20 16:27:59 +08:00
<van-popup
:show="YHZConfirmpopup"
position="center"
round
close-on-click-overlay
:style="{ height: '20%', width: '80%' }"
@close="onYHZConfirmClose"
class="confirmpopup"
>
<div class="confirmpopup__content">
<h3>请在服务站授权定位</h3>
</div>
<div class="btn-box">
<van-button class="btn" @click="onYHZConfirmClose">取消</van-button>
<van-button class="btn" type="primary" @click="getLocation"
>授权定位</van-button
>
</div>
</van-popup>
2026-04-02 16:20:33 +08:00
</PageContainer>
2025-10-15 14:07:39 +08:00
</template>
<script setup>
2025-11-05 17:29:08 +08:00
import "vant/es/toast/style";
import "vant/es/popup/style";
2025-11-04 17:29:45 +08:00
import { ref, onMounted } from "vue";
2025-11-12 11:39:38 +08:00
import { useRouter, useRoute } from "vue-router";
2026-04-02 15:39:27 +08:00
import { useYHZStore } from "../stores/yhzStore";
2025-10-16 15:04:54 +08:00
import { showToast } from "vant";
2025-11-04 15:17:12 +08:00
import { request } from "../../../shared/utils/request";
2026-04-02 16:20:33 +08:00
import PageContainer from "@/components/PageContainer.vue";
import CurrentSite from "@/components/CurrentSite.vue";
import group63Icon from "@/assets/images/组 63.png";
import group105Icon from "@/assets/images/组 105.png";
import group10501Icon from "@/assets/images/组 105(1).png";
import group104Icon from "@/assets/images/组 104.png";
import group106Icon from "@/assets/images/组 106.png";
2025-10-15 14:07:39 +08:00
2025-10-16 15:04:54 +08:00
const router = useRouter();
2025-11-12 11:39:38 +08:00
const yhzinfo = ref({});
2026-04-02 15:39:27 +08:00
const yhzStore = useYHZStore();
2025-10-15 14:07:39 +08:00
2025-11-12 11:39:38 +08:00
const route = useRoute();
const token = route.query.token;
2025-11-20 16:27:59 +08:00
const YHZConfirmpopup = ref(false);
2025-11-12 11:39:38 +08:00
2026-04-02 16:20:33 +08:00
// 配置项
const gridItems = [
{
icon: group63Icon,
text: "设备管理",
to: {
name: "EquipManage",
params: { data: encodeURIComponent(JSON.stringify(yhzinfo.value)) },
},
},
{
icon: group10501Icon,
text: "物资管理",
to: {
name: "MaterialManage",
params: { data: encodeURIComponent(JSON.stringify(yhzinfo.value)) },
},
},
{
icon: group104Icon,
text: "人员管理",
to: {
name: "StaffManage",
params: { data: encodeURIComponent(JSON.stringify(yhzinfo.value)) },
},
},
{
icon: group106Icon,
text: "冰雪灾害",
to: {
name: "IceEventManage",
params: { data: encodeURIComponent(JSON.stringify(yhzinfo.value)) },
},
},
2026-04-07 14:26:35 +08:00
{
icon: group106Icon,
text: "灾害管理",
to: {
name: "DisasterManagement",
},
},
2026-04-02 16:20:33 +08:00
{
icon: group105Icon,
text: "预警信息",
to: {
name: "WarningMessage",
},
},
2026-04-07 14:39:16 +08:00
{
icon: group106Icon,
text: '恢复重建',
to: {
name: 'Rebuild',
}
}
2026-04-02 16:20:33 +08:00
];
2025-11-12 11:39:38 +08:00
// 获取当前登录用于就职的养护站信息
const getYHZinfo = async () => {
try {
const res = await request({
url: `/snow-ops-platform/yhz/getStationByUser`,
method: "GET",
});
if (res.code === "00000") {
yhzinfo.value = res.data[0];
2026-04-02 15:39:27 +08:00
yhzStore.setYHZInfo(res.data[0]);
2026-04-02 16:20:33 +08:00
// 更新配置项中的params确保使用最新的yhzinfo
gridItems.forEach(item => {
if (item.to.params && item.to.params.data) {
item.to.params.data = encodeURIComponent(JSON.stringify(yhzinfo.value));
}
});
2025-11-12 11:39:38 +08:00
} else {
throw new Error(res.message);
}
} catch (error) {
showToast({
message: error.message,
type: "fail",
});
}
};
2025-11-20 16:27:59 +08:00
const onYHZConfirmClose = () => {
YHZConfirmpopup.value = false;
};
2026-04-02 16:20:33 +08:00
const getLocation = () => {
// 定位逻辑
YHZConfirmpopup.value = false;
};
2025-11-12 11:39:38 +08:00
onMounted(async () => {
if (token) {
localStorage.setItem("token", token);
router.replace({ path: route.path }).then(() => {
window.location.reload();
});
}
await getYHZinfo();
2025-11-20 16:27:59 +08:00
if (
yhzinfo.value.isManager &&
(yhzinfo.value.jd === "" || yhzinfo.value.wd === "")
) {
YHZConfirmpopup.value = true;
}
2025-11-04 17:29:45 +08:00
});
2025-10-15 14:07:39 +08:00
const goToUser = () => {
2025-10-16 15:04:54 +08:00
router.push("/user");
};
2025-10-15 14:07:39 +08:00
</script>
2026-04-02 16:20:33 +08:00
<style lang="scss" scoped>
2025-11-20 16:27:59 +08:00
.btn-box {
width: 100%;
display: flex;
gap: 16px;
padding: 16px;
}
2025-10-15 14:07:39 +08:00
.btn {
2025-11-20 16:27:59 +08:00
width: 50%;
}
.confirmpopup__content {
padding: 20px;
2025-10-15 14:07:39 +08:00
}
2026-04-02 16:20:33 +08:00
.grid-icon {
width: 48px;
height: 48px;
object-fit: contain;
}
.grid-text {
font-size: 14px;
color: #323233;
}
:deep(.grid-item) {
.grid-text {
margin-top: 16px;
font-weight: 400;
font-size: 16px;
color: #333333;
line-height: 16px;
}
}
</style>