project_user.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="user" lay-filter="user"></table>
  3. </div>
  4. <script type="text/html" id="toolbaruser">
  5. <div class="layui-btn-container">
  6. <button class="layui-btn layui-btn-sm" lay-event="add">+ 新增作业负责人</button>
  7. <button class="layui-btn layui-btn-sm picker-more" lay-event="adda">+ 新增作业成员</button>
  8. <button class="layui-btn layui-btn-sm picker-more" lay-event="adc">+ 新增送审单位成员</button>
  9. </div>
  10. </script>
  11. <script>
  12. function project_user() {
  13. if ($('#projectTab').find('li').eq(4).data('load') == 'true') {
  14. return false;
  15. }
  16. $('#projectTab').find('li').eq(4).data('load', 'true');
  17. let tool = layui.tool, table = layui.table, employeepicker = layui.employeepicker;
  18. //项目成员
  19. layui.userTable = table.render({
  20. elem: '#user',
  21. title: '项目成员列表',
  22. cellMinWidth: 80,
  23. toolbar: '#toolbaruser',
  24. url: "/admin/project.cost/project_user", //数据接口
  25. where: {'project_id': project_id},
  26. page: false, //开启分页
  27. limit: 20,
  28. cols: [[ //表头
  29. {field: 'nickname', fixed: 'left', title: '成员姓名', width: 200, align: 'center', rowspan: 2},
  30. {field: 'unit_name', title: '所在单位', align: 'center', width: 200, rowspan: 2},
  31. {
  32. field: 'type', title: '成员类型', align: 'center', width: 200, rowspan: 2,
  33. templet: function (a) {
  34. var html = "";
  35. if (a.type == 1) {
  36. html = "委托单位负责人"
  37. } else if (a.type == 2) {
  38. html = "评审单位负责人"
  39. } else if (a.type == 3) {
  40. html = "作业负责人"
  41. } else if (a.type == 4) {
  42. html = "作业成员"
  43. } else if (a.type == 6) {
  44. html = "评审单位负责人"
  45. }
  46. return html;
  47. }
  48. },
  49. {field: 'unit_type', title: '单位类型', align: 'center', width: 200, rowspan: 2},
  50. {field: 'mobile', title: '手机号码', align: 'center', rowspan: 2},
  51. {field: 'email', title: '单位邮箱', align: 'center', rowspan: 2},
  52. {
  53. title: '操作', fixed: 'right', align: 'center', width: 150, rowspan: 2, templet: function (d) {
  54. var html = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove">移除</span>';
  55. return html;
  56. }
  57. }
  58. ]]
  59. });
  60. //触发事件
  61. table.on('toolbar(user)', function (obj) {
  62. var checkStatus = table.checkStatus(obj.config.id);
  63. switch (obj.event) {
  64. case 'add':
  65. employeepicker.init({
  66. type: 0,
  67. department_url: "/admin/project.cost_company/get_department_tree",
  68. employee_url: "/admin/project.cost_company/get_employee",
  69. callback: function (ids, names, dids, departments) {
  70. let callback = function (e) {
  71. layer.msg(e.msg);
  72. if (e.code == 0) {
  73. layui.userTable.reload();
  74. }
  75. }
  76. tool.post("/admin/project.cost_company/add_user", {
  77. id: ids,
  78. project_id: project_id,
  79. type: 1
  80. }, callback);
  81. }
  82. })
  83. break;
  84. case "adda":
  85. employeepicker.init({
  86. type: 0,
  87. department_url: "/admin/project.cost_company/get_department_tree",
  88. employee_url: "/admin/project.cost_company/get_employee",
  89. callback: function (ids, names, dids, departments) {
  90. let callback = function (e) {
  91. layer.msg(e.msg);
  92. if (e.code == 0) {
  93. layui.userTable.reload();
  94. }
  95. }
  96. tool.post("/admin/project.cost_company/add_user_company_type2", {
  97. id: ids,
  98. project_id: project_id,
  99. type: 2
  100. }, callback);
  101. }
  102. })
  103. break;
  104. case "adc":
  105. employeepicker.init({
  106. type: 0,
  107. department_url: "/admin/project.cost_company/get_yezhu_tree",
  108. employee_url: "/admin/project.cost_company/get_employee",
  109. callback: function (ids, names, dids, departments) {
  110. let callback = function (e) {
  111. layer.msg(e.msg);
  112. if (e.code == 0) {
  113. layui.userTable.reload();
  114. }
  115. }
  116. tool.post("/admin/project.cost_company/add_company_user", {
  117. id: ids,
  118. project_id: project_id,
  119. type: 2
  120. }, callback);
  121. }
  122. })
  123. break;
  124. }
  125. ;
  126. });
  127. //监听行工具事件
  128. table.on('tool(user)', function (obj) {
  129. let postData = {"id": obj.data.id, "project_id": project_id, "type": obj.data.type};
  130. let callback = function (e) {
  131. layer.closeAll();
  132. layer.msg(e.msg);
  133. if (e.code == 0) {
  134. layui.userTable.reload();
  135. }
  136. }
  137. if (obj.event === 'remove') {
  138. if (obj.data.type == 3 || obj.data.type == 4) {
  139. console.log(postData);
  140. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  141. tool.delete("/admin/project.cost_company/remove_user_company", postData, callback);
  142. });
  143. } else {
  144. layer.msg("该成员不可移除");
  145. }
  146. }
  147. if (obj.event === 'recover') {
  148. console.log(postData);
  149. layer.confirm('确定要恢复该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  150. tool.post("/project/api/recover_user", postData, callback);
  151. });
  152. }
  153. return;
  154. });
  155. }
  156. </script>