master
xy 3 years ago
parent bb0dd27ffc
commit 06289dde6e

@ -170,3 +170,47 @@ export function getSex(idCard) {
} }
return sexStr; return sexStr;
} }
//深拷贝数据
export function deepCopy(data) {
//string,number,bool,null,undefined,symbol
//object,array,date
if (data && typeof data === "object") {
//针对函数的拷贝
if (typeof data === "function") {
let tempFunc = data.bind(null);
tempFunc.prototype = deepCopy(data.prototype);
return tempFunc;
}
switch (Object.prototype.toString.call(data)) {
case "[object String]":
return data.toString();
case "[object Number]":
return Number(data.toString());
case "[object Boolean]":
return new Boolean(data.toString());
case "[object Date]":
return new Date(data.getTime());
case "[object Array]":
let arr = [];
for (let i = 0; i < data.length; i++) {
arr[i] = deepCopy(data[i]);
}
return arr;
//js自带对象或用户自定义类实例
case "[object Object]":
let obj = {};
for (let key in data) {
//会遍历原型链上的属性方法可以用hasOwnProperty来控制 obj.hasOwnProperty(prop)
obj[key] = deepCopy(data[key]);
}
return obj;
}
} else {
//string,number,bool,null,undefined,symbol
return data;
}
}

@ -61,6 +61,7 @@
import { import {
getList as getTypes getList as getTypes
} from '@/api/productType' } from '@/api/productType'
import { deepCopy } from '@/utils'
import addCustomer from "@/views/customer/component/addCustomer"; import addCustomer from "@/views/customer/component/addCustomer";
import addOrder from './component/addOrder' import addOrder from './component/addOrder'
@ -72,7 +73,7 @@
data() { data() {
return { return {
select: { select: {
product_type_id:'', product_type_id:[],
page: 1, page: 1,
page_size: 10, page_size: 10,
keyword: '' keyword: ''
@ -264,7 +265,9 @@
}, },
async getCustomers() { async getCustomers() {
const res = await getList(this.select) let copySelect = deepCopy(this.select)
copySelect.product_type_id = copySelect?.product_type_id.toString()
const res = await getList(copySelect)
this.list = res.data.data this.list = res.data.data
this.total = res.data.total this.total = res.data.total
}, },

@ -7,7 +7,11 @@
<slot> <slot>
<div class="xy-table-item-content"> <div class="xy-table-item-content">
<el-select size="small" placeholder="关联板块" multiple v-model="selector.product_type_id" style="width:260px;margin-right: 10px;">
<el-option v-for="(item,index) in types" :key="item.id" :value="item.id" :label="item.name" ></el-option>
</el-select>
<el-cascader <el-cascader
size="small"
:value="selector.area_id" :value="selector.area_id"
style="width: 200px;" style="width: 200px;"
placeholder="区域选择" placeholder="区域选择"
@ -20,6 +24,7 @@
@change="areaClick" @change="areaClick"
> >
</el-cascader> </el-cascader>
<el-button size="small" type="primary" style="margin-left: 10px;" @click="search"></el-button>
</div> </div>
<!-- <Input placeholder="关键字搜索" v-model="selector.keyword" style="width: 200px; margin-right: 10px" />--> <!-- <Input placeholder="关键字搜索" v-model="selector.keyword" style="width: 200px; margin-right: 10px" />-->
@ -63,6 +68,8 @@
import { getparameter } from '@/api/system/dictionary' import { getparameter } from '@/api/system/dictionary'
import { AMapManager,lazyAMapApiLoaderInstance } from 'vue-amap' import { AMapManager,lazyAMapApiLoaderInstance } from 'vue-amap'
import { getList } from '@/api/customer' import { getList } from '@/api/customer'
import {getList as getTypes} from "@/api/productType";
import {deepCopy} from "@/utils";
const amapManager = new AMapManager() const amapManager = new AMapManager()
export default { export default {
@ -73,7 +80,8 @@ export default {
page: 1, page: 1,
page_size: 9999, page_size: 9999,
keyword: '', keyword: '',
area_id:'' area_id:'',
product_type_id:[]
}, },
height:0, height:0,
amapManager, amapManager,
@ -82,6 +90,7 @@ export default {
markers:[], markers:[],
polygons:[], polygons:[],
areas:[], areas:[],
types:[],
isShowCard:false, isShowCard:false,
select:'', select:'',
@ -89,6 +98,19 @@ export default {
} }
}, },
methods: { methods: {
async search(){
await this.getCustomers()
this.draw()
},
async getTypes() {
const res = await getTypes({
page: 1,
page_size: 9999
}, false)
this.types = res.data
},
async getAreas(){ async getAreas(){
let city = await getparameter({ let city = await getparameter({
number: 'city' number: 'city'
@ -115,8 +137,6 @@ export default {
async areaClick(e){ async areaClick(e){
this.selector.area_id = e this.selector.area_id = e
await this.getCustomers()
this.draw()
}, },
initDistrict(){ initDistrict(){
@ -147,7 +167,9 @@ export default {
}) })
this.polygons.push(polygon) this.polygons.push(polygon)
} }
this.map.add(this.polygons) this.polygons.forEach(item1 => {
this.map.add(item1)
})
this.map.setFitView(this.polygons) this.map.setFitView(this.polygons)
} }
}) })
@ -183,7 +205,9 @@ export default {
}, },
async getCustomers(){ async getCustomers(){
let res = await getList(this.selector) let copySelect = deepCopy(this.selector)
copySelect.product_type_id = copySelect?.product_type_id.toString()
let res = await getList(copySelect)
this.customers = res.data.data.map(item => { this.customers = res.data.data.map(item => {
let address = item.customer_address.filter(item => item.default === 1)[0] ? item.customer_address.filter(item => item.default === 1)[0] : item.customer_address[0] let address = item.customer_address.filter(item => item.default === 1)[0] ? item.customer_address.filter(item => item.default === 1)[0] : item.customer_address[0]
return { return {
@ -223,7 +247,10 @@ export default {
}, },
draw(){ draw(){
this.map.remove(this.polygons) this.map.clearMap()
this.polygons.forEach(item => {
this.map.remove(item)
})
this.map.remove(this.markers) this.map.remove(this.markers)
this.drawMarkers() this.drawMarkers()
this.drawPolygon(this.areaMap.get(this.selector.area_id) || '常州市') this.drawPolygon(this.areaMap.get(this.selector.area_id) || '常州市')
@ -243,6 +270,7 @@ export default {
created() { created() {
this.initLoad() this.initLoad()
this.getAreas() this.getAreas()
this.getTypes()
} }
} }
</script> </script>

@ -140,7 +140,7 @@ export default {
page:1, page:1,
page_size:9999, page_size:9999,
is_export:1 is_export:1
},'服务统计表.xls') },`服务统计表${this.select.month}.xls`)
}, },

Loading…
Cancel
Save