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