PreferenceForm.vue
6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
<a-card title="信息" :bordered="false" size="small">
<a-spin :spinning="submitted">
<a-form layout="vertical" v-if="formState" :model="formState" :label-col="labelCol"
:wrapper-col="wrapperCol" ref="formRef" class="flex-form">
<title-divider title="经营信息"></title-divider>
<a-form-item label="经营模式" name="businessModel" :rules="[{ required: true, message: '请选择经营模式' }]">
<a-select ref="select" v-model:value="formState.businessModel" placeholder="请选择经营模式">
<a-select-option value="1">批发</a-select-option>
<a-select-option value="2">零售</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="注册地区" :name="['ownership', 'carProvinceCity']"
:rules="[{ required: true, message: '请选择注册地区!' }]">
<a-cascader v-model:value="formState.carProvinceCity" :options="areaData" placeholder="请选择注册地区"
@change="handleCitiesChange" />
</a-form-item>
<title-divider title="收车偏好"></title-divider>
<a-form-item label="偏好车况" name="vehicleCondition" :rules="[{ required: true, message: '请选择偏好车况' }]">
<a-select v-model:value="formState.vehicleCondition" mode="tags" placeholder="请选择偏好车况">
<a-select-option v-for="(item, index) in vehicleConditionList" :key="index"
:value="item.value">{{ item.label }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="偏好车龄" name="vehicleAge" :rules="[{ required: true, message: '请选择偏好车龄' }]">
<a-select v-model:value="formState.vehicleAge" mode="tags" placeholder="请选择偏好车龄">
<a-select-option v-for="(item, index) in vehicleAgeList" :key="index" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="燃油类型" name="vehicleFuelType" :rules="[{ required: true, message: '请选择燃油类型' }]">
<a-select v-model:value="formState.vehicleFuelType" mode="tags" placeholder="请选择燃油类型">
<a-select-option v-for="(item, index) in fuelTypeList" :key="index" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="收车车型" name="vehicleType" :rules="[{ required: true, message: '请选择收车车型' }]">
<a-select v-model:value="formState.vehicleType" mode="tags" placeholder="请选择收车车型">
<a-select-option v-for="(item, index) in vehicleTypeList" :key="index" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="偏好品牌" name="vehicleBrand" :rules="[{ required: true, message: '请选择偏好品牌' }]">
<a-select v-model:value="formState.vehicleBrand" mode="tags" placeholder="请选择偏好品牌">
<a-select-option v-for="(item, index) in brands" :key="index" :value="item.value">
{{ item.label }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item class="footer-btns">
<a-button type="primary" class="mr-10" @click="submitForm">保存</a-button>
<a-button @click="$goBack()">取消</a-button>
</a-form-item>
</a-form>
</a-spin>
</a-card>
</template>
<script lang="ts">
import { Component } from "vue-facing-decorator";
import { reactive } from 'vue';
import { Venue } from "lib/src/entity/venue/entity/Venue";
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons-vue";
import { FormComponent } from "autumn-antv/lib/core/form/FormComponent";
import TitleDivider from "@/components/TitleDivider.vue";
import { DefaultOptionType } from "ant-design-vue/es/vc-cascader/Cascader";
import { convertToTree } from "@/common/chinaarea";
import { returnPreferenceList } from "@/views/finance/preference/listData";
import { GscApiController } from "@/api/GscApiController";
@Component({
components: { TitleDivider, EditOutlined, DeleteOutlined, PlusOutlined }
})
export default class PreferenceForm extends FormComponent<Venue> {
areaData: DefaultOptionType[] = [];
vehicleConditionList = returnPreferenceList('vehicleConditionList');
vehicleAgeList = returnPreferenceList('vehicleAgeList');
fuelTypeList = returnPreferenceList('vehicleFuelTypeList');
vehicleTypeList = returnPreferenceList('vehicleModelList');
brands: DefaultOptionType[] = [];
created(): void {
const venue = new Venue();
this.formState = reactive<Venue>(venue);
this.areaData = convertToTree(false);
GscApiController.getCarBrandComplete(this.axios).then(res => {
const brandRes: any = res.data;
this.brands = (brandRes.data.carinfos || []).map(item => ({ label: item.name, value: item.id, }));
});
}
handleCitiesChange(value, selectedOptions: DefaultOptionType[]): void {
console.log(value);
this.formState.carProvinceId = Number(selectedOptions[0].value);
this.formState.carProvinceName = selectedOptions[0].label;
this.formState.carCityId = Number(selectedOptions[1].value);
this.formState.carCityName = selectedOptions[1].label;
}
onValidSuccess(formValue: Venue): void {
}
onValidFailure(errorMessage: any) {
console.error('错误信息:', errorMessage);
}
}
</script>
<style lang="less" scoped>
</style>