SelectUser.cshtml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. @{
  2. ViewBag.Title = "选择人员";
  3. Layout = "~/Views/Shared/_Layout.cshtml";
  4. }
  5. @using MES.Production.Service;
  6. @using Central.Control.Domain;
  7. @using Ant.Service.Common;
  8. @using Ant.Service.Common.Enums;
  9. @using CommonToolHelper;
  10. @using MES.Production.Entity;
  11. @model PageInfo
  12. <style type="text/css">
  13. body {
  14. background-color: #fff;
  15. }
  16. .tn {
  17. text-align: center !important;
  18. }
  19. .ckcenter {
  20. margin: 6px auto !important;
  21. }
  22. .table tbody tr td {
  23. padding: 5px 3px !important;
  24. vertical-align: middle;
  25. text-align: left;
  26. }
  27. .table tbody tr td a {
  28. margin-left: 10px;
  29. }
  30. .userlist span {
  31. vertical-align: middle;
  32. text-align: center;
  33. line-height: 25px;
  34. cursor: pointer;
  35. }
  36. .userlist span input[type=checkbox] {
  37. margin-top: -4px;
  38. }
  39. .show-content ul {
  40. list-style: none;
  41. line-height: 25px;
  42. color: #337ab7;
  43. display: inline-block;
  44. margin-top: 20px;
  45. }
  46. .show-content ul li {
  47. float: left;
  48. width: 90px;
  49. margin-right: 15px;
  50. border: 1px solid #18a689;
  51. padding: 2px 3px;
  52. margin-bottom: 10px;
  53. text-align: center;
  54. color: #18a689
  55. }
  56. .show-content ul li input[type=checkbox] {
  57. display: inline;
  58. margin-top: 5px;
  59. }
  60. .show-content ul li:hover {
  61. background-color: #18a689;
  62. color: #ffffff;
  63. cursor: pointer;
  64. }
  65. .show-content .active {
  66. background-color: #18a689;
  67. color: #ffffff;
  68. }
  69. </style>
  70. <!-- table star -->
  71. <div class="row col-lg-12" style=" overflow-y:auto;">
  72. <div class="wrapper-content">
  73. <div class="tab-content">
  74. @using (Ajax.BeginForm("SelectUser", null, new AjaxOptions() { }, new { @id = "form1", @class = "form-horizontal", @method = "get" }))
  75. {
  76. <div id="tab-1" class="tab-pane active">
  77. <!-- search star -->
  78. <div class="form-horizontal clearfix">
  79. <div class="col-lg-4 col-sm-3 pl0" style="width:380px;margin-top:5px;">
  80. <div class="form-group">
  81. <label class="control-label" style="width:70px; float:left;">岗位:</label>
  82. <div class="col-lg-8 col-sm-7" style="width:300px !important;overflow-x:hidden;">
  83. <select id="postid" name="postid" class="input-sm form-control input-s-sm inline">
  84. <option value="" @(ViewData["postid"] == null || ViewData["postid"] == "" ? "selected=\"selected\"" : "")>--请选择--</option>
  85. @{ var post = ViewData["postType"] as List<SYS_CODE>;
  86. foreach (var item in post)
  87. {
  88. <option value="@item.CODEVALUE" @(ViewData["postid"] != null && ViewData["postid"] != "" && Convert.ToInt32(ViewData["postid"]) == Convert.ToInt32(item.CODEVALUE) ? "selected" : "")>@item.NAMETEXT</option>
  89. }
  90. }
  91. </select>
  92. </div>
  93. </div>
  94. </div>
  95. <div class="col-lg-4 col-sm-4" style="float:right; width:200px; margin-right:30px;padding-top:5px;">
  96. <div class="form-group">
  97. <div class="col-lg-12 col-sm-12 input-group">
  98. @Html.TextBox("Search", null, new { @class = "input-sm form-control", @placeholder = "请输入查询用户名" })
  99. <span class="input-group-btn">
  100. <button type="button" onclick="submit()" class="btn btn-sm btn-primary" id="btn-search"> 搜索</button>
  101. </span>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <!-- search end -->
  107. <div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  108. <table class="table table-striped table-bordered table-hover dataTables-example dataTable" cellspacing="0" width="100%">
  109. <thead>
  110. <tr>
  111. <th class="tn"><input id="checkall" class="ckcenter" type="checkbox" value=""></th>
  112. <th style="width:180px !important;">帐号</th>
  113. <th>姓名</th>
  114. <th>角色</th>
  115. </tr>
  116. </thead>
  117. <tbody class="tbshow">
  118. @{foreach (var item in Model.List)
  119. {
  120. <tr data-id="@item.ID">
  121. <td class="tn">
  122. <input name="ckb_per" class="ckcenter" type="checkbox" value="@item.ID" data-parent="@item.NAME">
  123. <input name="hid_per" type="hidden" value="@item.NAME" />
  124. </td>
  125. <td>
  126. @item.ACCOUNT
  127. </td>
  128. <td>@item.NAME</td>
  129. <td>@item.ROLENAME</td>
  130. </tr>
  131. }
  132. }
  133. </tbody>
  134. </table>
  135. <!-- page -->
  136. <div class="bottom">
  137. @if (Model != null)
  138. {
  139. <div class="dataTables_info" id="example_info" Post="status" aria-live="polite">显示第 @Model.BeginPage 至 @Model.EndPage 项结果,共 @Model.Count 项</div>
  140. <div class="dataTables_length" id="example_length">
  141. <label>
  142. 显示
  143. <select name="example_length" onchange="submit()" aria-controls="example" class="form-control input-sm">
  144. <option value="10" @(Model.PageSize == 10 ? "selected" : "")>10</option>
  145. <option value="25" @(Model.PageSize == 25 ? "selected" : "")>25</option>
  146. <option value="50" @(Model.PageSize == 50 ? "selected" : "")>50</option>
  147. <option value="100" @(Model.PageSize == 100 ? "selected" : "")>100</option>
  148. </select> 项结果
  149. </label>
  150. </div>
  151. @CommonHtmlHelper.PaginationPager(Model.Index, Model.PageSize, Model.Count, 7, Model.Url);
  152. }
  153. <div class="clear"></div>
  154. </div>
  155. <!-- page -->
  156. </div>
  157. </div>
  158. }
  159. </div>
  160. </div>
  161. </div>
  162. <div class="hr-line-dashed">
  163. <div class="form-group" style="margin-top:10px !important;">
  164. <div class="col-sm-2 col-sm-offset-2">
  165. <button class="btn btn-primary" id="btn-save" type="submit"><i class="fa fa-check"></i> <span>确定保存</span></button>
  166. <button class="btn btn-warning" id="btn-dig-close1" type="button"><i class="im-undo2"></i> 取消返回</button>
  167. </div>
  168. </div>
  169. </div>
  170. <!-- table end -->
  171. @section scripts{
  172. <script type="text/javascript">
  173. //控制条件显示隐藏
  174. function Show() {
  175. var d = $('#dpt').val();
  176. var s = $('#Search').val();
  177. if (d == '' && s == '') {
  178. $('.tbshow').children('tr').show();
  179. $('.tbshow').children('tr').find('.userlist').children('li').show();
  180. } else if (d != '' && s == '') {
  181. $('.tbshow').children('tr').hide();
  182. $('.tbshow').children('tr').each(function () {
  183. if ($(this).attr('data-id') == d) {
  184. $(this).show();
  185. $(this).children('td').find('.userlist').children('li').show();
  186. }
  187. });
  188. } else if (d == '' && s != '') {
  189. var tr = '';
  190. $('.tbshow').children('tr').children('td').find('.userlist').children('li').each(function () {
  191. var li = $(this).attr('data-user');
  192. if (li.indexOf(s) >= 0) {
  193. $(this).show();
  194. tr += $(this).parent().parent().parent().attr('data-id') + ',';
  195. } else {
  196. $(this).hide();
  197. }
  198. });
  199. if (tr != '') {
  200. $('.tbshow').children('tr').each(function () {
  201. if (tr.indexOf($(this).attr('data-id') + ',') >= 0) {
  202. $(this).show();
  203. } else {
  204. $(this).hide();
  205. }
  206. });
  207. } else {
  208. $('.tbshow').children('tr').hide();
  209. }
  210. } else {
  211. $('.tbshow').children('tr').hide();
  212. $('.tbshow').children('tr').each(function () {
  213. if ($(this).attr('data-id') == d) {
  214. $(this).show();
  215. $(this).children('td').find('.userlist').children('li').each(function () {
  216. var li = $(this).attr('data-user');
  217. if (li.indexOf(s) >= 0) {
  218. $(this).show();
  219. } else {
  220. $(this).hide();
  221. }
  222. });
  223. }
  224. });
  225. }
  226. }
  227. $(function () {
  228. $('.select2').select2();
  229. var dialog = top.dialog.get(window);
  230. //全选 反选
  231. $('input[id="checkall"]').change(function () {
  232. if ($(this).prop("checked")) {
  233. $("input[name='ckb_module']:checkbox,input[id='checkall']:checkbox").each(function () {
  234. if ($(this).prop("checked") == false) {
  235. $(this).prop("checked", true);
  236. $('.ckcenter').each(function () {
  237. $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]:checkbox').prop('checked', true);
  238. });
  239. }
  240. });
  241. }
  242. else {
  243. $("input[name='ckb_module']:checkbox,input[id='checkall']:checkbox").each(function () {
  244. if ($(this).prop("checked") == true) {
  245. $(this).prop("checked", false);
  246. $('.ckcenter').each(function () {
  247. $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]:checkbox').prop('checked', false);
  248. });
  249. }
  250. });
  251. }
  252. });
  253. //自身选中 反选
  254. $('.userlist span').click(function () {
  255. var ckb = $(this).prev('input');
  256. if (ckb.prop('checked') == true) {
  257. ckb.prop('checked', false);
  258. } else {
  259. ckb.prop('checked', true);
  260. }
  261. });
  262. //递归子节点的ParentId
  263. function GetParentModuleId(t, s) {
  264. $('input[name="ckb_module"]').each(function () {
  265. if ($(this).attr('data-parent') == t) {
  266. s += $(this).attr('value') + ',';
  267. GetParentModuleId($(this).attr('value'), s);
  268. }
  269. });
  270. return s;
  271. }
  272. //选择部门 选中人员
  273. $('.ckcenter').bind('change', function () {
  274. //选中
  275. if ($(this).prop('checked') == true) {
  276. //选中当前部门下的人员
  277. $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]').prop('checked', true);
  278. //选中当前部门下级部门的人员
  279. //var moduleId = $(this).attr('value') + ',';
  280. //moduleId = GetParentModuleId($(this).attr('value'), moduleId);
  281. //$('input[name="ckb_module"]').each(function () {
  282. // var parentId = $(this).attr('data-parent');
  283. // if (parentId != '' && moduleId.indexOf(parentId) > -1) {
  284. // $(this).prop('checked', true);
  285. // $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]').prop('checked', true);
  286. // }
  287. //});
  288. } else {
  289. //取消选中当前部门下的人员
  290. $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]').prop('checked', false);
  291. //取消选中当前部门下级部门的人员
  292. //var moduleId = $(this).attr('value') + ',';
  293. //moduleId = GetParentModuleId($(this).attr('value'), moduleId);
  294. //$('input[name="ckb_module"]').each(function () {
  295. // var parentId = $(this).attr('data-parent');
  296. // if (parentId != '' && moduleId.indexOf(parentId) > -1) {
  297. // $(this).prop('checked', false);
  298. // $(this).parent().next().next().find('.userlist').find('input[name="ckb_per"]').prop('checked', false);
  299. // }
  300. //});
  301. }
  302. });
  303. $('#btn-dig-close1').click(function () {
  304. dialog.close('no').remove();
  305. });
  306. $('#btn-save').click(function () {
  307. var perid = '', n = '', a = '';
  308. $('input[name="ckb_per"]:checked').each(function () {
  309. perid += $(this).attr('value') + ',';
  310. n += $(this).next('span').html() + ',';
  311. a += $(this).attr('data-parent') + ',';
  312. });
  313. if (perid != '') {
  314. perid = perid.substr(0, perid.length - 1);
  315. n = n.substr(0, n.length - 1);
  316. a = a.substr(0, a.length - 1);
  317. }
  318. //if (perid.split(',').length == $('input[name="ckb_per"]').length) {
  319. // perid = 'all';
  320. // n = '全体成员';
  321. // a = '全体成员';
  322. //}
  323. dialog.close(perid + '|' + a + '|' + n).remove();
  324. });
  325. /*检索功能--部门*/
  326. $('#dpt').change(function () { Show(); });
  327. /*检索功能--关键词*/
  328. //$('#btn-search').click(function () { Show(); });
  329. /*检索功能--回车*/
  330. $('#Search').keydown(function (e) { if (e.keyCode == 13) { Show(); } });
  331. });
  332. </script>
  333. }