areasite.js备份20231205
11.8 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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
require(['jstree'], function () {
Table.api.init();
// 巡检点列表
var table1 = $("#table1");
table1.bootstrapTable({
toolbar: '#toolbar1',
url: "inspection/areasite/index",
extend: {
index_url: 'inspection/areasite/index',
add_url: 'inspection/areasite/add',
edit_url: 'inspection/areasite/edit',
del_url: 'inspection/areasite/del',
multi_url: 'inspection/areasite/multi',
table: 'inspection_areasite',
},
sortName: 'id',
pageSize:10,
search: false,
columns: [
[
{field: '',radio: true},
{field: 'id', title: __('Id'),operate:false},
{field: 'site_name', title: __('巡检点名称'),operate:'like'},
{field: 'verify', title: __('验证方式'),operate:false,formatter: Controller.api.formatter.verify},
{field: 'lnglat', title: __('经纬度'),operate:false},
{field: 'distance', title: __('有效距离(米)'),operate:false},
{field: 'createtime', title: __('添加时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate,
buttons: [
{
name: 'qrcode',
title: __('二维码'),
text:'二维码',
classname: 'btn btn-xs btn-default btn-dialog qrcode',
icon: 'fa fa-file-text',
url:'inspection/areasite/qrcode',
click: function (e, data) {
alert(123)
}
}
,{
name: 'item',
title: __('检查项管理'),
text:'检查项管理',
classname: 'btn btn-xs btn-default btn-click',
icon: 'fa fa-file-text',
click: function (e, data) {
}
}
],
formatter: Table.api.formatter.operate}
]
]
});
// 为表格1绑定事件
Table.api.bindevent(table1);
// 表格2
var table2 = $("#table2");
table2.bootstrapTable({
url: "inspection/areaitem/index",
extend: {
index_url: 'inspection/areaitem/index',
add_url: 'inspection/areaitem/add',
edit_url: 'inspection/areaitem/edit',
del_url: 'inspection/areaitem/del',
multi_url: 'inspection/areaitem/multi',
table: 'inspection_areaitem',
},
toolbar: '#toolbar2',
sortName: 'id',
pageSize:5,
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'item_name', title: __('检查项名称')},
{field: 'weigh', title: __('排序')},
{field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格2绑定事件
Table.api.bindevent(table2);
table1.on('click-row.bs.table', function (e, data) {
table2.bootstrapTable('refreshOptions',{url: "inspection/areaitem/index?areasite_id="+data.id,pageNumber:1, extend: {
index_url: 'inspection/areaitem/index?areasite_id='+data.id,
add_url: 'inspection/areaitem/add?areasite_id='+data.id,
edit_url: 'inspection/areaitem/edit',
del_url: 'inspection/areaitem/del',
multi_url: 'inspection/areaitem/multi',
table: 'inspection_areaitem',
},pageSize:5})
$("#toolbar2").find(".btn-add").removeClass("btn-disabled").removeClass("disabled");
});
$('#channeltree').on("changed.jstree", function (e, data) {
if(data.node){
node_id = data.node.id;
table1.bootstrapTable('refresh', {url: "inspection/areasite/index?area_id="+node_id,pageNumber:1});
table2.bootstrapTable('refreshOptions',{url: "inspection/areaitem/index?areasite_id="+data.id,pageNumber:1, extend: {
index_url: 'inspection/areaitem/index?areasite_id='+data.id,
add_url: 'inspection/areaitem/add?areasite_id='+data.id,
edit_url: 'inspection/areaitem/edit',
del_url: 'inspection/areaitem/del',
multi_url: 'inspection/areaitem/multi',
table: 'inspection_areaitem',
}})
$("#toolbar2").find(".btn-add").addClass("btn-disabled").addClass("disabled");
}
return false;
});
$('#channeltree').jstree({
"checkbox": {"keep_selected_style": false,},
"types": {
"total": {"icon": "fa fa-folder-o",},
"folder": {"icon": "fa fa-folder",},
"disabled": {"check_node": false,"uncheck_node": false}
},
'plugins': ["types"],
"core": {
"themes": {
"stripes": false,
"dots": false,//是否显示树连接线
"icons": true,//是否显示节点的图标
},
'check_callback': true,
'data':{
'url' : 'inspection/area/tree',
'data' : function (node) {
return { 'id' : node.id};
}
}
}
});
})
},
add: function () {
var timer;
$("input[type='radio']").on("click",function () {
if($("input[name='row[verify]']:checked").val()=="1"){
$(".lnglat").show()
timer = setInterval(function () {
$.ajax({
url:'inspection/areasite/getLnglat',
data:{id:0,distance:$("#c-distance").val()},
success:function (response) {
if(response.code){
// if(response.data.lng && response.data.lat){
// $("#c-lnglat").val(response.data.lng+","+response.data.lat);
// }
}
}
})
},2000)
}else{
$(".lnglat").hide()
clearInterval(timer)
}
})
$(".btn-getlnglat").click(function () {
Fast.api.open("inspection/areasite/ercode?id=0", __('扫码获取精确定位'), {
area:["250px","300px"],
callback:function (data) {
$("#c-audio_id").val(data.MediaId);
$("#c-audio_title").val(data.AudioTitle);
}
});
})
Controller.api.bindevent();
},
edit: function () {
var timer;
$("input[type='radio']").on("click",function () {
if($("input[name='row[verify]']:checked").val()=="1"){
$(".lnglat").show()
timer = setInterval(function () {
$.ajax({
url:'inspection/areasite/getLnglat',
data:{id:$("#c-id").val(),distance:$("#c-distance").val()},
success:function (response) {
if(response.code){
// if(response.data.lng && response.data.lat){
// $("#c-lnglat").val(response.data.lng+","+response.data.lat);
// }
}
}
})
},2000)
}else{
$(".lnglat").hide()
clearInterval(timer)
}
})
if($("input[name='row[verify]']:checked").val()=="1"){
timer = setInterval(function () {
$.ajax({
url:'inspection/areasite/getLnglat',
data:{id:$("#c-id").val(),distance:$("#c-distance").val()},
success:function (response) {
if(response.code){
// if(response.data.lng && response.data.lat){
// $("#c-lnglat").val(response.data.lng+","+response.data.lat);
// }
}
}
})
},2000)
}
$(".btn-getlnglat").click(function () {
Fast.api.open("inspection/areasite/ercode?id="+$("#c-id").val(), __('扫码获取精确定位'), {
area:["250px","300px"],
callback:function (data) {
$("#c-audio_id").val(data.MediaId);
$("#c-audio_title").val(data.AudioTitle);
}
});
})
Controller.api.bindevent();
},
api: {
formatter:{
verify: function (value, row, index) {
switch (value) {
case 0:
return "不验证";
case 1:
return "定位";
}
},
},
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});