index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="container">
  3. <div
  4. class="row"
  5. ref="row"
  6. v-for="(orderListItem, index) in orderList"
  7. :key="index"
  8. >
  9. <div class="time" :style="{ height: `${rowHeightList[index]}px` }">
  10. <span>{{ orderListItem.time.start }}</span>
  11. <span>-</span>
  12. <span>{{ orderListItem.time.end }}</span>
  13. </div>
  14. <div class="project-wrapper">
  15. <div
  16. class="project"
  17. v-for="(projectItem, index) in orderListItem.list"
  18. :key="index"
  19. @click="toOrderDetail(projectItem)"
  20. :style="{
  21. color: getStyleByOrderStatus(projectItem).color,
  22. borderLeft: '1px solid',
  23. backgroundColor: getStyleByOrderStatus(projectItem).backgroundColor,
  24. }"
  25. >
  26. <div class="name">{{ projectItem.nickname }}</div>
  27. <div class="project-time">
  28. <span>{{ projectItem.start }}</span>
  29. <span>-</span>
  30. <span>{{ projectItem.end }}</span>
  31. </div>
  32. </div>
  33. <!-- 添加订单 -->
  34. <i
  35. class="el-icon-plus"
  36. @click="orderCreate(orderListItem.time)"
  37. v-if="nowTime < orderListItem.time.end"
  38. ></i>
  39. </div>
  40. </div>
  41. <!-- 侧边图标 -->
  42. <div class="calendar" @click="openCalendar">
  43. <i class="el-icon-date"></i>
  44. <span>日历</span>
  45. </div>
  46. <div class="setUp" @click="orderCreate">
  47. <i class="el-icon-circle-plus-outline"></i>
  48. <span>创建预约</span>
  49. </div>
  50. <div class="backNow">
  51. <i class="el-icon-refresh-right"></i>
  52. <span>返回今天</span>
  53. </div>
  54. <!-- 日历弹窗 -->
  55. <calendar-pop :visible.sync="visible"></calendar-pop>
  56. <!-- 创建订单弹窗 -->
  57. <create-order :toTime="toTime" :orderShow.sync="orderShow"></create-order>
  58. </div>
  59. </template>
  60. <script>
  61. import api from "@/server/home";
  62. import calendarPop from "../calendarPop/index.vue";
  63. import createOrder from "../createOrder/index.vue";
  64. export default {
  65. components: { calendarPop, createOrder },
  66. data() {
  67. return {
  68. orderList: [],
  69. timeList: [],
  70. rowHeightList: [],
  71. colorStyleList: [
  72. { orderStatus: [3, 5], color: "#A3A3A3", backgroundColor: "#F0F0F0" },
  73. { orderStatus: [2], color: "#FA7D22", backgroundColor: "#FEF4ED" },
  74. { orderStatus: [0, 1], color: "#42D351", backgroundColor: "#F5FCF5" },
  75. ],
  76. timer: null,
  77. visible: false, //控制日历
  78. orderShow: false, //控制创建订单弹窗
  79. nowTime: "", //当前小时分钟
  80. toTime: "", //点击加号创建订单时传过去的时间
  81. };
  82. },
  83. created() {
  84. this.nowTime = `${new Date().getHours()}:${new Date().getMinutes()}`;
  85. this.fetchOrderList();
  86. this.timer = setInterval(() => {
  87. this.fetchOrderList();
  88. }, 10000);
  89. },
  90. mounted() {
  91. if (this.$refs.row) {
  92. this.$refs.row.forEach((item) => {
  93. this.rowHeightList.push(item.clientHeight);
  94. });
  95. }
  96. },
  97. destroyed() {
  98. if (this.timer) {
  99. clearInterval(this.timer);
  100. this.timer = null;
  101. }
  102. },
  103. methods: {
  104. // 创建订单 打开创建订单弹窗
  105. orderCreate(e) {
  106. if (e.end) {
  107. e.isClick = true;
  108. this.toTime = e;
  109. } else {
  110. e.isClick = false;
  111. this.toTime = e;
  112. }
  113. this.orderShow = true;
  114. },
  115. // 打开日历弹窗
  116. openCalendar() {
  117. this.visible = true;
  118. },
  119. async fetchOrderList() {
  120. let resp = await api.reservedRecords();
  121. if (resp.code === 200) {
  122. console.log(resp);
  123. this.orderList = resp.data;
  124. console.log(this.orderList);
  125. }
  126. },
  127. getStyleByOrderStatus(orderSource) {
  128. let style = null;
  129. // 订单状态,0已预约,未支付,1已支付,待使用,2正在使用,3已结算,5已取消
  130. switch (orderSource.status) {
  131. case 0:
  132. style = this.colorStyleList[2];
  133. break;
  134. case 1:
  135. style = this.colorStyleList[2];
  136. break;
  137. case 2:
  138. style = this.colorStyleList[1];
  139. break;
  140. case 3:
  141. style = this.colorStyleList[0];
  142. break;
  143. case 5:
  144. style = this.colorStyleList[0];
  145. break;
  146. }
  147. return style;
  148. },
  149. toOrderDetail(source) {
  150. if (source.status === 0) {
  151. this.$router.push({
  152. path: "/confirmOrder/details",
  153. query: {
  154. id: source.order_id,
  155. },
  156. });
  157. } else {
  158. this.$router.push({
  159. path: "/historicalOrder/details",
  160. query: {
  161. id: source.order_id,
  162. },
  163. });
  164. }
  165. },
  166. },
  167. };
  168. </script>
  169. <style lang="less" scoped>
  170. .container {
  171. width: 100%;
  172. height: 100%;
  173. background-color: #ffffff;
  174. overflow: hidden;
  175. overflow-y: auto;
  176. border-radius: 8px;
  177. position: relative;
  178. .row {
  179. display: flex;
  180. .time,
  181. .project-wrapper .project {
  182. width: 77px;
  183. height: 80px;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. font-family: PingFangSC-Medium, PingFang SC;
  189. }
  190. .time {
  191. border-bottom: 2px #f5f5f5 solid;
  192. }
  193. .project-wrapper {
  194. flex: 1;
  195. display: flex;
  196. flex-wrap: wrap;
  197. .project {
  198. padding: 3px;
  199. box-sizing: border-box;
  200. .name {
  201. width: 100%;
  202. text-align: center;
  203. font-size: 14px;
  204. margin-bottom: 3px;
  205. overflow: hidden;
  206. white-space: nowrap;
  207. text-overflow: ellipsis;
  208. }
  209. .project-time {
  210. display: flex;
  211. font-size: 10px;
  212. }
  213. }
  214. .el-icon-plus {
  215. color: #ededed;
  216. font-size: 32px;
  217. line-height: 80px;
  218. margin-left: 29px;
  219. }
  220. }
  221. }
  222. // 侧边图表样式
  223. .calendar,
  224. .setUp,
  225. .backNow {
  226. position: fixed;
  227. height: 42px;
  228. width: 125px;
  229. border-radius: 100px 0px 0px 100px;
  230. right: 20px;
  231. background-color: #fff;
  232. box-shadow: 0px 0px 4px 0px rgba(228, 228, 228, 0.5);
  233. line-height: 42px;
  234. color: #333333;
  235. font-size: 16px;
  236. i {
  237. font-size: 20px;
  238. margin-left: 15px;
  239. margin-right: 15px;
  240. }
  241. }
  242. .calendar {
  243. top: 102px;
  244. span {
  245. width: 64px;
  246. display: inline-block;
  247. text-align: justify;
  248. text-justify: distribute-all-lines;
  249. text-align-last: justify;
  250. }
  251. }
  252. .setUp {
  253. top: 154px;
  254. }
  255. .backNow {
  256. top: 206px;
  257. }
  258. }
  259. </style>