book-day - 副本.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="book-day">
  3. <z-date-slide :dataList="headerList" @getDateInfo="getDateInfo" @getDateRange="getDateRange"></z-date-slide>
  4. <view class="day_scroll-view flex-n">
  5. <view class="time_area">
  6. <view v-for="(item,index) in timeList" :key="index" class="time_area_item">
  7. <view class="time_area_item_content flex-n fje" v-if="index%2==0">
  8. <view class="time_area_item_content_left">{{index/2+7}}</view>
  9. <view class="time_area_item_content_right">: 00</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view>
  14. <view class="book-day_container" :style="{'grid-template-columns': '15rpx repeat('+(maxline+1)+', 8rpx)'}">
  15. <!-- 最少划线64 -->
  16. <view class="item_line" v-for="(item,index) in linelist" :key="item" :style="{'grid-row':(index*2+1)+'/'+(index*2+3),'grid-column':'1/'+(maxline+1)}">
  17. </view>
  18. <view class="item_card " :class="[{'item_card_order_state_1':item.orderState=='02'},{'item_card_order_state_2':item.orderState=='01'},{'item_card_order_state_3':item.orderState=='03'}]"
  19. v-for="(item,index) in dataList" @click="gotoDetail(item.id)" :key="index" :style="{'grid-row':item.gridRow,'grid-column':item.gridColumn}">
  20. <view class="item_card_text line-1">{{item.houseName}}</view>
  21. <view class="item_card_text2 line-1" v-if="item.gridRowEnd-item.gridRowStart>1">{{item.customName}}</view>
  22. <view class="item_card_text2 line-1" v-if="item.gridRowEnd-item.gridRowStart>2">{{item.packageName||'未选套餐'}}{{item.paycontent}}</view>
  23. <view class="item_card_text2 line-1" v-if="item.gridRowEnd-item.gridRowStart>3">{{item.createUserName}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <u-toast ref="uToast"></u-toast>
  29. </view>
  30. </template>
  31. <!-- 5个七点 就排开 -->
  32. <!-- 最大宽度等于最小卡片宽度 -->
  33. <script>
  34. const app = getApp({
  35. allowDefault: true
  36. });
  37. export default {
  38. name: 'book-day',
  39. props: {
  40. refresh: Boolean
  41. },
  42. data() {
  43. return {
  44. timeList: new Array(34),
  45. linelist: new Array(17),
  46. dataList: [],
  47. headerList: [],
  48. daterange: [],
  49. date: '',
  50. maxline: 52, //63
  51. }
  52. },
  53. watch: {
  54. refresh(newval, oldval) {
  55. if (newval) {
  56. this.bookList(this.date);
  57. this.bookHeader(this.daterange[0].date, this.daterange[6].date)
  58. }
  59. }
  60. },
  61. methods: {
  62. //获取预定表头
  63. bookHeader(startTime, endTime) {
  64. var houseTypeIds = uni.getStorageSync('searchField')||[];
  65. this.$axios.post('app/order/orderCalendarHeader', {
  66. "storeId": uni.getStorageSync('storeId'),
  67. "startTime": startTime,
  68. "endTime": endTime,
  69. "houseTypeIds":houseTypeIds
  70. }).then(res => {
  71. console.log('预定表头', res)
  72. var data = res.data.list;
  73. var headerList = [];
  74. for (var i in data) {
  75. headerList.push({
  76. record: data[i].record,
  77. isImportant: data[i].importantDates.length > 0 ? true : false
  78. });
  79. }
  80. this.headerList = headerList;
  81. }).catch(err => {
  82. this.$refs.uToast.error(err.msg)
  83. })
  84. },
  85. //获取预定列表
  86. bookList(date) {
  87. var houseTypeIds = uni.getStorageSync('searchField') || [];
  88. console.log(date)
  89. this.$axios.post('app/order/orderList', {
  90. "storeId": uni.getStorageSync('storeId'),
  91. "customName": "",
  92. "phone": "",
  93. "startTime": date,
  94. "endTime": date,
  95. "houseTypeIds": houseTypeIds,
  96. "packageId": "",
  97. "confirmState": "-1",
  98. "pageNum": "1",
  99. }).then(res => {
  100. console.log('预定列表', res)
  101. this.dataList = res.data.list;
  102. for (var i in this.dataList) {
  103. var paycontent = '';
  104. if (this.dataList[i].mainPayType == '03') {
  105. paycontent += '包场地'
  106. if (this.dataList[i].payTypes.length > 1) {
  107. paycontent += '('
  108. }
  109. }
  110. for (var j in this.dataList[i].payTypes) {
  111. if (this.dataList[i].payTypes[j].payTypeCode == '01') {
  112. paycontent += (this.dataList[i].payTypes[j].orderCount || 0) + '人、'
  113. }
  114. if (this.dataList[i].payTypes[j].payTypeCode == '02') {
  115. paycontent += (this.dataList[i].payTypes[j].orderCount || 0) + '桌、'
  116. }
  117. }
  118. if (paycontent.length > 0) {
  119. paycontent = paycontent.substring(0, paycontent.length - 1);
  120. }
  121. if (this.dataList[i].mainPayType == '03' && this.dataList[i].payTypes.length > 1) {
  122. paycontent += ')'
  123. }
  124. this.dataList[i].paycontent = paycontent.length > 0 ? ('[' + paycontent + ']') : ''
  125. }
  126. this.getNewDataList(this.dataList);
  127. }).catch(err => {
  128. this.$refs.uToast.error(err.msg);
  129. })
  130. },
  131. getDataPos() {
  132. //时间段算出条数,row,row为1 直接30宽样式2
  133. //重复的时间段算出 num num>5 自动最小 num<=5 60/num
  134. //orderState 01预留 02已定 03免费
  135. var tempdata = this.dataList;
  136. var gridColumnStart=2,gridColumnEnd=14;
  137. //先计算grid-row 这个是固定的
  138. for (var i = 0, len = tempdata.length; i < len; i++) {
  139. var text_len = 0, //文字长度
  140. repeat_column_pos_end = -1, //记录最后重复的位置
  141. repeat_num = 0; //重复数量
  142. tempdata[i].index = i;
  143. tempdata[i].gridRowStart = (Number(tempdata[i].activityBeginTime.replace(':', '')) / 50).toFixed(0) - 13;
  144. tempdata[i].gridRowEnd = (Number(tempdata[i].activityEndTime.replace(':', '')) / 50).toFixed(0) - 13;
  145. tempdata[i].gridRow = tempdata[i].gridRowStart + '/' + tempdata[i].gridRowEnd;
  146. tempdata[i].height = tempdata[i].gridRowEnd - tempdata[i].gridRowStart;
  147. text_len = this.getByteLen(tempdata[i].customName); //获取文字长度设置省略
  148. if (tempdata[i].gridRowEnd - tempdata[i].gridRowStart == 1) {
  149. text_len = 16;
  150. }
  151. tempdata[i].textlen = text_len;
  152. tempdata[i].gridColumn = gridColumnStart+'/span 12'; //并不是完全确定的
  153. tempdata[i].gridColumnStart = gridColumnStart;
  154. tempdata[i].gridColumnEnd = gridColumnEnd;
  155. if(i>0){
  156. if (tempdata[i].houseNo != tempdata[i-1].houseNo) {
  157. console.log('换厅',tempdata[i].houseName)
  158. gridColumnStart=gridColumnEnd;
  159. gridColumnEnd +=12;
  160. tempdata[i].gridColumnStart=gridColumnStart;
  161. tempdata[i].gridColumnEnd=gridColumnEnd;
  162. tempdata[i].gridColumn=gridColumnStart + '/span 12';
  163. //分割线得宽度
  164. if (this.maxline < tempdata[i].gridColumnEnd) {
  165. this.maxline = tempdata[i].gridColumnEnd;
  166. }
  167. }
  168. }
  169. }
  170. this.dataList = tempdata;
  171. //找出重复时间段的数据
  172. },
  173. getNewDataList(dataList) {
  174. console.log(dataList)
  175. this.$axios.post('app/house/houseList', {
  176. storeId: uni.getStorageSync('storeId')
  177. }).then(res => {
  178. console.log('场地列表', res.data)
  179. console.log(dataList)
  180. this.dataList = [];
  181. var houseList = res.data.list;
  182. for (var i in houseList) {
  183. for (var j in dataList) {
  184. //同厅
  185. if (houseList[i].id == dataList[j].houseId) {
  186. this.dataList.push(dataList[j])
  187. }
  188. }
  189. }
  190. console.log('排序后', this.dataList);
  191. this.getDataPos();
  192. }).catch(err => {
  193. // uni.hideLoading();
  194. // this.$refs.uToast.error(err.msg)
  195. })
  196. },
  197. getByteLen(val) {
  198. var len = 0;
  199. for (var i = 0; i < val.length; i++) {
  200. var length = val.charCodeAt(i);
  201. if (length >= 0 && length <= 128) {
  202. len += 1;
  203. } else {
  204. len += 2;
  205. }
  206. }
  207. return len;
  208. },
  209. getDateInfo(date) {
  210. console.log(date)
  211. this.$emit('getDateInfo', date);
  212. this.bookList(date.date)
  213. this.date = date.date;
  214. },
  215. getDateRange(daterange) {
  216. this.bookHeader(daterange[0].date, daterange[6].date);
  217. this.daterange = daterange;
  218. },
  219. gotoDetail(id) {
  220. uni.navigateTo({
  221. url: '../detail/index?id=' + id
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .book-day {
  229. height: 100%;
  230. .day_scroll-view {
  231. height: calc(100% - 230rpx);
  232. overflow-y: scroll;
  233. position: relative;
  234. overflow-x: hidden;
  235. .time_area {
  236. width: 100rpx;
  237. .time_area_item {
  238. color: #666666;
  239. font-size: 20rpx;
  240. min-height: 38rpx;
  241. position: relative;
  242. width: 100rpx;
  243. .time_area_item_content {
  244. position: absolute;
  245. right: 0;
  246. top: 10rpx;
  247. z-index: 100;
  248. .time_area_item_content_left {
  249. font-size: 30rpx;
  250. color: #666666;
  251. }
  252. .time_area_item_content_right {
  253. color: #999999;
  254. font-size: 25rpx;
  255. transform: scale(0.72);
  256. transform-origin: right center;
  257. }
  258. }
  259. }
  260. }
  261. .book-day_container {
  262. width: calc(100vw - 100rpx);
  263. overflow-x: scroll;
  264. height: max-content;
  265. display: grid;
  266. grid-auto-flow: column;
  267. grid-column-gap: 5rpx;
  268. grid-template-rows: repeat(34, 38rpx);
  269. // grid-template-columns: 15rpx repeat(100, 8rpx);
  270. .item_line {
  271. border-bottom: 1px solid #E4E4E4;
  272. }
  273. .item_card {
  274. padding: 0 10rpx;
  275. font-size: 25rpx;
  276. .item_card_text {
  277. color: #333333;
  278. transform: scale(0.88);
  279. width: 120%;
  280. transform-origin: left center;
  281. }
  282. .item_card_text2 {
  283. color: #666666;
  284. transform: scale(0.72);
  285. width: 150%;
  286. transform-origin: left center;
  287. }
  288. }
  289. .item_card_order_state_1 {
  290. background: #BCDAFF;
  291. border-top: 6rpx solid #2C8BFF;
  292. }
  293. .item_card_order_state_2 {
  294. background: #D8C9FC;
  295. border-top: 6rpx solid #9164F7;
  296. }
  297. .item_card_order_state_3 {
  298. background: #e6e6e6;
  299. border-top: 6rpx solid #c1c1c1;
  300. }
  301. }
  302. }
  303. }
  304. </style>