bxztApp/packages/mobile/src/views/Material/MaterialDetails.vue

244 lines
6.1 KiB
Vue
Raw Normal View History

2025-11-05 17:29:08 +08:00
<template>
2025-11-06 11:35:29 +08:00
<div class="home">
<van-nav-bar title="物资管理" fixed left-arrow @click-left="onClickLeft" />
<van-cell-group>
<van-cell title="当前站点" :value="yhzDetail.mc" />
</van-cell-group>
<div class="content">
2025-11-05 17:29:08 +08:00
<van-cell-group>
2025-11-06 11:35:29 +08:00
<van-cell
title="物资信息"
style="font-size: 18px; font-weight: bold; line-height: inherit"
>
</van-cell>
<van-cell :title="'物资名称: ' + wzDetailData.wzmc">
<template #right-icon>
<van-image
:src="photos[0]?.photoUrl"
fit="cover"
width="100px"
@click="showImage(photos)"
></van-image>
</template>
</van-cell>
<van-cell :title="'余量: ' + wzDetailData.ye + ' ' + wzDetailData.dw">
</van-cell>
<van-cell :title="'物资经度: ' + wzDetailData.jd"> </van-cell>
<van-cell :title="'物资纬度: ' + wzDetailData.wd"> </van-cell>
2025-11-06 11:35:29 +08:00
<van-cell :title="'负责人: ' + wzDetailData.fzr"> </van-cell>
<van-cell
:title="'入库日期: ' + (wzDetailData.rkrq?.split(' ')[0] || '')"
>
</van-cell>
<van-cell :title="'所属养护站: ' + wzDetailData.yhzMc"> </van-cell>
<van-cell :title="'备注: ' + wzDetailData.remark"> </van-cell>
2025-11-05 17:29:08 +08:00
</van-cell-group>
<van-button type="primary" class="remark-btn" @click="handleRemarkOpen">
备注
</van-button>
<van-popup
:show="showRemarkPopup"
position="bottom"
closeable
close-on-click-overlay
:style="{ height: '30%' }"
@close="onRemarkPopupClose"
>
<div
style="
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 0 16px;
"
>
<h1
style="
margin: 0 0 12px 0;
font-size: 18px;
color: #333;
text-align: center;
"
>
备注信息
</h1>
<van-field
v-model="wzDetailData.remark"
placeholder="请输入备注"
style="
width: 100%;
margin-bottom: 16px;
border-radius: 8px;
background: #f7f8fa;
"
/>
<div style="display: flex; gap: 20px; width: 100%">
<van-button
type="default"
style="flex: 1; border-radius: 8px"
@click="onRemarkPopupClose"
>
取消
</van-button>
<van-button
type="primary"
style="flex: 1; border-radius: 8px"
@click="onRemarkConfirm"
>
确认
</van-button>
</div>
</div>
</van-popup>
2025-11-05 17:29:08 +08:00
</div>
2025-11-06 11:35:29 +08:00
</div>
</template>
2025-11-05 17:29:08 +08:00
<script setup>
2025-11-06 11:35:29 +08:00
import { ref, onMounted, toRaw, reactive } from "vue";
import { useRouter, useRoute } from "vue-router";
import { showToast, showLoadingToast, showImagePreview } from "vant";
2025-11-06 11:35:29 +08:00
import { request } from "../../../../shared/utils/request";
2025-11-05 17:29:08 +08:00
2025-11-06 11:35:29 +08:00
const router = useRouter();
const route = useRoute();
2025-11-05 17:58:35 +08:00
2025-11-06 11:35:29 +08:00
const yhzDetail = ref({});
const wzData = ref([]);
const wzDetailData = ref({}); // 物资详情数据
const photos = ref([]); // 物资图片数据
2025-11-06 11:35:29 +08:00
onMounted(() => {
const data = JSON.parse(decodeURIComponent(route.params.data));
yhzDetail.value = data.yhzDetail;
wzData.value = data.material;
console.log("传递过来的参数:", data);
getwzDetail();
});
// 获取物资详情
const getwzDetail = async () => {
try {
const res = await request({
url: `/snow-ops-platform/yjwz/getById?rid=${wzData.value.rid}`,
method: "GET",
2025-11-05 17:29:08 +08:00
});
2025-11-06 11:35:29 +08:00
if (res.code && res.code === "00000") {
2025-11-10 18:07:30 +08:00
wzDetailData.value = res.data.material;
photos.value = res.data.photos;
2025-11-06 11:35:29 +08:00
} else {
throw new Error(res.message);
}
} catch (error) {
showToast({
message: error.message,
type: "error",
});
console.log("error", error);
}
};
const onClickLeft = () => {
router.push({
name: "MaterialManage",
params: { data: encodeURIComponent(JSON.stringify(yhzDetail.value)) },
});
};
const showImage = (photos) => {
const photosArr = photos.map((item) => item.photoUrl);
showImagePreview({
images: photosArr,
closeable: true,
});
};
// 编辑备注相关
const showRemarkPopup = ref(false);
const handleRemarkOpen = () => {
showRemarkPopup.value = true;
};
const onRemarkPopupClose = () => {
getwzDetail();
showRemarkPopup.value = false;
};
const onRemarkConfirm = async () => {
try {
const data = {
material: wzDetailData.value,
photos: photos.value,
},
res = await request({
url: `/snow-ops-platform/yjwz/update`,
method: "POST",
data,
});
if (res.code && res.code === "00000") {
showToast({
message: "备注信息保存成功",
type: "success",
});
onRemarkPopupClose();
} else {
throw new Error(res.message);
}
} catch (error) {
showToast({
message: error.message,
type: "fail",
});
}
};
2025-11-06 11:35:29 +08:00
</script>
2025-11-05 17:29:08 +08:00
<style scoped>
2025-11-06 11:35:29 +08:00
.home {
padding-top: var(--van-nav-bar-height); /* 自动匹配导航栏高度 */
}
.content {
padding: 16px 16px 80px 16px;
2025-11-06 11:35:29 +08:00
}
.grid {
margin-top: 16px;
}
.btn {
margin-top: 24px;
}
.status-tag {
display: inline-block;
padding: 3px 8px;
border-radius: 4px;
color: white;
font-size: 12px;
}
.status-good {
background-color: #07c160;
}
.status-warning {
background-color: #ff976a;
}
.status-danger {
background-color: #ee0a24;
}
.remark-btn {
position: fixed;
bottom: 20px;
left: 16px;
right: 16px;
width: calc(100% - 32px);
margin: 0 auto;
border-radius: 24px;
font-size: 16px;
height: 44px;
z-index: 999;
}
2025-11-06 11:35:29 +08:00
</style>
2025-11-05 17:29:08 +08:00