edit_user.html 21 KB

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