project_appointment.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <div class="p-3 bg-white">
  2. <table class="layui-hide" id="appointment" lay-filter="appointment"></table>
  3. </div>
  4. <script>
  5. function appointment() {
  6. let tool = layui.tool, table = layui.table;
  7. //项目任务
  8. var allcount;
  9. parent.layui.appointmentTable = table.render({
  10. elem: '#appointment',
  11. title: '文档列表',
  12. toolbar: '#toolbarappointment',
  13. cellMinWidth: 80,
  14. parseData: function (res) { // 数据解析回调函数
  15. // 在这里可以获取数据总数
  16. allcount = res.data.length;
  17. return {
  18. code: res.code, // 数据状态码
  19. msg: res.msg, // 状态信息
  20. count: res.count, // 数据总数
  21. data: res.data // 当前页数据
  22. };
  23. },
  24. url: "/admin/project.appointment/datalist",
  25. where: {'project_id': project_id},
  26. page: false, //开启分页
  27. limit: 20,
  28. cols: [[
  29. {field: 'id', title: '记录编号', width: 80, align: 'center',
  30. templet: function (d) {
  31. console.log(allcount,d.LAY_NUM)
  32. return allcount - (d.LAY_NUM - 1);
  33. }
  34. },
  35. {field: 'appointment_time', title: '预约时间',align: 'center', width: 200},
  36. {field: 'dispatch_num', title: '派遣人数', align: 'center', width: 100},
  37. {field: 'address_or_remark', title: '地址/备注', align: 'center'},
  38. {field: 'sponsor_name', title: '发起人', align: 'center', width: 100},
  39. {field: 'approval_name', title: '审批人', align: 'center', width: 100},
  40. {field: 'audit_status', title: '状态', align: 'center', width: 100,templet:function(d){
  41. if(d.audit_status==0){
  42. return "待审核"
  43. }else if(d.audit_status==1){
  44. return "通过"
  45. }else if(d.audit_status==2){
  46. return "拒绝"
  47. }
  48. }},
  49. {field: 'audit_remark', title: '回执', align: 'center', width: 150},
  50. ]]
  51. });
  52. //触发事件
  53. table.on('toolbar(appointment)', function (obj) {
  54. var checkStatus = table.checkStatus(obj.config.id);
  55. switch (obj.event) {
  56. case 'add':
  57. parent.layui.tool.side('/admin/project.appointment/add?project_id=' + project_id); // 项目id
  58. break;
  59. }
  60. });
  61. table.on('tool(appointment)', function (obj) {
  62. var data = obj.data; //获得当前行数据
  63. console.log(data);
  64. if (obj.event === 'agree') {
  65. layer.prompt({
  66. title: '请输入<span style="color: green">回执</span>',
  67. formType: 2,
  68. area: ['35vw', '15vw']
  69. }, function (text, index) {
  70. let callback = function (e) {
  71. parent.layui.appointmentTable.reload()
  72. layer.msg(e.msg);
  73. setTimeout(function () {
  74. layer.close(index);
  75. }, 2000)
  76. }
  77. if (text !== "") {
  78. tool.post("/admin/project.appointment/agree", {id: data.id,audit_remark:text,project_id:data.project_id}, callback);// 项目id
  79. } else {
  80. layer.msg("回执不能为空")
  81. }
  82. })
  83. return;
  84. }
  85. if (obj.event === 'disagree') {
  86. layer.prompt({
  87. title: '请输入<span style="color: red">回执</span>',
  88. formType: 2,
  89. area: ['35vw', '15vw']
  90. }, function (text, index) {
  91. let callback = function (e) {
  92. parent.layui.appointmentTable.reload()
  93. layer.msg(e.msg);
  94. setTimeout(function () {
  95. layer.close(index);
  96. }, 2000)
  97. }
  98. if (text !== "") {
  99. tool.post("/admin/project.appointment/disagree", {id: data.id,audit_remark:text,project_id:data.project_id}, callback);// 项目id
  100. } else {
  101. layer.msg("回执不能为空")
  102. }
  103. })
  104. return;
  105. }
  106. })
  107. }
  108. </script>