list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view>
  3. <view class="tab">
  4. <u-tabs :list="tab" @click="click" :lineHeight="5"></u-tabs>
  5. </view>
  6. <view class="goodsManageList">
  7. <view class="item" v-for="(item, index) in list" :key="index" @click="detail(item)">
  8. <view class="top">
  9. <view class="title omit">{{ item.goodsName }}</view>
  10. <view class="state" v-if="item.isRelease == 0" @click.stop="del(item)" style="color: #f44336">删除</view>
  11. <view class="state" style="color: #4581fb" v-if="item.isRelease == 1 && item.isOrders == 0 && item.isConfirm == 0">发布中</view>
  12. <view class="state" style="color: #4caf50" v-if="item.isRelease == 1 && item.isOrders == 1 && item.isConfirm == 0">已接单</view>
  13. <view class="state" style="color: #4caf50" v-if="item.isRelease == 1 && item.isOrders == 1 && item.isConfirm == 1">已确认</view>
  14. </view>
  15. <view class="con">
  16. <view class="flex fs">
  17. <view class="f left" style="flex: 0.5">
  18. <view class="tag">商品量:{{ item.goodsQuantity }}</view>
  19. </view>
  20. <view class="f left">
  21. <view class="tag">{{ item.createTime }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="op">
  26. <view class="flex">
  27. <view class="f rline" v-if="item.isRelease == 0 && item.isOrders == 0" @click.stop="edit(item)">编辑</view>
  28. <view class="f" v-if="item.isRelease == 0 && item.isOrders == 0 && item.isConfirm == 0" style="color: #4581fb" @click.stop="op(item, 1)">发布</view>
  29. <view class="f" v-if="item.isRelease == 1 && item.isOrders == 0 && item.isConfirm == 0" style="color: #f44336" @click.stop="op(item, 0)">取消发布</view>
  30. <view class="f" v-if="item.isRelease == 1 && item.isOrders == 1 && item.isConfirm == 0" style="color: #4581fb" @click.stop="confirm(item, 0)">前往确认</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  35. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. tab: [
  44. //isRelease:是否发布[0=待发布,1=已发布] isOrders:是否被接单[0=待接单,1=已被接单] isConfirm:收购商是否确认:0=未确认,1=已确认
  45. { name: '全部', isRelease: '', isOrders: '' ,isConfirm:''},
  46. { name: '待发布', isRelease: 0, isOrders: 0 ,isConfirm: 0},
  47. { name: '发布中', isRelease: 1, isOrders: 0 ,isConfirm: 0},
  48. { name: '已接单', isRelease: 1, isOrders: 1 ,isConfirm: 0},
  49. { name: '已确认', isRelease: 1, isOrders: 1 ,isConfirm: 1},
  50. //{ name: '已完成', isRelease: 1 ,isOrders: 1}
  51. ],
  52. list: [],
  53. param: { pageNo: 1, pageSize: 10 },
  54. loadMore: true
  55. };
  56. },
  57. onLoad(e) {
  58. this.getData();
  59. uni.$on('purchaser_buy_list', res => {
  60. this.refresh();
  61. });
  62. },
  63. methods: {
  64. getData() {
  65. this.http.request({
  66. url: '/level-two-server/app/TbGoodsDemand/getAppList',
  67. data: this.param,
  68. loading: 'false',
  69. success: res => {
  70. this.loadMore = parseInt(res.data.pageCount) > this.param.pageNo;
  71. this.list.push(...res.data.data);
  72. }
  73. });
  74. },
  75. //点击tab切换
  76. click(e) {
  77. this.param.isRelease = e.isRelease;
  78. this.param.isOrders = e.isOrders;
  79. this.param.isConfirm = e.isConfirm;
  80. this.refresh();
  81. },
  82. detail(item) {
  83. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/detail?id=' + item.id });
  84. },
  85. //编辑
  86. edit(item) {
  87. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/add?id=' + item.id });
  88. },
  89. //前往确认
  90. confirm(item) {
  91. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/detail?id=' + item.id });
  92. },
  93. //取消发布或发布
  94. op(item, isRelease) {
  95. uni.showModal({
  96. title: '提示',
  97. content: isRelease == 0 ? '确定取消发布' : '确定发布到市场?',
  98. success: res => {
  99. if (res.confirm) {
  100. this.http.request({
  101. url: '/level-two-server/app/TbGoodsDemand/changeState',
  102. method: 'POST',
  103. data: { id: item.id, isRelease: isRelease },
  104. success: res => {
  105. uni.showToast({ title: '操作成功' });
  106. item.isRelease = isRelease;
  107. }
  108. });
  109. }
  110. }
  111. });
  112. },
  113. del(item) {
  114. uni.showModal({
  115. title: '提示',
  116. content: '确定删除该需求?',
  117. success: res => {
  118. if (res.confirm) {
  119. this.http.request({
  120. url: '/level-two-server/app/TbGoodsDemand/delete?id=' + item.id,
  121. success: res => {
  122. uni.showToast({ title: '删除成功' });
  123. this.list.splice(this.list.indexOf(item), 1);
  124. }
  125. });
  126. }
  127. }
  128. });
  129. },
  130. //刷新数据
  131. refresh() {
  132. this.loadMore = true;
  133. this.param.pageNo = 1;
  134. this.list = [];
  135. this.getData();
  136. }
  137. },
  138. //下拉刷新
  139. onPullDownRefresh() {
  140. setTimeout(() => {
  141. this.refresh();
  142. uni.stopPullDownRefresh();
  143. }, 1000);
  144. },
  145. //上拉加载
  146. onReachBottom() {
  147. if (this.loadMore) {
  148. this.param.pageNo++;
  149. this.getData();
  150. }
  151. },
  152. onNavigationBarButtonTap() {
  153. uni.navigateTo({ url: '/pages/market/two/purchaser/buy/add' });
  154. }
  155. };
  156. </script>
  157. <style lang="scss">
  158. page {
  159. background-color: $pg;
  160. }
  161. </style>