KeyBoxList.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /// <reference path="../../easyui/jquery.min.js" />
  2. (function () {
  3. $.fn.combotree.defaults.editable = true;
  4. $.extend($.fn.combotree.defaults.keyHandler, {
  5. up: function () {
  6. console.log('up');
  7. },
  8. down: function () {
  9. console.log('down');
  10. },
  11. enter: function () {
  12. console.log('enter');
  13. },
  14. query: function (q) {
  15. var t = $(this).combotree('tree');
  16. var nodes = t.tree('getChildren');
  17. for (var i = 0; i < nodes.length; i++) {
  18. var node = nodes[i];
  19. if (node.text.indexOf(q) >= 0) {
  20. $(node.target).show();
  21. } else {
  22. $(node.target).hide();
  23. }
  24. }
  25. var opts = $(this).combotree('options');
  26. if (!opts.hasSetEvents) {
  27. opts.hasSetEvents = true;
  28. var onShowPanel = opts.onShowPanel;
  29. opts.onShowPanel = function () {
  30. var nodes = t.tree('getChildren');
  31. for (var i = 0; i < nodes.length; i++) {
  32. $(nodes[i].target).show();
  33. }
  34. onShowPanel.call(this);
  35. };
  36. $(this).combo('options').onShowPanel = opts.onShowPanel;
  37. }
  38. }
  39. });
  40. })(jQuery);
  41. jQuery.ajaxSetup({
  42. complete: function (data) {
  43. //对返回的数据data做判断,
  44. //session过期的话,就location到一个页面
  45. if (data.responseText == 'TimeOut') {
  46. alert("登录超时,请重新登录!");
  47. top.location.href = '../Default.aspx';
  48. }
  49. }
  50. });
  51. //function initAddKey() {
  52. // $("#hid_UserType").val("add");
  53. // $('#txtEquipmentNo').val("");
  54. // //$('#cbLockKeyTypeNo').val("");
  55. // $('#TextRegionGroupsNo').combotree('setValue', $('#Hid_treeValue').val());
  56. // $('#TextUserNo').val("");
  57. // $('#TextKeyName').val("");
  58. // $('#winSetKeyInfo').window('open');
  59. //}
  60. function initEditKey(row) {
  61. $("#hid_UserType").val("modify");
  62. $("#hid_KeyBoxNo").val(row.KeyBoxNo);
  63. $('#txtKeyBoxName').val(row.KeyBoxName);
  64. $('#txtBoxEquipNum').val(row.BoxEquipNum);
  65. $('#txtPosition').val(row.Position);
  66. $('#txtRegionGroupName').combotree('setValue', row.RegionGroupNo);
  67. $('#winSetKeyBoxInfo').window('open');
  68. }
  69. function submit() {
  70. // if (!$('#txtBoxEquipNum').val()) {
  71. // $.messager.alert('提醒', '设备号不能为空', 'error');
  72. // return;
  73. // }
  74. //// if (!$('#TextUserNo').val()) {
  75. //// $.messager.alert('提醒', '保管人不能为空', 'error');
  76. //// return;
  77. //// }
  78. var type = "";
  79. if ($("#hid_UserType").val() === "modify") {
  80. type = "modify";
  81. }
  82. console.log(type);
  83. $.post("../EquipmentAjax/KeyBoxEditAjax.aspx",
  84. {
  85. Type: type,
  86. KeyBoxNo: $("#hid_KeyBoxNo").val(),
  87. KeyBoxName: $('#txtKeyBoxName').val(),
  88. BoxEquipNum: $('#txtBoxEquipNum').val(),
  89. Position: $('#txtPosition').val(),
  90. RegionNo: $('#txtRegionGroupName').combotree('getValue')
  91. },
  92. function(msg) {
  93. if (msg === "true") {
  94. $.messager.alert('提示', '操作成功!');
  95. window.flashTable();
  96. $('#winSetKeyBoxInfo').window('close');
  97. } else {
  98. $.messager.alert('提示', msg, 'error');
  99. }
  100. });
  101. console.log(2);
  102. }
  103. function ShowKeyBoxKey(row) {
  104. $('#boxKeyBoxName').val(row.KeyBoxName);
  105. $('#boxBoxEquipNum').val(row.BoxEquipNum);
  106. $('#boxPosition').val(row.Position);
  107. $('#boxRegionGroupName').val(row.RegionGroupName);
  108. $('#dgKey').datagrid({
  109. url: '../EquipmentAjax/KeyInBoxListAjax.aspx?BoxEquipNum=' +
  110. escape(row.BoxEquipNum),
  111. singleSelect: true,
  112. method: 'post',
  113. multiSort: false,
  114. toolbar: "#tbKey",
  115. rownumbers: false,
  116. remoteSort: false,
  117. pagination: true,
  118. pageSize: 20
  119. });
  120. $("#winGetKeyBoxKeyInfo").window("open");
  121. }
  122. function ShowUserSelector() {
  123. flashUsersAuthTable();
  124. $("#winGetUserInfo").window("open");
  125. }
  126. function resetSearchUser() {
  127. document.getElementById("txtName").value = "";
  128. document.getElementById("TextPosition").value = "";
  129. }
  130. function f_searchuser() {
  131. $('#dgUserSearch').datagrid({
  132. url: '../apply/UserListAjax.aspx?username=' +
  133. escape(document.getElementById("txtName").value) +
  134. '&position=' +
  135. escape(document.getElementById("TextPosition").value)
  136. });
  137. }
  138. function flashUsersAuthTable() {
  139. $('#dgUserSearch').datagrid({
  140. url: '../LockAuthMG/getUsersByRegionNo.ashx?regionno=' + $("#Hid_treeValue3").val()
  141. });
  142. }
  143. function ConfirmClickUser() {
  144. var rows = $('#dgUserSearch').datagrid('getSelections');
  145. if (rows.length === 1) {
  146. var row = rows[0];
  147. //window.returnValue = row.UserName;
  148. //window.close();
  149. document.getElementById("TextUserNo").value = row.UserNo;
  150. $("#winGetUserInfo").window("close");
  151. } else {
  152. //alert("请选择一条记录进行操作");
  153. }
  154. }
  155. function initTreeSelect3(node, data) {
  156. //var rootNode = data[0].children[0];
  157. var rootNode = $('#tt').tree('getRoot');
  158. $('#tt').tree('select', rootNode.target);
  159. var node = $('#tt').tree('getSelected');
  160. document.getElementById("Hid_treeValue3").value = node.id;
  161. if (data) {
  162. var childrens = $("#tt").tree("getChildren", rootNode.target);
  163. if (childrens) {
  164. for (var i = 0; i < childrens.length; i++) {
  165. $("#ut1").tree("collapse", childrens[i].target);
  166. }
  167. }
  168. }
  169. flashUsersAuthTable();
  170. }
  171. function loadTarget3() {
  172. var node = $('#tt').tree('getSelected');
  173. document.getElementById("Hid_treeValue3").value = node.id;
  174. flashUsersAuthTable();
  175. }