From 0fa01e3826d7675af2b43259f3431085d6900cbb Mon Sep 17 00:00:00 2001 From: Shan Ao <178391389@qq.com> Date: Mon, 15 Sep 2025 09:40:54 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E7=9C=9F=E6=9C=BA?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E8=BD=A6=E8=BE=86=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share_office_vehicle_info/add.vue | 70 ++++++++++++------- .../share_office_vehicle_info/index.vue | 3 +- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/pages/door_access_control/share_office_vehicle_info/add.vue b/pages/door_access_control/share_office_vehicle_info/add.vue index c109f9d..f497b65 100644 --- a/pages/door_access_control/share_office_vehicle_info/add.vue +++ b/pages/door_access_control/share_office_vehicle_info/add.vue @@ -213,48 +213,64 @@ export default { this.VEHICLE_TYPE_LIST = TYPE_LIST; }, async getData() { - const resData = await getVehiclemessageView({VEHICLE_ID: this.$route.query.VEHICLE_ID}); - this.form = resData.pd; + const resData = await getVehiclemessageView({VEHICLE_ID: this.VEHICLE_ID}); + // 使用 this.$set 确保表单数据的响应式更新 + Object.keys(resData.pd).forEach(key => { + this.$set(this.form, key, resData.pd[key]); + }); + // 处理车牌类型 const matchedItem = this.VEHICLE_LICENSE_PLATE_TYPE_LIST.find(item => item.id === resData.pd.LICENCE_TYPE.toString()); if (matchedItem) { - this.form.LICENCE_TYPE_NAME = matchedItem.name; - this.form.LICENCE_TYPE = resData.pd.LICENCE_TYPE.toString(); + this.$set(this.form, 'LICENCE_TYPE_NAME', matchedItem.name); + this.$set(this.form, 'LICENCE_TYPE', resData.pd.LICENCE_TYPE.toString()); } + + // 处理车辆类型 const vehicleType = this.VEHICLE_TYPE_LIST.find(item => item.id === resData.pd.VEHICLE_TYPE.toString()); if (vehicleType) { - this.form.VEHICLE_TYPE_NAME = vehicleType.name; - this.form.VEHICLE_TYPE = resData.pd.VEHICLE_TYPE.toString(); + this.$set(this.form, 'VEHICLE_TYPE_NAME', vehicleType.name); + this.$set(this.form, 'VEHICLE_TYPE', resData.pd.VEHICLE_TYPE.toString()); } + + // 处理范围 const vehiclePort = this.VEHICLE_PORT_LIST.find(item => item.id === resData.pd.portId.toString()); if (vehiclePort) { - this.form.portName = vehiclePort.name; - this.form.portId = resData.pd.portId.toString(); + this.$set(this.form, 'portName', vehiclePort.name); + this.$set(this.form, 'portId', resData.pd.portId.toString()); } + + // 处理车辆所属类型 const vehicleOwnership = this.VEHICLE_BELONG_TYPE_LIST.find(item => item.id === resData.pd.VEHICLE_BELONG_TYPE.toString()); if (vehicleOwnership) { - this.form.VEHICLE_BELONG_TYPE = vehicleOwnership.id; - this.form.VEHICLE_BELONG_TYPE_NAME = vehicleOwnership.name; + this.$set(this.form, 'VEHICLE_BELONG_TYPE', vehicleOwnership.id); + this.$set(this.form, 'VEHICLE_BELONG_TYPE_NAME', vehicleOwnership.name); } + + // 处理审批人 const auditor = this.userList.find(item => item.userId === resData.pd.QY_AUDITOR); if (auditor) { - this.form.QY_AUDITOR_NAME = auditor.name; + this.$set(this.form, 'QY_AUDITOR_NAME', auditor.name); } - for (let i = 0; i < resData.pd.drivingImgs.length; i++) { - if (!Array.isArray(this.form.drivingImgFiles)) { - this.$set(this.form, "drivingImgFiles", []); - } - this.form.drivingImgFiles.push({ - url: this.$store.state.filePath + resData.pd.drivingImgs[i].filepath, - ...resData.pd.drivingImgs[i], + + // 处理行驶证图片 + this.$set(this.form, 'drivingImgFiles', []); + if (resData.pd.drivingImgs && Array.isArray(resData.pd.drivingImgs)) { + resData.pd.drivingImgs.forEach((img, index) => { + this.$set(this.form.drivingImgFiles, index, { + url: this.$store.state.filePath + img.filepath, + ...img, + }); }); } - for (let i = 0; i < resData.pd.vehicleImgs.length; i++) { - if (!Array.isArray(this.form.vehicleImgFiles)) { - this.$set(this.form, "vehicleImgFiles", []); - } - this.form.vehicleImgFiles.push({ - url: this.$store.state.filePath + resData.pd.vehicleImgs[i].filepath, - ...resData.pd.vehicleImgs[i], + + // 处理车辆图片 + this.$set(this.form, 'vehicleImgFiles', []); + if (resData.pd.vehicleImgs && Array.isArray(resData.pd.vehicleImgs)) { + resData.pd.vehicleImgs.forEach((img, index) => { + this.$set(this.form.vehicleImgFiles, index, { + url: this.$store.state.filePath + img.filepath, + ...img, + }); }); } }, @@ -297,8 +313,8 @@ export default { const params = { ...this.form, DEPARTMENT_ID: this.userInfo.DEPARTMENT_ID, - USER_ID: this.form.VEHICLE_BELONG_TYPE == 1 ? '' : this.userInfo.USER_ID, - USER_NAME: this.form.VEHICLE_BELONG_TYPE == 1 ? '' : this.userInfo.NAME, + USER_ID: this.form.VEHICLE_BELONG_TYPE === 1 ? '' : this.userInfo.USER_ID, + USER_NAME: this.form.VEHICLE_BELONG_TYPE === 1 ? '' : this.userInfo.NAME, VEHICLE_DEPARTMENT_ID: this.userInfo.DEPARTMENT_ID, VEHICLE_DEPARTMENT_NAME: this.userInfo.DEPARTMENT_NAME, vehicleImgs: JSON.stringify(vehicleImgs), diff --git a/pages/door_access_control/share_office_vehicle_info/index.vue b/pages/door_access_control/share_office_vehicle_info/index.vue index 15c1b9d..1de3a9b 100644 --- a/pages/door_access_control/share_office_vehicle_info/index.vue +++ b/pages/door_access_control/share_office_vehicle_info/index.vue @@ -158,8 +158,7 @@ export default { } const TYPE_MAP = new Map(TYPE_LIST.map(item => [item.id, item.name])); // 如果你需要将 Map 转换为普通对象 - const TYPE_OBJECT_MAP = Object.fromEntries(TYPE_MAP); - this.VEHICLE_TYPE_MAP = TYPE_OBJECT_MAP; + this.VEHICLE_TYPE_MAP = Object.fromEntries(TYPE_MAP); console.log(this.VEHICLE_TYPE_MAP); }, }