修改车辆信息

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

View File

@ -5,7 +5,14 @@
<u-form labelPosition="top">
<view class="card">
<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 borderBottom label="车牌号" labelWidth="200" @click="carInputClick();">
<u-input
@ -20,18 +27,11 @@
name="arrow-right"
></u-icon>
</u-form-item>
<u-form-item label="车辆品牌" labelWidth="200" @click="brandType = true;">
<u-input
v-model="car.brandStr"
border="none"
disabled
disabledColor="#ffffff"
placeholder="请选择车辆品牌"
></u-input>
<u-icon
slot="right"
name="arrow-right"
></u-icon>
<!-- @click="brandType = true;"-->
<u-form-item label="车辆品牌" labelWidth="200">
<picker @change="picker($event)" :value="arrayIndex" :range="brandList" range-key="brandName">
<view class="uni-input">{{ brandList && brandList[arrayIndex] ? brandList[arrayIndex].brandName : '' }}</view>
</picker>
</u-form-item>
<u-form-item label="车辆型号" labelWidth="200">
<u-input
@ -40,6 +40,11 @@
placeholder="请输入车辆型号"
></u-input>
</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 class="card">
@ -91,24 +96,6 @@
</view>
</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
@change="getPlateNum"></keyboard-plate>
@ -131,8 +118,10 @@
<script>
import VNavigationBar from '@/components/VNavigationBar.vue';
import {bus} from "@/utils/eventBus";
import request from "@/utils/request";
import config from '@/config'
import upload from "@/utils/upload";
import {getDictByCode} from "@/utils/utils";
export default {
components: {
@ -158,18 +147,24 @@ export default {
brandAndModel: [],
},
userInfo: {},
arrayIndex: 0,
bo1: false,
bo2: true,
datePickerShow: false,
datePickerValue: new Date().getTime(),
pickerConfirmField: 'njDate',
brandId:'',
brandId: '',
showType: false,
brandType: false,
typeList: [],
brandList: [],
fileList1: [],
imageUrl: '',
//
natureList: [],
natureIndex: 0,
};
},
onLoad(options) {
@ -182,42 +177,60 @@ export default {
this.bo1 = true;
this.bo2 = false;
this.pageTitle = '修改车辆信息'
if (this.car.carLicenseImg) {
this.fileList1.push({
url: config.baseImageUrl + this.car.carLicenseImg
})
}
} else {
//
this.bo1 = false;
this.bo2 = true;
this.pageTitle = '添加车辆信息'
}
this.getBrandList()
this.getNatureList()
this.car.userId = JSON.parse(decodeURIComponent(options.userInfo)).userId;
this.userInfo = JSON.parse(decodeURIComponent(options.userInfo))
console.log(this.car)
this.getBrandList()
},
methods: {
typeSelect(e) {
console.log('e', e)
},
brandSelect(e) {
console.log('e', e)
this.brandId = e.value
this.car.brandStr = e.name
// this.getCarModule()
picker(e) {
//
this.arrayIndex = e.target.value;
this.brandId = this.brandList[e.target.value].value
},
//
natureChange(event) {
const newIndex = event.detail.value;
this.natureIndex = newIndex;
//
this.car.carNature = this.natureList[newIndex].value;
},
getBrandList() {
request({
url: '/admin-api/base/carBrand/page',
method: 'GET',
params: {
page: 1,
size: 10000
pageNo: 1,
pageSize: 10000
}
}).then(res => {
console.log(res);
res.data.records.forEach(item => {
item.name = item.brandName,
item.value = item.id
item.value = item.id
})
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;
}
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)
},
datePickerCancel(picker) {
@ -274,18 +286,28 @@ export default {
if (type === 'day') {
return `${value}`
}
console.log('for value', value)
return value
},
//
async submit() {
// bus.$emit('updateCarInfo', this.car)
this.car.brandAndModel = [this.brandId, this.car.carModel]
console.log("car",this.car)
//
this.car.inspectionDate = new Date(this.car.inspectionDate).getTime()
this.car.insuranceDate = new Date(this.car.insuranceDate).getTime()
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime()
if (this.car.inspectionDate) {
this.car.inspectionDate = new Date(this.car.inspectionDate).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) {
request({
url: '/admin-api/base/carMain/update',
@ -304,36 +326,103 @@ export default {
url: '/admin-api/base/carMain/page',
method: 'GET',
params: {
licenseNumber:this.car.licenseNumber
licenseNumber: this.car.licenseNumber
}
}).then( res =>{
}).then(res => {
this.car = res.data.records[0]
console.log("执行")
request({
url: '/admin-api/base/custom/bindCustomerCar',
method: 'post',
data :{
data: {
carList: [this.car],
id: this.userInfo.id
}
}).then( res =>{
}).then(res => {
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',
// data: this.car,
// })
// if (res.code == 200) {
// //
// bus.$emit('updateCarInfo', res.result)
// uni.navigateBack();
// }
},
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1)
},
//
async afterRead(event) {
// multiple true , file
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"
:show="datePickerShow"
mode="date"
:min-date="minDate"
@cancel="datePickerCancel"
@confirm="datePickerConfirm"
></u-datetime-picker>
@ -100,6 +101,7 @@ export default {
},
bo1: false,
bo2: true,
minDate: new Date(1900, 0, 1).getTime(),
datePickerShow: false,
datePickerValue: new Date().getTime(),