修改车辆信息

This commit is contained in:
许允枞 2024-10-30 15:53:34 +08:00
parent 780b080efe
commit 7c879c9549
3 changed files with 182 additions and 72 deletions

View File

@ -220,7 +220,9 @@ export default {
}, },
onShow() { onShow() {
if (this.phone != '') { if (this.phone != '') {
this.listUserInfo() setTimeout(() => {
this.listUserInfo()
}, 500)
} }
}, },
methods: { methods: {
@ -306,7 +308,7 @@ export default {
}) })
} else { } else {
uni.showToast({ uni.showToast({
title: '请输入手机号', title: '请输入手机号|车牌号|车架号',
icon: 'none' icon: 'none'
}) })
} }
@ -340,7 +342,9 @@ export default {
getCarList() { getCarList() {
const params = { const params = {
userId: this.userInfo.userId userId: this.userInfo.userId,
pageNo: 1,
pageSize: 100000
} }
request({ request({
url: '/admin-api/base/carMain/page', url: '/admin-api/base/carMain/page',
@ -348,7 +352,6 @@ export default {
params: params params: params
}).then(res => { }).then(res => {
this.carList = res.data.records this.carList = res.data.records
console.log('车列表', this.carList)
for (let i = 0; i < this.carList.length; i++) { for (let i = 0; i < this.carList.length; i++) {
if (this.carList[i].licenseNumber.toLowerCase() == this.phone.toLowerCase()) { if (this.carList[i].licenseNumber.toLowerCase() == this.phone.toLowerCase()) {
this.activeCarIndex = i this.activeCarIndex = i
@ -360,9 +363,21 @@ export default {
} }
// //
this.carList.forEach(item => { this.carList.forEach(item => {
item.inspectionDate = formatTimestampCustom(item.inspectionDate) if (item.inspectionDate) {
item.insuranceDate = formatTimestampCustom(item.insuranceDate) item.inspectionDate = formatTimestampCustom(item.inspectionDate)
item.carRegisterDate = formatTimestampCustom(item.carRegisterDate) }else {
item.inspectionDate = ''
}
if (item.insuranceDate) {
item.insuranceDate = formatTimestampCustom(item.insuranceDate)
}else {
item.insuranceDate = ''
}
if (item.carRegisterDate) {
item.carRegisterDate = formatTimestampCustom(item.carRegisterDate)
}else {
item.carRegisterDate = ''
}
}) })
}) })
}, },
@ -389,6 +404,10 @@ export default {
}, },
editUserInfo(userInfo) { editUserInfo(userInfo) {
if (this.phone == '') return uni.showToast({
title: '请先输入手机号,再添加客户',
icon: 'none'
})
bus.$off('updateUserInfo') bus.$off('updateUserInfo')
bus.$on('updateUserInfo', (userInfo) => { bus.$on('updateUserInfo', (userInfo) => {
this.userInfo = userInfo this.userInfo = userInfo

View File

@ -5,7 +5,14 @@
<u-form labelPosition="top"> <u-form labelPosition="top">
<view class="card"> <view class="card">
<u-form-item borderBottom label="上传图片" labelWidth="200"> <u-form-item borderBottom label="上传图片" labelWidth="200">
<u-upload></u-upload> <u-upload
:fileList="fileList1"
@afterRead="afterRead"
@delete="deletePic"
name="1"
:maxCount="1"
multiple
></u-upload>
</u-form-item> </u-form-item>
<u-form-item borderBottom label="车牌号" labelWidth="200" @click="carInputClick();"> <u-form-item borderBottom label="车牌号" labelWidth="200" @click="carInputClick();">
<u-input <u-input
@ -20,18 +27,11 @@
name="arrow-right" name="arrow-right"
></u-icon> ></u-icon>
</u-form-item> </u-form-item>
<u-form-item label="车辆品牌" labelWidth="200" @click="brandType = true;"> <!-- @click="brandType = true;"-->
<u-input <u-form-item label="车辆品牌" labelWidth="200">
v-model="car.brandStr" <picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName">
border="none" <view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>
disabled </picker>
disabledColor="#ffffff"
placeholder="请选择车辆品牌"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
</u-form-item> </u-form-item>
<u-form-item label="车辆型号" labelWidth="200"> <u-form-item label="车辆型号" labelWidth="200">
<u-input <u-input
@ -40,6 +40,11 @@
placeholder="请输入车辆型号" placeholder="请输入车辆型号"
></u-input> ></u-input>
</u-form-item> </u-form-item>
<u-form-item class="formItem" label="车辆性质" labelWidth="200">
<picker @change="natureChange" :value="natureIndex" :range="natureList" range-key="value">
<view class="uni-input">{{ natureList[natureIndex].value}}</view>
</picker>
</u-form-item>
</view> </view>
<view class="card"> <view class="card">
@ -91,24 +96,6 @@
</view> </view>
</u-form> </u-form>
<!-- 车辆品牌 -->
<u-action-sheet
:actions="brandList"
:show="brandType"
title="请选择车辆品牌"
@close="brandType = false"
@select="brandSelect"
>
</u-action-sheet>
<!-- 车辆型号 -->
<u-action-sheet
:actions="typeList"
:show="showType"
title="请选择车辆型号"
@close="showType = false"
@select="typeSelect"
>
</u-action-sheet>
<keyboard-plate ref="plateNumber" :plateNum.sync='car.licenseNumber' isShow <keyboard-plate ref="plateNumber" :plateNum.sync='car.licenseNumber' isShow
@change="getPlateNum"></keyboard-plate> @change="getPlateNum"></keyboard-plate>
@ -131,8 +118,10 @@
<script> <script>
import VNavigationBar from '@/components/VNavigationBar.vue'; import VNavigationBar from '@/components/VNavigationBar.vue';
import {bus} from "@/utils/eventBus";
import request from "@/utils/request"; import request from "@/utils/request";
import config from '@/config'
import upload from "@/utils/upload";
import {getDictByCode} from "@/utils/utils";
export default { export default {
components: { components: {
@ -158,18 +147,24 @@ export default {
brandAndModel: [], brandAndModel: [],
}, },
userInfo: {}, userInfo: {},
arrayIndex: 0,
bo1: false, bo1: false,
bo2: true, bo2: true,
datePickerShow: false, datePickerShow: false,
datePickerValue: new Date().getTime(), datePickerValue: new Date().getTime(),
pickerConfirmField: 'njDate', pickerConfirmField: 'njDate',
brandId:'', brandId: '',
showType: false, showType: false,
brandType: false, brandType: false,
typeList: [], typeList: [],
brandList: [], brandList: [],
fileList1: [],
imageUrl: '',
//
natureList: [],
natureIndex: 0,
}; };
}, },
onLoad(options) { onLoad(options) {
@ -182,42 +177,60 @@ export default {
this.bo1 = true; this.bo1 = true;
this.bo2 = false; this.bo2 = false;
this.pageTitle = '修改车辆信息' this.pageTitle = '修改车辆信息'
if (this.car.carLicenseImg) {
this.fileList1.push({
url: config.baseImageUrl + this.car.carLicenseImg
})
}
} else { } else {
// //
this.bo1 = false; this.bo1 = false;
this.bo2 = true; this.bo2 = true;
this.pageTitle = '添加车辆信息' this.pageTitle = '添加车辆信息'
} }
this.getBrandList()
this.getNatureList()
this.car.userId = JSON.parse(decodeURIComponent(options.userInfo)).userId; this.car.userId = JSON.parse(decodeURIComponent(options.userInfo)).userId;
this.userInfo = JSON.parse(decodeURIComponent(options.userInfo)) this.userInfo = JSON.parse(decodeURIComponent(options.userInfo))
console.log(this.car) console.log(this.car)
this.getBrandList()
}, },
methods: { methods: {
typeSelect(e) { typeSelect(e) {
console.log('e', e)
}, },
brandSelect(e) { picker(e) {
console.log('e', e) //
this.brandId = e.value this.arrayIndex = e.target.value;
this.car.brandStr = e.name this.brandId = this.brandList[e.target.value].value
// this.getCarModule() },
//
natureChange(event) {
const newIndex = event.detail.value;
this.natureIndex = newIndex;
//
this.car.carNature = this.natureList[newIndex].value;
}, },
getBrandList() { getBrandList() {
request({ request({
url: '/admin-api/base/carBrand/page', url: '/admin-api/base/carBrand/page',
method: 'GET', method: 'GET',
params: { params: {
page: 1, pageNo: 1,
size: 10000 pageSize: 10000
} }
}).then(res => { }).then(res => {
console.log(res);
res.data.records.forEach(item => { res.data.records.forEach(item => {
item.name = item.brandName, item.name = item.brandName,
item.value = item.id item.value = item.id
}) })
this.brandList = res.data.records this.brandList = res.data.records
if (this.car) {
for (let i = 0; i < this.brandList.length; i++) {
if (this.car.carBrand == this.brandList[i].id) {
this.arrayIndex = i;
}
}
}
}) })
}, },
@ -257,7 +270,6 @@ export default {
return; return;
} }
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(2, '0') + '-' + (date.getDate() + '').padStart(2, '0') this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
console.log("this.car[this.pickerConfirmField]",this.car[this.pickerConfirmField])
this.datePickerCancel(picker) this.datePickerCancel(picker)
}, },
datePickerCancel(picker) { datePickerCancel(picker) {
@ -274,18 +286,28 @@ export default {
if (type === 'day') { if (type === 'day') {
return `${value}` return `${value}`
} }
console.log('for value', value)
return value return value
}, },
// //
async submit() { async submit() {
// bus.$emit('updateCarInfo', this.car) // bus.$emit('updateCarInfo', this.car)
this.car.brandAndModel = [this.brandId, this.car.carModel] this.car.brandAndModel = [this.brandId, this.car.carModel]
console.log("car",this.car)
// //
this.car.inspectionDate = new Date(this.car.inspectionDate).getTime() if (this.car.inspectionDate) {
this.car.insuranceDate = new Date(this.car.insuranceDate).getTime() this.car.inspectionDate = new Date(this.car.inspectionDate).getTime()
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime() }else {
this.car.inspectionDate = undefined
}
if (this.car.insuranceDate) {
this.car.insuranceDate = new Date(this.car.insuranceDate).getTime()
}else {
this.car.insuranceDate = undefined
}
if (this.car.carRegisterDate) {
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime()
}else {
this.car.carRegisterDate = undefined
}
if (this.car.id != null) { if (this.car.id != null) {
request({ request({
url: '/admin-api/base/carMain/update', url: '/admin-api/base/carMain/update',
@ -304,36 +326,103 @@ export default {
url: '/admin-api/base/carMain/page', url: '/admin-api/base/carMain/page',
method: 'GET', method: 'GET',
params: { params: {
licenseNumber:this.car.licenseNumber licenseNumber: this.car.licenseNumber
} }
}).then( res =>{ }).then(res => {
this.car = res.data.records[0] this.car = res.data.records[0]
console.log("执行")
request({ request({
url: '/admin-api/base/custom/bindCustomerCar', url: '/admin-api/base/custom/bindCustomerCar',
method: 'post', method: 'post',
data :{ data: {
carList: [this.car], carList: [this.car],
id: this.userInfo.id id: this.userInfo.id
} }
}).then( res =>{ }).then(res => {
uni.navigateBack(); uni.navigateBack();
}) })
}) })
}) })
} }
},
//
async getNatureList() {
this.natureList= getDictByCode('car_nature')
if (this.bo2 == true) {
this.car.carNature = this.natureList[0].value;
} else {
// index
this.natureList.forEach((item, index) => {
if (item.value == this.car.carNature) {
this.natureIndex = index;
}
})
}
// let res = await request({ },
// url: '/userClient/base/myCar/create', //
// method: 'POST', deletePic(event) {
// data: this.car, this[`fileList${event.name}`].splice(event.index, 1)
// }) },
// if (res.code == 200) { //
// // async afterRead(event) {
// bus.$emit('updateCarInfo', res.result) // multiple true , file
// uni.navigateBack(); let lists = [].concat(event.file)
// } let fileListLen = this[`fileList${event.name}`].length
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: 'uploading',
message: '上传中'
})
})
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url)
let item = this[`fileList${event.name}`][fileListLen]
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
status: 'success',
message: '',
url: result
}))
fileListLen++
}
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
upload({
url: '/admin-api/infra/file/upload',
filePath: url
}).then(res => {
resolve(config.baseImageUrl +res.data)
this.car.carLicenseImg = res.data
this.imageUrl = config.baseImageUrl + res.data
request({
url: '/admin-api/base/carMain/vehicleLicenseOCR',
method: 'POST',
data: this.imageUrl,
tenantIdFlag: false
}).then((res) => {
this.car.vin = res.data.vin
this.car.licenseNumber = res.data.plateNo
this.car.carRegisterDate = res.data.issueDate
this.car.engineNumber = res.data.engineNo
//
this.brandList.forEach((item, index) => {
if (item.brandName == res.data.brand) {
this.arrayIndex = index;
this.brandId = this.brandList[index].id;
}
})
//
this.natureList.forEach((item, index) => {
if (item.label == res.data.useCharacter) {
this.natureIndex = index;
this.car.carNature = this.natureList[index].value;
}
})
})
})
})
}, },
} }
} }

View File

@ -66,6 +66,7 @@
:formatter="formatter" :formatter="formatter"
:show="datePickerShow" :show="datePickerShow"
mode="date" mode="date"
:min-date="minDate"
@cancel="datePickerCancel" @cancel="datePickerCancel"
@confirm="datePickerConfirm" @confirm="datePickerConfirm"
></u-datetime-picker> ></u-datetime-picker>
@ -100,6 +101,7 @@ export default {
}, },
bo1: false, bo1: false,
bo2: true, bo2: true,
minDate: new Date(1900, 0, 1).getTime(),
datePickerShow: false, datePickerShow: false,
datePickerValue: new Date().getTime(), datePickerValue: new Date().getTime(),