微信

index.vue 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. export default {
  24. name: '',
  25. data () {
  26. return {
  27. topCaseInfoData: {
  28. caseName: '',
  29. caseId: '',
  30. showSelect: false
  31. },
  32. list: []
  33. }
  34. },
  35. components: {
  36. topCaseInfo,
  37. salesRecordItem
  38. },
  39. computed: {
  40. ...mapState({
  41. userInfo: x => x.userCenter.userInfo,
  42. CaseList: x => x.app.CaseList,
  43. }),
  44. ...mapForbidState({
  45. salesList: x => x.salesList,
  46. forbidList: x => x.forbidList,
  47. }),
  48. },
  49. created () {
  50. this.getCaseList().then((res) => {
  51. this.topCaseInfoData.caseId = this.userInfo.customer.BelongCaseId
  52. for (let i=0;i<this.CaseList.length;i++){
  53. if (this.CaseList[i].CaseId === this.topCaseInfoData.caseId){
  54. this.topCaseInfoData.caseName = this.CaseList[i].CaseName
  55. }
  56. }
  57. })
  58. this.init()
  59. },
  60. methods: {
  61. ...actions([
  62. 'getCaseList',
  63. ]),
  64. fibdata (item) {
  65. const couponfib = this.forbidList.filter(x => x.UserId === item.UserId && x.ForbidType === 'coupon').length > 0 ? true : false
  66. const orderfib = this.forbidList.filter(x => x.UserId === item.UserId && x.ForbidType === 'goods').length > 0 ? true : false
  67. return {
  68. 'coupon': couponfib,
  69. 'order': orderfib
  70. }
  71. },
  72. showVanPicker () {
  73. this.showSelect = true
  74. },
  75. selectCase (val) { // 选择案场
  76. this.topCaseInfoData.caseName = val.CaseName
  77. this.topCaseInfoData.caseId = val.CaseId
  78. this.getCaseTableList({
  79. caseid: this.topCaseInfoData.caseId
  80. })
  81. this.showSelect = false
  82. },
  83. ...mapForbidActions(['getSales', 'getForbidList', 'putForbid', 'putForbidOpen']),
  84. triggerCardAndCoupon (val) { // 切换卡券状态 type='close':关闭;type='open':开启;
  85. console.log(val)
  86. if (val.type === 'open') {
  87. this.putForbid({ userid: val.data.UserId, type: 'coupon' })
  88. } else {
  89. this.putForbidOpen({ userid: val.data.UserId, type: 'coupon' })
  90. }
  91. this.init()
  92. },
  93. triggerDrink (val) { // 切换饮品状态 type='close':关闭;type='open':开启;
  94. console.log(val)
  95. if (val.type === 'open') {
  96. this.putForbid({ userid: val.data.UserId, type: 'goods' })
  97. } else {
  98. this.putForbidOpen({ userid: val.data.UserId, type: 'goods' })
  99. }
  100. this.init()
  101. },
  102. toDetail (item) {
  103. console.log(item)
  104. this.$router.push({ name: 'salesGiveOutDetail', query: { id: item.UserId } })
  105. },
  106. init () {
  107. this.getSales({ type: 'sales' }).then(() => {
  108. this.getForbidList().then(() => {
  109. this.list = []
  110. for (let i = 0; i < this.salesList.length; i++) {
  111. let CustomerCard = this.salesList[i].CustomerCard || []
  112. let CustomerCoupon = this.salesList[i].CustomerCoupon || []
  113. let OrdersDetail = this.salesList[i].OrdersDetail || []
  114. let item = {
  115. name: this.salesList[i].RealName,
  116. id: i,
  117. cardAndCoupon: {
  118. totalNum: '100',
  119. usedNum: CustomerCard.length + CustomerCoupon.length
  120. },
  121. drink: {
  122. totalNum: '100',
  123. usedNum: OrdersDetail.length
  124. },
  125. UserId: this.salesList[i].UserId
  126. }
  127. this.list.push(item)
  128. }
  129. })
  130. })
  131. }
  132. }
  133. }
  134. </script>
  135. <!-- Add "scoped" attribute to limit CSS to this component only -->
  136. <style lang="scss" scoped>
  137. @import 'page.scss';
  138. </style>