merchantList.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. merchantList: [{
  44. equipmentList: []
  45. }],
  46. extraIcon: {
  47. color: '#4cd964',
  48. size: '22',
  49. type: 'spinner'
  50. },
  51. id: null,
  52. pname:null,
  53. list: []
  54. }
  55. },
  56. computed: {
  57. ...mapState(['loginUser']),
  58. },
  59. onShow() {
  60. uni.setNavigationBarTitle({title: this.$t('merchantList.title')});
  61. var globalUser = uni.getStorageSync("globalUser");
  62. this.id = globalUser.id;
  63. },
  64. onLoad(state) {
  65. var globalUser = uni.getStorageSync("globalUser");
  66. this.id = globalUser.id;
  67. this.getEquipmentListData();
  68. },
  69. onPullDownRefresh() {
  70. this.getEquipmentListData();
  71. },
  72. methods: {
  73. ...mapActions('chart', ['getEquipmentListByUser', 'getEquipmentListByProvince']),
  74. openByAdmin(pname, adminId) {
  75. uni.navigateTo({
  76. url: '/pages/Charts/elseStatistics?adminId=' + adminId + '&pname=' + pname,
  77. });
  78. },
  79. openByEquipment(pname, equipmentId) {
  80. uni.navigateTo({
  81. url: '/pages/Charts/elseStatistics?equipmentId=' + equipmentId + '&pname=' + pname,
  82. });
  83. },
  84. //点击最后一级时触发该事件
  85. treeItemClick(item) {
  86. let {
  87. id,
  88. name,
  89. parentId
  90. } = item;
  91. if(name=="总销售情况"){
  92. uni.request({
  93. url: this.serverurl + '/TAdmin/findById',
  94. data: {
  95. "id": id,
  96. },
  97. method: "POST",
  98. success: (res) => {
  99. this.pname = res.data.data.name;
  100. uni.navigateTo({
  101. url: '/pages/Charts/elseStatistics?adminId=' + id + '&pname=' + this.pname,
  102. });
  103. }
  104. })
  105. }else{
  106. uni.request({
  107. url: this.serverurl + '/TEquipment/findByEquipment',
  108. data: {
  109. "id": id,
  110. },
  111. method: "POST",
  112. success: (res) => {
  113. this.pname = res.data.data.name;
  114. uni.navigateTo({
  115. url: '/pages/Charts/elseStatistics?equipmentId=' + id + '&pname=' + this.pname,
  116. });
  117. }
  118. })
  119. }
  120. console.log(item)
  121. },
  122. getMerchantTitle(merchant) {
  123. return merchant.name ? merchant.name : merchant.username;
  124. },
  125. getEquipmentTitle(equipment) {
  126. return equipment.name ? equipment.name : equipment.clientId;
  127. },
  128. getEquipmentListData() {
  129. if(this.id==1){
  130. this.getEquipmentListByProvince(this.loginUser)
  131. .then(data => {
  132. this.list = data;
  133. }, _ => void uni.stopPullDownRefresh());
  134. }else{
  135. this.getEquipmentListByUser(this.loginUser)
  136. .then(data => {
  137. this.merchantList = data;
  138. var listName = data[0].equipmentList;
  139. var listId = data[0].id;
  140. if(listId!=null && listId!='1'){
  141. uni.setStorageSync("listName",listName);
  142. }
  143. uni.stopPullDownRefresh();
  144. }
  145. , _ => void uni.stopPullDownRefresh());
  146. }
  147. }
  148. }
  149. }
  150. </script>
  151. <style>
  152. .titlelist {
  153. color: #363D44;
  154. font-size: 16upx;
  155. font-family: "PingFang-SC-Medium";
  156. }
  157. </style>