merchantList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. var token = uni.getStorageSync("token");
  98. uni.request({
  99. url: this.serverurl + '/TAdmin/findById',
  100. data: {
  101. "id": id,
  102. },
  103. method: "POST",
  104. header:{
  105. 'token':token
  106. },
  107. success: (res) => {
  108. this.pname = res.data.data.name;
  109. uni.navigateTo({
  110. url: '/pages/Charts/elseStatistics?adminId=' + id + '&pname=' + this.pname,
  111. });
  112. }
  113. })
  114. }else{
  115. var token = uni.getStorageSync("token");
  116. uni.request({
  117. url: this.serverurl + '/TEquipment/findByEquipment',
  118. data: {
  119. "id": id,
  120. },
  121. method: "POST",
  122. header:{
  123. 'token':token
  124. },
  125. success: (res) => {
  126. this.pname = res.data.data.name;
  127. uni.navigateTo({
  128. url: '/pages/Charts/elseStatistics?equipmentId=' + id + '&pname=' + this.pname,
  129. });
  130. }
  131. })
  132. }
  133. console.log(item)
  134. },
  135. getMerchantTitle(merchant) {
  136. return merchant.name ? merchant.name : merchant.username;
  137. },
  138. getEquipmentTitle(equipment) {
  139. return equipment.name ? equipment.name : equipment.clientId;
  140. },
  141. getEquipmentListData() {
  142. if(this.id==1){
  143. this.getEquipmentListByProvince(this.globalUser)
  144. .then(data => {
  145. this.list = data;
  146. }, _ => void uni.stopPullDownRefresh());
  147. }else{
  148. this.getEquipmentListByUser(this.globalUser)
  149. .then(data => {
  150. this.merchantList = data;
  151. var listName = data[0].equipmentList;
  152. var listId = data[0].id;
  153. if(listId!=null && listId!='1'){
  154. uni.setStorageSync("listName",listName);
  155. }
  156. uni.stopPullDownRefresh();
  157. }
  158. , _ => void uni.stopPullDownRefresh());
  159. }
  160. }
  161. }
  162. }
  163. </script>
  164. <style>
  165. .titlelist {
  166. color: #363D44;
  167. font-size: 16upx;
  168. font-family: "PingFang-SC-Medium";
  169. }
  170. </style>