edit_user.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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. {if $detail.maker_type==2}<button class="layui-btn layui-btn-sm" lay-event="addEntrust">+ 新增委托单位成员</button>{/if}
  7. <button class="layui-btn layui-btn-sm" lay-event="add_head">+ 新增项目负责人</button>
  8. <button class="layui-btn layui-btn-sm" lay-event="add">+ 新增作业负责人</button>
  9. <button class="layui-btn layui-btn-sm picker-more" lay-event="adda">+ 新增作业成员</button>
  10. <button class="layui-btn layui-btn-sm picker-more" lay-event="adc">+ 新增送审单位成员</button>
  11. </div>
  12. </script>
  13. <script>
  14. function project_user() {
  15. let tool = layui.tool, table = layui.table, employeepicker = layui.employeepicker;
  16. //项目成员
  17. parent.layui.userTable = table.render({
  18. elem: '#user',
  19. title: '项目成员列表',
  20. cellMinWidth: 80,
  21. toolbar: '#toolbaruser',
  22. url: "/admin/project.cost_company/project_user", //数据接口
  23. where: {'project_id': project_id},
  24. page: false, //开启分页
  25. limit: 20,
  26. cols: [[ //表头
  27. {field: 'nickname', fixed: 'left', title: '成员姓名', width: 200, align: 'center', rowspan: 2},
  28. {field: 'unit_name', title: '所在单位', align: 'center', width: 200, rowspan: 2},
  29. {
  30. field: 'type', title: '成员类型', align: 'center', width: 200, rowspan: 2,
  31. templet: function (a) {
  32. var html = "";
  33. if (a.type == 1) {
  34. html = "项目负责人"
  35. } else if (a.type == 2) {
  36. html = "项目负责人"
  37. } else if (a.type == 3) {
  38. html = "作业负责人"
  39. } else if (a.type == 4) {
  40. html = "作业成员"
  41. } else if (a.type == 5) {
  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 'addEntrust':
  65. // let callback = function (){
  66. // layui.alert("hhh")
  67. // }
  68. aaa()
  69. break;
  70. case 'add':
  71. employeepicker.init({
  72. type: 0,
  73. department_url: "/admin/project.cost_company/get_department_tree",
  74. employee_url: "/admin/project.cost_company/get_employee",
  75. callback: function (ids, names, dids, departments) {
  76. let callback = function (e) {
  77. layer.msg(e.msg);
  78. if (e.code == 0) {
  79. parent.layui.userTable.reload();
  80. }
  81. }
  82. tool.post("/admin/project.cost_company/add_user_company_type1", {
  83. id: ids,
  84. project_id: project_id,
  85. type: 1
  86. }, callback);
  87. }
  88. })
  89. break;
  90. case "adda":
  91. employeepicker.init({
  92. type: 0,
  93. department_url: "/admin/project.cost_company/get_department_tree",
  94. employee_url: "/admin/project.cost_company/get_employee",
  95. callback: function (ids, names, dids, departments) {
  96. let callback = function (e) {
  97. layer.msg(e.msg);
  98. if (e.code == 0) {
  99. parent.layui.userTable.reload();
  100. }
  101. }
  102. tool.post("/admin/project.cost_company/add_user_company_type2", {
  103. id: ids,
  104. project_id: project_id,
  105. type: 2
  106. }, callback);
  107. }
  108. })
  109. break;
  110. case "adc":
  111. // getSentReview()
  112. let call = function () {
  113. layer.msg(e.msg);
  114. if (e.code == 0) {
  115. parent.layui.userTable.reload();
  116. }
  117. }
  118. // employeepicker.init({
  119. // type: 0,
  120. // department_url: "/admin/project.cost_company/get_department_tree",
  121. // employee_url: "/admin/project.cost_company/get_employee",
  122. // callback: function (ids, names, dids, departments) {
  123. // let callback = function (e) {
  124. // layer.msg(e.msg);
  125. // if (e.code == 0) {
  126. // parent.layui.userTable.reload();
  127. // }
  128. // }
  129. // tool.post("/admin/project.cost_company/add_sent_review_unit", {
  130. // id: ids,
  131. // project_id: project_id,
  132. // }, callback);
  133. // }
  134. // })
  135. parent.layui.tool.side('/admin/project.cost_company/add_sent_review_unit?project_id=' + project_id, call);
  136. break;
  137. case "add_head":
  138. employeepicker.init({
  139. type: 0,
  140. department_url: "/admin/project.cost_company/get_department_tree",
  141. employee_url: "/admin/project.cost_company/get_employee",
  142. callback: function (ids, names, dids, departments) {
  143. let callback = function (e) {
  144. layer.msg(e.msg);
  145. if (e.code == 0) {
  146. parent.layui.userTable.reload();
  147. }
  148. }
  149. tool.post("/admin/project.cost_company/add_user_company_head", {
  150. id: ids,
  151. project_id: project_id,
  152. }, callback);
  153. }
  154. })
  155. break;
  156. }
  157. });
  158. //监听行工具事件
  159. table.on('tool(user)', function (obj) {
  160. let postData = {"id": obj.data.id, "project_id": project_id, "type": obj.data.type};
  161. let callback = function (e) {
  162. layer.closeAll();
  163. layer.msg(e.msg);
  164. if (e.code == 0) {
  165. parent.layui.userTable.reload();
  166. }
  167. }
  168. if (obj.event === 'remove') {
  169. if (obj.data.type == 3 || obj.data.type == 4) {
  170. console.log(postData);
  171. layer.confirm('确定要移除该项目成员吗?', {icon: 3, title: '提示'}, function (index) {
  172. tool.delete("/admin/project.cost_company/remove_user_company", postData, callback);
  173. });
  174. } else if (obj.data.type == 6) {
  175. layer.confirm('确定要移除该送审单位成员吗?', {icon: 3, title: '提示'}, function (index) {
  176. tool.delete("/admin/project.cost_company/remove_sent_review", {
  177. "id": obj.data.id,
  178. "project_id": project_id,
  179. "type": obj.data.type,
  180. "nickname": obj.data.nickname
  181. }, callback);
  182. });
  183. } else if (obj.data.type == 2) {
  184. layer.confirm('确定要移除该送审单位成员吗?', {icon: 3, title: '提示'}, function (index) {
  185. tool.delete("/admin/project.cost_company/remove_review_head", postData, callback);
  186. });
  187. } else if (obj.data.type == 1) {
  188. layer.confirm('确定要移除该委托单位成员吗?', {icon: 3, title: '提示'}, function (index) {
  189. tool.delete("/admin/project.cost_company/remove_entrust_head", postData, callback);
  190. });
  191. }else {
  192. layer.msg("该成员不可移除");
  193. }
  194. }
  195. return;
  196. });
  197. //委托单位
  198. function aaa(callback){
  199. var customeTable,form = layui.form;
  200. const a = layer.open({
  201. title: '选择委托单位',
  202. area: ['600px', '580px'],
  203. type: 1,
  204. content: '<div class="picker-table">\
  205. <form class="layui-form pb-2">\
  206. <div class="layui-input-inline" style="width:480px;">\
  207. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  208. </div>\
  209. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  210. </form>\
  211. <div id="customerTable"></div></div>',
  212. success: function () {
  213. customeTable = table.render({
  214. elem: '#customerTable'
  215. , url: '/admin/project.api/get_entrust'
  216. , page: true //开启分页
  217. , limit: 10
  218. , cols: [[
  219. {type: 'radio', title: '选择'},
  220. {field: 'title', title: '委托单位名称', align: 'center'},
  221. {field: 'address', title: ' 评审单位地址', align: 'center'}
  222. ]]
  223. });
  224. //客户搜索提交
  225. form.on('submit(search_customer)', function (data) {
  226. customeTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  227. return false;
  228. });
  229. },
  230. btn: ['确定'],
  231. btnAlign: 'c',
  232. yes: function () {
  233. var checkStatus = table.checkStatus(customeTable.config.id);
  234. var data = checkStatus.data;
  235. console.log(data)
  236. if (data.length > 0) {
  237. bbb(data);
  238. layer.close(a);
  239. } else {
  240. layer.msg('请先选择委托单位');
  241. return false;
  242. }
  243. }
  244. })
  245. }
  246. function bbb(e){
  247. var entrustPeopleTable,form = layui.form;
  248. layer.open({
  249. title: '选择委托单位',
  250. area: ['600px', '580px'],
  251. type: 1,
  252. content: '<div class="picker-table">\
  253. <form class="layui-form pb-2">\
  254. <div class="layui-input-inline" style="width:480px;">\
  255. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  256. </div>\
  257. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="entrustPeople">提交搜索</button>\
  258. </form>\
  259. <div id="entrustPeopleTable"></div></div>',
  260. success: function () {
  261. entrustPeopleTable = table.render({
  262. elem: '#entrustPeopleTable'
  263. , url: '/admin/project.api/get_entrust_people'
  264. , where:{unit_id:e[0]["id"]}
  265. , page: true //开启分页
  266. , limit: 10
  267. , cols: [[
  268. {type: 'radio', title: '选择'},
  269. {field: 'id', width: 80, title: '编号', align: 'center'},
  270. {field: 'nickname', title: '昵称', align: 'center'},
  271. ]]
  272. });
  273. //客户搜索提交
  274. form.on('submit(entrustPeople)', function (data) {
  275. entrustPeopleTable.reload({where: {keywords: data.field.keywords,unit_id:e[0]["id"]}, page: {curr: 1}});
  276. return false;
  277. });
  278. },
  279. btn: ['确定'],
  280. btnAlign: 'c',
  281. yes: function () {
  282. var checkStatus = table.checkStatus(entrustPeopleTable.config.id);
  283. var data = checkStatus.data;
  284. console.log(data)
  285. if (data.length > 0) {
  286. let callback = function (e) {
  287. layer.msg(e.msg);
  288. if (e.code == 0) {
  289. layer.closeAll();
  290. parent.layui.userTable.reload();
  291. }
  292. }
  293. tool.post("/admin/project.cost_company/add_entrust_people", {
  294. id: data[0]["id"],
  295. project_id: project_id,
  296. }, callback);
  297. } else {
  298. layer.msg('请先选择委托单位人员');
  299. return false;
  300. }
  301. }
  302. })
  303. }
  304. function getSentReview(){
  305. var sentReviewTable,form = layui.form;
  306. const a = layer.open({
  307. title: '选择送审单位',
  308. area: ['600px', '580px'],
  309. type: 1,
  310. content: '<div class="picker-table">\
  311. <form class="layui-form pb-2">\
  312. <div class="layui-input-inline" style="width:480px;">\
  313. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  314. </div>\
  315. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_customer">提交搜索</button>\
  316. </form>\
  317. <div id="sentReviewTable"></div></div>',
  318. success: function () {
  319. sentReviewTable = table.render({
  320. elem: '#sentReviewTable'
  321. , url: '/admin/project.api/get_sent_review'
  322. , page: true //开启分页
  323. , limit: 10
  324. , cols: [[
  325. {type: 'radio', title: '选择'},
  326. {field: 'id', width: 80, title: '编号', align: 'center'},
  327. {field: 'title', title: '送审单位名称', align: 'center'},
  328. {field: 'address', title: ' 送审单位地址', align: 'center'}
  329. ]]
  330. });
  331. //客户搜索提交
  332. form.on('submit(search_customer)', function (data) {
  333. sentReviewTable.reload({where: {keywords: data.field.keywords}, page: {curr: 1}});
  334. return false;
  335. });
  336. },
  337. btn: ['确定'],
  338. btnAlign: 'c',
  339. yes: function () {
  340. var checkStatus = table.checkStatus(sentReviewTable.config.id);
  341. var data = checkStatus.data;
  342. console.log(data)
  343. if (data.length > 0) {
  344. getSentReviewPeople(data);
  345. layer.close(a);
  346. } else {
  347. layer.msg('请先选择送审单位');
  348. return false;
  349. }
  350. }
  351. })
  352. }
  353. function getSentReviewPeople(e){
  354. var sentReviewPeople,form = layui.form;
  355. layer.open({
  356. title: '选择送审单位',
  357. area: ['600px', '580px'],
  358. type: 1,
  359. content: '<div class="picker-table">\
  360. <form class="layui-form pb-2">\
  361. <div class="layui-input-inline" style="width:480px;">\
  362. <input type="text" name="keywords" placeholder="委托单位" class="layui-input" autocomplete="off" />\
  363. </div>\
  364. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="entrustPeople">提交搜索</button>\
  365. </form>\
  366. <div id="sentReviewPeople"></div></div>',
  367. success: function () {
  368. sentReviewPeople = table.render({
  369. elem: '#sentReviewPeople'
  370. , url: '/admin/project.api/get_sent_review_people'
  371. , where:{unit_id:e[0]["id"]}
  372. , page: true //开启分页
  373. , limit: 10
  374. , cols: [[
  375. {type: 'radio', title: '选择'},
  376. {field: 'id', width: 80, title: '编号', align: 'center'},
  377. {field: 'nickname', title: '昵称', align: 'center'},
  378. ]]
  379. });
  380. //客户搜索提交
  381. form.on('submit(entrustPeople)', function (data) {
  382. sentReviewPeople.reload({where: {keywords: data.field.keywords,unit_id:e[0]["id"]}, page: {curr: 1}});
  383. return false;
  384. });
  385. },
  386. btn: ['确定'],
  387. btnAlign: 'c',
  388. yes: function () {
  389. var checkStatus = table.checkStatus(sentReviewPeople.config.id);
  390. var data = checkStatus.data;
  391. console.log(data)
  392. if (data.length > 0) {
  393. let callback = function (e) {
  394. layer.msg(e.msg);
  395. if (e.code == 0) {
  396. layer.closeAll();
  397. parent.layui.userTable.reload();
  398. }
  399. }
  400. tool.post("/admin/project.cost_company/add_sent_review_unit", {
  401. id: data[0]["id"],
  402. project_id: project_id,
  403. }, callback);
  404. } else {
  405. layer.msg('请先选择送审单位人员');
  406. return false;
  407. }
  408. }
  409. })
  410. }
  411. }
  412. </script>