index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="sj_history">
  3. <van-tabs :active="active" color="rgba(138, 5, 84, 1)" @change="onChange">
  4. <van-tab title="待签到"></van-tab>
  5. <van-tab title="待入厂"></van-tab>
  6. <van-tab title="装卸中"></van-tab>
  7. <van-tab title="已完成"></van-tab>
  8. <van-tab title="已过期"></van-tab>
  9. <van-tab title="已取消"></van-tab>
  10. <van-tab title="全部"></van-tab>
  11. </van-tabs>
  12. <div class="list">
  13. <div class="list-item" v-for="item in list" :key="item.id">
  14. <div class="status qd" v-if="item.status == 0">待签到</div>
  15. <div class="status rc" v-if="item.status == 1">待入厂</div>
  16. <div class="status zx" v-if="item.status == 2">装卸中</div>
  17. <div class="status wc" v-if="item.status == 3">已完成</div>
  18. <div class="status gq" v-if="item.status == 4">已过期</div>
  19. <div class="status qx" v-if="item.status == 5">已取消</div>
  20. <div
  21. class="time"
  22. @click="
  23. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  24. "
  25. >
  26. {{ item.reservationDate }}
  27. {{ item.timeStart + "~" + item.timeEnd }} {{ item.loadType }}
  28. </div>
  29. <div
  30. @click="
  31. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  32. "
  33. class="info"
  34. >
  35. {{ item.loadNum }}个托盘
  36. </div>
  37. <div
  38. @click="
  39. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  40. "
  41. class="info1"
  42. >
  43. 车辆:{{ item.carNo }}/{{ item.carType }}
  44. </div>
  45. <div
  46. @click="
  47. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  48. "
  49. class="info1"
  50. >
  51. 司机:{{ item.driverName }}
  52. </div>
  53. <div
  54. @click="
  55. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  56. "
  57. class="info1"
  58. v-if="item.createUser"
  59. >
  60. 预约账号:{{ item.createUser }}
  61. </div>
  62. <div
  63. @click="
  64. jumpPage('/pages/subPackages/sj_history/detail?id=' + item.id)
  65. "
  66. v-if="item.status == 5"
  67. class="info1 qxrq"
  68. >
  69. 取消日期:{{ item.cancelTime }}
  70. </div>
  71. <div class="bottborder"></div>
  72. <!-- -->
  73. <div class="foot-btn" v-if="item.status == 0">
  74. <van-button
  75. color="rgba(138, 5, 84, 1)"
  76. plain
  77. type="default"
  78. v-if="nowTimeCheck(item.reservationDate, item.status)"
  79. size="small"
  80. @click="cancelRow(item)"
  81. >取消</van-button
  82. >
  83. <van-button
  84. style="margin-left: 24rpx"
  85. color="rgba(138, 5, 84, 1)"
  86. type="default"
  87. size="small"
  88. v-if="nowTimeCheck(item.reservationDate, item.status)"
  89. @click="
  90. jumpPage('/pages/subPackages/sj_history/edit?id=' + item.id)
  91. "
  92. >修改</van-button
  93. >
  94. <van-button
  95. style="margin-left: 24rpx"
  96. color="rgba(138, 5, 84, 1)"
  97. type="default"
  98. size="small"
  99. @click="
  100. jumpPage('/pages/subPackages/yy_history/code?id=' + item.id)
  101. "
  102. >签到码</van-button
  103. >
  104. </div>
  105. <div class="foot-btn" v-if="item.status == 2">
  106. <van-button
  107. style="margin-left: 24rpx"
  108. color="rgba(138, 5, 84, 1)"
  109. type="default"
  110. size="small"
  111. @click="
  112. jumpPage('/pages/subPackages/yy_history/code?id=' + item.id)
  113. "
  114. >签退码</van-button
  115. >
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { reservationListPage, cancelReservation } from "@/js_sdk/sjTools.js";
  123. import { getUserLocalStorageInfo } from "@/js_sdk/localUserInfo.js";
  124. export default {
  125. data() {
  126. return {
  127. searchData: {
  128. pageNum: 1,
  129. pageSize: 10,
  130. status: 0,
  131. },
  132. active: 0,
  133. total: 0,
  134. list: [],
  135. };
  136. },
  137. onLoad() {
  138. console.log(getUserLocalStorageInfo().user.id);
  139. this.searchData.userId = getUserLocalStorageInfo().user.id;
  140. this.reservationListPage();
  141. },
  142. onReachBottom() {
  143. // 触底加载更多
  144. this.searchData.pageNum += 1;
  145. this.reservationListPage();
  146. },
  147. methods: {
  148. nowTimeCheck(yyTime, status) {
  149. const timeString = `${yyTime} 08`.replaceAll("-", "/");
  150. const fullTimeString = `${timeString}:00:00`;
  151. console.log(fullTimeString);
  152. const date = new Date(fullTimeString);
  153. const timestamp = date.getTime();
  154. // 预约日期的当天八点时间戳
  155. // console.log(timestamp);
  156. if (Date.now() < timestamp && status == 0) {
  157. return true;
  158. }
  159. },
  160. async cancelRow(e) {
  161. let that = this;
  162. console.log(e);
  163. // cancelReservation
  164. wx.showModal({
  165. title: "提示!",
  166. content: "是否取消该预约",
  167. success: async function (res) {
  168. if (res.confirm) {
  169. let data = await cancelReservation({
  170. id: e.id,
  171. userId: getUserLocalStorageInfo().user.id,
  172. });
  173. if (data.errmsg == "成功") {
  174. that.$showToast("取消成功");
  175. that.searchData.pageNum = 1;
  176. that.list = [];
  177. that.reservationListPage();
  178. }
  179. }
  180. },
  181. });
  182. },
  183. onChange(e) {
  184. console.log(e);
  185. this.list = [];
  186. let statusList = {
  187. 0: 0,
  188. 1: 1,
  189. 2: 2,
  190. 3: 3,
  191. 4: 4,
  192. 5: 5,
  193. 6: "",
  194. };
  195. this.searchData.status = statusList[e.detail.index];
  196. this.reservationListPage();
  197. },
  198. async reservationListPage() {
  199. let { data } = await reservationListPage(this.searchData);
  200. console.log(data);
  201. if (this.list.length != data.total) {
  202. this.list.push(...data.list);
  203. }
  204. },
  205. jumpPage(path) {
  206. console.log(path);
  207. uni.navigateTo({
  208. url: path,
  209. fail: (fail) => {},
  210. });
  211. },
  212. },
  213. };
  214. </script>
  215. <style lang="scss">
  216. .sj_history {
  217. .list {
  218. .list-item {
  219. padding: 24rpx 32rpx;
  220. background: #ffffff;
  221. position: relative;
  222. margin-top: 24rpx;
  223. .foot-btn {
  224. display: flex;
  225. justify-content: flex-end;
  226. padding-top: 16rpx;
  227. .van-button {
  228. border-radius: 30rpx 30rpx 30rpx 30rpx;
  229. }
  230. }
  231. .bottborder {
  232. padding-bottom: 24rpx;
  233. border-bottom: 2rpx solid #e8edf5;
  234. }
  235. .info {
  236. font-weight: 400;
  237. font-size: 28rpx;
  238. color: #333333;
  239. }
  240. .info1 {
  241. margin-top: 8rpx;
  242. font-weight: 400;
  243. font-size: 28rpx;
  244. color: #666666;
  245. }
  246. .qxrq {
  247. color: rgba(142, 139, 228, 1);
  248. }
  249. .time {
  250. font-weight: 400;
  251. font-size: 32rpx;
  252. color: #333333;
  253. margin-bottom: 8rpx;
  254. }
  255. .status {
  256. width: 144rpx;
  257. height: 56rpx;
  258. text-align: center;
  259. line-height: 56rpx;
  260. border-top-right-radius: 5%;
  261. border-bottom-left-radius: 50%;
  262. position: absolute;
  263. top: -1rpx;
  264. right: 0;
  265. font-weight: 400;
  266. font-size: 28rpx;
  267. }
  268. .qd {
  269. background: rgba(3, 101, 249, 0.2);
  270. color: #0365f9;
  271. }
  272. .rc {
  273. background: rgba(255, 184, 0, 0.3);
  274. color: #d99f00;
  275. }
  276. .zx {
  277. background: rgba(138, 5, 84, 0.2);
  278. color: #8a0554;
  279. }
  280. .wc {
  281. background: rgba(34, 181, 101, 0.2);
  282. color: #22b565;
  283. }
  284. .gq {
  285. color: #c7191f;
  286. background: rgba(199, 25, 31, 0.2);
  287. }
  288. .qx {
  289. color: #888888;
  290. background: rgba(136, 136, 136, 0.3);
  291. }
  292. }
  293. }
  294. }
  295. </style>