郑永安
2023-06-19 2befd4a5d3733520b69ed97da88e675b6b086a3c
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
<template>
    <el-dialog
        :visible.sync="dialogVisible"
        append-to-body
        :title="title"
        :close-on-click-modal="false"
        width="600px"
    >
        <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"  width="600px">
            <el-form-item label="省:" prop="name">
                <el-select v-model="dataForm.province" clearable filterable @change="changeArea('province')">
                    <el-option
                        v-for="item in provinceList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="市:">
                <el-select v-model="dataForm.city" clearable filterable @change="changeArea('city')">
                    <el-option
                        v-for="item in cityList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item type="textarea" label="区:" prop="memo">
                <el-select v-model="dataForm.district" clearable filterable>
                    <el-option
                        v-for="item in districtList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <div  align="right">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="submitApproach()">确认</el-button>
        </div>
    </el-dialog>
 
</template>
 
<script>
 
import {getCityListData, getProvinceListData} from "../../../../api/area";
 
export default {
    name: "lookStoreHouse",
    data(){
        return{
            title:'',
            dialogVisible:false,
            dataForm:{
                province:'',
                city:'',
                district:'',
            },
            provinceList:[],
            cityList:[],
            districtList:[],
            dataFormRules:{
 
            },
        }
    },
    created(){
        this.getProvince()
    },
    methods:{
        selectApproach(){
            this.dataForm = {
                province:'',
                city:'',
                district:'',
            }
            this.dialogVisible = true
        },
        async getProvince(){
            let res = await getProvinceListData()
            if(res.data.code === "200"){
                this.provinceList = res.data.result.provinceList
            }
        },
        async changeArea(value){
            if(value === 'province'){
                this.dataForm.city = ''
                this.dataForm.district = ''
                this.areaListQuery = {
                    type: 2,
                    parenttype: 1,
                    parentname: this.dataForm.province,
                }
                let res = await getCityListData(this.areaListQuery)
                if(res.data.code === "200"){
                    this.cityList = res.data.result
                }
            }else if(value === 'city'){
                this.dataForm.district = ''
                this.areaListQuery = {
                    type: 3,
                    parenttype: 2,
                    parentname: this.dataForm.city,
                }
                let res = await getCityListData(this.areaListQuery)
                if(res.data.code === "200"){
                    this.districtList = res.data.result
                }
            }
        },
        submitApproach(){
            this.$emit('giveApproach',this.dataForm)
            this.dialogVisible = false
        }
    }
}
</script>
 
<style scoped>
/deep/ .el-input__inner {
    width:300px;
}
</style>