merchantList.vue 4.1 KB

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