微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div class="mainPage flex-v">
  3. <div class="top">
  4. <topCaseInfo :data="topCaseInfoData" :userName="userInfo.customer !== undefined ? userInfo.customer.CustomerName : ''" @selectCase="showVanPicker"></topCaseInfo>
  5. </div>
  6. <div class="flex-item body">
  7. <div>
  8. <ul>
  9. <li v-for="(item,index) in list" :key="index">
  10. <salesRecordItem :data="item" :fibdata="fibdata(item)" @triggerCardAndCoupon="triggerCardAndCoupon" @triggerDrink="triggerDrink" @toDetail='toDetail'></salesRecordItem>
  11. </li>
  12. </ul>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. import topCaseInfo from '../../../components/topCaseInfo/index'
  19. import salesRecordItem from '../../../components/salesRecordItem/index'
  20. import { mapState, createNamespacedHelpers } from 'vuex'
  21. const { mapState: mapForbidState, mapActions: mapForbidActions } = createNamespacedHelpers('forbid')
  22. const { mapActions: actions } = createNamespacedHelpers('app')
  23. const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
  24. const { mapState: mapCaseState, mapActions: mapCaseActions } = createNamespacedHelpers('case')
  25. export default {
  26. name: '',
  27. data () {
  28. return {
  29. topCaseInfoData: {
  30. CaseName: '',
  31. caseId: '',
  32. showSelect: false
  33. },
  34. list: []
  35. }
  36. },
  37. components: {
  38. topCaseInfo,
  39. salesRecordItem
  40. },
  41. computed: {
  42. ...mapState({
  43. userInfo: x => x.userCenter.userInfo,
  44. CaseList: x => x.app.CaseList,
  45. CaseTableList: x => x.placeOrderForCoffee.CaseTableList,
  46. }),
  47. ...mapCaseState({
  48. caseTotal: x => x.caseTotal,
  49. }),
  50. ...mapForbidState({
  51. salesList: x => x.salesList,
  52. forbidList: x => x.forbidList,
  53. }),
  54. },
  55. created () {
  56. this.getCaseList().then((res) => {
  57. this.topCaseInfoData.CaseName = res.cases[0].CaseName
  58. this.topCaseInfoData.CaseId = res.cases[0].CaseId
  59. })
  60. this.init()
  61. },
  62. methods: {
  63. ...actions([
  64. 'getCaseList',
  65. ]),
  66. ...mapCaseActions([
  67. 'getCaseTotal',
  68. ]),
  69. fibdata (item) {
  70. const couponfib = this.forbidList.filter(x => x.UserId === item.UserId && x.ForbidType === 'coupon').length > 0 ? true : false
  71. const orderfib = this.forbidList.filter(x => x.UserId === item.UserId && x.ForbidType === 'order').length > 0 ? true : false
  72. return {
  73. 'coupon': couponfib,
  74. 'order': orderfib
  75. }
  76. },
  77. showVanPicker () {
  78. this.showSelect = true
  79. },
  80. selectCase (val) { // 选择案场
  81. this.topCaseInfoData.CaseName = val.CaseName
  82. this.topCaseInfoData.CaseId = val.CaseId
  83. this.getCaseTableList({
  84. caseid: this.topCaseInfoData.CaseId
  85. })
  86. this.showSelect = false
  87. },
  88. ...mapForbidActions(['getSales', 'getForbidList', 'putForbid', 'putForbidOpen']),
  89. triggerCardAndCoupon (val) { // 切换卡券状态 type='close':关闭;type='open':开启;
  90. console.log(val)
  91. if (val.type === 'open') {
  92. this.putForbid({ userid: val.data.UserId, type: 'coupon' })
  93. } else {
  94. this.putForbidOpen({ userid: val.data.UserId, type: 'coupon' })
  95. }
  96. this.init()
  97. },
  98. triggerDrink (val) { // 切换饮品状态 type='close':关闭;type='open':开启;
  99. console.log(val)
  100. if (val.type === 'open') {
  101. this.putForbid({ userid: val.data.UserId, type: 'order' })
  102. } else {
  103. this.putForbidOpen({ userid: val.data.UserId, type: 'order' })
  104. }
  105. this.init()
  106. },
  107. toDetail (item) {
  108. console.log(item)
  109. this.$router.push({ name: 'salesGiveOutDetail', query: { id: item.UserId } })
  110. },
  111. init () {
  112. this.getSales({ type: 'sales' }).then(() => {
  113. this.getForbidList().then(() => {
  114. this.list = []
  115. for (let i = 0; i < this.salesList.length; i++) {
  116. let CustomerCard = this.salesList[i].CustomerCard || []
  117. let CustomerCoupon = this.salesList[i].CustomerCoupon || []
  118. let OrdersDetail = this.salesList[i].OrdersDetail || []
  119. let item = {
  120. name: this.salesList[i].RealName,
  121. id: i,
  122. cardAndCoupon: {
  123. totalNum: '100',
  124. usedNum: CustomerCard.length + CustomerCoupon.length
  125. },
  126. drink: {
  127. totalNum: '100',
  128. usedNum: OrdersDetail.length
  129. },
  130. UserId: this.salesList[i].UserId
  131. }
  132. this.list.push(item)
  133. }
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <!-- Add "scoped" attribute to limit CSS to this component only -->
  141. <style lang="scss" scoped>
  142. @import 'page.scss';
  143. </style>