|
|
|
@ -160,6 +160,7 @@ import { add, getDictionary, getDetail, update } from '@/api/basicdata/basicdata
|
|
|
|
|
import { getList } from '@/api/basicdata/basicdataVehicleInfo'; |
|
|
|
|
import { getOwn } from '@/api/basicdata/basicdataDriverArtery'; |
|
|
|
|
import { useRoute, useRouter } from 'vue-router'; |
|
|
|
|
import { useStore } from 'vuex'; |
|
|
|
|
|
|
|
|
|
const details = reactive({ |
|
|
|
|
carBasicForm: [ |
|
|
|
@ -499,6 +500,9 @@ const formRef = ref();
|
|
|
|
|
const $router = useRouter(); |
|
|
|
|
const $route = useRoute(); |
|
|
|
|
|
|
|
|
|
// vuex |
|
|
|
|
const $store = useStore(); |
|
|
|
|
|
|
|
|
|
// 处理数据 |
|
|
|
|
const handleData = (key, res) => { |
|
|
|
|
const { code, data } = res.data; |
|
|
|
@ -520,151 +524,159 @@ const handleData = (key, res) => {
|
|
|
|
|
|
|
|
|
|
// 请求下拉框码值 |
|
|
|
|
const initData = async () => { |
|
|
|
|
// 请求车辆类型 |
|
|
|
|
const handleCarModel = async () => { |
|
|
|
|
const [res1, res2] = await Promise.all([getList(), getDictionaryBiz('basic_vehicle_model')]); |
|
|
|
|
|
|
|
|
|
const { code: code1, data: data1 } = res1.data; |
|
|
|
|
const { code: code2, data: data2 } = res2.data; |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
code1 !== 200 || |
|
|
|
|
code2 !== 200 || |
|
|
|
|
getObjType(data1) !== 'array' || |
|
|
|
|
getObjType(data2) !== 'array' |
|
|
|
|
) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// 处理数据 |
|
|
|
|
for (let i = 0; i < data1.length; i++) { |
|
|
|
|
const value = data1[i]; |
|
|
|
|
|
|
|
|
|
for (let j = 0; j < data2.length; j++) { |
|
|
|
|
const item = data2[j]; |
|
|
|
|
|
|
|
|
|
if (value.vehicleModel !== item.dictKey) continue; |
|
|
|
|
value.label = item.dictValue; |
|
|
|
|
value.value = item.dictKey; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
details.loadingObj.pageLoading = true; |
|
|
|
|
|
|
|
|
|
// 赋值 |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
// 请求车辆类型 |
|
|
|
|
const handleCarModel = async () => { |
|
|
|
|
const [res1, res2] = await Promise.all([getList(), getDictionaryBiz('basic_vehicle_model')]); |
|
|
|
|
|
|
|
|
|
if (value.label !== '车辆类型') continue; |
|
|
|
|
value.checkarr = data1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 并发请求 |
|
|
|
|
await Promise.all([ |
|
|
|
|
// 车辆来源 |
|
|
|
|
getDictionaryBiz('basic_vehicle_source').then(res => handleData('车辆来源', res)), |
|
|
|
|
// 是否车头 |
|
|
|
|
getDictionaryBiz('yes_no').then(res => handleData('是否车头', res)), |
|
|
|
|
// 挂车类型 |
|
|
|
|
getDictionaryBiz('basic_trailer_type').then(res => handleData('挂车类型', res)), |
|
|
|
|
// 车厢类型 |
|
|
|
|
getDictionaryBiz('basic_car_type').then(res => handleData('车厢类型', res)), |
|
|
|
|
// 付款方式 |
|
|
|
|
getDictionaryBiz('basicdata_vehicle_paymentmethod').then(res => handleData('付款方式', res)), |
|
|
|
|
// 车牌颜色 |
|
|
|
|
getDictionaryBiz('basic_plate_color').then(res => handleData('车牌颜色', res)), |
|
|
|
|
// 车身颜色 |
|
|
|
|
getDictionaryBiz('basic_vehicle_color').then(res => handleData('车身颜色', res)), |
|
|
|
|
// 能源类型 |
|
|
|
|
getDictionaryBiz('basic_energy_type').then(res => handleData('能源类型', res)), |
|
|
|
|
// 车牌类型 |
|
|
|
|
getDictionaryBiz('basic_plate_type').then(res => handleData('车牌类型', res)), |
|
|
|
|
// 车辆类型 |
|
|
|
|
handleCarModel(), |
|
|
|
|
// 承运商 |
|
|
|
|
getDictionary().then(res => { |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
const { code: code1, data: data1 } = res1.data; |
|
|
|
|
const { code: code2, data: data2 } = res2.data; |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
code1 !== 200 || |
|
|
|
|
code2 !== 200 || |
|
|
|
|
getObjType(data1) !== 'array' || |
|
|
|
|
getObjType(data2) !== 'array' |
|
|
|
|
) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (value.label === '承运商') |
|
|
|
|
return (value.checkarr = |
|
|
|
|
getObjType(data) === 'array' |
|
|
|
|
? data.map(val => { |
|
|
|
|
val.label = val.carrierName; |
|
|
|
|
val.value = val.id; |
|
|
|
|
return val; |
|
|
|
|
}) |
|
|
|
|
: []); |
|
|
|
|
// 处理数据 |
|
|
|
|
for (let i = 0; i < data1.length; i++) { |
|
|
|
|
const value = data1[i]; |
|
|
|
|
|
|
|
|
|
for (let j = 0; j < data2.length; j++) { |
|
|
|
|
const item = data2[j]; |
|
|
|
|
|
|
|
|
|
if (value.vehicleModel !== item.dictKey) continue; |
|
|
|
|
value.label = item.dictValue; |
|
|
|
|
value.value = item.dictKey; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
// 驾驶人 |
|
|
|
|
getOwn().then(res => { |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
|
|
|
|
|
// 赋值 |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
if (value.label === '车辆所属人') |
|
|
|
|
return (value.checkarr = |
|
|
|
|
getObjType(data) === 'array' |
|
|
|
|
? data.map(val => { |
|
|
|
|
val.label = val.name; |
|
|
|
|
val.value = val.id; |
|
|
|
|
return val; |
|
|
|
|
}) |
|
|
|
|
: []); |
|
|
|
|
if (value.label !== '车辆类型') continue; |
|
|
|
|
value.checkarr = data1; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
]); |
|
|
|
|
details.pageInfo = $route.query; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 并发请求 |
|
|
|
|
await Promise.all([ |
|
|
|
|
// 车辆来源 |
|
|
|
|
getDictionaryBiz('basic_vehicle_source').then(res => handleData('车辆来源', res)), |
|
|
|
|
// 是否车头 |
|
|
|
|
getDictionaryBiz('yes_no').then(res => handleData('是否车头', res)), |
|
|
|
|
// 挂车类型 |
|
|
|
|
getDictionaryBiz('basic_trailer_type').then(res => handleData('挂车类型', res)), |
|
|
|
|
// 车厢类型 |
|
|
|
|
getDictionaryBiz('basic_car_type').then(res => handleData('车厢类型', res)), |
|
|
|
|
// 付款方式 |
|
|
|
|
getDictionaryBiz('basicdata_vehicle_paymentmethod').then(res => handleData('付款方式', res)), |
|
|
|
|
// 车牌颜色 |
|
|
|
|
getDictionaryBiz('basic_plate_color').then(res => handleData('车牌颜色', res)), |
|
|
|
|
// 车身颜色 |
|
|
|
|
getDictionaryBiz('basic_vehicle_color').then(res => handleData('车身颜色', res)), |
|
|
|
|
// 能源类型 |
|
|
|
|
getDictionaryBiz('basic_energy_type').then(res => handleData('能源类型', res)), |
|
|
|
|
// 车牌类型 |
|
|
|
|
getDictionaryBiz('basic_plate_type').then(res => handleData('车牌类型', res)), |
|
|
|
|
// 车辆类型 |
|
|
|
|
handleCarModel(), |
|
|
|
|
// 承运商 |
|
|
|
|
getDictionary().then(res => { |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
if (value.label === '承运商') |
|
|
|
|
return (value.checkarr = |
|
|
|
|
getObjType(data) === 'array' |
|
|
|
|
? data.map(val => { |
|
|
|
|
val.label = val.carrierName; |
|
|
|
|
val.value = val.id; |
|
|
|
|
return val; |
|
|
|
|
}) |
|
|
|
|
: []); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
// 驾驶人 |
|
|
|
|
getOwn().then(res => { |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
if (value.label === '车辆所属人') |
|
|
|
|
return (value.checkarr = |
|
|
|
|
getObjType(data) === 'array' |
|
|
|
|
? data.map(val => { |
|
|
|
|
val.label = val.name; |
|
|
|
|
val.value = val.id; |
|
|
|
|
return val; |
|
|
|
|
}) |
|
|
|
|
: []); |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
]); |
|
|
|
|
details.pageInfo = $route.query; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
details.form[value.prop] = value.type === 2 ? 0 : value.multiple ? [] : ''; |
|
|
|
|
} |
|
|
|
|
details.form[value.prop] = value.type === 2 ? 0 : value.multiple ? [] : ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(' details.form :>> ', details.form); |
|
|
|
|
console.log(' details.form :>> ', details.form); |
|
|
|
|
|
|
|
|
|
if (details.pageInfo.type === 'add') return; |
|
|
|
|
// 获取详情数据 |
|
|
|
|
const res = await getDetail(details.pageInfo.id); |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
// details.form = data; |
|
|
|
|
if (details.pageInfo.type === 'add') return; |
|
|
|
|
// 获取详情数据 |
|
|
|
|
const res = await getDetail(details.pageInfo.id); |
|
|
|
|
const { code, data } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
// details.form = data; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
for (let i = 0; i < details.carBasicForm.length; i++) { |
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
if (value.type === 3 && value.multiple) { |
|
|
|
|
details.form[value.prop] = data[value.prop] ? data[value.prop].split(',') : []; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (value.type === 3 && value.multiple) { |
|
|
|
|
details.form[value.prop] = data[value.prop] ? data[value.prop].split(',') : []; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (value.type === 2) { |
|
|
|
|
let _num = Number(data[value.prop]); |
|
|
|
|
details.form[value.prop] = isNumber(_num) ? _num : 0; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (value.type === 2) { |
|
|
|
|
let _num = Number(data[value.prop]); |
|
|
|
|
details.form[value.prop] = isNumber(_num) ? _num : 0; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
details.form[value.prop] = data[value.prop] || ''; |
|
|
|
|
} |
|
|
|
|
details.form[value.prop] = data[value.prop] || ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('details.form :>> ', details.form); |
|
|
|
|
console.log('details.form :>> ', details.form); |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < details.imgArr.length; i++) { |
|
|
|
|
const value = details.imgArr[i]; |
|
|
|
|
for (let i = 0; i < details.imgArr.length; i++) { |
|
|
|
|
const value = details.imgArr[i]; |
|
|
|
|
|
|
|
|
|
let _imgList = []; |
|
|
|
|
const _value = data[value.prop]; |
|
|
|
|
let _imgList = []; |
|
|
|
|
const _value = data[value.prop]; |
|
|
|
|
|
|
|
|
|
value.imgList = _value |
|
|
|
|
? _value.split(',').map(val => { |
|
|
|
|
return { url: val, imgUrl: val }; |
|
|
|
|
}) |
|
|
|
|
: []; |
|
|
|
|
value.imgList = _value |
|
|
|
|
? _value.split(',').map(val => { |
|
|
|
|
return { url: val, imgUrl: val }; |
|
|
|
|
}) |
|
|
|
|
: []; |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log('error :>> ', error); |
|
|
|
|
} finally { |
|
|
|
|
details.loadingObj.pageLoading = false; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -722,6 +734,7 @@ const handleEmpty = item => {
|
|
|
|
|
|
|
|
|
|
/** 返回 */ |
|
|
|
|
const back = () => { |
|
|
|
|
$store.commit('DEL_TAG_CURRENT'); |
|
|
|
|
$router.back(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -739,7 +752,10 @@ const handleSubmit = async () => {
|
|
|
|
|
const value = details.carBasicForm[i]; |
|
|
|
|
|
|
|
|
|
if (value.type === 3 && value.multiple) { |
|
|
|
|
submitData[value.prop] = details.form[value.prop].join(','); |
|
|
|
|
submitData[value.prop] = |
|
|
|
|
getObjType(details.form[value.prop]) === 'array' |
|
|
|
|
? details.form[value.prop].join(',') |
|
|
|
|
: ''; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|