MemberForm.cshtml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. @{
  2. ViewBag.Title = "添加成员";
  3. Layout = "~/Views/Shared/_LayoutIndex.cshtml";
  4. }
  5. <script>
  6. $(function () {
  7. InitialPage();
  8. GetMember();
  9. GetTree();
  10. });
  11. //初始化页面
  12. function InitialPage() {
  13. //layout布局
  14. $('#layout').layout({
  15. applyDemoStyles: true,
  16. west__size: 200,
  17. spacing_open: 0,
  18. onresize: function () {
  19. $(window).resize()
  20. }
  21. });
  22. $(".center-Panel").height($(window).height() - 40)
  23. }
  24. //加载树
  25. var departmentid = "card-box";
  26. function GetTree() {
  27. var item = {
  28. height: $(window).height(),
  29. url: "../../BaseManage/Department/GetOrganizeTreeJson",
  30. onnodeclick: function (item) {
  31. Loading(true);
  32. window.setTimeout(function () {
  33. if (item.parentnodes == "0") {
  34. $(".card-box").show();
  35. departmentid = "card-box";
  36. } else {
  37. $(".card-box").hide();
  38. $('.' + item.id).show();
  39. departmentid = item.id;
  40. }
  41. Loading(false);
  42. }, 200);
  43. }
  44. };
  45. //初始化
  46. $("#itemTree").treeview(item);
  47. }
  48. //加载成员
  49. function GetMember() {
  50. $.ajax({
  51. url: "../../BaseManage/User/GetListJson",
  52. type: "get",
  53. dataType: "json",
  54. async: false,
  55. success: function (data) {
  56. var _html = "";
  57. $.each(data, function (i) {
  58. var row = data[i];
  59. var imgName = "UserCard01.png";
  60. if (row.Gender == 1) {
  61. imgName = "UserCard02.png";
  62. }
  63. _html += '<div class="card-box ' + row.DepartmentId + '">';
  64. _html += ' <div class="card-box-img">';
  65. _html += ' <img src="/Content/images/' + imgName + '" />';
  66. _html += ' </div>';
  67. _html += ' <div id="' + row.UserId + '" class="card-box-content">';
  68. _html += ' <p>账户:' + row.Account + '</p>';
  69. _html += ' <p>姓名:' + row.RealName + '</p>';
  70. _html += ' <p>部门:' + top.clientdepartmentData[row.DepartmentId].FullName + '</p>';
  71. _html += ' </div><i></i>';
  72. _html += '</div>';
  73. });
  74. $(".gridPanel").html(_html);
  75. $(".card-box").click(function () {
  76. if (!$(this).hasClass("active")) {
  77. $(this).addClass("active")
  78. } else {
  79. $(this).removeClass("active")
  80. }
  81. })
  82. Loading(false);
  83. }, beforeSend: function () {
  84. Loading(true);
  85. }
  86. });
  87. //模糊查询用户(注:这个方法是理由jquery查询)
  88. $("#txt_TreeKeyword").keyup(function () {
  89. var value = $(this).val();
  90. if (value != "") {
  91. window.setTimeout(function () {
  92. $("." + departmentid)
  93. .hide()
  94. .filter(":contains('" + (value) + "')")
  95. .show();
  96. }, 200);
  97. } else {
  98. $("." + departmentid).show();
  99. }
  100. }).keyup();
  101. var getRowData = $.currentIframe().$("#gridTable").jqGrid("getRowData");
  102. for (var i = 0; i < getRowData.length; i++) {
  103. $("#" + getRowData[i].Id).parents('.card-box').remove();
  104. }
  105. }
  106. //保存表单
  107. function AcceptClick() {
  108. var userIds = [];
  109. $('.gridPanel .active .card-box-content').each(function () {
  110. userIds.push($(this).attr('id'));
  111. });
  112. var postData = $("#form1").GetWebControls();
  113. postData["userIds"] = String(userIds)
  114. $.SaveForm({
  115. url: "../../WeChatManage/User/SaveMember",
  116. param: postData,
  117. success: function () {
  118. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  119. }
  120. })
  121. }
  122. </script>
  123. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  124. <div class="ui-layout-west">
  125. <div class="west-Panel" style="margin: 0px; border-top: none; border-left: none; border-bottom: none;">
  126. <div id="itemTree"></div>
  127. </div>
  128. </div>
  129. <div class="ui-layout-center">
  130. <div class="treesearch">
  131. <input id="txt_TreeKeyword" type="text" class="form-control" style="border-top: none;" placeholder="请输入要查询关键字" />
  132. <span id="btn_TreeSearch" class="input-query" title="Search"><i class="fa fa-search"></i></span>
  133. </div>
  134. <div class="center-Panel" style="margin: 0px; border-right: none; border-left: none; border-bottom: none; background-color: #fff; overflow: auto; padding-bottom: 10px;">
  135. <div class="gridPanel">
  136. </div>
  137. </div>
  138. </div>
  139. </div>