Queue.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="queue">
  3. <van-nav-bar
  4. title="当前队列"
  5. @click-left="toAdmin"
  6. left-text="添加预定"
  7. left-arrow
  8. />
  9. <van-cell-group>
  10. <van-cell v-for="(item, i) in queueList" :key="i">
  11. <template #title>
  12. {{ [i + 1 + ".", item.orderTime + " ", item.userName].join(" ") }}
  13. </template>
  14. <template #default>
  15. <van-button
  16. v-if="i === 0"
  17. type="default"
  18. size="small"
  19. @click="skipUser"
  20. >
  21. 跳过
  22. </van-button>
  23. <van-button
  24. v-if="i === 0"
  25. type="info"
  26. size="small"
  27. @click="nextItem"
  28. >
  29. 完成
  30. </van-button>
  31. <van-button
  32. type="warning"
  33. size="small"
  34. @click="() => removequeue(item.id, i)"
  35. >删除</van-button
  36. >
  37. </template>
  38. </van-cell>
  39. </van-cell-group>
  40. </div>
  41. </template>
  42. <script>
  43. // @ is an alias to /src
  44. import {
  45. Cell as vanCell,
  46. CellGroup as vanCellGroup,
  47. Button as vanButton,
  48. NavBar as vanNavBar,
  49. Dialog,
  50. } from "vant";
  51. import "vant/lib/cell/style/index";
  52. import "vant/lib/cell-group/style/index";
  53. import "vant/lib/dialog/style/index";
  54. import "vant/lib/button/style/index";
  55. import "vant/lib/nav-bar/style/index";
  56. import { orderList, skip, nextone, cancel } from "../api/index";
  57. export default {
  58. name: "Queue",
  59. data() {
  60. return {
  61. queueList: [],
  62. };
  63. },
  64. mounted() {
  65. this.reloadOrder();
  66. },
  67. computed: {},
  68. methods: {
  69. reloadOrder() {
  70. orderList().then(res => {
  71. this.queueList = res || [];
  72. });
  73. },
  74. toAdmin() {
  75. this.$router.push({ name: "Apply", params: { a: 0 } });
  76. },
  77. skipUser() {
  78. Dialog.confirm({
  79. message: "是否跳过该用户?",
  80. confirmButtonColor: "#2a7ef4",
  81. }).then(() => {
  82. skip().then(() => {
  83. this.reloadOrder();
  84. });
  85. });
  86. },
  87. nextItem() {
  88. Dialog.confirm({
  89. message: "该服务是否已完成?",
  90. confirmButtonColor: "#2a7ef4",
  91. }).then(() => {
  92. nextone().then(() => {
  93. this.reloadOrder();
  94. });
  95. });
  96. },
  97. removequeue(id, i) {
  98. console.log(id);
  99. Dialog.confirm({
  100. message: "确定要删除该预约?",
  101. confirmButtonColor: "#2a7ef4",
  102. }).then(() => {
  103. // on confirm
  104. cancel({
  105. id,
  106. }).then(() => {
  107. let queueList = JSON.parse(JSON.stringify(this.queueList));
  108. queueList.splice(i, 1);
  109. this.queueList = queueList;
  110. });
  111. });
  112. },
  113. },
  114. beforeUnmount: function () {},
  115. components: {
  116. vanCell,
  117. vanCellGroup,
  118. vanButton,
  119. vanNavBar,
  120. },
  121. };
  122. </script>
  123. <style>
  124. .queue {
  125. width: 990px;
  126. height: 100%;
  127. margin: 0 auto;
  128. background-color: #fff;
  129. }
  130. </style>