master
lion 10 months ago
parent 2932df86ac
commit 2b925b5af8

@ -419,6 +419,7 @@ export default {
visitShow: false,
visitData: null,
vehicleImages: [], // 车辆照片数组
originalVehicleImageIds: [], // 进入弹窗时原有的车辆照片ID,用于识别新上传的照片
remarkValue: "", // 备注值
personNoValue: "", // 人员编号
uploading: false, // 上传状态
@ -713,6 +714,11 @@ export default {
});
});
this.vehicleImages = arr;
// 记录原始车辆照片ID列表,用于后续判断是否有新照片
this.originalVehicleImageIds = arr.map((item) => item.id);
} else {
this.vehicleImages = [];
this.originalVehicleImageIds = [];
}
// 核销的值
this.codeForm.code = visitor.code;
@ -814,6 +820,7 @@ export default {
this.visitData = null;
// 清空输入数据
this.vehicleImages = [];
this.originalVehicleImageIds = [];
this.remarkValue = "";
this.personNoValue = "";
this.uploading = false;
@ -950,43 +957,69 @@ export default {
// 验证必填字段 - 由于去除action,暂无必填验证
this.updating = true;
console.log("this.visitData", this.visitData);
// return
try {
const updateParams = {
...this.visitData,
id: this.visitData.id,
remark: this.remarkValue,
person_no: this.personNoValue,
// follw_people 中包含了每个人员的 follw_people_person_no 字段
};
// 内部方法:执行更新
const performUpdate = async (alsoCancel) => {
this.updating = true;
try {
const updateParams = {
...this.visitData,
id: this.visitData.id,
remark: this.remarkValue,
person_no: this.personNoValue,
// follw_people 中包含了每个人员的 follw_people_person_no 字段
};
// 如果type==3,添加车辆照片数据(做空值防护)
if (this.visitData.type == 3) {
updateParams.vehicle_images = (this.vehicleImages || [])
.filter((img) => img && img.id)
.map((img) => img.id);
}
await this.$u.api.visitUpdate(updateParams);
uni.showToast({
title: "更新成功",
icon: "success",
});
// 如果type==3,添加车辆照片数据
if (this.visitData.type == 3) {
updateParams.vehicle_images = this.vehicleImages.map((img) => img.id);
if (alsoCancel) {
// 更新成功后直接核销并关闭弹窗
this.cancelCode();
setTimeout(() => {
this.closeVisitModal();
}, 800);
}
} catch (error) {
console.error("更新失败:", error);
uni.showToast({
title: "更新失败",
icon: "none",
});
} finally {
this.updating = false;
}
};
const res = await this.$u.api.visitUpdate(updateParams);
// 所有类型都弹出确认弹窗
const isVehicleType = this.visitData.type == 3; // 需要提交照片的类型
uni.showToast({
title: "更新成功",
icon: "success",
});
// 更新成功后直接核销并关闭弹窗
this.cancelCode();
setTimeout(() => {
this.closeVisitModal();
}, 800);
} catch (error) {
console.error("更新失败:", error);
uni.showToast({
title: "更新失败",
icon: "none",
});
} finally {
this.updating = false;
}
uni.showModal({
title: "提示",
content: "是否立即核销?",
cancelText: isVehicleType ? "仅提交照片" : "取消",
confirmText: "提交并核销",
success: async (res) => {
if (res.confirm) {
// 提交并核销(所有类型通用)
await performUpdate(true);
} else if (res.cancel && isVehicleType) {
// 仅提交照片(状态不变,仅对需要提交照片的类型生效)
await performUpdate(false);
}
// 其他类型点击“取消”不做任何处理,仅关闭确认弹窗
},
});
},
// 关闭访客列表弹窗
@ -1427,7 +1460,7 @@ export default {
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
z-index: 10; // 调低层级,避免遮挡系统弹窗(如 uni.showModal)
}
.modal-content {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.
Loading…
Cancel
Save