Commit bf7dc4c3 by lixiaomin

修改城市显示

parent 0bfd8a1f
...@@ -45,7 +45,6 @@ export function delShop(id) { ...@@ -45,7 +45,6 @@ export function delShop(id) {
// 查询店铺分类 // 查询店铺分类
export function getCategoryGoods(id) { export function getCategoryGoods(id) {
console.log(id);
return request({ return request({
url: "/system/shop/getCategoryGoods?shopId=" + id, url: "/system/shop/getCategoryGoods?shopId=" + id,
method: "get", method: "get",
...@@ -139,3 +138,10 @@ export function turnRecommendList(query) { ...@@ -139,3 +138,10 @@ export function turnRecommendList(query) {
params: query, params: query,
}); });
} }
export function getShopCity() {
return request({
url: "/system/shop/getShopCity",
method: "get",
});
}
...@@ -185,9 +185,14 @@ export default { ...@@ -185,9 +185,14 @@ export default {
getProvince(province){ getProvince(province){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == province){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
// 取消按钮 // 取消按钮
......
...@@ -157,9 +157,14 @@ export default { ...@@ -157,9 +157,14 @@ export default {
getProvince(province){ getProvince(province){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == province){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
// 取消按钮 // 取消按钮
......
...@@ -48,9 +48,14 @@ export default { ...@@ -48,9 +48,14 @@ export default {
getProvince(city){ getProvince(city){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == city){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
getList(){ getList(){
......
...@@ -160,9 +160,14 @@ export default { ...@@ -160,9 +160,14 @@ export default {
getProvince(province){ getProvince(province){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == province){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
formatterState(state){ formatterState(state){
......
...@@ -147,9 +147,14 @@ export default { ...@@ -147,9 +147,14 @@ export default {
getProvince(province){ getProvince(province){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == province){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
formatterState(state){ formatterState(state){
......
...@@ -6,14 +6,7 @@ ...@@ -6,14 +6,7 @@
<el-input v-model="queryParams.name" placeholder="请输入店铺名称" clearable @keyup.enter.native="handleQuery" /> <el-input v-model="queryParams.name" placeholder="请输入店铺名称" clearable @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="城市"> <el-form-item label="城市">
<el-select v-model="queryParams.province" placeholder="请选择城市" clearable> <el-cascader :options="provinceList" :show-all-levels="false" v-model="province" clearable></el-cascader>
<el-option
v-for="item in provinceList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="state"> <el-form-item label="状态" prop="state">
<el-select v-model="queryParams.state" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery"> <el-select v-model="queryParams.state" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
...@@ -54,7 +47,7 @@ ...@@ -54,7 +47,7 @@
</el-table-column> </el-table-column>
<el-table-column label="城市" align="center"> <el-table-column label="城市" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{getProvince(scope.row.province)}} {{getProvince(scope.row.city)}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="设备数量" align="center" prop="machineCount" /> <el-table-column label="设备数量" align="center" prop="machineCount" />
...@@ -107,7 +100,8 @@ ...@@ -107,7 +100,8 @@
import { import {
listShop, listShop,
delShop, delShop,
updateShop updateShop,
getShopCity
} from "@/api/system/shop"; } from "@/api/system/shop";
import SetShop from './setShop'; import SetShop from './setShop';
import piovince from '@/utils/piovince' import piovince from '@/utils/piovince'
...@@ -136,14 +130,12 @@ export default { ...@@ -136,14 +130,12 @@ export default {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: null, name: null,
province: null, city: null,
state: null, state: null,
machineCode: null machineCode: null
}, },
provinceList:[{ province:[],
value: '', provinceList:[],
label: '全部'
}],
options: [{ options: [{
value: '', value: '',
label: '全部' label: '全部'
...@@ -164,18 +156,47 @@ export default { ...@@ -164,18 +156,47 @@ export default {
this.getProvinceList(); this.getProvinceList();
}, },
methods: { methods: {
getProvinceList(){ getProvinceList(){
let list=this.piovince; let list=[];
for(let i=0;i<list.length;i++){ this.provinceList=[];
this.provinceList.push({value:list[i].value,label:list[i].name}) 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){ getProvince(province){
let list=this.piovince; let list=this.piovince;
for(let i=0;i<list.length;i++){ for(let i=0;i<list.length;i++){
if(list[i].value == province){ if(list[i].children.length>0){
return list[i].name; let childrenList=list[i].children;
} for(let j=0;j<childrenList.length;j++){
if(childrenList[j].value == province){
return childrenList[j].name;
}
}
}
} }
}, },
handleUpdate() { }, handleUpdate() { },
...@@ -191,6 +212,7 @@ export default { ...@@ -191,6 +212,7 @@ export default {
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1;
this.queryParams.city=this.province[1];
this.getList(); 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