From 77770026f28fe5422ef5d3ae0cecd135ab5a979b Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Mon, 7 Sep 2026 13:44:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B8=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/visit/component/showVisit.vue | 75 ++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/src/views/visit/component/showVisit.vue b/src/views/visit/component/showVisit.vue index 5306f2e..b3554a2 100644 --- a/src/views/visit/component/showVisit.vue +++ b/src/views/visit/component/showVisit.vue @@ -552,22 +552,33 @@ } } this.codeForm.type = nextType + this.codeForm.person_no = [] + this.codeForm.car_no = [] if(this.codeForm.type==1){ this.codeForm.person_no.push({name:this.form.name,person_no:''}) - for(var k of this.form.follw_people){ + const follows = Array.isArray(this.form.follw_people) ? this.form.follw_people : [] + for(var k of follows){ this.codeForm.person_no.push({name:k.name,person_no:''}) } - for(var m of this.form.cars){ + const cars = Array.isArray(this.form.cars) ? this.form.cars : [] + for(var m of cars){ this.codeForm.car_no.push({car:m,car_no:''}) } - }else{ - for(var k of this.form.person_no){ - this.codeForm.person_no.push(JSON.parse(k)) + }else if(this.codeForm.type==2){ + const personList = this.asGateList(this.form.person_no) + for(var k of personList){ + const personItem = this.normalizePersonNoItem(k, this.form.name) + if (personItem) { + this.codeForm.person_no.push(personItem) + } } - for(var m of this.form.car_no){ - this.codeForm.car_no.push(JSON.parse(m)) + const carList = this.asGateList(this.form.car_no) + for(var m of carList){ + const carItem = this.normalizeCarNoItem(m) + if (carItem) { + this.codeForm.car_no.push(carItem) + } } - } } @@ -577,6 +588,54 @@ } }, methods: { + asGateList(val) { + if (val == null || val === '') { + return [] + } + if (Array.isArray(val)) { + return val + } + return [val] + }, + parseGateJsonItem(val) { + if (val == null || val === '') { + return null + } + if (typeof val === 'object') { + return val + } + if (typeof val === 'string') { + try { + const parsed = JSON.parse(val) + if (parsed && typeof parsed === 'object') { + return parsed + } + } catch (e) { + return val + } + } + return val + }, + normalizePersonNoItem(item, fallbackName) { + const parsed = this.parseGateJsonItem(item) + if (parsed == null || parsed === '') { + return null + } + if (typeof parsed === 'object') { + return parsed + } + return { name: fallbackName || '', person_no: parsed } + }, + normalizeCarNoItem(item) { + const parsed = this.parseGateJsonItem(item) + if (parsed == null || parsed === '') { + return null + } + if (typeof parsed === 'object') { + return parsed + } + return { car: parsed, car_no: '' } + }, selectLevel(val) { this.form.audit.map(item => { if (item.level == val) {