1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* Created by cp on 2018/7/2.
*/
// 定义类
class LayerFuncServer {
constructor(vueThis) {
this.vm = vueThis;//类中变量
}
//类中函数
getLayerByMapId(mapId,succFunc,failFunc){
var param=this.getSearchQuery();
let vm = this.vm;
var tempToken =this.token;
vm.$https({
url: 'layer/getAllLayerByMapId',
method: 'get',authType:tempToken
}, param).then((res) => {
if(succFunc){
succFunc(res);
}
}, (error) => {
vm.$message({message: res.data.message, type: 'error'});
if(failFunc){
failFunc();
}
})
}
//获取当前查询参数
getSearchQuery(){
let searchObj = {
}
if(this.mapId){
searchObj.mapId=this.mapId;
}
return searchObj
}
setMapId(tempMapId){
this.mapId=tempMapId;
}
setToken(tempToken){
this.token=tempToken;
}
deleteLayer(layerId,succFunc,failFunc){
let vm=this.vm;
var tempToken =this.token;
//删除活动事件
vm.$confirm('此操作将删除该图层, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
vm.$https({
url:'/layer/delete?id='+layerId,
method:'delete',authType:tempToken,
},{})
.then((res) => {
let data=res.data;
//重新查询数据
if(res.data.status==200||res.data.status==201||res.data.status==203||res.data.status==204){
vm.$message({
type: 'success',
message: '删除成功!'
});
if(succFunc){
succFunc();
}
}else {
vm.$message({
type: 'fail',
message: data
});
}
},(error) => {
vm.$message({
type: 'fail',
message: "删除用户失败!"+error.response.data
});
}
)
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
addLayer(searchObj,succFunc,failFunc) {
var vm= this.vm;
if(!searchObj.mapId){
searchObj.mapId=this.mapId;
}
var param= vm.$querystring.stringify(searchObj);
var tempToken =this.token;
if(searchObj.id&&searchObj.id!=""){
vm.$https({
url:'/layer/edit',
method:'put',authType:tempToken,
},param)
.then((res) => {
if(succFunc){
succFunc(res);
}
}, (error) => {
vm.$message({message: error.data.message, type: 'error'});
if(failFunc){
failFunc(error);
}
}
)
}else{
vm.$https({
url:'/layer/add',
method:'post',authType:tempToken,
}, param)
.then((res) => {
if(succFunc){
succFunc(res);
}
}, (error) => {
vm.$message({message: error.data.message, type: 'error'});
if(failFunc){
failFunc(error);
}
}
)
}
}
}
//静态变量
// Point.para = 'Allen';
export {LayerFuncServer};