代码补正

This commit is contained in:
xiaofajia 2024-11-16 12:56:05 +08:00
parent 9a74a8414f
commit 8dc907e992

View File

@ -33,7 +33,7 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="车辆型号" prop="carModel"> <el-form-item label="车辆型号" prop="carModel">
<el-input v-model="formData.carModel" placeholder="车辆型号" /> <el-input v-model="formData.carModel" placeholder="车辆型号"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
@ -113,7 +113,9 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<el-button :loading="buttonLoading" icon="el-icon-date" @click="compute" size="small" type="primary">计算</el-button> <el-button :loading="buttonLoading" icon="el-icon-date" @click="compute" size="small" type="primary">
计算
</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-collapse-item> </el-collapse-item>
@ -205,7 +207,7 @@ export default {
nextMaintenanceMileage: undefined, nextMaintenanceMileage: undefined,
carModel: undefined carModel: undefined
}, },
buttonLoading:false, buttonLoading: false,
// //
formRules: { formRules: {
engineNumber: [{required: true, message: '发动机号码不能为空', trigger: 'blur'}], engineNumber: [{required: true, message: '发动机号码不能为空', trigger: 'blur'}],
@ -221,9 +223,13 @@ export default {
}, },
methods: { methods: {
/**计算车辆信息*/ /**计算车辆信息*/
async compute(){ async compute() {
this.buttonLoading = true this.buttonLoading = true
try{ try {
const brand = this.formData.brandAndModel
if (typeof brand === 'string'){
this.formData.brandAndModel = [brand, this.formData?.carModel]
}
const data = this.formData; const data = this.formData;
debugger debugger
const res = await CarMainApi.compute(data); const res = await CarMainApi.compute(data);
@ -259,7 +265,10 @@ export default {
async submitForm() { async submitForm() {
// //
// await this.$refs["formRef"].validate(); // await this.$refs["formRef"].validate();
this.formData.brandAndModel = [this.formData?.brandAndModel, this.formData?.carModel] const brand = this.formData.brandAndModel
if (typeof brand === 'string'){
this.formData.brandAndModel = [brand, this.formData?.carModel]
}
this.formLoading = true; this.formLoading = true;
try { try {
const data = this.formData; const data = this.formData;