edit_user.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. // getSentReview()
  61. let call = function () {
  62. layer.msg(e.msg);
  63. if (e.code == 0) {
  64. parent.layui.userTable.reload();
  65. }
  66. }
  67. parent.layui.tool.side('/admin/project.cost/add_sent_review_unit?project_id=' + project_id, call);
  68. break;
  69. case "adda":
  70. let callback = function (){
  71. layer.msg(e.msg);
  72. if (e.code == 0) {
  73. parent.layui.userTable.reload();
  74. }
  75. }
  76. parent.layui.tool.side('/admin/project.cost/addconstructionpeople?project_id=' + project_id,callback);
  77. break;
  78. }
  79. });
  80. //监听行工具事件
  81. table.on('tool(user)', function (obj) {
  82. let postData = {"id": obj.data.id, "project_id": project_id, "type": obj.data.type};
  83. let callback = function (e) {
  84. layer.closeAll();
  85. layer.msg(e.msg);
  86. if (e.code == 0) {
  87. parent.layui.userTable.reload();
  88. }
  89. }
  90. if (obj.event === 'remove') {
  91. if (obj.data.type == 3 || obj.data.type == 4) {
  92. let callback = function (e) {
  93. layer.closeAll();
  94. layer.msg(e.msg);
  95. if (e.code == 0) {
  96. parent.layui.userTable.reload();
  97. }
  98. }
  99. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  100. tool.delete("/admin/project.cost_company/remove_user", postData, callback);
  101. });
  102. }else if(obj.data.type == 5){
  103. let callback = function (e) {
  104. layer.closeAll();
  105. layer.msg(e.msg);
  106. if (e.code == 0) {
  107. parent.layui.userTable.reload();
  108. }
  109. }
  110. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  111. tool.delete("/admin/project.cost/remove_construction_user", postData, callback);
  112. });
  113. } else if(obj.data.type == 6){
  114. let callback = function (e) {
  115. layer.closeAll();
  116. layer.msg(e.msg);
  117. if (e.code == 0) {
  118. parent.layui.userTable.reload();
  119. }
  120. }
  121. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  122. 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);
  123. });
  124. }
  125. else {
  126. console.log(postData);
  127. layer.msg("该成员不可移除");
  128. }
  129. }
  130. return;
  131. });
  132. function getSentReview(){
  133. var sentReviewTable,form = layui.form;
  134. const a = layer.open({
  135. title: '选择送审单位',
  136. area: ['600px', '580px'],
  137. type: 1,
  138. content: '<div class="picker-table">\
  139. <form class="layui-form pb-2">\
  140. <div class="layui-input-inline" style="width:480px;">\
  141. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  142. </div>\
  143. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  144. </form>\
  145. <div id="sentReviewTable"></div></div>',
  146. success: function () {
  147. sentReviewTable = table.render({
  148. elem: '#sentReviewTable'
  149. , url: '/admin/project.api/get_sent_review'
  150. , page: true //开启分页
  151. , limit: 10
  152. , cols: [[
  153. {type: 'radio', title: '选择'},
  154. {field: 'id', width: 80, title: '编号', align: 'center'},
  155. {field: 'title', title: '送审单位名称', align: 'center'},
  156. {field: 'address', title: ' 送审单位地址', align: 'center'}
  157. ]]
  158. });
  159. //客户搜索提交
  160. form.on('submit(search_customer)', function (data) {
  161. sentReviewTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  162. return false;
  163. });
  164. },
  165. btn: ['确定'],
  166. btnAlign: 'c',
  167. yes: function () {
  168. var checkStatus = table.checkStatus(sentReviewTable.config.id);
  169. var data = checkStatus.data;
  170. console.log(data)
  171. if (data.length > 0) {
  172. getSentReviewPeople(data);
  173. layer.close(a);
  174. } else {
  175. layer.msg('请先选择送审单位');
  176. return false;
  177. }
  178. }
  179. })
  180. }
  181. function getSentReviewPeople(e){
  182. var sentReviewPeople,form = layui.form;
  183. layer.open({
  184. title: '选择送审单位',
  185. area: ['600px', '580px'],
  186. type: 1,
  187. content: '<div class="picker-table">\
  188. <form class="layui-form pb-2">\
  189. <div class="layui-input-inline" style="width:480px;">\
  190. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  191. </div>\
  192. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="entrustPeople">提交搜索</button>\
  193. </form>\
  194. <div id="sentReviewPeople"></div></div>',
  195. success: function () {
  196. sentReviewPeople = table.render({
  197. elem: '#sentReviewPeople'
  198. , url: '/admin/project.api/get_sent_review_people'
  199. , where:{unit_id:e[0]["id"]}
  200. , page: true //开启分页
  201. , limit: 10
  202. , cols: [[
  203. {type: 'radio', title: '选择'},
  204. {field: 'id', width: 80, title: '编号', align: 'center'},
  205. {field: 'nickname', title: '昵称', align: 'center'},
  206. ]]
  207. });
  208. //客户搜索提交
  209. form.on('submit(entrustPeople)', function (data) {
  210. sentReviewPeople.reload({where: {keywords: data.field.keywords,unit_id:e[0]["id"]}, page: {curr: 1}});
  211. return false;
  212. });
  213. },
  214. btn: ['确定'],
  215. btnAlign: 'c',
  216. yes: function () {
  217. var checkStatus = table.checkStatus(sentReviewPeople.config.id);
  218. var data = checkStatus.data;
  219. console.log(data)
  220. if (data.length > 0) {
  221. let callback = function (e) {
  222. layer.msg(e.msg);
  223. if (e.code == 0) {
  224. layer.closeAll();
  225. parent.layui.userTable.reload();
  226. }
  227. }
  228. tool.post("/admin/project.cost/add_sent_review_unit", {
  229. id: data[0]["id"],
  230. project_id: project_id,
  231. }, callback);
  232. } else {
  233. layer.msg('请先选择送审单位人员');
  234. return false;
  235. }
  236. }
  237. })
  238. }
  239. }
  240. </script>