物资管理添加

This commit is contained in:
huangchenhao 2025-11-12 17:28:02 +08:00
parent eda01c8043
commit cbf4e4e327
4 changed files with 511 additions and 149 deletions

View File

@ -27,7 +27,16 @@
> >
</template> </template>
</van-cell> </van-cell>
<van-cell :title="'设备名称: ' + equipmentDetailInfo.sbmc"> </van-cell> <van-cell :title="'设备名称: ' + equipmentDetailInfo.sbmc">
<template #right-icon>
<van-image
:src="photos[0]?.photoUrl"
fit="cover"
width="100px"
@click="showImage(photos)"
></van-image>
</template>
</van-cell>
<van-cell :title="'设备大类: ' + equipmentDetailInfo.sbdl"> </van-cell> <van-cell :title="'设备大类: ' + equipmentDetailInfo.sbdl"> </van-cell>
<van-cell :title="'设备类型: ' + equipmentDetailInfo.sblx"> </van-cell> <van-cell :title="'设备类型: ' + equipmentDetailInfo.sblx"> </van-cell>
<van-cell :title="'设备编号: ' + equipmentDetailInfo.sbbh"> </van-cell> <van-cell :title="'设备编号: ' + equipmentDetailInfo.sbbh"> </van-cell>
@ -56,6 +65,7 @@
<van-cell :title="'辐射范围: ' + equipmentDetailInfo.fsfw"> </van-cell> <van-cell :title="'辐射范围: ' + equipmentDetailInfo.fsfw"> </van-cell>
<van-cell :title="'所属服务站: ' + equipmentDetailInfo.sbwz"> <van-cell :title="'所属服务站: ' + equipmentDetailInfo.sbwz">
</van-cell> </van-cell>
<van-cell :title="'备注: ' + equipmentDetailInfo.remark"> </van-cell>
</van-cell-group> </van-cell-group>
</div> </div>
@ -636,7 +646,7 @@ 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 } from "vue";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import { showToast, showLoadingToast } from "vant"; import { showToast, showLoadingToast, showImagePreview } from "vant";
import { request } from "../../../../shared/utils/request"; import { request } from "../../../../shared/utils/request";
const router = useRouter(); const router = useRouter();
@ -653,7 +663,9 @@ const onSelect = (action) => {
} }
}; };
const equipmentInfo = ref({}); const equipmentInfo = ref({});
const yhzInfo = ref({});
const equipmentDetailInfo = ref({}); const equipmentDetailInfo = ref({});
const photos = ref([]);
// //
const getEquipmentDetailInfo = async () => { const getEquipmentDetailInfo = async () => {
@ -664,6 +676,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;
console.log("设备详情", toRaw(equipmentDetailInfo.value)); console.log("设备详情", toRaw(equipmentDetailInfo.value));
} else { } else {
throw new Error(res.data.message); throw new Error(res.data.message);
@ -674,15 +687,17 @@ const getEquipmentDetailInfo = async () => {
}; };
onMounted(() => { onMounted(() => {
equipmentInfo.value = JSON.parse(decodeURIComponent(route.params.data)); const data = JSON.parse(decodeURIComponent(route.params.data));
console.log("equipmentInfo", toRaw(equipmentInfo.value)); equipmentInfo.value = data.equipmentInfo;
yhzInfo.value = data.yhzInfo;
getEquipmentDetailInfo(); getEquipmentDetailInfo();
}); });
const onClickLeft = () => { const onClickLeft = () => {
router.push({ router.push({
name: "EquipManage", name: "EquipManage",
params: { data: encodeURIComponent(JSON.stringify(equipmentInfo.value)) }, params: { data: encodeURIComponent(JSON.stringify(yhzInfo.value)) },
}); });
}; };
@ -786,7 +801,7 @@ const onDeleteConfirm = 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 {
@ -1009,6 +1024,14 @@ const onEditSubmit = async () => {
console.log("error", error); console.log("error", error);
} }
}; };
const showImage = (photos) => {
const photosArr = photos.map((item) => item.photoUrl);
showImagePreview({
images: photosArr,
closeable: true,
});
};
</script> </script>
<style scoped> <style scoped>
@ -1017,7 +1040,7 @@ const onEditSubmit = async () => {
} }
.content { .content {
padding: 16px; padding: 16px 16px 80px 16px;
} }
.grid { .grid {

View File

@ -9,7 +9,7 @@
placeholder="请输入设备名称" placeholder="请输入设备名称"
/> />
<van-cell-group> <van-cell-group>
<van-cell title="当前站点" :value="detailData.mc || detailData.sbwz" /> <van-cell title="当前站点" :value="detailData.mc" />
</van-cell-group> </van-cell-group>
<van-notice-bar mode="link">20台设备待确认</van-notice-bar> <van-notice-bar mode="link">20台设备待确认</van-notice-bar>
@ -23,7 +23,14 @@
:label="`设备类型: ` + item.sblx" :label="`设备类型: ` + item.sblx"
:to="{ :to="{
name: 'EquipDetail', name: 'EquipDetail',
params: { data: encodeURIComponent(JSON.stringify(item)) }, params: {
data: encodeURIComponent(
JSON.stringify({
equipmentInfo: item,
yhzInfo: detailData,
})
),
},
}" }"
> >
<template #value> <template #value>
@ -63,28 +70,23 @@
@close="onPopupClose" @close="onPopupClose"
> >
<!-- 表单部分 --> <!-- 表单部分 -->
<van-form <van-form class="device-form" label-align="left" colon>
class="device-form"
label-align="left"
colon
>
<h3>设备信息</h3> <h3>设备信息</h3>
<!-- 设备名称 --> <!-- 设备名称 -->
<van-field <van-field
v-model="form.sbmc" v-model="form.equipment.sbmc"
label="设备名称" label="设备名称"
placeholder="请输入设备名称" placeholder="请输入设备名称"
:rules="[{ required: true, message: '请填写设备名称' }]" :rules="[{ required: true, message: '请填写设备名称' }]"
maxlength="20"
show-word-limit
> >
<template #button>
<span class="counter">{{ form.sbmc.length }}/20</span>
</template>
</van-field> </van-field>
<!-- 设备大类 --> <!-- 设备大类 -->
<van-field <van-field
v-model="form.sbdl" v-model="form.equipment.sbdl"
is-link is-link
arrow-direction="down" arrow-direction="down"
label="设备大类" label="设备大类"
@ -95,7 +97,7 @@
<!-- 设备类型 --> <!-- 设备类型 -->
<van-field <van-field
v-model="form.sblx" v-model="form.equipment.sblx"
is-link is-link
arrow-direction="down" arrow-direction="down"
label="设备类型" label="设备类型"
@ -106,7 +108,7 @@
<!-- 设备编号 --> <!-- 设备编号 -->
<van-field <van-field
v-model="form.sbbh" v-model="form.equipment.sbbh"
label="设备编号" label="设备编号"
placeholder="请输入设备编号" placeholder="请输入设备编号"
:rules="[{ required: true, message: '请填写设备编号' }]" :rules="[{ required: true, message: '请填写设备编号' }]"
@ -114,7 +116,7 @@
<!-- 设备型号 --> <!-- 设备型号 -->
<van-field <van-field
v-model="form.sbxh" v-model="form.equipment.sbxh"
label="设备型号" label="设备型号"
placeholder="请输入设备型号" placeholder="请输入设备型号"
:rules="[{ required: true, message: '请填写设备型号' }]" :rules="[{ required: true, message: '请填写设备型号' }]"
@ -122,21 +124,21 @@
<!-- 设备经度 --> <!-- 设备经度 -->
<van-field <van-field
v-model="form.jd" v-model="form.equipment.jd"
label="设备经度" label="设备经度"
placeholder="请输入设备经度" placeholder="请输入设备经度"
/> />
<!-- 设备纬度 --> <!-- 设备纬度 -->
<van-field <van-field
v-model="form.wd" v-model="form.equipment.wd"
label="设备纬度" label="设备纬度"
placeholder="请输入设备纬度" placeholder="请输入设备纬度"
/> />
<!-- 设备管理员 --> <!-- 设备管理员 -->
<van-field <van-field
v-model="form.glry" v-model="form.equipment.glry"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -147,7 +149,7 @@
<!-- 操作员 --> <!-- 操作员 -->
<van-field <van-field
v-model="form.czy" v-model="form.equipment.czy"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -158,7 +160,7 @@
<!-- 购买费用 --> <!-- 购买费用 -->
<van-field <van-field
v-model="form.gmfy" v-model="form.equipment.gmfy"
type="number" type="number"
label="购买费用(万元)" label="购买费用(万元)"
placeholder="请输入购买费用" placeholder="请输入购买费用"
@ -166,7 +168,7 @@
<!-- 购置日期 --> <!-- 购置日期 -->
<van-field <van-field
v-model="form.gzrq" v-model="form.equipment.gzrq"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -177,7 +179,7 @@
<!-- 设备状态 --> <!-- 设备状态 -->
<van-field <van-field
v-model="form.sbzt" v-model="form.equipment.sbzt"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -188,14 +190,14 @@
<!-- 生产厂家 --> <!-- 生产厂家 -->
<van-field <van-field
v-model="form.sccj" v-model="form.equipment.sccj"
label="生产厂家" label="生产厂家"
placeholder="请输入生产厂家" placeholder="请输入生产厂家"
/> />
<!-- 是否应急设备 --> <!-- 是否应急设备 -->
<van-field <van-field
v-model="form.sfyjsb" v-model="form.equipment.sfyjsb"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -206,7 +208,7 @@
<!-- 是否纳入市级补助范围 --> <!-- 是否纳入市级补助范围 -->
<van-field <van-field
v-model="form.sfnrsjbz" v-model="form.equipment.sfnrsjbz"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly readonly
@ -217,11 +219,34 @@
<!-- 辐射范围 --> <!-- 辐射范围 -->
<van-field <van-field
v-model="form.fsfw" v-model="form.equipment.fsfw"
label="辐射范围" label="辐射范围"
placeholder="请输入辐射范围" placeholder="请输入辐射范围"
/> />
<!-- 备注 -->
<van-field
v-model="form.equipment.remark"
label="备注"
placeholder="请输入备注"
type="textarea"
/>
<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
@ -392,6 +417,7 @@ const searchValue = ref(""); // 搜索框输入值
const equipmentList = ref([]); const equipmentList = ref([]);
const INIT_FORM = { const INIT_FORM = {
equipment: {
qxmc: "", qxmc: "",
sbbh: "", sbbh: "",
sbdl: "", sbdl: "",
@ -413,15 +439,16 @@ const INIT_FORM = {
sfnrsjbz: "", sfnrsjbz: "",
fsfw: "", fsfw: "",
yhzid: "", yhzid: "",
},
photos: [],
}; // }; //
const form = reactive({ ...INIT_FORM }); // const form = reactive({ ...INIT_FORM }); //
// //
onMounted(() => { onMounted(() => {
detailData.value = JSON.parse(decodeURIComponent(route.params.data)); detailData.value = JSON.parse(decodeURIComponent(route.params.data));
console.log('detailData',toRaw(detailData.value));
getEquipmentList(); getEquipmentList();
form.yhzid = detailData.value.id || detailData.value.yhzid;
form.qxmc = detailData.value.qxmc;
}); });
watch( watch(
@ -436,12 +463,12 @@ watch(
// //
const getEquipmentList = async (sbmc) => { const getEquipmentList = async (sbmc) => {
try { try {
const yhzid = detailData.value.id || detailData.value.yhzid; const yhzid = detailData.value.id;
if (!yhzid) { if (!yhzid) {
return; return;
} }
const data = { const data = {
yhzid: detailData.value.id || detailData.value.yhzid, yhzid: detailData.value.id,
sbmc: sbmc, sbmc: sbmc,
pageNum: 1, pageNum: 1,
pageSize: 9999, pageSize: 9999,
@ -471,7 +498,44 @@ const onClickLeft = () => {
router.push("/"); router.push("/");
}; };
const handleAddDevice = () => { //
const getPersonList = async () => {
try {
const data = {
pageNum: 1,
pageSize: 9999,
yhzid: detailData.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 handleAddDevice = async () => {
await getPersonList();
form.equipment.sfnrsjbz = "否";
form.equipment.sfyjsb = "否";
showPopup.value = true; showPopup.value = true;
}; };
@ -529,7 +593,7 @@ const onCategoryConfirm = (value) => {
showCategoryPicker.value = false; showCategoryPicker.value = false;
categoryField.value.focus(); categoryField.value.focus();
} else { } else {
form.sbdl = value.selectedValues[0]; form.equipment.sbdl = value.selectedValues[0];
showCategoryPicker.value = false; showCategoryPicker.value = false;
} }
}; };
@ -538,32 +602,36 @@ const onTypeConfirm = (value) => {
showTypePicker.value = false; showTypePicker.value = false;
typeField.value.focus(); typeField.value.focus();
} else { } else {
form.sblx = value.selectedValues[0]; form.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) => {
form.glry = value.selectedValues[0]; const selectedOption = adminOptions.value.find(
(opt) => opt.value === value.selectedValues[0]
);
if (selectedOption) {
form.equipment.glry = selectedOption.text;
form.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) => {
form.czy = value.selectedValues[0]; const selectedOption = operatorOptions.value.find(
(opt) => opt.value === value.selectedValues[0]
);
if (selectedOption) {
form.equipment.czy = selectedOption.text;
form.equipment.czyid = selectedOption.value;
}
showOperatorPicker.value = false; showOperatorPicker.value = false;
}; };
@ -575,7 +643,7 @@ const currentDate = ref([
new Date().getDate(), new Date().getDate(),
]); ]);
const onDateConfirm = ({ selectedValues }) => { const onDateConfirm = ({ selectedValues }) => {
form.gzrq = selectedValues.join("-"); form.equipment.gzrq = selectedValues.join("-");
showTimePicker.value = false; showTimePicker.value = false;
}; };
@ -587,7 +655,7 @@ const statusOptions = [
{ text: "报废", value: "报废" }, { text: "报废", value: "报废" },
]; ];
const onStatusConfirm = (value) => { const onStatusConfirm = (value) => {
form.sbzt = value.selectedValues[0]; form.equipment.sbzt = value.selectedValues[0];
showStatusPicker.value = false; showStatusPicker.value = false;
}; };
@ -598,7 +666,7 @@ const emergencyOptions = [
{ text: "否", value: "否" }, { text: "否", value: "否" },
]; ];
const onEmergencyConfirm = (value) => { const onEmergencyConfirm = (value) => {
form.sfyjsb = value.selectedValues[0]; form.equipment.sfyjsb = value.selectedValues[0];
showEmergencyPicker.value = false; showEmergencyPicker.value = false;
}; };
@ -609,10 +677,59 @@ const subsidyOptions = [
{ text: "否", value: "否" }, { text: "否", value: "否" },
]; ];
const onSubsidyConfirm = (value) => { const onSubsidyConfirm = (value) => {
form.sfnrsjbz = value.selectedValues[0]; form.equipment.sfnrsjbz = value.selectedValues[0];
showSubsidyPicker.value = false; showSubsidyPicker.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 handleSubmit = async () => { const handleSubmit = async () => {
try { try {
showLoadingToast({ showLoadingToast({
@ -620,6 +737,9 @@ const handleSubmit = async () => {
forbidClick: true, forbidClick: true,
loadingType: "spinner", loadingType: "spinner",
}); });
form.equipment.yhzid = detailData.value.id;
form.equipment.qxmc = detailData.value.qxmc;
// console.log('detailData', toRaw(detailData.value))
console.log("form", toRaw(form)); console.log("form", toRaw(form));
const res = await request({ const res = await request({
url: "/snow-ops-platform/yjsb/add", url: "/snow-ops-platform/yjsb/add",
@ -648,6 +768,7 @@ const handleSubmit = async () => {
onPopupClose(); onPopupClose();
getEquipmentList(searchValue.value); getEquipmentList(searchValue.value);
} else { } else {
console.log("res", res);
throw new Error(res.message); throw new Error(res.message);
} }
} catch (error) { } catch (error) {

View File

@ -19,7 +19,7 @@
:key="index" :key="index"
:title="item.wzmc" :title="item.wzmc"
is-link is-link
:label="`余量:${item.sl} (${item.dw})`" :label="`余量:${item.ye} (${item.dw})`"
:to="{ :to="{
name: 'MaterialDetail', name: 'MaterialDetail',
params: { params: {
@ -46,7 +46,6 @@
position="bottom" position="bottom"
closeable closeable
close-on-click-overlay close-on-click-overlay
:style="{ height: '60%' }"
@close="onPopupClose" @close="onPopupClose"
> >
<van-form class="materialAddForm" label-align="left" colon> <van-form class="materialAddForm" label-align="left" colon>
@ -54,82 +53,133 @@
<!-- 物资名称 --> <!-- 物资名称 -->
<van-field <van-field
v-model="form.wzmc" v-model="form.material.wzmc"
label="物资名称" label="物资名称"
placeholder="请输入物资名称" placeholder="请输入物资名称"
:rules="[{ required: true, message: '请填写物资名称' }]" :rules="[{ required: true, message: '请填写物资名称' }]"
maxlength="20"
show-word-limit
> >
<template #button>
<span class="counter">{{ form.wzmc.length }}/20</span>
</template>
</van-field> </van-field>
<!-- 数量 --> <!-- 数量 -->
<van-field <van-field
v-model="form.sl" v-model="form.material.sl"
label="数量" label="数量"
placeholder="请输入数量" placeholder="请输入数量"
type="number" type="number"
:rules="[{ required: true, message: '请填写物资数量' }]" :rules="[{ required: true, message: '请填写物资数量' }]"
/> ></van-field>
<!-- 单位 --> <!-- 单位 -->
<van-field v-model="form.dw" label="单位" placeholder="物资单位" />
<!-- 负责人 -->
<van-field <van-field
v-model="form.fzr" v-model="form.material.dw"
label="负责人"
placeholder="请输入负责人"
/>
<!-- 联系电话 -->
<van-field
v-model="form.lxdh"
label="联系电话"
placeholder="请输入联系电话"
/>
<!-- 存放地点 -->
<van-field
v-model="form.cfdd"
label="存放地点"
placeholder="请输入存放地点"
/>
<!-- 入库单位 -->
<van-field
v-model="form.rkdw"
label="入库单位"
placeholder="请输入入库单位"
/>
<!-- 入库日期 -->
<van-field
v-model="form.rkrq"
is-link is-link
arrow-direction="down" arrow-direction="down"
readonly label="单位"
label="入库日期" placeholder="物资单位"
placeholder="请选择日期" @click="showDwPicker = true"
@click="showTimePicker = true" ref="dwField"
/> />
<!-- 入库日期弹窗 -->
<van-popup <van-popup
:show="showTimePicker" :show="showDwPicker"
round round
position="bottom" position="bottom"
close-on-click-overlay close-on-click-overlay
@close="showTimePicker = false" @close="showDwPicker = false"
> >
<van-date-picker <van-picker
v-model="currentDate" title="选择物资单位"
title="选择入库日期" :columns="dwOptions"
@confirm="onDateConfirm" @confirm="onDwConfirm"
@cancel="showTimePicker = false" @cancel="showDwPicker = false"
/> />
</van-popup> </van-popup>
<!-- 物资经度 -->
<van-field
v-model="form.material.jd"
label="物资经度"
placeholder="请输入物资经度"
>
<template #button>
<van-button
size="small"
type="primary"
@click.stop="handleGetLocation"
>获取位置</van-button
>
</template>
</van-field>
<!-- 物资纬度 -->
<van-field
v-model="form.material.wd"
label="物资纬度"
placeholder="请输入物资纬度"
>
<template #button>
<van-button
size="small"
type="primary"
@click.stop="handleGetLocation"
>获取位置</van-button
>
</template>
</van-field>
<!-- 负责人 -->
<van-field
v-model="form.material.fzr"
is-link
arrow-direction="down"
readonly
label="负责人"
placeholder="请选择负责人"
@click="showFzrPicker = true"
/>
<!-- 负责人弹窗 -->
<van-popup
:show="showFzrPicker"
round
position="bottom"
close-on-click-overlay
@close="showFzrPicker = false"
>
<van-picker
title="选择设备管理员"
:columns="fzrOptions"
@confirm="onFzrConfirm"
@cancel="showFzrPicker = false"
/>
</van-popup>
<!-- 备注 -->
<van-field
v-model="form.material.remark"
label="备注"
type="textarea"
placeholder=""
maxlength="20"
show-word-limit
>
</van-field>
<!-- -->
<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-form> </van-form>
<div <div
style=" style="
@ -172,7 +222,9 @@ const showPopup = ref(false); // 控制弹出层显示隐藏
const yhzDetail = ref({}); // const yhzDetail = ref({}); //
const materialList = ref([]); // const materialList = ref([]); //
const INIT_FORM = { const INIT_FORM = {
rid: "", material: {
jd: "", //
wd: "", //
rkrq: "", // rkrq: "", //
rkdw: "", // rkdw: "", //
sl: 0, // sl: 0, //
@ -184,7 +236,11 @@ const INIT_FORM = {
qxmc: "", // qxmc: "", //
wzmc: "", // wzmc: "", //
fzrid: "", // id fzrid: "", // id
fzr: "", //
yhzid: "", // id yhzid: "", // id
remark: "", //
},
photos: [],
}; };
const form = reactive({ ...INIT_FORM }); // const form = reactive({ ...INIT_FORM }); //
@ -226,7 +282,7 @@ onMounted(() => {
getMaterialList(); getMaterialList();
}); });
// //
const showTimePicker = ref(false); const showTimePicker = ref(false);
const currentDate = ref([ const currentDate = ref([
new Date().getFullYear(), new Date().getFullYear(),
@ -238,6 +294,32 @@ const onDateConfirm = ({ selectedValues }) => {
showTimePicker.value = false; 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 () => { const handleSubmit = async () => {
try { try {
showLoadingToast({ showLoadingToast({
@ -245,8 +327,8 @@ const handleSubmit = async () => {
forbidClick: true, forbidClick: true,
loadingType: "spinner", loadingType: "spinner",
}); });
form.yhzid = yhzDetail.value.id; form.material.yhzid = yhzDetail.value.id;
form.qxmc = yhzDetail.value.qxmc; form.material.qxmc = yhzDetail.value.qxmc;
console.log("form", toRaw(form)); console.log("form", toRaw(form));
const res = await request({ const res = await request({
url: "/snow-ops-platform/yjwz/add", url: "/snow-ops-platform/yjwz/add",
@ -273,6 +355,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( watch(
() => searchValue.value, () => searchValue.value,
(newVal, oldVal) => { (newVal, oldVal) => {
@ -286,7 +473,38 @@ const onClickLeft = () => {
router.push("/"); 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; showPopup.value = true;
}; };

View File

@ -196,11 +196,11 @@ const columns = [
label: '预计恢复时间', label: '预计恢复时间',
}, },
{ {
prop: 'actualRecoverTime', prop: 'trafficActualRecoverTime',
label: '实际恢复时间', label: '实际恢复时间',
}, },
{ {
prop: 'serviceStationId', prop: 'stationName',
label: '所属服务站', label: '所属服务站',
}, },
{ {