merchantList.vue 4.0 KB

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