Commit a8cd38c6 authored by youjj's avatar youjj

Merge remote-tracking branch 'origin/master'

parents a6d108e1 6f7d6c8e
......@@ -10,6 +10,22 @@ export function page(query) {
});
}
export function allPage(query) {
return fetch({
url: '/vehicle/campsite/allPage',
method: 'get',
params: query
});
}
export function campsiteAllPage(query) {
return fetch({
url: '/vehicle/campsite/allPage',
method: 'get',
params: query
});
}
export function getObj(id) {
return fetch({
url: '/vehicle/campsite/' + id,
......
......@@ -79,7 +79,7 @@ Object.keys(filters).forEach(key => {
});
// register global progress.
const whiteList = ['/login', '/authredirect', '/map', '/stockCrowd', '/stockCrowdDetail', '/companyInfo', '/provinceMap'];// 不重定向白名单
const whiteList = ['/login', '/authredirect', '/map', '/stockCrowd', '/stockCrowdDetail', '/companyInfo', '/provinceMap', '/campsite'];// 不重定向白名单
router.beforeEach((to, from, next) => {
NProgress.start(); // 开启Progress
if (getToken()) { // 判断是否有token
......
......@@ -21,7 +21,7 @@
</div>
</div>
<!--营地分布图-->
<company-map v-on:headCallBack="headCall" v-if="toList" :toSonData="list" :provinceName="provinceName"></company-map>
<company-map v-on:headCallBack="headCall" v-if="toList" :toSonData="type" :provinceName="provinceName"></company-map>
<!--营地数据-->
<div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="0">
<div class="shoppings company-list"
......@@ -72,7 +72,7 @@
/*引入postcss-px2rem 通过require的形式*/
// var px2rem = require('postcss-px2rem');
import {
page
allPage
} from 'api/base_info/campsite';
import chinaMap from '../companyInfo/chinaMap';
import companyMap from "../companyInfo/companyMap";
......@@ -99,6 +99,7 @@
companyMap},
data() {
return {
type: "campsite",
toList: false,
nodata: false,
nomore:false,
......@@ -339,7 +340,7 @@
let params = this.objDeepCopy(this.listQuery);//深拷贝
params.page = this.page++;
this.send = !0;
page(params)
allPage(params)
.then(res => {
this.loading = false;
let allList = [];
......@@ -358,7 +359,7 @@
}
res.data.data.forEach(function (item) {
allList.push(item);
});debugger
});
if(res.data.data.length< this.listQuery.limit && this.list.length>0){
//已加载全部
this.nomore = true;
......
......@@ -13,11 +13,10 @@
getRegionByCodes,
} from 'api/base_info/region/';
import {
page,
addObj,
getObj,
delObj,
putObj
campsiteAllPage,
} from 'api/base_info/campsite';
import {
allPage,
} from 'api/base_info/branch_company';
export default {
props: ["toSonData","provinceName"],
......@@ -41,9 +40,17 @@
}
},
mounted() {
// let that = this;
// if(this.map){
// this.map.addEventListener("zoomend", function(e){
// var ZoomNum = that.map.getZoom();
// this.addMarker(map);
// });
// }
},
watch: {
provinceName(newValue, oldValue) {
let that = this;
console.log(this.provinceName);
if(this.map){
if(this.provinceName == "兰州"){
......@@ -52,50 +59,68 @@
this.map.centerAndZoom(this.provinceName,6);
}
}
// this.map.addEventListener("zoomend", function(e){
// var ZoomNum = that.map.getZoom();
// that.map.clearOverlays();//清空地图上标注点
// that.addMarker(this,map);
// });
},
},
methods: {
getList() {
page(this.listQuery)
handler({map}) {
this.map = map;
if(this.toSonData =="campsite"){
campsiteAllPage(this.listQuery)
.then(response => {
let listTemp = response.data.data;
//一次读入所有涉及地区,防止多次读取
if (!this.$utils.isEmpty(listTemp)) {
let allRegions = new Set();
for (let index in listTemp) {
allRegions.add(listTemp[index].addrProvince);
allRegions.add(listTemp[index].addrCity);
allRegions.add(listTemp[index].addrTown);
let regions = getRegionByCodes([listTemp[index].addrProvince, listTemp[index].addrCity, listTemp[index].addrTown]);
listTemp[index].address = regions[0].name + ' ' + regions[1].name + ' ' + regions[2].name + ' ';
}
getRegionByCodes([...allRegions]);
}
let arr = this.list;
let arr = [];
listTemp.map(function(item){
arr.push(item);
});
this.list = arr;
// 定位
this.geolocation(map);
// 产生随机点
const bounds = map.getBounds();
for (let i = 0; i < arr.length; i++) {
const point = {
title: "",//list[i].name
point: {
lng: arr[i].longitude,
lat: arr[i].latitude
}
};
this.pointList.push(point);
}
this.addMarker(map);
})
},
handler({map}) {
this.map = map;
let list = this.toSonData;
} else {
allPage(this.listQuery)
.then(response => {
let listTemp = response.data.data;
let arr = [];
listTemp.map(function(item){
arr.push(item);
});
this.list = arr;
// 定位
this.geolocation(map);
// 产生随机点
const bounds = map.getBounds();
for (let i = 0; i < list.length; i++) {
for (let i = 0; i < arr.length; i++) {
const point = {
title: "",//list[i].name
point: {
lng: list[i].longitude,
lat: list[i].latitude
lng: arr[i].longitude,
lat: arr[i].latitude
}
};
this.pointList.push(point);
}
this.addMarker(map);
})
}
},
mapClick(map, e) {
const point = e.point;
......@@ -108,6 +133,7 @@
const p = new BMap.Point(point.lng, point.lat);
this.pickPoint = new BMap.Marker(p);
this.addressDetail(point);//根据经纬度获取省市信息
// this.addMarker(map);
},
addressDetail(point){ //获取地理位置
let mydata = getSonRegionByCodes(1);
......@@ -130,9 +156,17 @@
});
},
addMarker(map) {
let zoom = map.getZoom();
var myIcon = new BMap.Icon('https://cwmp.upyuns.com/attachment/images/4/2019/05/HnFr78H280dv972KuNZku70297rz7z.png',new BMap.Size(16,16));//这里先不用第三个参数IconOptions;
// if(zoom <6){
// myIcon = new BMap.Icon('https://cwmp.upyuns.com/attachment/images/4/2019/05/HnFr78H280dv972KuNZku70297rz7z.png',new BMap.Size(16,16));//这里先不用第三个参数IconOptions
// }
for (const item of this.pointList) {
const point = new BMap.Point(item.point.lng, item.point.lat);
const mk = new BMap.Marker(point);
var mk = new BMap.Marker(point, {icon:myIcon});
// if(zoom > 6){
// mk = new BMap.Marker(point);
// }
const label = new BMap.Label(item.title);
label.setOffset(new BMap.Size(15, -15));
label.setStyle({
......
......@@ -21,26 +21,28 @@
</div>
</div>
<!--分公司分布图-->
<company-map v-on:headCallBack="headCall" v-if="toList" :toSonData="list" :provinceName="provinceName"></company-map>
<!--地图-->
<!--<china-map v-on:headCallBack="headCall" :list="list" :provinceName="provinceName"></china-map>-->
<company-map v-on:headCallBack="headCall" v-if="toList" :toSonData="type" :provinceName="provinceName"></company-map>
<!--分公司数据-->
<div v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="0">
<div class="shoppings company-list"
v-for="item in list"
:key="item.key"
>
<div class="item-right-p company-item">
<div class="ellipsis company-name">{{item.name}}</div>
<p class="ellipsis">负责人{{item.leader}}</p>
<p class="ellipsis">总经理{{item.leader}}</p>
<p>地址: {{item.address + item.addrDetail}}</p>
<p class="ellipsis">电话:{{item.leaderContactInfo}}</p>
</div>
</div>
<div class="tip-css" v-if="nodata">
暂无数据
<infinite-loading v-show="loading" spinner="spiral" style="margin-top:2em" ref="sroller">
</infinite-loading>
<div v-if="nomore && !loading" style="text-align: center;color: #999;padding: 10px;">
---暂无更多数据---
</div>
<div v-if="toList && !loading && list.length == 0" style="text-align: center;color: #999;padding: 10px;">
---暂无数据---
</div>
<div v-else-if="nomore" class="tip-css">
已加载全部
</div>
</div>
</div>
......@@ -88,18 +90,25 @@
import {mapGetters} from 'vuex';
import BmMap from "../../../../node_modules/vue-baidu-map/components/map/Map.vue";
import infiniteScroll from 'vue-infinite-scroll'
import InfiniteLoading from 'vue-infinite-loading'
export default {
name: 'branchCompany',
directives: {
infiniteScroll
},
components: {
BmMap,
chinaMap,
InfiniteLoading,
companyMap},
data() {
return {
type: "companyInfo",
toList: false,
nodata: false,
nomore:false,
loading: false,
form: {
id: undefined,
name: undefined,
......@@ -209,11 +218,11 @@
}
]
},
list: null,
list: [],
total: null,
listLoading: true,
listQuery: {
page: 1,
listQuery: {
limit: 10,
addrProvince: undefined,
addrCity: undefined,
......@@ -232,10 +241,10 @@
provinceName: "",
tableKey: 0,
send: !1,//是否已发送请求
nomore: false
}
},
created() {
this.getList();
this.branchCompany_btn_edit = this.elements['branchCompany:btn_edit'];
this.branchCompany_btn_del = this.elements['branchCompany:btn_del'];
this.branchCompany_btn_add = this.elements['branchCompany:btn_add'];
......@@ -307,24 +316,40 @@
}
return this.companyStatusAndCode[code].val;
},
getList(reachBottom) {
if(this.send){
return;
}
if(!reachBottom){
getList(){
this.page = 1;
this.list = [];
this.listQuery.page = 1;
this.nodata = false;
this.nomore = false;
} else if(reachBottom) {
this.loadMore();
},
/**
* 深拷贝
*/
objDeepCopy (source) {
var sourceCopy = source instanceof Array ? [] : {};
for (var item in source) {
sourceCopy[item] = typeof source[item] === 'object' ? objDeepCopy(source[item]) : source[item];
}
return sourceCopy;
},
loadMore: function() {
let that = this;
if(this.nomore){
return false
return;
}
if(this.send){
return;
}
this.busy = true;
this.loading = true;
let params = this.objDeepCopy(this.listQuery);//深拷贝
params.page = this.page++;
this.send = !0;
allPage(this.listQuery)
.then(response => {
let listTemp = response.data.data;
allPage(params)
.then(res => {
this.loading = false;
let allList = [];
let listTemp = res.data.data;
//一次读入所有涉及地区,防止多次读取
if (!this.$utils.isEmpty(listTemp)) {
let allRegions = new Set();
......@@ -337,160 +362,25 @@
}
getRegionByCodes([...allRegions]);
}
let arr = this.list;
// if(this.listQuery.page >1){
listTemp.map(function(item){
arr.push(item);
res.data.data.forEach(function (item) {
allList.push(item);
});
// }
this.list = arr;
this.total = response.data.totalCount;
this.listLoading = false;
if(arr.length == this.listQuery.page*this.listQuery.limit){
this.listQuery.page++;
}else if(arr.length == 0){
this.nodata = true;
}else if(arr.length < this.listQuery.page*this.listQuery.limit){
if(res.data.data.length< this.listQuery.limit && this.list.length>0){
//已加载全部
this.nomore = true;
}
this.list = [...this.list, ...allList];
this.send = !1;
this.toList = true;
})
});
this.busy = false;
},
getAddrStr(branchCompany) {
let regions = getRegionByCodes([branchCompany.addrProvince, branchCompany.addrCity, branchCompany.addrTown]);
return regions[0].name + ' ' + regions[1].name + ' ' + regions[2].name + ' ';
},
handleFilter() {
this.$refs.queryForm.validate(valid => {
if (valid) {
this.getList();
} else {
return false;
}
});
},
handleSizeChange(val) {
this.listQuery.limit = val;
this.getList();
},
handleCurrentChange(val) {
this.listQuery.page = val;
this.getList();
},
handleCreate() {
this.resetTemp();
this.dialogStatus = 'create';
this.dialogFormVisible = true;
},
handleUpdate(row) {
getObj(row.id)
.then(response => {
this.form = response.data;
this.dialogFormVisible = true;
this.dialogStatus = 'update';
this.selectedProvince = response.data.addrProvince;
this.selectedCity = response.data.addrCity;
});
},
scroll() {
let isLoading = false
window.onscroll = () => {
// 距离底部20px时加载一次
let bottomOfWindow = document.documentElement.offsetHeight - document.documentElement.scrollTop - window.innerHeight <= 0;
if (bottomOfWindow && isLoading == false) {
this.getList(true);
setTimeout(function(){
isLoading = true;
});
}
}
},
handleDelete(row) {
this.$confirm('此操作将永久删除, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
delObj(row.id)
.then(() => {
this.$notify({
title: '成功',
message: '删除成功',
type: 'success',
duration: 2000
});
const index = this.list.indexOf(row);
this.list.splice(index, 1);
});
});
},
create(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
addObj(this.form)
.then(() => {
this.dialogFormVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
});
})
} else {
return false;
}
});
},
cancel(formName) {
this.dialogFormVisible = false;
this.$refs[formName].resetFields();
},
update(formName) {
const set = this.$refs;
set[formName].validate(valid => {
if (valid) {
this.dialogFormVisible = false;
putObj(this.form).then(() => {
this.dialogFormVisible = false;
this.getList();
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
});
});
} else {
return false;
}
});
},
resetTemp() {
this.form = {
id: undefined,
name: undefined,
status: undefined,
addrProvince: undefined,
addrCity: undefined,
addrTown: undefined,
addrDetail: undefined,
leader: undefined,
leaderContactInfo: undefined,
updateTime: undefined
};
}
},
mounted() {    // 滚动加载更多 
const _this = this;
this.$nextTick(() => {
window.addEventListener('scroll', this.scroll)
})
mounted() {
},
}
</script>
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