PreferenceForm.vue
6.68 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<template>
<a-card title="信息" :bordered="false" size="small">
<a-spin :spinning="submitted">
<a-form layout="vertical" :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="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="multiple" :max-tag-count="3"
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="multiple" :max-tag-count="3"
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="multiple" :max-tag-count="3"
placeholder="请选择燃油类型">
<a-select-option v-for="(item, index) in vehicleFuelTypeList" :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="multiple" :max-tag-count="3"
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">
<a-select v-model:value="formState.vehicleBrand" mode="multiple" :max-tag-count="3"
:max-tag-text-length="10" 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>
<div class="footer-submit">
<a-button type="primary" class="mr-10" @click="submitForm">保存</a-button>
<a-button @click="$goBack()">取消</a-button>
</div>
</a-form>
</a-spin>
</a-card>
</template>
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { Venue } from "lib/src/entity/venue/entity/Venue";
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons-vue";
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 Vue {
pageData = {
businessModel: '',
cityCode: '',
cityName: '',
cityCn: '',
vehicleCondition: '1',
vehicleAge: '1',
vehicleFuelType: '1',
vehicleType: '1',
brandList: [] as string[],
}
formState = {}
areaData: DefaultOptionType[] = [];
vehicleConditionList = returnPreferenceList('vehicleConditionList');
vehicleAgeList = returnPreferenceList('vehicleAgeList');
vehicleFuelTypeList = returnPreferenceList('vehicleFuelTypeList');
vehicleTypeList = returnPreferenceList('vehicleTypeList');
brands: DefaultOptionType[] = [];
created(): void {
// 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, }));
});
}
//初始化数据
init(data: any) {
}
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 {
const pageData = {
}
}
onValidFailure(errorMessage: any) {
console.error('错误信息:', errorMessage);
}
}
</script>
<style lang="less" scoped>
.footer-submit {
width: 100%;
margin-top: 20px;
border-top: 1px solid #f2f4f7;
display: flex;
padding: 16px 0;
}
</style>