book-month - 副本 (2).vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="book-month">
  3. <CalendarCard>
  4. <template v-slot:default="slot">
  5. <!-- 上下班正常显示蓝色 -->
  6. <!-- 00 正常考勤 01迟到 02 早退 03请假 04考勤异常-->
  7. <view class="date">
  8. {{slot.data.dd}}
  9. <!-- <view class="pointer" v-if="monthInfo[slot.data.date]"
  10. :class="monthInfo[slot.data.date].workStartStatus=='00'&&monthInfo[slot.data.date].workStartStatus=='00'?'success':'error'">
  11. </view> -->
  12. </view>
  13. </template>
  14. </CalendarCard>
  15. <view class="book-month-xq flex-n fac fja">
  16. <view v-for="(item,index) in xqday" :key="index" :class="index==5||index==6?'book-month-zm':''">{{item}}
  17. </view>
  18. </view>
  19. <swiper class="book-out" :disable-touch="disabletouch" :current="1" circular @change="change"
  20. @animationfinish="animationfinish" @transition="transition">
  21. <swiper-item class="book-month-area" :key='index' v-for="(item,index) in threeMonthList">
  22. <scroll-view id="book-out" class="book-in" scroll-y :show-scrollbar="false">
  23. <view class="book-month-area_rows" v-for="(itm,idx) in item" :key="idx">
  24. <view class="flex-n">
  25. <view class="book-month-area_columns line-1 flex-1 ptb-10"
  26. :class="itm2.mm!=item[1][3].mm?'book-month-area_columns_gray':''"
  27. v-for="(itm2,idx2) in itm" :key="itm2.dd" @click="$emit('clickDate',itm2.date)">
  28. <view class="flex-n fac fjc">
  29. <!-- (new Date().getFullYear()==itm2.yy&&(new Date().getMonth()+1)==itm2.mm&&(new Date().getDate()==itm2.dd))?'item_today':'' -->
  30. <view class="item_day"
  31. :class="[{'item_today':new Date().getFullYear()==itm2.yy&&(new Date().getMonth()+1)==itm2.mm&&(new Date().getDate()==itm2.dd),'item_day_select':row==idx&&column==idx2}]">
  32. {{itm2.dd}}</view>
  33. <view class="iconfont iconxing2"
  34. v-if="ImpList[idx*7+idx2]&&ImpList[idx*7+idx2].importantDates&&ImpList[idx*7+idx2].importantDates.length>0"
  35. style="color: #e64340;font-size: 25rpx;transform: scale(0.8);width: 20rpx;">
  36. </view>
  37. <view class="item_daycn "
  38. :class="ImpList[idx*7+idx2]&&ImpList[idx*7+idx2].importantDates&&ImpList[idx*7+idx2].importantDates.length>0?'':'ml-22'">
  39. {{itm2.IDayCn}}</view>
  40. </view>
  41. <view class="book-month-area_data "
  42. v-if="orderTotalList[idx*7+idx2]&&orderTotalList[idx*7+idx2].houseOrderCalc.length>0">
  43. <view v-for="(itmorder,idxorder) in orderTotalList[idx*7+idx2].houseOrderCalc"
  44. :key="idxorder">
  45. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='01'">
  46. <image class="icon" src="../../../static/c1.png"></image>
  47. <view class="num flex-1">{{itmorder.orderCount}}</view>
  48. </view>
  49. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='03'">
  50. <image class="icon" src="../../../static/c2.png"></image>
  51. <view class="num flex-1">{{itmorder.orderCount}}</view>
  52. </view>
  53. <view class="flex-n fac" v-if="itmorder.houseTypeCode=='02'">
  54. <image class="icon" src="../../../static/c3.png"></image>
  55. <view class="num flex-1">{{itmorder.orderCount}}</view>
  56. </view>
  57. </view>
  58. <view class="flex-n fac" v-if="isDisplayPrein=='1'">
  59. <image class="icon" src="../../../static/c4.png"></image>
  60. <view class="num flex-1 line-1">{{orderTotalList[idx*7+idx2].totalMoney}}</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </scroll-view>
  67. </swiper-item>
  68. </swiper>
  69. <u-toast ref="uToast"></u-toast>
  70. </view>
  71. </template>
  72. <script>
  73. const app = getApp({
  74. allowDefault: true
  75. });
  76. export default {
  77. name: 'book-month',
  78. props: {
  79. refresh: Boolean
  80. },
  81. data() {
  82. return {
  83. current: 1,
  84. left: 0,
  85. right: 2,
  86. xqday: ['一', '二', '三', '四', '五', '六', '日'],
  87. monthList: [],
  88. ImpList: [], //重点日期
  89. orderTotalList: [], //订单总计数
  90. threeMonthList: ['', '', ''],
  91. // dataList: [],
  92. callPhone: '',
  93. column: -1,
  94. row: -1,
  95. disabletouch: false,
  96. monthday: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  97. showDataAnimate: {},
  98. dx: 0,
  99. weekName: ['一', '二', '三', '四', '五', '六', '日'],
  100. showday: {}, //需要传入的值
  101. choose: 0,
  102. animateIn: '',
  103. timeout: '',
  104. date: '',
  105. total: 0,
  106. pageNum: 1,
  107. scrollTop: 0,
  108. showLoading: false,
  109. savedata: {},
  110. isDisplayPrein: '0'
  111. }
  112. },
  113. methods: {
  114. getDate(date) {
  115. var d = date.split('-');
  116. var datelist = this.$Date.getDayDate({
  117. yy: d[0],
  118. mm: d[1],
  119. dd: 15
  120. });
  121. this.getDateList(datelist, this.current, this.left, this.right);
  122. },
  123. doNothing() {},
  124. //重点日期从
  125. bookImportantDate(dataList) {
  126. this.$axios.post("app/order/orderImportantDate", {
  127. "startTime": dataList[0].date,
  128. "endTime": dataList[dataList.length - 1].date,
  129. "storeId": uni.getStorageSync('storeId')
  130. }).then(res => {
  131. console.log(res)
  132. this.ImpList = res.data.list;
  133. }).catch(err => {
  134. this.$refs.uToast.error(err.msg)
  135. })
  136. },
  137. //日历订单汇总
  138. orderCalendarTotal(dataList) {
  139. var houseTypeIds = uni.getStorageSync('searchField') || [];
  140. this.$axios.post("app/order/orderCalendarTotalCalc", {
  141. "startTime": dataList[0].date,
  142. "endTime": dataList[dataList.length - 1].date,
  143. "storeId": uni.getStorageSync('storeId'),
  144. "houseTypeIds": houseTypeIds,
  145. }).then(res => {
  146. console.log(res)
  147. this.orderTotalList = res.data.list;
  148. }).catch(err => {
  149. this.$refs.uToast.error(err.msg)
  150. })
  151. },
  152. //获取日期数据 获取上一月 下一周月
  153. getDateList(datelist, current, x1, x2) {
  154. var dateString = '',
  155. oneList = [],
  156. twoList = [],
  157. threeList = [];
  158. //#ifdef APP-PLUS
  159. dateString = datelist.yy + '/' + Number(datelist.mm) + '/' + Number(datelist.dd);
  160. //#endif
  161. //#ifndef APP-PLUS
  162. dateString = datelist.date;
  163. //#endif
  164. var before = new Date(new Date(dateString).getTime() - datelist.dd * 24 * 60 * 60 * 1000),
  165. after = new Date(new Date(dateString).getTime() + (32 - datelist.dd) * 24 * 60 * 60 * 1000);
  166. var a1 = this.$Date.getMonthDate({
  167. yy: before.getFullYear(),
  168. mm: before.getMonth() + 1,
  169. dd: before.getDate()
  170. });
  171. for (var i = 0; i < a1.length / 7; i++) {
  172. oneList.push([])
  173. }
  174. for (var i = 0, len = a1.length; i < len; i++) {
  175. oneList[Math.floor(i / 7)].push(a1[i])
  176. }
  177. var a2 = this.$Date.getMonthDate(datelist);
  178. for (var i = 0; i < a2.length / 7; i++) {
  179. twoList.push([])
  180. }
  181. for (var i = 0, len = a2.length; i < len; i++) {
  182. twoList[Math.floor(i / 7)].push(a2[i])
  183. }
  184. var a3 = this.$Date.getMonthDate({
  185. yy: after.getFullYear(),
  186. mm: after.getMonth() + 1,
  187. dd: after.getDate()
  188. });
  189. for (var i = 0; i < a3.length / 7; i++) {
  190. threeList.push([])
  191. }
  192. for (var i = 0, len = a3.length; i < len; i++) {
  193. threeList[Math.floor(i / 7)].push(a3[i])
  194. }
  195. this.threeMonthList.splice(x1, 1, oneList);
  196. this.threeMonthList.splice(current, 1, twoList);
  197. this.threeMonthList.splice(x2, 1, threeList);
  198. this.$emit('changeDate', a2[15].date)
  199. this.disabletouch = false;
  200. var list = this.$Date.getMonthDate({
  201. yy: datelist.yy,
  202. mm: datelist.mm,
  203. dd: datelist.dd
  204. });
  205. this.bookImportantDate(list);
  206. this.orderCalendarTotal(list);
  207. console.log('yue', list)
  208. this.getAuthState();
  209. },
  210. getAuthState() {
  211. this.$axios.post("storeAuth/findByRoleIdStoreId", {
  212. "roleId": uni.getStorageSync('roleId'),
  213. "storeId": uni.getStorageSync('storeId')
  214. }).then(res => {
  215. console.log(res.data)
  216. //不可编辑
  217. this.isDisplayPrein = res.data.auth.isDisplayPrein;
  218. }).catch(err => {
  219. this.$refs.uToast.error(err.msg);
  220. })
  221. },
  222. change(e) {
  223. this.disabletouch = true;
  224. },
  225. animationfinish(e) {
  226. clearTimeout(this.timeout);
  227. var current = e.detail.current;
  228. this.current = current;
  229. var left = 0,
  230. right = 0;
  231. if (current - 1 >= 0) {
  232. left = current - 1;
  233. } else {
  234. left = 2;
  235. }
  236. if (current + 1 > 2) {
  237. right = 0;
  238. } else {
  239. right = current + 1;
  240. }
  241. this.left = left;
  242. this.right = right;
  243. if (this.dx < 0) {
  244. this.getDateList(this.threeMonthList[current][1][1], current, left, right);
  245. // console.log('左滑:左面是', left, '当前是', current, '右面是', right);
  246. } else if (this.dx > 0) {
  247. this.getDateList(this.threeMonthList[current][1][1], current, left, right);
  248. // console.log('右滑:左面是', left, '当前是', current, '右面是', right);
  249. } else {
  250. // console.log('没有滑动:左面是', left, '当前是', current, '右面是', right);
  251. this.disabletouch = false;
  252. }
  253. this.dx = 0;
  254. },
  255. transition(e) {
  256. this.dx = e.detail.dx;
  257. },
  258. }
  259. }
  260. </script>
  261. <style scoped lang="scss">
  262. .norecord {
  263. width: 457rpx;
  264. margin-left: 147rpx;
  265. margin-top: 20rpx;
  266. }
  267. .book-out {
  268. height: calc(100% - 82rpx);
  269. .book-in {
  270. height: 100%;
  271. }
  272. }
  273. .book-month {
  274. height: 100%;
  275. .book-month-xq {
  276. height: 80rpx;
  277. color: #333333;
  278. font-size: 28rpx;
  279. border-bottom: 1px solid #E4E4E4;
  280. .book-month-zm {
  281. color: #F7913D;
  282. }
  283. }
  284. .book-month-area {
  285. height: 100%;
  286. .book-month-area_rows {
  287. border-bottom: 1px solid #E4E4E4;
  288. .book-month-area_columns_gray {
  289. background: #FAFAFA;
  290. .item_day {
  291. color: #999999;
  292. font-size: 24rpx;
  293. }
  294. }
  295. .item_day_select {
  296. border: 2rpx solid #F7913D !important;
  297. border-radius: 50%;
  298. width: 32rpx;
  299. height: 32rpx;
  300. text-align: center;
  301. line-height: 32rpx;
  302. }
  303. .item_today {
  304. border: 2rpx solid #F7913D !important;
  305. color: white !important;
  306. background: #F7913D;
  307. border-radius: 50%;
  308. width: 32rpx;
  309. height: 32rpx;
  310. text-align: center;
  311. line-height: 32rpx;
  312. }
  313. .book-month-area_columns {
  314. border-right: 1px solid #E4E4E4;
  315. min-height: 160rpx;
  316. .item_day {
  317. color: #333333;
  318. font-size: 24rpx;
  319. }
  320. .item_daycn {
  321. color: #BBBBBB;
  322. font-size: 18rpx;
  323. }
  324. .book-month-area_data {
  325. padding: 0 10rpx;
  326. .icon {
  327. width: 30rpx;
  328. min-width: 30rpx;
  329. height: 30rpx;
  330. margin-top: 4rpx;
  331. }
  332. .num {
  333. color: #666666;
  334. font-size: 20rpx;
  335. text-align: center;
  336. }
  337. }
  338. }
  339. .book-month-area_columns:last-child {
  340. border-right: none;
  341. }
  342. }
  343. }
  344. }
  345. </style>