groupDetail.html
13.4 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<meta name="referrer" content="no-referrer">
<title>编辑分组</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
<link rel="stylesheet" type="text/css" href="../../css/home.css"/>
<link rel="stylesheet" type="text/css" href="../../css/element.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<style>
html,
body{
background: #F4F6F9;
height: 100%;
}
</style>
</head>
<body>
<div id="app">
<template>
<header class="aui-header-bar alarm-title" >
<div class="aui-header-left" tapmode onclick="closeWin();">
<i class="aui-iconfont aui-icon-left" style="color:#FFFFFF;font-size:16px;">返回</i>
</div>
<div class="aui-title title-font">编辑分组</div>
<div class="aui-header-right" tapmode @click="handleDevice();">
<div style="color: #FFFFFF;">{{ editTitle }}</div>
</div>
</header>
<div style="background:linear-gradient(90deg,rgba(91,127,248,1) 0%,rgba(75,175,239,1) 100%);height:50%;width:auto;"></div>
<div class="group-panel group-list-panel" @click= "editGroupName()">
<div class="group-list-inside-panel">
<el-row style="padding-bottom: 14px;">
<el-col :span=5><span class="group-detail-name-title">分组名称</span></el-col>
<el-col :span=18 style="text-align: right;"><span class="group-detail-name">{{ groupInfo.group_name }}</span></el-col>
<el-col :span=1 style="margin-top: 0.1rem;">
<i class="aui-iconfont aui-icon-right" ></i>
</el-col>
</el-row>
</div>
</div>
<p style="margin-top: 20px;margin-left: 15px;color:rgba(55,57,78,1);font-weight:bold;font-family:PingFang SC;font-size:16px;">分组内设备</p>
<div v-if="deviceList.length > 0" v-for="(list_d, list_i) in deviceList" class="group-panel group-list-panel">
<div class="group-list-inside-panel" tapmode @click= "chooseDevice(list_d, list_i)">
<el-row style="padding-bottom: 15px;">
<el-col :span=5>
<img :src="list_d.pic_url" style="height: 60px;">
</el-col>
<el-col :span=17 style="margin-top: 0.5rem;">
<p style="font-size:14px;font-weight:bold;color:rgba(55,57,78,1);">{{ list_d | storeNameFilter }}</p>
<p style="font-size: 12px;font-weight: 500;color:rgba(174,184,206,1);">型号:{{ list_d.name }} {{ list_d.remark }}</p>
<p style="font-size: 12px;font-weight: 500;color:rgba(174,184,206,1);">编号:{{ list_d.imei }}</p>
</el-col>
<el-col :span=spanImg>
<img src="../../image/alarm/icon-unselected.png" class="device-choose-area" :id="'select_'+ list_i" style="width:18px;height:18px;margin-top:1.3rem;margin-left:15px;" />
</el-col>
</el-row>
</div>
</div>
<div v-if="deviceList.length <= 0">
<div style="top: 10rem;" class="no-data"><img src="../../image/img-nullInfo.png" /><p style="font-size:16px;font-weight:500;color:rgba(55,57,78,1);">这里还没有内容</p><p>先去别的地方看看吧~</p></div>
</div>
</template>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/element.js"></script>
<script type="text/javascript" src="../../script/ctrl.js"></script>
<script type="text/javascript" src="../../script/fastclick.js "></script>
<script type="text/javascript">
var vm,that;
apiready = function(){
api.parseTapmode();
$(function() {
FastClick.attach(document.body);
});
//---------初始化vue
vm = new Vue({
el: '#app',
data: {
editTitle: '编辑',
editVisable: false,
groupInfo: api.pageParam.row,
userId: api.getPrefs({sync: true,key: 'userID'}),
deviceList: [],
spanImg: 0,
choosedDevices: [],
},
filters: {
storeNameFilter(v) {
if (v.storename === "") {
return v.imei
}else {
return v.storename
}
}
},
mounted() {
//window.chooseProduct = this.chooseProduct;
},
created() {
that = this
api.addEventListener({
name: 'groupDetailSelectAll'
}, function(ret, err){
that.choosedDevices = []
var chooseDoms = $api.domAll('.device-choose-area')
if (ret.value.chooseAll) {
for (var j = 0; j < chooseDoms.length; j++) {
chooseDoms[j].src = '../../image/alarm/icon-selected.png';
}
that.deviceList.forEach(d => {
that.choosedDevices.push(d.id)
});
}else {
for (var j = 0; j < chooseDoms.length; j++) {
chooseDoms[j].src = '../../image/alarm/icon-unselected.png';
}
}
});
api.addEventListener({
name: 'group_device_batch_del'
}, function(ret, err){
that.removeDevices()
});
this.initDeviceByGroup()
},
methods: {
handleDevice() {
if (!this.editVisable) {
this.editVisable = true
this.editTitle = '取消'
this.spanImg = 2
//打开底部操作栏
api.openFrame({
name: 'group_tool',
url: './group_footer.html',
rect: {
x: 0,
y: api.winHeight - 60,
w: api.winWidth,
h: 65
},
pageParam: {
from: 'groupDetail'
}
});
}else {
this.editVisable = false
this.editTitle = '编辑'
this.spanImg = 0
api.closeFrame({
name: 'group_tool'
});
var chooseDoms = $api.domAll('.device-choose-area');
for (var j = 0; j < chooseDoms.length; j++) {
chooseDoms[j].src = '../../image/alarm/icon-unselected.png';
}
this.choosedDevices = []
}
},
editGroupName() {
api.prompt({
title: '编辑分组名称',
text: this.groupInfo.group_name,
buttons: ['取消', '修改']
},async function(ret, err) {
var index = ret.buttonIndex;
var text = ret.text;
if (index == 2) {
if (text.length <= 15 && text != '') {
let params = {
id: that.groupInfo.id,
group_name: text
}
let result = await post_update_user_groups(params)
if (result && result.message === '成功') {
api.toast({msg: '修改成功!'});
}
that.initUserGroups()
}else if (text == '') {
api.toast({msg: '分组名称不可为空'});
}else if (text.length > 15) {
api.toast({msg: '分组名称最多15个字符!'});
}
}
});
},
async initUserGroups() {
let dataRes = await get_user_groups(this.userId)
let groupList = dataRes.data.List
api.sendEvent({
name: 'init_group_list',
});
api.sendEvent({
name: 'init_group_list2',
});
groupList.forEach(d => {
if (d.id === this.groupInfo.id) {
this.groupInfo = d
}
});
},
async initDeviceByGroup() {
let deviceListRes =await get_devices_by_group_id(this.groupInfo.id)
console.log(JSON.stringify(deviceListRes));
if (deviceListRes && deviceListRes.data.TotalCount > 0) {
let deviceList_ = deviceListRes.data.List
// deviceList_.forEach(d => {
// // 缓存图片
// let pic_url_ = $api.getStorage(d.pic_url)
// if (!pic_url_) {
// api.imageCache({
// url: d.pic_url
// }, function(ret, err) {
// var url = ret.url;
// $api.setStorage(d.pic_url, url);
// d.pic_url = url
// });
// }else {
// d.pic_url = pic_url_
// }
// });
//--------
this.deviceList = deviceList_
}else {
this.deviceList = []
}
},
chooseDevice(row, i) {
let imgPath = $api.byId('select_' + i).src
if (imgPath.indexOf("unselected") != -1) { //点击前是未选择状态(点击选择)
$api.byId('select_' + i).src = '../../image/alarm/icon-selected.png'
//handle...
this.choosedDevices.push(row.id)
}else {
$api.byId('select_' + i).src = '../../image/alarm/icon-unselected.png'
//handle...
let index = this.choosedDevices.indexOf(row.id);
this.choosedDevices.splice(index,1)
}
},
removeDevices() {
var dialogBox = api.require('dialogBox');
dialogBox.alert({
texts: {
title: '',
content: '确定删除已选择的设备吗?',
leftBtnTitle: '取消',
rightBtnTitle: '确定'
},
styles: {
bg: '#fff',
w: 300,
corner:2,
title: {
marginT: 20,
icon: '../../image/mine/img-signOut.png',
iconSize: 74,
titleSize: 14,
titleColor: '#000'
},
content: {
color: '#37394E',
size: 14
},
left: {
marginB: 0,
marginL: 0,
w: 150,
h: 47,
corner: 10,
bg: '#FFFFFF',
color: '#818295',
size: 16
},
right: {
marginB: 0,
marginL: 0,
w: 150,
h: 47,
corner: 10,
bg: '#FFFFFF',
color: '#5B7FF8',
size: 16
},
horizontalLine:{
color:'rgba(240,245,255,1)',
height:1
},
verticalLine:{
color:'rgba(240,245,255,1)',
width:1 //(可选项)数字类型;左右边按钮竖线的高度;默认:0
}
}
},async function(ret) {
dialogBox.close({
dialogName: 'alert'
});
if (ret.eventType == 'right') {
let params = {
ids: that.choosedDevices
}
console.log(JSON.stringify(that.choosedDevices));
let delRes = await post_remove_device_by_group(params)
console.log(JSON.stringify(delRes));
if (delRes.code === 200) {
api.toast({msg: '删除成功!',duration: 2000,location: 'bottom'});
}else {
api.toast({msg: '删除失败!',duration: 2000,location: 'bottom'});
}
that.initDeviceByGroup()
api.sendEvent({
name: 'delDeviceToGroupFinish',
});
}
});
}
}
})
};
</script>
</html>