PersonList.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 initAddPerson() {
  52. $('#txtLoginCode').removeAttr("readonly");
  53. //$('#txtUserNo').attr("readonly", "false");
  54. $("#hid_UserType").val("add");
  55. $("#txtPassword2").removeAttr("readonly");
  56. $("#txtPassword").removeAttr("readonly");
  57. $('#txtPersonName').val("");
  58. $('#txtLoginCode').val("");
  59. $('#txtDescription').val("");
  60. $("#TextPersonGroupsNo").combotree('setValue', $('#hid_PersonGroupsNo').val());
  61. $("#cbGroupGroupsNo").combotree('setValue', $('#Hid_treeValue').val());
  62. $("#txtMobile").val("");
  63. $("#txtPassword2").val("");
  64. $("#txtPassword").val("");
  65. var curr_time = new Date();
  66. var strDate = curr_time.getFullYear();
  67. strDate = strDate + 10;
  68. strDate = strDate + "-";
  69. strDate += curr_time.getMonth() + 1 + "-";
  70. strDate += curr_time.getDate();
  71. $("#ExpirationDate").datebox('setValue', strDate);
  72. //$("#ExpirationDate").datebox('setValue', myformatter(new Date(rows[0].Expiration)));
  73. $('#winSetPersonInfo').window('open');
  74. }
  75. function myformatter(date) {
  76. var y = date.getFullYear();
  77. var m = date.getMonth() + 1;
  78. var d = date.getDate();
  79. return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
  80. }
  81. function initEditPerson(row) {
  82. $("#hid_UserType").val("modify");
  83. $('#txtLoginCode').attr("readonly", "true");
  84. //var rows = $('#dg').datagrid('getSelections');
  85. //var row = rows[0];
  86. $("#txtPassword2").attr("readonly", "readonly");
  87. $("#txtPassword").attr("readonly", "readonly");
  88. $('#txtLoginCode').val(row.LoginCode);
  89. $('#txtPersonName').val(row.PersonName);
  90. $('#txtDescription').val(row.Description);
  91. $("#txtMobile").val(row.Mobile);
  92. $("#txtPassword2").val(row.Password);
  93. $("#txtPassword").val(row.Password);
  94. //$('#TextIDCard').val(row.IDCard);
  95. //$("#cbSysRoleNo").val(row.SysRoleNo.trim());
  96. $("#cbPersonType").val(row.PersonType);
  97. $('#TextPersonGroupsNo').combotree('setValue', row.PersonGroupNo);
  98. $("#cbGroupGroupsNo").combotree('setValue', row.RegionGroupNo);
  99. $("#ExpirationDate").datebox('setValue', myformatter(new Date(row.Expiration)));
  100. $('#winSetPersonInfo').window('open');
  101. }
  102. function submit() {
  103. if (!$('#txtLoginCode').val()) {
  104. $.messager.alert('提醒', '用户编号不能为空', 'error');
  105. return;
  106. }
  107. if (!$('#txtPassword').val()) {
  108. $.messager.alert('提醒', '密码不能为空', 'error');
  109. return;
  110. }
  111. if ($('#txtPassword').val().length < 6) {
  112. $.messager.alert('提醒', '密码不能小于6位', 'error');
  113. return;
  114. }
  115. if ($('#txtPassword').val() != $('#txtPassword2').val()) {
  116. $.messager.alert('提醒', '两次输入的密码不一致!', 'error');
  117. return;
  118. }
  119. // var userno;
  120. // if ($("#hid_UserType").val() == "modify") {
  121. // var rows = $('#dg').datagrid('getSelections');
  122. // var row = rows[0];
  123. // userno = row.UserNo;
  124. // }
  125. $.post("../UserMGAjax/PersonsEditAjax.aspx", {
  126. LoginCode: $('#txtLoginCode').val(), type: $('#hid_UserType').val(), PersonName: $('#txtPersonName').val(),
  127. Description: $('#txtDescription').val(), regionno: $("#cbGroupGroupsNo").combotree("getValue"),
  128. PersonGroupsNo: $('#TextPersonGroupsNo').combotree("getValue"), Mobile: $('#txtMobile').val(), ExpirationDate: $("#ExpirationDate").datebox('getValue'),
  129. PersonType: $("#cbPersonType").val(), password: $("#txtPassword").val().trim()
  130. }, function (msg) {
  131. if (msg == "true") {
  132. $.messager.alert('提示', '操作成功!');
  133. flashTable();
  134. $('#winSetPersonInfo').window('close');
  135. } else {
  136. $.messager.alert('提示', msg, 'error');
  137. }
  138. })
  139. }