list.vue 5.2 KB

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