Commit bf7dc4c3 by lixiaomin

修改城市显示

parent 0bfd8a1f
......@@ -45,7 +45,6 @@ export function delShop(id) {
// 查询店铺分类
export function getCategoryGoods(id) {
console.log(id);
return request({
url: "/system/shop/getCategoryGoods?shopId=" + id,
method: "get",
......@@ -139,3 +138,10 @@ export function turnRecommendList(query) {
params: query,
});
}
export function getShopCity() {
return request({
url: "/system/shop/getShopCity",
method: "get",
});
}
......@@ -185,8 +185,13 @@ export default {
getProvince(province){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == province){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......
......@@ -157,8 +157,13 @@ export default {
getProvince(province){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == province){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......
......@@ -48,8 +48,13 @@ export default {
getProvince(city){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == city){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......
......@@ -160,8 +160,13 @@ export default {
getProvince(province){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == province){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......
......@@ -147,8 +147,13 @@ export default {
getProvince(province){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == province){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......
......@@ -6,14 +6,7 @@
<el-input v-model="queryParams.name" placeholder="请输入店铺名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="城市">
<el-select v-model="queryParams.province" placeholder="请选择城市" clearable>
<el-option
v-for="item in provinceList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-cascader :options="provinceList" :show-all-levels="false" v-model="province" clearable></el-cascader>
</el-form-item>
<el-form-item label="状态" prop="state">
<el-select v-model="queryParams.state" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
......@@ -54,7 +47,7 @@
</el-table-column>
<el-table-column label="城市" align="center">
<template slot-scope="scope">
{{getProvince(scope.row.province)}}
{{getProvince(scope.row.city)}}
</template>
</el-table-column>
<el-table-column label="设备数量" align="center" prop="machineCount" />
......@@ -107,7 +100,8 @@
import {
listShop,
delShop,
updateShop
updateShop,
getShopCity
} from "@/api/system/shop";
import SetShop from './setShop';
import piovince from '@/utils/piovince'
......@@ -136,14 +130,12 @@ export default {
pageNum: 1,
pageSize: 10,
name: null,
province: null,
city: null,
state: null,
machineCode: null
},
provinceList:[{
value: '',
label: '全部'
}],
province:[],
provinceList:[],
options: [{
value: '',
label: '全部'
......@@ -165,16 +157,45 @@ export default {
},
methods: {
getProvinceList(){
let list=this.piovince;
for(let i=0;i<list.length;i++){
this.provinceList.push({value:list[i].value,label:list[i].name})
let list=[];
this.provinceList=[];
getShopCity().then((response) => {
if(response.code==200){
list=response.data;
let piovinceList=this.piovince;
for(let i=0;i<piovinceList.length;i++){
if(piovinceList[i].children.length>0){
let childrenList=piovinceList[i].children;
let obj={};
let tag=false;
obj.value=piovinceList[i].value;
obj.label=piovinceList[i].label;
let children=[];
for(let j=0;j<childrenList.length;j++){
if(list.indexOf(childrenList[j].value)>-1){
children.push({"value":childrenList[j].value,"label":childrenList[j].name});
tag=true;
}
}
obj.children=children;
if(tag){
this.provinceList.push(obj);
}
}
}
}
});
},
getProvince(province){
let list=this.piovince;
for(let i=0;i<list.length;i++){
if(list[i].value == province){
return list[i].name;
if(list[i].children.length>0){
let childrenList=list[i].children;
for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
}
},
......@@ -191,6 +212,7 @@ export default {
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.queryParams.city=this.province[1];
this.getList();
},
/** 重置按钮操作 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment