supplychainon.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="supplychainon-wrapper">
  3. <headerCom headerTitle="供应链列表" @headerJump="headerJump"></headerCom>
  4. <view class="headers-box">
  5. <searchVue
  6. placeholder="请输入商品名称"
  7. @search="onHandleSearch"
  8. ></searchVue>
  9. <tablist
  10. class="mt"
  11. :category="category"
  12. :curruntActive="curruntActive"
  13. @tabs="tabsHandleClick"
  14. ></tablist>
  15. </view>
  16. <view class="content-wrapper">
  17. <template v-if="list.length > 0">
  18. <ProductCard
  19. class="mrb"
  20. v-for="(item, index) in list"
  21. :key="index"
  22. :data="item"
  23. @status-change="handleStatusChange"
  24. @edit-price="handleEditPrice"
  25. />
  26. </template>
  27. <template v-else>
  28. <emptyDataVue style="top: initial" />
  29. </template>
  30. <view
  31. v-if="tihsi == 0 && list.length > 0"
  32. class=""
  33. style="margin: 0rpx 0 30rpx 0; color: #999999; font-size: 26rpx"
  34. >
  35. —— 已经到最底部了哦 ——
  36. </view>
  37. </view>
  38. <priceEditModal v-if="isshow" @close="isshow=false"/>
  39. </view>
  40. </template>
  41. <script>
  42. import headerCom from "../../shop/components/headers/headers.vue";
  43. import searchVue from "./search/search.vue";
  44. import tablist from "./tablist.vue";
  45. import ProductCard from "./ProductCard.vue";
  46. import emptyDataVue from "../../shop/components/emptyData/emptyData.vue";
  47. import priceEditModal from './price-edit-modal.vue'
  48. import {
  49. getSupplyChainList,
  50. getSupplyChainTab,
  51. postchangeshow,
  52. } from "@/commit/product.js";
  53. export default {
  54. components: {
  55. headerCom,
  56. searchVue,
  57. tablist,
  58. ProductCard,
  59. emptyDataVue,
  60. priceEditModal
  61. },
  62. data() {
  63. return {
  64. page: 1,
  65. limit: 10,
  66. tihsi: "",
  67. list: [],
  68. keywords: "",
  69. is_panudn: true,
  70. productData: {},
  71. curruntActive: 0,
  72. category: [],
  73. type: 1,
  74. isshow:false
  75. };
  76. },
  77. async onLoad(options) {
  78. this.curruntActive = options.indexs || options.tabIndex || "0";
  79. this.type = options.type || 1;
  80. await this.getSupplyChainTabData();
  81. await this.getSupplyChainListData();
  82. },
  83. onPullDownRefresh() {
  84. uni.showLoading({
  85. title: "加载中",
  86. });
  87. this.page = 1;
  88. this.is_panudn = true;
  89. this.list = [];
  90. this.getSupplyChainListData();
  91. },
  92. onReachBottom() {
  93. if (this.is_panudn == true) {
  94. this.page++;
  95. this.getSupplyChainListData();
  96. } else {
  97. return;
  98. }
  99. },
  100. methods: {
  101. async tabsHandleClick({ index, item }) {
  102. this.indexs = index;
  103. this.curruntActive = index;
  104. this.list = [];
  105. this.type = item.type || 1;
  106. this.page = 1;
  107. this.is_panudn = true;
  108. await this.getSupplyChainListData();
  109. },
  110. async getSupplyChainTabData() {
  111. try {
  112. const res = await getSupplyChainTab();
  113. if (res.data.status === 200) {
  114. this.category = res.data.data || [];
  115. }
  116. } catch (error) {}
  117. },
  118. async getSupplyChainListData() {
  119. uni.showLoading({
  120. title: "加载中",
  121. });
  122. try {
  123. const res = await getSupplyChainList({
  124. page: this.page,
  125. limit: this.limit,
  126. keyword: this.keywords,
  127. type: this.type,
  128. spec_type: null, //商品规格 null 0 1
  129. });
  130. uni.stopPullDownRefresh();
  131. if (res.data.status === 200) {
  132. this.tihsi = res.data.data.list.length || 0;
  133. console.log(this.tihsi, "this.tihsi");
  134. if (res.data.data.count > 0) {
  135. if (this.page == 1) {
  136. this.list = res.data.data.list;
  137. } else {
  138. this.list = this.list.concat(res.data.data.list);
  139. }
  140. } else {
  141. if (this.page == 1) {
  142. this.list = [];
  143. }
  144. this.is_panudn = false;
  145. }
  146. uni.hideLoading();
  147. }
  148. } catch (error) {}
  149. },
  150. headerJump() {
  151. uni.switchTab({ url: "/shop/productManagementModule/index" });
  152. },
  153. async onHandleSearch(val) {
  154. this.keywords = val;
  155. await this.getSupplyChainListData();
  156. },
  157. handleStatusChange(row) {
  158. let ids = [];
  159. ids.push(row.product_id);
  160. uni.showLoading({
  161. title: "状态更改中",
  162. });
  163. postchangeshow({ ids: ids, is_show: row.is_show })
  164. .then((res) => {
  165. if (res.data.status === 200) {
  166. uni.showToast({
  167. title: res.data.message,
  168. icon: "none",
  169. });
  170. this.getSupplyChainTabData();
  171. this.getSupplyChainListData();
  172. }
  173. })
  174. .catch((err) => {
  175. uni.hideLoading();
  176. uni.hideToast();
  177. });
  178. },
  179. handleEditPrice(data){
  180. // this.productData = data;
  181. this.isshow = true;
  182. }
  183. },
  184. };
  185. </script>
  186. <style>
  187. page {
  188. background-color: #f7f8fc;
  189. /* height: 100%; */
  190. }
  191. </style>
  192. <style lang="scss" scoped>
  193. .supplychainon-wrapper {
  194. .headers-box {
  195. position: fixed;
  196. top: 88rpx;
  197. left: 0;
  198. width: 100%;
  199. z-index: 33;
  200. }
  201. .content-wrapper {
  202. width: calc(100% - 52rpx);
  203. height: 100%;
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. margin: 340rpx 26rpx 0rpx;
  208. padding-bottom: 60rpx;
  209. }
  210. }
  211. .mt {
  212. margin-top: 0rpx;
  213. }
  214. .mrb {
  215. margin-bottom: 26rpx;
  216. }
  217. </style>