project_user.html 6.6 KB

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