list.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 class="tradeAreaName">{{ item.tradeAreaName }}</view>
  41. <view class="date">发布于:{{ item.createTime }}</view>
  42. </view>
  43. <view class="op">
  44. <view class="flex">
  45. <view class="f rline" style="color: #0081ff" @click.stop="edit(item.id)">
  46. <text class="icon">&#xe668;</text>
  47. <text>编辑</text>
  48. </view>
  49. <view class="f" style="color: #f44336" @click.stop="del(item.id)">
  50. <text class="icon">&#xe852;</text>
  51. <text>删除</text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="clear"></view>
  56. </view>
  57. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  58. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. tab: [
  67. { name: '全部', goodsStatus: '' },
  68. { name: '在售', goodsStatus: 1 },
  69. { name: '下架', goodsStatus: 0 }
  70. ],
  71. param: { pageNo: 1, pageSize: 10, isOrders: 0 },
  72. list: [],
  73. loadMore: true,
  74. dataCount: 0
  75. };
  76. },
  77. onLoad() {
  78. this.getData();
  79. uni.$on('goodsHandle', res => {
  80. this.refresh();
  81. });
  82. },
  83. methods: {
  84. getData() {
  85. this.http.request({
  86. url: '/level-one-server/app/TbGoodsTransit/getTransitList',
  87. loading: 'false',
  88. data: this.param,
  89. success: res => {
  90. this.dataCount = res.data.dataCount;
  91. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  92. this.list.push(...res.data.data);
  93. }
  94. });
  95. },
  96. //点击tab切换
  97. click(e) {
  98. this.param.goodsStatus = e.goodsStatus;
  99. this.refresh();
  100. },
  101. del(id) {
  102. uni.showModal({
  103. title: '提示',
  104. content: '确定删除?',
  105. success: res => {
  106. if (res.confirm) {
  107. this.http.request({
  108. url: '/level-one-server/app/TbGoodsTransit/deleteById?id=' + id,
  109. success: res => {
  110. uni.showToast({ title: '删除成功' });
  111. this.refresh();
  112. }
  113. });
  114. }
  115. }
  116. });
  117. },
  118. edit(id) {
  119. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add?id=' + id });
  120. },
  121. //刷新数据
  122. refresh() {
  123. this.loadMore = true;
  124. this.param.pageNo = 1;
  125. this.list = [];
  126. this.getData();
  127. }
  128. },
  129. //下拉刷新
  130. onPullDownRefresh() {
  131. setTimeout(() => {
  132. this.refresh();
  133. uni.stopPullDownRefresh();
  134. }, 1000);
  135. },
  136. //上拉加载
  137. onReachBottom() {
  138. if (this.loadMore) {
  139. this.param.pageNo++;
  140. this.getData();
  141. }
  142. },
  143. onNavigationBarButtonTap() {
  144. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add' });
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page {
  150. background-color: $pg;
  151. }
  152. </style>