edit_appointment.html 5.7 KB

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