list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 class="mfooter">
  59. <view class="order">
  60. <view class="f bage">
  61. <text class="icon">&#xe830;</text>
  62. <text>你有新的订单待处理</text>
  63. </view>
  64. <view class="f op" @click="order()">
  65. <text class="icon">&#xe67b;</text>
  66. <text>查看订单</text>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. tab: [
  77. { name: '全部', goodsStatus: '' },
  78. { name: '在售', goodsStatus: 1 },
  79. { name: '下架', goodsStatus: 0 }
  80. ],
  81. param: { pageNo: 1, pageSize: 10, isOrders: 0 },
  82. list: [],
  83. loadMore: true,
  84. dataCount: 0
  85. };
  86. },
  87. onLoad() {
  88. this.getData();
  89. uni.$on('goodsHandle', res => {
  90. this.refresh();
  91. });
  92. },
  93. methods: {
  94. getData() {
  95. this.http.request({
  96. url: '/level-one-server/app/TbGoodsTransit/getTransitList',
  97. loading: 'false',
  98. data: this.param,
  99. success: res => {
  100. this.dataCount = res.data.dataCount;
  101. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  102. this.list.push(...res.data.data);
  103. }
  104. });
  105. },
  106. //点击tab切换
  107. click(e) {
  108. this.param.goodsStatus = e.goodsStatus;
  109. this.refresh();
  110. },
  111. del(id) {
  112. uni.showModal({
  113. title: '提示',
  114. content: '确定删除?',
  115. success: res => {
  116. if (res.confirm) {
  117. this.http.request({
  118. url: '/level-one-server/app/TbGoodsTransit/deleteById?id=' + id,
  119. success: res => {
  120. uni.showToast({ title: '删除成功' });
  121. this.refresh();
  122. }
  123. });
  124. }
  125. }
  126. });
  127. },
  128. edit(id) {
  129. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add?id=' + id });
  130. },
  131. order() {
  132. uni.navigateTo({ url:'/pages/market/one/merchant/order/list' });
  133. },
  134. //刷新数据
  135. refresh() {
  136. this.loadMore = true;
  137. this.param.pageNo = 1;
  138. this.list = [];
  139. this.getData();
  140. }
  141. },
  142. //下拉刷新
  143. onPullDownRefresh() {
  144. setTimeout(() => {
  145. this.refresh();
  146. uni.stopPullDownRefresh();
  147. }, 1000);
  148. },
  149. //上拉加载
  150. onReachBottom() {
  151. if (this.loadMore) {
  152. this.param.pageNo++;
  153. this.getData();
  154. }
  155. },
  156. onNavigationBarButtonTap() {
  157. uni.navigateTo({ url: '/pages/market/one/merchant/goods/add' });
  158. }
  159. };
  160. </script>
  161. <style lang="scss">
  162. page {
  163. background-color: $pg;
  164. }
  165. .goodsManageList {
  166. padding-bottom: 55px;
  167. }
  168. .mfooter {
  169. .order {
  170. display: flex;
  171. .f {
  172. flex: 1;
  173. padding: 16px;
  174. }
  175. .bage {
  176. color: #f44336;
  177. text-align: left;
  178. font-size: 14px;
  179. }
  180. .op {
  181. background-color: $main-color;
  182. color: white;
  183. flex: 0.5;
  184. }
  185. .icon {
  186. padding-right: 5px;
  187. }
  188. }
  189. }
  190. </style>
  191. s