deviceGroup_win.html
7.11 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
<!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">
<title>我的分组_win</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%;
width: 100%;
}
</style>
</head>
<body>
<div id="app">
<template>
<div v-if="groupList.length > 0">
<div class="group-panel" v-for="(list_d, list_i) in groupList">
<div class="group-list-panel" tapmode @click="chooseToHandle(list_d, list_i)">
<div class="group-list-inside-panel">
<el-row>
<el-col :span=12>
<span class="group-list-panel-title">{{ list_d.group_name }}</span>
</el-col>
<el-col :span=11>
<div class="group-list-panel-subtitle">{{ list_d.total }}个设备</div>
</el-col>
<el-col :span=1>
<i class="aui-iconfont aui-icon-right"></i>
</el-col>
</el-row>
<div class="group-list-line"></div>
<el-row style="padding-bottom: 10px;">
<el-col :span=1>
<img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
</el-col>
<el-col :span=6><span class="group-normal-span">在线: {{ list_d.on_line }}</span></el-col>
<el-col :span=2> </el-col>
<el-col :span=1>
<img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
</el-col>
<el-col :span=6><span class="group-normal-span">离线: {{ list_d.off_line }}</span></el-col>
</el-row>
</div>
</div>
</div>
<div class="group-panel group-manage-btn" tapmode @click="groupManage()">分组管理</div>
</div>
<div v-if="groupList.length <= 0">
<div class="no-list-data" style="top: 2rem;">
<img src="../../image/img-nullInfo.png" />
<!-- <p style="font-size:16px;font-weight:500;color:rgba(55,57,78,1);">这里还没有内容</p> -->
<p><div class="aui-btn add-device-btn" tapmode @click="addGroup">添加分组</div></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(){
$(function() {
FastClick.attach(document.body);
});
//---------初始化vue
vm = new Vue({
el: '#app',
data: {
userId: api.getPrefs({sync: true,key: 'userID'}),
token: api.getPrefs({sync: true,key: 'userToken'}),
groupList: [],
},
created() {
that = this
api.setRefreshHeaderInfo({
bgColor: '#F4F6F9',
textColor: 'rgba(55,57,78,1)',
textDown: '下拉刷新设备列表...',
textUp: '松开刷新...'
}, function(ret, err) {
that.initUserGroups()
});
api.addEventListener({
name: 'init_group_list'
}, function(ret, err){
that.initUserGroups()
});
api.addEventListener({
name: 'addDeviceToGroupFinish'
}, function(ret, err){
that.initUserGroups()
});
api.addEventListener({
name: 'delDeviceToGroupFinish'
}, function(ret, err){
that.initUserGroups()
});
this.initUserGroups()
// this.chooseToHandle({"id":18,"user_id":"45e3019e-b22f-401c-92b4-03363aae0291","group_name":"2020-06-23","created_at":"2020-06-23 09:53:12","total":0,"on_line":0,"off_line":0}, 1)
},
methods: {
async initUserGroups() {
let dataRes = await get_user_groups(this.userId)
console.log(JSON.stringify(dataRes));
if (dataRes.data.List != null) {
this.groupList = dataRes.data.List
}else {
this.groupList = []
}
api.refreshHeaderLoadDone();
},
chooseToHandle(d, i) {
// console.log(JSON.stringify(d));
api.openWin({
name: 'group_device_info_win.html',
url: './group_device_info_win.html',
bounces: false,
pageParam: {row: d},
});
},
groupManage() {
api.openWin({
name: 'groupManage_win',
url: './groupManage_win.html',
bounces: false
});
},
addGroup() {
let text_ = parseTime(new Date(),'{y}-{m}-{d}')
api.prompt({
title: '新建分组',
text: text_,
buttons: ['取消', '创建']
},async function(ret, err) {
var index = ret.buttonIndex;
var text = ret.text;
if (index == 2) {
if (text.length <= 15 && text != '') {
that.groupList.forEach(d => {
if (d.group_name === text) {
api.toast({msg: '当前组名已存在!'});
return;
}
});
let params = {
user_id: that.userId,
group_name: text
}
let result = await post_create_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个字符!'});
}
}
});
}
}
})
};
</script>
</html>