冰雪专题App端 物资管理 设备管理 详情页面完善 编辑功能修改

This commit is contained in:
huangchenhao 2025-11-13 10:59:57 +08:00
parent 81412db42f
commit 7bdc705e25
3 changed files with 301 additions and 92 deletions

View File

@ -63,8 +63,12 @@
<van-cell :title="'纳入市级补助范围: ' + equipmentDetailInfo.sfnrsjbz"> <van-cell :title="'纳入市级补助范围: ' + equipmentDetailInfo.sfnrsjbz">
</van-cell> </van-cell>
<van-cell :title="'辐射范围: ' + equipmentDetailInfo.fsfw"> </van-cell> <van-cell :title="'辐射范围: ' + equipmentDetailInfo.fsfw"> </van-cell>
<van-cell :title="'所属服务站: ' + equipmentDetailInfo.sbwz"> <van-cell :title="'所属服务站: ' + equipmentDetailInfo.yhzmc">
</van-cell> </van-cell>
<van-cell
v-if="equipmentDetailInfo.sbzt !== '完好'"
:title="equipmentDetailInfo.sbzt + '原因:' + latestStatusDesc"
/>
<van-cell :title="'备注: ' + equipmentDetailInfo.remark"> </van-cell> <van-cell :title="'备注: ' + equipmentDetailInfo.remark"> </van-cell>
</van-cell-group> </van-cell-group>
</div> </div>
@ -350,14 +354,17 @@
<h3>编辑设备信息</h3> <h3>编辑设备信息</h3>
<!-- 设备名称 --> <!-- 设备名称 -->
<van-field <van-field
v-model="editForm.sbmc" v-model="editForm.equipment.sbmc"
label="设备名称" label="设备名称"
placeholder="请输入设备名称" placeholder="请输入设备名称"
:rules="[{ required: true, message: '请填写设备名称' }]" :rules="[{ required: true, message: '请填写设备名称' }]"
/> maxlength="20"
show-word-limit
>
</van-field>
<!-- 设备大类 --> <!-- 设备大类 -->
<van-field <van-field
v-model="editForm.sbdl" v-model="editForm.equipment.sbdl"
is-link is-link
arrow-direction="down" arrow-direction="down"
label="设备大类" label="设备大类"
@ -367,7 +374,7 @@
/> />
<!-- 设备类型 --> <!-- 设备类型 -->
<van-field <van-field
v-model="editForm.sblx" v-model="editForm.equipment.sblx"
is-link is-link
arrow-direction="down" arrow-direction="down"
label="设备类型" label="设备类型"
@ -377,34 +384,34 @@
/> />
<!-- 设备编号 --> <!-- 设备编号 -->
<van-field <van-field
v-model="editForm.sbbh" v-model="editForm.equipment.sbbh"
label="设备编号" label="设备编号"
placeholder="请输入设备编号" placeholder="请输入设备编号"
:rules="[{ required: true, message: '请填写设备编号' }]" :rules="[{ required: true, message: '请填写设备编号' }]"
/> />
<!-- 设备型号 --> <!-- 设备型号 -->
<van-field <van-field
v-model="editForm.sbxh" v-model="editForm.equipment.sbxh"
label="设备型号" label="设备型号"
placeholder="请输入设备型号" placeholder="请输入设备型号"
:rules="[{ required: true, message: '请填写设备型号' }]" :rules="[{ required: true, message: '请填写设备型号' }]"
/> />
<!-- 经纬度 --> <!-- 经纬度 -->
<van-field <van-field
v-model="editForm.jd" v-model="editForm.equipment.jd"
label="设备经度" label="设备经度"
placeholder="请输入经度" placeholder="请输入经度"
type="number" type="number"
/> />
<van-field <van-field
v-model="editForm.wd" v-model="editForm.equipment.wd"
label="设备纬度" label="设备纬度"
placeholder="请输入纬度" placeholder="请输入纬度"
type="number" type="number"
/> />
<!-- 管理人员 --> <!-- 管理人员 -->
<van-field <van-field
v-model="editForm.glry" v-model="editForm.equipment.glry"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -414,7 +421,7 @@
/> />
<!-- 操作员 --> <!-- 操作员 -->
<van-field <van-field
v-model="editForm.czy" v-model="editForm.equipment.czy"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -424,14 +431,14 @@
/> />
<!-- 购买费用 --> <!-- 购买费用 -->
<van-field <van-field
v-model="editForm.gmfy" v-model="editForm.equipment.gmfy"
type="number" type="number"
label="购买费用(万元)" label="购买费用(万元)"
placeholder="请输入购买费用" placeholder="请输入购买费用"
/> />
<!-- 购置日期 --> <!-- 购置日期 -->
<van-field <van-field
v-model="editForm.gzrq" v-model="editForm.equipment.gzrq"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -440,27 +447,16 @@
@click="showTimePicker = true" @click="showTimePicker = true"
/> />
<!-- 设备状态 -->
<van-field
v-model="editForm.sbzt"
is-link
arrow-direction="down"
readonly
label="设备状态"
placeholder="请选择设备状态"
@click="showStatusPicker = true"
/>
<!-- 生产厂家 --> <!-- 生产厂家 -->
<van-field <van-field
v-model="editForm.sccj" v-model="editForm.equipment.sccj"
label="生产厂家" label="生产厂家"
placeholder="请输入生产厂家" placeholder="请输入生产厂家"
/> />
<!-- 是否应急设备 --> <!-- 是否应急设备 -->
<van-field <van-field
v-model="editForm.sfyjsb" v-model="editForm.equipment.sfyjsb"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -471,7 +467,7 @@
<!-- 是否纳入市级补助范围 --> <!-- 是否纳入市级补助范围 -->
<van-field <van-field
v-model="editForm.sfnrsjbz" v-model="editForm.equipment.sfnrsjbz"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -482,11 +478,26 @@
<!-- 辐射范围 --> <!-- 辐射范围 -->
<van-field <van-field
v-model="editForm.fsfw" v-model="editForm.equipment.fsfw"
label="辐射范围" label="辐射范围"
placeholder="请输入辐射范围" placeholder="请输入辐射范围"
/> />
<van-field label="设备照片" center>
<template #input>
<van-uploader
v-model="fileList"
@delete="handleDelete"
name="photos"
:file-list="fileList"
:file-type="['image/jpeg', 'image/png']"
:after-read="afterRead"
multiple
:max-count="6"
/>
</template>
</van-field>
<!-- 选择器弹窗 --> <!-- 选择器弹窗 -->
<!-- 设备大类弹窗 --> <!-- 设备大类弹窗 -->
<van-popup <van-popup
@ -568,22 +579,6 @@
/> />
</van-popup> </van-popup>
<!-- 设备状态弹窗 -->
<van-popup
:show="showStatusPicker"
round
position="bottom"
close-on-click-overlay
@close="showStatusPicker = false"
>
<van-picker
title="选择设备状态"
:columns="statusOptions"
@confirm="onStatusConfirm"
@cancel="showStatusPicker = false"
/>
</van-popup>
<!-- 是否应急设备弹窗 --> <!-- 是否应急设备弹窗 -->
<van-popup <van-popup
:show="showEmergencyPicker" :show="showEmergencyPicker"
@ -644,7 +639,7 @@
<script setup> <script setup>
import "vant/es/toast/style"; import "vant/es/toast/style";
import "vant/es/popup/style"; import "vant/es/popup/style";
import { ref, onMounted, toRaw, reactive } from "vue"; import { ref, onMounted, toRaw, reactive, computed } from "vue";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import { showToast, showLoadingToast, showImagePreview } from "vant"; import { showToast, showLoadingToast, showImagePreview } from "vant";
import { request } from "../../../../shared/utils/request"; import { request } from "../../../../shared/utils/request";
@ -666,6 +661,7 @@ const equipmentInfo = ref({});
const yhzInfo = ref({}); const yhzInfo = ref({});
const equipmentDetailInfo = ref({}); const equipmentDetailInfo = ref({});
const photos = ref([]); const photos = ref([]);
const statusList = ref([]);
// //
const getEquipmentDetailInfo = async () => { const getEquipmentDetailInfo = async () => {
@ -677,6 +673,7 @@ const getEquipmentDetailInfo = async () => {
if (res.code && res.code === "00000") { if (res.code && res.code === "00000") {
equipmentDetailInfo.value = res.data.equipment; equipmentDetailInfo.value = res.data.equipment;
photos.value = res.data.photos; photos.value = res.data.photos;
statusList.value = res.data.statusList;
console.log("设备详情", toRaw(equipmentDetailInfo.value)); console.log("设备详情", toRaw(equipmentDetailInfo.value));
} else { } else {
throw new Error(res.data.message); throw new Error(res.data.message);
@ -711,12 +708,12 @@ const onScrapConfirm = async () => {
try { try {
console.log("equipmentDetailInfo", toRaw(equipmentDetailInfo.value)); console.log("equipmentDetailInfo", toRaw(equipmentDetailInfo.value));
const res = await request({ const res = await request({
url: `/snow-ops-platform/yjsb/update`, url: `/snow-ops-platform/yjsb/updateEquipmentStatus`,
method: "POST", method: "POST",
data: { data: {
...equipmentDetailInfo.value, equipmentId: equipmentDetailInfo.value.rid,
sbzt: "报废", equipmentStatus: "报废",
remark: scrapReason.value, statusDesc: scrapReason.value,
}, },
}); });
if (res.code && res.code === "00000") { if (res.code && res.code === "00000") {
@ -724,7 +721,7 @@ const onScrapConfirm = async () => {
router.push({ router.push({
name: "EquipManage", name: "EquipManage",
params: { params: {
data: encodeURIComponent(JSON.stringify(equipmentInfo.value)), data: encodeURIComponent(JSON.stringify(yhzInfo.value)),
}, },
}); });
} else { } else {
@ -747,12 +744,12 @@ const brokenReason = ref(""); // 损坏原因
const onBrokenConfirm = async () => { const onBrokenConfirm = async () => {
try { try {
const res = await request({ const res = await request({
url: `/snow-ops-platform/yjsb/update`, url: `/snow-ops-platform/yjsb/updateEquipmentStatus`,
method: "POST", method: "POST",
data: { data: {
...equipmentDetailInfo.value, equipmentId: equipmentDetailInfo.value.rid,
sbzt: "损坏", // equipmentStatus: "损坏",
remark: brokenReason.value, statusDesc: brokenReason.value,
}, },
}); });
if (res.code && res.code === "00000") { if (res.code && res.code === "00000") {
@ -760,7 +757,7 @@ const onBrokenConfirm = async () => {
router.push({ router.push({
name: "EquipManage", name: "EquipManage",
params: { params: {
data: encodeURIComponent(JSON.stringify(equipmentInfo.value)), data: encodeURIComponent(JSON.stringify(yhzInfo.value)),
}, },
}); });
} else { } else {
@ -830,9 +827,10 @@ const onRemarkConfirm = async () => {
url: "/snow-ops-platform/yjsb/update", url: "/snow-ops-platform/yjsb/update",
method: "POST", method: "POST",
data: { data: {
...equipmentDetailInfo.value, equipment: {
...equipmentDetailInfo.value,
remark: equipmentDetailInfo.value.remark, },
photos: photos.value,
}, },
}); });
if (res.code && res.code === "00000") { if (res.code && res.code === "00000") {
@ -856,10 +854,53 @@ const onRemarkPopupClose = () => {
const showEditPopup = ref(false); const showEditPopup = ref(false);
// //
const editForm = reactive({}); const editForm = reactive({});
//
const onEditPopupOpen = () => {
Object.assign(editForm, equipmentDetailInfo.value);
//
const getPersonList = async () => {
try {
const data = {
pageNum: 1,
pageSize: 9999,
yhzid: yhzInfo.value.id,
};
const res = await request({
url: "/snow-ops-platform/yhzry/list",
method: "get",
params: data,
});
if (res.code === "00000") {
adminOptions.value = res.data.records.map((item) => ({
text: item.xm,
value: item.userId,
}));
operatorOptions.value = res.data.records.map((item) => ({
text: item.xm,
value: item.userId,
}));
} else {
throw new Error("人员信息获取失败");
}
} catch (error) {
console.log(error);
showToast({
type: "fail",
message: error.message,
});
}
};
//
const onEditPopupOpen = async () => {
await getPersonList();
Object.assign(editForm, {
equipment: equipmentDetailInfo.value,
photos: photos.value,
});
fileList.value = photos.value.map((photo) => ({
url: photo.photoUrl, // URL
status: "done", //
message: "上传成功", //
serverUrl: photo.photoUrl, // URL
}));
showEditPopup.value = true; showEditPopup.value = true;
}; };
// //
@ -917,7 +958,7 @@ const onCategoryConfirm = (value) => {
showCategoryPicker.value = false; showCategoryPicker.value = false;
categoryField.value.focus(); categoryField.value.focus();
} else { } else {
editForm.sbdl = value.selectedValues[0]; editForm.equipment.sbdl = value.selectedValues[0];
showCategoryPicker.value = false; showCategoryPicker.value = false;
} }
}; };
@ -926,32 +967,36 @@ const onTypeConfirm = (value) => {
showTypePicker.value = false; showTypePicker.value = false;
typeField.value.focus(); typeField.value.focus();
} else { } else {
editForm.sblx = value.selectedValues[0]; editForm.equipment.sblx = value.selectedValues[0];
showTypePicker.value = false; showTypePicker.value = false;
} }
}; };
// //
const showAdminPicker = ref(false); const showAdminPicker = ref(false);
const adminOptions = [ const adminOptions = ref([]);
{ text: "管理员1", value: "管理员1" },
{ text: "管理员2", value: "管理员2" },
{ text: "管理员3", value: "管理员3" },
];
const onAdminConfirm = (value) => { const onAdminConfirm = (value) => {
editForm.glry = value.selectedValues[0]; const selectedOption = adminOptions.value.find(
(opt) => opt.value === value.selectedValues[0]
);
if (selectedOption) {
editForm.equipment.glry = selectedOption.text;
editForm.equipment.glryid = selectedOption.value;
}
showAdminPicker.value = false; showAdminPicker.value = false;
}; };
// //
const showOperatorPicker = ref(false); const showOperatorPicker = ref(false);
const operatorOptions = [ const operatorOptions = ref([]);
{ text: "操作员1", value: "操作员1" },
{ text: "操作员2", value: "操作员2" },
{ text: "操作员3", value: "操作员3" },
];
const operatorConfirm = (value) => { const operatorConfirm = (value) => {
editForm.czy = value.selectedValues[0]; const selectedOption = operatorOptions.value.find(
(opt) => opt.value === value.selectedValues[0]
);
if (selectedOption) {
editForm.equipment.czy = selectedOption.text;
editForm.equipment.czyid = selectedOption.value;
}
showOperatorPicker.value = false; showOperatorPicker.value = false;
}; };
@ -968,16 +1013,19 @@ const onDateConfirm = ({ selectedValues }) => {
}; };
// //
const showStatusPicker = ref(false); const latestStatusDesc = computed(() => {
const statusOptions = [ if (
{ text: "完好", value: "完好" }, !equipmentDetailInfo.value.sbzt ||
{ text: "损坏", value: "损坏" }, equipmentDetailInfo.value.sbzt === "完好"
{ text: "报废", value: "报废" }, )
]; return "";
const onStatusConfirm = (value) => {
editForm.sbzt = value.selectedValues[0]; const records = statusList.value
showStatusPicker.value = false; .filter((item) => item.equipmentStatus === equipmentDetailInfo.value.sbzt)
}; .sort((a, b) => new Date(b.reportTime) - new Date(a.reportTime));
return records.length > 0 ? `${records[0].statusDesc}` : "暂无相关记录";
});
// //
const showEmergencyPicker = ref(false); const showEmergencyPicker = ref(false);
@ -1001,11 +1049,62 @@ const onSubsidyConfirm = (value) => {
showSubsidyPicker.value = false; showSubsidyPicker.value = false;
}; };
//
const fileList = ref([]);
//
const handleDelete = (file) => {
if (file.serverUrl) {
const index = editForm.photos.findIndex(
(p) => p.photoUrl === file.serverUrl
);
if (index !== -1) {
editForm.photos.splice(index, 1);
}
}
};
//
const afterRead = async (file) => {
try {
const toast = showLoadingToast({
message: "上传中...",
forbidClick: true,
duration: 0, // 0
});
const formData = new FormData();
formData.append("file", file.file);
const res = await request({
url: "/snow-ops-platform/file/upload",
method: "post",
data: formData,
});
toast.close();
if (res.code === "00000") {
editForm.photos.push({ photoUrl: res.data });
const index = fileList.value.findIndex((f) => f.file === file.file);
if (index !== -1) {
fileList.value[index].serverUrl = res.data;
}
console.log("editForm.photos", toRaw(editForm.photos));
console.log("fileList.value", fileList.value);
} else {
throw new Error(res.message);
}
} catch (error) {
toast.close();
showToast({
type: "fail",
message: error.message,
});
}
};
// //
const onEditSubmit = async () => { const onEditSubmit = async () => {
try { try {
showLoadingToast({ message: "提交中...", forbidClick: true }); showLoadingToast({ message: "提交中...", forbidClick: true });
// console.log('editForm',toRaw(editForm)) console.log('editForm',toRaw(editForm))
const res = await request({ const res = await request({
url: "/snow-ops-platform/yjsb/update", url: "/snow-ops-platform/yjsb/update",

View File

@ -28,10 +28,72 @@
<van-cell :title="'物资经度: ' + wzDetailData.jd"> </van-cell> <van-cell :title="'物资经度: ' + wzDetailData.jd"> </van-cell>
<van-cell :title="'物资纬度: ' + wzDetailData.wd"> </van-cell> <van-cell :title="'物资纬度: ' + wzDetailData.wd"> </van-cell>
<van-cell :title="'负责人: ' + wzDetailData.fzr"> </van-cell> <van-cell :title="'负责人: ' + wzDetailData.fzr"> </van-cell>
<van-cell :title="'入库日期: ' + wzDetailData.rksj"> </van-cell> <van-cell
:title="'入库日期: ' + (wzDetailData.rkrq?.split(' ')[0] || '')"
>
</van-cell>
<van-cell :title="'所属养护站: ' + wzDetailData.yhzMc"> </van-cell> <van-cell :title="'所属养护站: ' + wzDetailData.yhzMc"> </van-cell>
<van-cell :title="'备注: ' + wzDetailData.remark"> </van-cell> <van-cell :title="'备注: ' + wzDetailData.remark"> </van-cell>
</van-cell-group> </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>
</div> </div>
</div> </div>
</template> </template>
@ -96,6 +158,43 @@ const showImage = (photos) => {
closeable: true, 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",
});
}
};
</script> </script>
<style scoped> <style scoped>
@ -104,7 +203,7 @@ const showImage = (photos) => {
} }
.content { .content {
padding: 16px; padding: 16px 16px 80px 16px;
} }
.grid { .grid {
@ -131,5 +230,17 @@ const showImage = (photos) => {
.status-danger { .status-danger {
background-color: #ee0a24; 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;
}
</style> </style>

View File

@ -34,12 +34,11 @@
> >
</van-cell> </van-cell>
</van-cell-group> </van-cell-group>
<van-button type="primary" class="add-btn" icon="plus" @click="handleAdd">
添加物资
</van-button>
</div> </div>
<van-button type="primary" class="add-btn" icon="plus" @click="handleAdd">
添加物资
</van-button>
<!-- 弹出层 --> <!-- 弹出层 -->
<van-popup <van-popup
:show="showPopup" :show="showPopup"