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