merchantList.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!-- 机器销售列表页 -->
  2. <template>
  3. <view class="">
  4. <view v-if="id!=1">
  5. <view v-if="merchantList[0].equipmentList.length>1">
  6. <uni-collapse :accordion="true">
  7. <uni-list>
  8. <uni-list-item :title="$t('merchantList.total')" @click="openByAdmin(merchantList[0].name,merchantList[0].id)" />
  9. <view class="titlelist" v-for="equipment in merchantList[0].equipmentList" :key="equipment.id">
  10. <uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(merchantList[0].name,equipment.id)" />
  11. </view>
  12. </uni-list>
  13. </uni-collapse>
  14. </view>
  15. <view v-else style="text-align: center;">{{$t('merchantList.data')}}</view>
  16. </view>
  17. <view class="">
  18. <mix-tree :list="list" @treeItemClick="treeItemClick"></mix-tree>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapState,
  25. mapActions,
  26. mapMutations
  27. } from 'vuex'
  28. import uniCollapse from '@/components/uni-collapse/uni-collapse.vue'
  29. import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue'
  30. import uniList from '@/components/uni-list/uni-list.vue'
  31. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  32. import mixTree from '@/components/mix-tree/mix-tree'
  33. export default {
  34. components: {
  35. uniCollapse,
  36. uniCollapseItem,
  37. uniList,
  38. uniListItem,
  39. mixTree
  40. },
  41. data() {
  42. return {
  43. globalUser:{},
  44. merchantList: [{
  45. equipmentList: []
  46. }],
  47. extraIcon: {
  48. color: '#4cd964',
  49. size: '22',
  50. type: 'spinner'
  51. },
  52. id: null,
  53. pname:null,
  54. list: []
  55. }
  56. },
  57. computed: {
  58. ...mapState(['loginUser']),
  59. },
  60. onShow() {
  61. uni.setNavigationBarTitle({title: this.$t('merchantList.title')});
  62. uni.setTabBarItem({ index: 1,text: this.$t('tabs.tab2')});
  63. this.globalUser = uni.getStorageSync("globalUser");
  64. this.id = this.globalUser.id;
  65. this.getEquipmentListData();
  66. },
  67. onLoad(state) {
  68. // this.globalUser = uni.getStorageSync("globalUser");
  69. // this.id = this.globalUser.id;
  70. // this.getEquipmentListData();
  71. },
  72. onPullDownRefresh() {
  73. this.getEquipmentListData();
  74. },
  75. methods: {
  76. ...mapActions('chart', ['getEquipmentListByUser', 'getEquipmentListByProvince']),
  77. openByAdmin(pname, adminId) {
  78. uni.navigateTo({
  79. url: '/pages/Charts/elseStatistics?adminId=' + adminId + '&pname=' + pname,
  80. });
  81. },
  82. openByEquipment(pname, equipmentId) {
  83. uni.navigateTo({
  84. url: '/pages/Charts/elseStatistics?equipmentId=' + equipmentId + '&pname=' + pname,
  85. });
  86. },
  87. //点击最后一级时触发该事件
  88. treeItemClick(item) {
  89. let {
  90. id,
  91. name,
  92. parentId
  93. } = item;
  94. if(name=="总销售情况"){
  95. uni.request({
  96. url: this.serverurl + '/TAdmin/findById',
  97. data: {
  98. "id": id,
  99. },
  100. method: "POST",
  101. success: (res) => {
  102. this.pname = res.data.data.name;
  103. uni.navigateTo({
  104. url: '/pages/Charts/elseStatistics?adminId=' + id + '&pname=' + this.pname,
  105. });
  106. }
  107. })
  108. }else{
  109. uni.request({
  110. url: this.serverurl + '/TEquipment/findByEquipment',
  111. data: {
  112. "id": id,
  113. },
  114. method: "POST",
  115. success: (res) => {
  116. this.pname = res.data.data.name;
  117. uni.navigateTo({
  118. url: '/pages/Charts/elseStatistics?equipmentId=' + id + '&pname=' + this.pname,
  119. });
  120. }
  121. })
  122. }
  123. console.log(item)
  124. },
  125. getMerchantTitle(merchant) {
  126. return merchant.name ? merchant.name : merchant.username;
  127. },
  128. getEquipmentTitle(equipment) {
  129. return equipment.name ? equipment.name : equipment.clientId;
  130. },
  131. getEquipmentListData() {
  132. if(this.id==1){
  133. this.getEquipmentListByProvince(this.globalUser)
  134. .then(data => {
  135. this.list = data;
  136. }, _ => void uni.stopPullDownRefresh());
  137. }else{
  138. this.getEquipmentListByUser(this.globalUser)
  139. .then(data => {
  140. this.merchantList = data;
  141. var listName = data[0].equipmentList;
  142. var listId = data[0].id;
  143. if(listId!=null && listId!='1'){
  144. uni.setStorageSync("listName",listName);
  145. }
  146. uni.stopPullDownRefresh();
  147. }
  148. , _ => void uni.stopPullDownRefresh());
  149. }
  150. }
  151. }
  152. }
  153. </script>
  154. <style>
  155. .titlelist {
  156. color: #363D44;
  157. font-size: 16upx;
  158. font-family: "PingFang-SC-Medium";
  159. }
  160. </style>