master
xy 3 years ago
parent bb0dd27ffc
commit 06289dde6e

@ -170,3 +170,47 @@ export function getSex(idCard) {
}
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 {
getList as getTypes
} from '@/api/productType'
import { deepCopy } from '@/utils'
import addCustomer from "@/views/customer/component/addCustomer";
import addOrder from './component/addOrder'
@ -72,7 +73,7 @@
data() {
return {
select: {
product_type_id:'',
product_type_id:[],
page: 1,
page_size: 10,
keyword: ''
@ -264,7 +265,9 @@
},
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.total = res.data.total
},

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

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

Loading…
Cancel
Save