list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view>
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
  5. <view class="length">{{ dataCount }}件商品</view>
  6. </view>
  7. <view class="goodsManageList">
  8. <view class="item" v-for="(item, index) in list" :key="index">
  9. <view class="top">
  10. <view class="title omit">{{ item.goodsName }}</view>
  11. <view class="state" v-if="item.goodsStatus == 1">
  12. <text class="icon" style="color: #13ce66">&#xe830;</text>
  13. <text>在售</text>
  14. </view>
  15. <view class="state" v-else>
  16. <text class="icon" style="color: #f44336">&#xe622;</text>
  17. <text>下架</text>
  18. </view>
  19. <view class="clear"></view>
  20. </view>
  21. <view class="con">
  22. <view class="flex fs">
  23. <view class="f">
  24. <view class="tag">类型</view>
  25. <view class="v omit">{{ item.goodsType }}</view>
  26. </view>
  27. <view class="f">
  28. <view class="tag">单位</view>
  29. <view class="v omit">{{ item.goodsUnits || '吨' }}</view>
  30. </view>
  31. <view class="f">
  32. <view class="tag">价格</view>
  33. <view class="v omit">¥{{ item.price }}</view>
  34. </view>
  35. <view class="f">
  36. <view class="tag">库存</view>
  37. <view class="v omit">{{ item.stock }}吨</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="op">
  42. <view class="flex">
  43. <view class="f rline" style="color: #0081ff" @click.stop="edit(item.id)">
  44. <text class="icon">&#xe668;</text>
  45. <text>编辑</text>
  46. </view>
  47. <view class="f" style="color: #f44336" @click.stop="del(item.id)">
  48. <text class="icon">&#xe852;</text>
  49. <text>删除</text>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="clear"></view>
  54. </view>
  55. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  56. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. data() {
  63. return {
  64. tab: [
  65. { name: '全部', goodsStatus: '' },
  66. { name: '在售', goodsStatus: 1 },
  67. { name: '下架', goodsStatus: 0 }
  68. ],
  69. param: { pageNo: 1, pageSize: 10, isOrders: 0 },
  70. list: [],
  71. loadMore: true,
  72. dataCount: 0
  73. };
  74. },
  75. onLoad() {
  76. this.getData();
  77. uni.$on('goodsHandle', res => {
  78. this.refresh();
  79. });
  80. },
  81. methods: {
  82. getData() {
  83. this.http.request({
  84. url: '/level-one-server/app/TbGoodsTransit/getTransitList',
  85. loading: 'false',
  86. data: this.param,
  87. success: res => {
  88. this.dataCount = res.data.dataCount;
  89. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  90. this.list.push(...res.data.data);
  91. }
  92. });
  93. },
  94. //点击tab切换
  95. click(e) {
  96. this.param.goodsStatus = e.goodsStatus;
  97. this.refresh();
  98. },
  99. del(id) {
  100. uni.showModal({
  101. title: '提示',
  102. content: '确定删除?',
  103. success: res => {
  104. if (res.confirm) {
  105. this.http.request({
  106. url: '/level-one-server/app/TbGoodsTransit/deleteById?id=' + id,
  107. success: res => {
  108. uni.showToast({ title: '删除成功' });
  109. this.refresh();
  110. }
  111. });
  112. }
  113. }
  114. });
  115. },
  116. edit(id) {
  117. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add?id=' + id });
  118. },
  119. //刷新数据
  120. refresh() {
  121. this.loadMore = true;
  122. this.param.pageNo = 1;
  123. this.list = [];
  124. this.getData();
  125. }
  126. },
  127. //下拉刷新
  128. onPullDownRefresh() {
  129. setTimeout(() => {
  130. this.refresh();
  131. uni.stopPullDownRefresh();
  132. }, 1000);
  133. },
  134. //上拉加载
  135. onReachBottom() {
  136. if (this.loadMore) {
  137. this.param.pageNo++;
  138. this.getData();
  139. }
  140. },
  141. onNavigationBarButtonTap() {
  142. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add' });
  143. }
  144. };
  145. </script>
  146. <style lang="scss">
  147. page {
  148. background-color: $pg;
  149. }
  150. </style>