project_user.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. if ($('#projectTab').find('li').eq(4).data('load') == 'true') {
  13. return false;
  14. }
  15. $('#projectTab').find('li').eq(4).data('load', 'true');
  16. let tool = layui.tool, table = layui.table, employeepicker = layui.employeepicker;
  17. //项目成员
  18. parent.layui.userTable = table.render({
  19. elem: '#user',
  20. title: '项目成员列表',
  21. cellMinWidth: 80,
  22. toolbar: '#toolbaruser',
  23. url: "/admin/project.cost/project_user", //数据接口
  24. where: {'project_id': project_id},
  25. page: false, //开启分页
  26. limit: 20,
  27. cols: [[ //表头
  28. {field: 'nickname', fixed: 'left', title: '成员姓名', width: 200, align: 'center', rowspan: 2},
  29. {field: 'unit_name', title: '所在单位', align: 'center', width: 200, rowspan: 2},
  30. {field: 'unit_type', title: '单位类型', align: 'center', width: 200, rowspan: 2},
  31. {field: 'mobile', title: '手机号码', align: 'center', rowspan: 2},
  32. {field: 'email', title: '单位邮箱', align: 'center', rowspan: 2},
  33. {
  34. title: '操作', fixed: 'right', align: 'center', width: 150, rowspan: 2, templet: function (d) {
  35. var html = '<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove">移除</span>';
  36. return html;
  37. }
  38. }
  39. ]]
  40. });
  41. //触发事件
  42. table.on('toolbar(user)', function (obj) {
  43. var checkStatus = table.checkStatus(obj.config.id);
  44. switch (obj.event) {
  45. case 'add':
  46. employeepicker.init({
  47. type: 0,
  48. department_url: "/admin/project.cost_company/get_yezhu_tree",
  49. employee_url: "/admin/project.cost_company/get_employee",
  50. callback: function (ids, names, dids, departments) {
  51. let callback = function (e) {
  52. layer.msg(e.msg);
  53. if (e.code == 0) {
  54. layui.userTable.reload();
  55. }
  56. }
  57. tool.post("/admin/project.cost_company/add_user", {
  58. id: ids,
  59. project_id: project_id,
  60. type: 2
  61. }, callback);
  62. }
  63. })
  64. break;
  65. case "adda":
  66. parent.layui.tool.side('/admin/project.cost/addconstructionpeople?project_id=' + project_id);
  67. break;
  68. }
  69. });
  70. //监听行工具事件
  71. table.on('tool(user)', function (obj) {
  72. let postData = {"id": obj.data.id, "project_id": project_id, "type": obj.data.type};
  73. let callback = function (e) {
  74. layer.closeAll();
  75. layer.msg(e.msg);
  76. if (e.code == 0) {
  77. layui.userTable.reload();
  78. }
  79. }
  80. if (obj.event === 'remove') {
  81. if (obj.data.type == 3 || obj.data.type == 4) {
  82. console.log(postData);
  83. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  84. tool.delete("/admin/project.cost_company/remove_user", postData, callback);
  85. });
  86. } else {
  87. layer.msg("该成员不可移除");
  88. }
  89. }
  90. if (obj.event === 'recover') {
  91. layer.confirm('确定要恢复该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  92. tool.post("/project/api/recover_user", postData, callback);
  93. });
  94. }
  95. return;
  96. });
  97. }
  98. </script>