diff --git a/packages/mobile/src/views/Equipment/EquipmentDetails.vue b/packages/mobile/src/views/Equipment/EquipmentDetails.vue index d88d26a..e3c05d3 100644 --- a/packages/mobile/src/views/Equipment/EquipmentDetails.vue +++ b/packages/mobile/src/views/Equipment/EquipmentDetails.vue @@ -27,7 +27,16 @@ > - + + + @@ -54,8 +63,13 @@ - + + + @@ -340,14 +354,17 @@

编辑设备信息

+ maxlength="20" + show-word-limit + > + - - - + + + + - - - - - 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 } from "vant"; +import { showToast, showLoadingToast, showImagePreview } from "vant"; import { request } from "../../../../shared/utils/request"; const router = useRouter(); @@ -653,7 +658,10 @@ const onSelect = (action) => { } }; const equipmentInfo = ref({}); +const yhzInfo = ref({}); const equipmentDetailInfo = ref({}); +const photos = ref([]); +const statusList = ref([]); // 获取设备详情 const getEquipmentDetailInfo = async () => { @@ -664,6 +672,8 @@ 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); @@ -674,15 +684,17 @@ const getEquipmentDetailInfo = async () => { }; onMounted(() => { - equipmentInfo.value = JSON.parse(decodeURIComponent(route.params.data)); - console.log("equipmentInfo", toRaw(equipmentInfo.value)); + const data = JSON.parse(decodeURIComponent(route.params.data)); + equipmentInfo.value = data.equipmentInfo; + + yhzInfo.value = data.yhzInfo; getEquipmentDetailInfo(); }); const onClickLeft = () => { router.push({ name: "EquipManage", - params: { data: encodeURIComponent(JSON.stringify(equipmentInfo.value)) }, + params: { data: encodeURIComponent(JSON.stringify(yhzInfo.value)) }, }); }; @@ -696,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") { @@ -709,7 +721,7 @@ const onScrapConfirm = async () => { router.push({ name: "EquipManage", params: { - data: encodeURIComponent(JSON.stringify(equipmentInfo.value)), + data: encodeURIComponent(JSON.stringify(yhzInfo.value)), }, }); } else { @@ -732,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") { @@ -745,7 +757,7 @@ const onBrokenConfirm = async () => { router.push({ name: "EquipManage", params: { - data: encodeURIComponent(JSON.stringify(equipmentInfo.value)), + data: encodeURIComponent(JSON.stringify(yhzInfo.value)), }, }); } else { @@ -786,7 +798,7 @@ const onDeleteConfirm = async () => { router.push({ name: "EquipManage", params: { - data: encodeURIComponent(JSON.stringify(equipmentInfo.value)), + data: encodeURIComponent(JSON.stringify(yhzInfo.value)), }, }); } else { @@ -815,9 +827,10 @@ const onRemarkConfirm = async () => { url: "/snow-ops-platform/yjsb/update", method: "POST", data: { - ...equipmentDetailInfo.value, - - remark: equipmentDetailInfo.value.remark, + equipment: { + ...equipmentDetailInfo.value, + }, + photos: photos.value, }, }); if (res.code && res.code === "00000") { @@ -841,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; }; // 关闭编辑弹窗 @@ -902,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; } }; @@ -911,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; }; @@ -953,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); @@ -986,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", @@ -1009,6 +1123,14 @@ const onEditSubmit = async () => { console.log("error", error); } }; + +const showImage = (photos) => { + const photosArr = photos.map((item) => item.photoUrl); + showImagePreview({ + images: photosArr, + closeable: true, + }); +}; \ No newline at end of file diff --git a/packages/mobile/src/views/Material/MaterialManagement.vue b/packages/mobile/src/views/Material/MaterialManagement.vue index b48dcfc..d8d4f87 100644 --- a/packages/mobile/src/views/Material/MaterialManagement.vue +++ b/packages/mobile/src/views/Material/MaterialManagement.vue @@ -19,7 +19,7 @@ :key="index" :title="item.wzmc" is-link - :label="`余量:${item.sl} (${item.dw})`" + :label="`余量:${item.ye} (${item.dw})`" :to="{ name: 'MaterialDetail', params: { @@ -34,19 +34,17 @@ >
+ + 添加物资 + - - 添加物资 - - @@ -54,82 +52,133 @@ - + > - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + +
{ getMaterialList(); }); -// 购置日期 +// 购置日期相关 const showTimePicker = ref(false); const currentDate = ref([ new Date().getFullYear(), @@ -238,6 +293,32 @@ const onDateConfirm = ({ selectedValues }) => { showTimePicker.value = false; }; +// 选择单位相关 +const dwField = ref(null); +const showDwPicker = ref(false); +const dwOptions = [ + { text: "辆", value: "辆" }, + { text: "米", value: "米" }, + { text: "桶", value: "桶" }, + { text: "把", value: "把" }, + { text: "吨", value: "吨" }, + { text: "双", value: "双" }, + { text: "件", value: "件" }, + { text: "付", value: "付" }, + { text: "个", value: "个" }, + { text: "件", value: "件" }, + { text: "自定义", value: "自定义" }, +]; +const onDwConfirm = (value) => { + if (value.selectedValues[0] === "自定义") { + showDwPicker.value = false; + dwField.value.focus(); + } else { + form.material.dw = value.selectedValues[0]; + showDwPicker.value = false; + } +}; + const handleSubmit = async () => { try { showLoadingToast({ @@ -245,8 +326,8 @@ const handleSubmit = async () => { forbidClick: true, loadingType: "spinner", }); - form.yhzid = yhzDetail.value.id; - form.qxmc = yhzDetail.value.qxmc; + form.material.yhzid = yhzDetail.value.id; + form.material.qxmc = yhzDetail.value.qxmc; console.log("form", toRaw(form)); const res = await request({ url: "/snow-ops-platform/yjwz/add", @@ -273,6 +354,111 @@ const handleSubmit = async () => { } }; +// 负责人相关 +const showFzrPicker = ref(false); +const fzrOptions = ref([]); +const onFzrConfirm = (value) => { + // 获取选中的负责人ID + const selectedId = value.selectedValues[0]; + + // 在fzrOptions中查找对应的负责人名称 + const selectedPerson = fzrOptions.value.find( + (item) => item.value === selectedId + ); + // 同时设置id和名称 + if (selectedPerson) { + form.material.fzrid = selectedId; + form.material.fzr = selectedPerson.text; + } else { + form.material.fzrid = ""; + form.material.fzr = ""; + } + showFzrPicker.value = false; +}; + +// 图片上传相关 +const fileList = ref([]); +// 文件删除 +const handleDelete = (file) => { + if (file.serverUrl) { + const index = form.photos.findIndex((p) => p.photoUrl === file.serverUrl); + if (index !== -1) { + form.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") { + form.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("form.photos", toRaw(form.photos)); + console.log("fileList.value", fileList.value); + } else { + throw new Error(res.message); + } + } catch (error) { + toast.close(); + showToast({ + type: "fail", + message: error.message, + }); + } +}; + +// 获取经纬度 +const handleGetLocation = () => { + if (!navigator.geolocation) { + showToast("您的浏览器不支持地理位置获取"); + return; + } + + showLoadingToast({ + message: "定位中...", + forbidClick: true, + }); + + navigator.geolocation.getCurrentPosition( + (position) => { + form.material.jd = position.coords.longitude.toFixed(6); + form.material.wd = position.coords.latitude.toFixed(6); + showToast("定位成功"); + }, + (error) => { + const errorMessage = + { + 1: "位置服务被拒绝", + 2: "暂时无法获取位置", + 3: "定位超时", + }[error.code] || "定位失败"; + showToast(errorMessage); + }, + { + enableHighAccuracy: true, // 高精度模式 + timeout: 5000, // 超时时间 + maximumAge: 0, // 不缓存位置 + } + ); +}; + watch( () => searchValue.value, (newVal, oldVal) => { @@ -286,7 +472,38 @@ const onClickLeft = () => { router.push("/"); }; -const handleAdd = () => { +// 获取养护站人员列表 +const getPersonList = async () => { + try { + const data = { + pageNum: 1, + pageSize: 9999, + yhzid: yhzDetail.value.id, + }; + const res = await request({ + url: "/snow-ops-platform/yhzry/list", + method: "get", + params: data, + }); + if (res.code === "00000") { + fzrOptions.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 handleAdd = async () => { + await getPersonList(); + handleGetLocation(); showPopup.value = true; }; diff --git a/packages/screen/src/views/SnowEventManagement/index.js b/packages/screen/src/views/SnowEventManagement/index.js index 35f9c94..2d1bc69 100644 --- a/packages/screen/src/views/SnowEventManagement/index.js +++ b/packages/screen/src/views/SnowEventManagement/index.js @@ -196,11 +196,11 @@ const columns = [ label: '预计恢复时间', }, { - prop: 'actualRecoverTime', + prop: 'trafficActualRecoverTime', label: '实际恢复时间', }, { - prop: 'serviceStationId', + prop: 'stationName', label: '所属服务站', }, {