merchantList.vue 4.2 KB

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