冰雪专题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>
<van-cell :title="'辐射范围: ' + equipmentDetailInfo.fsfw"> </van-cell>
<van-cell :title="'所属服务站: ' + equipmentDetailInfo.sbwz">
<van-cell :title="'所属服务站: ' + equipmentDetailInfo.yhzmc">
</van-cell>
<van-cell
v-if="equipmentDetailInfo.sbzt !== '完好'"
:title="equipmentDetailInfo.sbzt + '原因:' + latestStatusDesc"
/>
<van-cell :title="'备注: ' + equipmentDetailInfo.remark"> </van-cell>
</van-cell-group>
</div>
@ -350,14 +354,17 @@
<h3>编辑设备信息</h3>
<!-- 设备名称 -->
<van-field
v-model="editForm.sbmc"
v-model="editForm.equipment.sbmc"
label="设备名称"
placeholder="请输入设备名称"
:rules="[{ required: true, message: '请填写设备名称' }]"
/>
maxlength="20"
show-word-limit
>
</van-field>
<!-- 设备大类 -->
<van-field
v-model="editForm.sbdl"
v-model="editForm.equipment.sbdl"
is-link
arrow-direction="down"
label="设备大类"
@ -367,7 +374,7 @@
/>
<!-- 设备类型 -->
<van-field
v-model="editForm.sblx"
v-model="editForm.equipment.sblx"
is-link
arrow-direction="down"
label="设备类型"
@ -377,34 +384,34 @@
/>
<!-- 设备编号 -->
<van-field
v-model="editForm.sbbh"
v-model="editForm.equipment.sbbh"
label="设备编号"
placeholder="请输入设备编号"
:rules="[{ required: true, message: '请填写设备编号' }]"
/>
<!-- 设备型号 -->
<van-field
v-model="editForm.sbxh"
v-model="editForm.equipment.sbxh"
label="设备型号"
placeholder="请输入设备型号"
:rules="[{ required: true, message: '请填写设备型号' }]"
/>
<!-- 经纬度 -->
<van-field
v-model="editForm.jd"
v-model="editForm.equipment.jd"
label="设备经度"
placeholder="请输入经度"
type="number"
/>
<van-field
v-model="editForm.wd"
v-model="editForm.equipment.wd"
label="设备纬度"
placeholder="请输入纬度"
type="number"
/>
<!-- 管理人员 -->
<van-field
v-model="editForm.glry"
v-model="editForm.equipment.glry"
is-link
arrow-direction="down"
readonly
@ -414,7 +421,7 @@
/>
<!-- 操作员 -->
<van-field
v-model="editForm.czy"
v-model="editForm.equipment.czy"
is-link
arrow-direction="down"
readonly
@ -424,14 +431,14 @@
/>
<!-- 购买费用 -->
<van-field
v-model="editForm.gmfy"
v-model="editForm.equipment.gmfy"
type="number"
label="购买费用(万元)"
placeholder="请输入购买费用"
/>
<!-- 购置日期 -->
<van-field
v-model="editForm.gzrq"
v-model="editForm.equipment.gzrq"
is-link
arrow-direction="down"
readonly
@ -440,27 +447,16 @@
@click="showTimePicker = true"
/>
<!-- 设备状态 -->
<van-field
v-model="editForm.sbzt"
is-link
arrow-direction="down"
readonly
label="设备状态"
placeholder="请选择设备状态"
@click="showStatusPicker = true"
/>
<!-- 生产厂家 -->
<van-field
v-model="editForm.sccj"
v-model="editForm.equipment.sccj"
label="生产厂家"
placeholder="请输入生产厂家"
/>
<!-- 是否应急设备 -->
<van-field
v-model="editForm.sfyjsb"
v-model="editForm.equipment.sfyjsb"
is-link
arrow-direction="down"
readonly
@ -471,7 +467,7 @@
<!-- 是否纳入市级补助范围 -->
<van-field
v-model="editForm.sfnrsjbz"
v-model="editForm.equipment.sfnrsjbz"
is-link
arrow-direction="down"
readonly
@ -482,11 +478,26 @@
<!-- 辐射范围 -->
<van-field
v-model="editForm.fsfw"
v-model="editForm.equipment.fsfw"
label="辐射范围"
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
@ -568,22 +579,6 @@
/>
</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
:show="showEmergencyPicker"
@ -644,7 +639,7 @@
<script setup>
import "vant/es/toast/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 { showToast, showLoadingToast, showImagePreview } from "vant";
import { request } from "../../../../shared/utils/request";
@ -666,6 +661,7 @@ const equipmentInfo = ref({});
const yhzInfo = ref({});
const equipmentDetailInfo = ref({});
const photos = ref([]);
const statusList = ref([]);
//
const getEquipmentDetailInfo = async () => {
@ -677,6 +673,7 @@ const getEquipmentDetailInfo = async () => {
if (res.code && res.code === "00000") {
equipmentDetailInfo.value = res.data.equipment;
photos.value = res.data.photos;
statusList.value = res.data.statusList;
console.log("设备详情", toRaw(equipmentDetailInfo.value));
} else {
throw new Error(res.data.message);
@ -711,12 +708,12 @@ const onScrapConfirm = async () => {
try {
console.log("equipmentDetailInfo", toRaw(equipmentDetailInfo.value));
const res = await request({
url: `/snow-ops-platform/yjsb/update`,
url: `/snow-ops-platform/yjsb/updateEquipmentStatus`,
method: "POST",
data: {
...equipmentDetailInfo.value,
sbzt: "报废",
remark: scrapReason.value,
equipmentId: equipmentDetailInfo.value.rid,
equipmentStatus: "报废",
statusDesc: scrapReason.value,
},
});
if (res.code && res.code === "00000") {
@ -724,7 +721,7 @@ const onScrapConfirm = async () => {
router.push({
name: "EquipManage",
params: {
data: encodeURIComponent(JSON.stringify(equipmentInfo.value)),
data: encodeURIComponent(JSON.stringify(yhzInfo.value)),
},
});
} else {
@ -747,12 +744,12 @@ const brokenReason = ref(""); // 损坏原因
const onBrokenConfirm = async () => {
try {
const res = await request({
url: `/snow-ops-platform/yjsb/update`,
url: `/snow-ops-platform/yjsb/updateEquipmentStatus`,
method: "POST",
data: {
...equipmentDetailInfo.value,
sbzt: "损坏", //
remark: brokenReason.value,
equipmentId: equipmentDetailInfo.value.rid,
equipmentStatus: "损坏",
statusDesc: brokenReason.value,
},
});
if (res.code && res.code === "00000") {
@ -760,7 +757,7 @@ const onBrokenConfirm = async () => {
router.push({
name: "EquipManage",
params: {
data: encodeURIComponent(JSON.stringify(equipmentInfo.value)),
data: encodeURIComponent(JSON.stringify(yhzInfo.value)),
},
});
} else {
@ -830,9 +827,10 @@ const onRemarkConfirm = async () => {
url: "/snow-ops-platform/yjsb/update",
method: "POST",
data: {
equipment: {
...equipmentDetailInfo.value,
remark: equipmentDetailInfo.value.remark,
},
photos: photos.value,
},
});
if (res.code && res.code === "00000") {
@ -856,10 +854,53 @@ const onRemarkPopupClose = () => {
const showEditPopup = ref(false);
//
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;
};
//
@ -917,7 +958,7 @@ const onCategoryConfirm = (value) => {
showCategoryPicker.value = false;
categoryField.value.focus();
} else {
editForm.sbdl = value.selectedValues[0];
editForm.equipment.sbdl = value.selectedValues[0];
showCategoryPicker.value = false;
}
};
@ -926,32 +967,36 @@ const onTypeConfirm = (value) => {
showTypePicker.value = false;
typeField.value.focus();
} else {
editForm.sblx = value.selectedValues[0];
editForm.equipment.sblx = value.selectedValues[0];
showTypePicker.value = false;
}
};
//
const showAdminPicker = ref(false);
const adminOptions = [
{ text: "管理员1", value: "管理员1" },
{ text: "管理员2", value: "管理员2" },
{ text: "管理员3", value: "管理员3" },
];
const adminOptions = ref([]);
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;
};
//
const showOperatorPicker = ref(false);
const operatorOptions = [
{ text: "操作员1", value: "操作员1" },
{ text: "操作员2", value: "操作员2" },
{ text: "操作员3", value: "操作员3" },
];
const operatorOptions = ref([]);
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;
};
@ -968,16 +1013,19 @@ const onDateConfirm = ({ selectedValues }) => {
};
//
const showStatusPicker = ref(false);
const statusOptions = [
{ text: "完好", value: "完好" },
{ text: "损坏", value: "损坏" },
{ text: "报废", value: "报废" },
];
const onStatusConfirm = (value) => {
editForm.sbzt = value.selectedValues[0];
showStatusPicker.value = false;
};
const latestStatusDesc = computed(() => {
if (
!equipmentDetailInfo.value.sbzt ||
equipmentDetailInfo.value.sbzt === "完好"
)
return "";
const records = statusList.value
.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);
@ -1001,11 +1049,62 @@ const onSubsidyConfirm = (value) => {
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 () => {
try {
showLoadingToast({ message: "提交中...", forbidClick: true });
// console.log('editForm',toRaw(editForm))
console.log('editForm',toRaw(editForm))
const res = await request({
url: "/snow-ops-platform/yjsb/update",

View File

@ -28,10 +28,72 @@
<van-cell :title="'物资经度: ' + wzDetailData.jd"> </van-cell>
<van-cell :title="'物资纬度: ' + wzDetailData.wd"> </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.remark"> </van-cell>
</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>
</template>
@ -96,6 +158,43 @@ const showImage = (photos) => {
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>
<style scoped>
@ -104,7 +203,7 @@ const showImage = (photos) => {
}
.content {
padding: 16px;
padding: 16px 16px 80px 16px;
}
.grid {
@ -131,5 +230,17 @@ const showImage = (photos) => {
.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;
}
</style>

View File

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