提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
//test data start |
|
7 |
// var data_getList = Mock.mock('/basicconfig/gates/getCEquipmentList.htm', {code: 0, list: [{id: '33', eqname: '显示器', equipmentno: 'e123213', mclientNo: 'mc12312321', type: '道闸', ip: '1.1.2.1', serviceIP: '2.2.3.3', port: '235', servicePort: '5555', aname: 'zhangsan', password: '', state: false, aspect: 1}]}) |
|
8 |
// var data_doDel = Mock.mock('/basicconfig/gates/delCEquipmentItem.htm', {code: 0, }) |
|
9 |
// var data_doUsed = Mock.mock('/basicconfig/gates/cequipmentChangeState.htm', {code: 0, }) |
|
10 |
//test data end |
|
11 |
|
|
12 |
window.I = { |
|
13 |
relationno: $('#relationno').val() |
|
14 |
} |
|
15 |
|
|
16 |
var ViewModel = function() { |
|
17 |
var self = this; |
|
18 |
self.list = ko.observableArray(); |
|
19 |
self.used = function (item) { |
|
20 |
// doUsed(item); |
|
21 |
} |
|
22 |
|
|
23 |
self.del = function(item) { |
|
24 |
delConfirm(item); |
|
25 |
} |
|
26 |
} |
|
27 |
|
|
28 |
$(function () { |
|
29 |
window.vm = new ViewModel(); |
|
30 |
ko.applyBindings(vm); |
|
31 |
if (I.relationno) { |
|
32 |
getList(I.relationno); |
|
33 |
} |
|
34 |
pageInit(); |
|
35 |
$('#newceq').click(function(event) { |
|
36 |
var relationno=$('#relationno').val(); |
|
37 |
jQuery.post('/basicconfig/gates/getMClient.htm', {relationno:relationno}, function(data, textStatus, xhr) { |
|
38 |
if(data.item!=null){ |
|
39 |
window.location.href="gates_cequipmentEdit.jsf?mclientNo="+data.item.mclientNo; |
|
40 |
}else{ |
|
41 |
// parent.showErrmsg("没有门禁客户端,请先配置门禁客户端!"); |
|
42 |
swal({title:'',text:'没有门禁客户端,请先配置门禁客户端',type:'error',confirmButtonText:'确定'}); |
|
43 |
} |
|
44 |
}); |
|
45 |
}); |
|
46 |
}); |
|
47 |
|
|
48 |
function pageInit() { |
|
49 |
} |
|
50 |
|
|
51 |
function getList(mclientNo) { |
|
52 |
$.post("/basicconfig/gates/getCEquipmentList.htm", {mclientNo: mclientNo}, |
|
53 |
function (data, textStatus, jqXHR) { |
|
54 |
vm.list.removeAll(); |
|
55 |
if (data.code >= 1) { |
|
56 |
//parent.showErrmsg(data.errmsg); |
|
57 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
58 |
return; |
|
59 |
} |
|
60 |
if (data.code == 0) { |
|
61 |
if (isList(data.list)) { |
|
62 |
$.each(data.list, function (index, value) { |
|
63 |
value.state = ko.observable(value.state); |
|
64 |
vm.list.push(value); |
|
65 |
}); |
|
66 |
} |
|
67 |
return; |
|
68 |
} |
|
69 |
}, |
|
70 |
"json" |
|
71 |
); |
|
72 |
} |
|
73 |
|
|
74 |
function delConfirm(item) { |
|
75 |
$("#modalContent").html('确定要删除【' + item.eqname + '】吗?'); |
|
76 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
77 |
resizable: false, |
|
78 |
width: '320', |
|
79 |
modal: true, |
|
80 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
81 |
title_html: true, |
|
82 |
position: { my: "center", at: "center", of: window }, |
|
83 |
buttons: [ |
|
84 |
{ |
|
85 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
86 |
"class" : "btn btn-danger btn-minier", |
|
87 |
click: function() { |
|
88 |
$( this ).dialog( "close" ); |
|
89 |
doDel(item); |
|
90 |
} |
|
91 |
} |
|
92 |
, |
|
93 |
{ |
|
94 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
95 |
"class" : "btn btn-minier", |
|
96 |
click: function() { |
|
97 |
$( this ).dialog( "close" ); |
|
98 |
} |
|
99 |
} |
|
100 |
] |
|
101 |
}); |
|
102 |
} |
|
103 |
|
|
104 |
|
|
105 |
function doDel(item) { |
|
106 |
if (!!I.AjaxDelItem) return; |
|
107 |
I.AjaxDelItem = true; |
|
108 |
$.post('/basicconfig/gates/delCEquipmentItem.htm', {id: item.id}, function(data, textStatus, xhr) { |
|
109 |
I.AjaxDelItem = false; |
|
110 |
if (data.code >= 1) { |
|
111 |
// parent.showErrmsg(data.errmsg); |
|
112 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
113 |
return; |
|
114 |
} |
|
115 |
if (data.code == 0) { |
|
116 |
vm.list.remove(item); |
|
117 |
location.replace(location.href); |
|
118 |
return; |
|
119 |
} |
|
120 |
}, 'json'); |
|
121 |
} |
|
122 |
|
|
123 |
function doUsed(item) { |
|
124 |
if (!I.AjaxChangeUsed) { |
|
125 |
var used = !item.state(); |
|
126 |
I.AjaxChangeUsed = true; |
|
127 |
$.post('/basicconfig/gates/cequipmentChangeState.htm', {id: item.id, state: used}, function(data, textStatus, xhr) { |
|
128 |
I.AjaxChangeUsed = false; |
|
129 |
if (data.code >= 1) { |
|
130 |
//parent.showErrmsg(data.errmsg); |
|
131 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
132 |
return; |
|
133 |
} |
|
134 |
if (data.code == 0) { |
|
135 |
item.state(used); |
|
136 |
return; |
|
137 |
} |
|
138 |
}, 'json'); |
|
139 |
} |
|
140 |
} |