浏览代码

修改商品分页查询

YY 2 年之前
父节点
当前提交
5b013301d9
共有 2 个文件被更改,包括 28 次插入10 次删除
  1. 14 5
      src/views/platmanag/goods/index.vue
  2. 14 5
      src/views/selfShop/goods/index.vue

+ 14 - 5
src/views/platmanag/goods/index.vue

@@ -11,7 +11,7 @@
         >
           <search-1
             :form="searchInfo"
-            @onSubmit="search"
+            @onSubmit="toSearch"
             @querySearch="querySearch"
             @toReset="toClose"
             @changeTags="changeTags"
@@ -180,11 +180,14 @@ export default {
       statusList: [],
       // 返现金额类型
       typeList: [{ label: '固定金额' }, { label: '百分比' }],
+      searchQuery: {},
     };
   },
   created() {
     this.searchOthers();
-    this.search();
+    let route = JSON.parse(sessionStorage.getItem(this.$route.path));
+    if (route) this.search(route);
+    else this.search();
   },
   methods: {
     ...dictData({ getDict: 'query' }),
@@ -193,6 +196,11 @@ export default {
     ...shop({ shopQuery: 'query', shopFetch: 'fetch' }),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
     ...methodsUtil,
+    toSearch() {
+      // this.$refs.dataTable.resetPage();
+      const res = this.$refs.dataTable.getPageConfig();
+      this.search(res);
+    },
     // 查询
     async search({ skip = 0, limit = this.$limit, ...others } = {}) {
       let query = { skip, limit, ...others };
@@ -201,6 +209,7 @@ export default {
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
+        this.$set(this, `searchQuery`, query);
       }
       this.loadings = false;
     },
@@ -265,7 +274,6 @@ export default {
         if (this.$checkRes(res)) {
           this.$message({ type: `success`, message: `复制成功` });
           this.toBack();
-          this.search();
         }
       });
     },
@@ -335,13 +343,13 @@ export default {
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
         this.toBack();
-        this.search();
       }
     },
     // 执行返回
     toBack() {
       this.form = {};
       this.view = 'list';
+      this.search(this.searchQuery);
     },
     // 上架
     async toPuton({ data }) {
@@ -355,11 +363,12 @@ export default {
         let res;
         if (data._id) res = await this.update(data);
         if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
-        this.search();
+        this.search(this.searchQuery);
       });
     },
     // 库存管理
     toSpec({ data }) {
+      sessionStorage.setItem(this.$route.path, JSON.stringify(this.searchQuery));
       this.$router.push({ path: `/platmanag/spec/${data._id}` });
     },
   },

+ 14 - 5
src/views/selfShop/goods/index.vue

@@ -105,6 +105,7 @@ const { mapActions: goods } = createNamespacedHelpers('goods');
 const { mapActions: goodsTags } = createNamespacedHelpers('goodsTags');
 const { mapActions: dictData } = createNamespacedHelpers('dictData');
 const { mapActions: actTags } = createNamespacedHelpers('actTags');
+
 export default {
   name: 'index',
   props: {},
@@ -172,22 +173,28 @@ export default {
       statusList: [],
       // 返现金额类型
       typeList: [{ label: '固定金额' }, { label: '百分比' }],
+      // 查询条件
+      searchQuery: {},
     };
   },
   created() {
     this.searchOthers();
-    this.search();
+    let route = JSON.parse(sessionStorage.getItem(this.$route.path));
+    if (route) this.search(route);
+    else this.search();
   },
+
   methods: {
     ...dictData({ getDict: 'query' }),
     ...actTags({ actQuery: 'query' }),
     ...goodsTags(['tree']),
     ...goods(['copy', 'query', 'delete', 'fetch', 'update', 'create']),
     ...methodsUtil,
+
     toSearch() {
       // this.$refs.dataTable.resetPage();
       const res = this.$refs.dataTable.getPageConfig();
-      console.log(res);
+      this.search(res);
     },
     // 查询
     async search({ skip = 0, limit = this.$limit, ...others } = {}) {
@@ -197,6 +204,8 @@ export default {
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
+        this.$set(this, `searchQuery`, query);
+        sessionStorage.removeItem(this.$route.path);
       }
       this.loadings = false;
     },
@@ -231,7 +240,6 @@ export default {
         if (this.$checkRes(res)) {
           this.$message({ type: `success`, message: `复制成功` });
           this.toBack();
-          this.search();
         }
       });
     },
@@ -253,13 +261,13 @@ export default {
       if (this.$checkRes(res)) {
         this.$message({ type: `success`, message: `维护信息成功` });
         this.toBack();
-        this.search();
       }
     },
     // 执行返回
     toBack() {
       this.form = {};
       this.view = 'list';
+      this.search(this.searchQuery);
     },
     // 上架
     async toPuton({ data }) {
@@ -273,11 +281,12 @@ export default {
         let res;
         if (data._id) res = await this.update(data);
         if (this.$checkRes(res)) this.$message({ type: `success`, message: `修改成功` });
-        this.search();
+        this.search(this.searchQuery);
       });
     },
     // 库存管理
     toSpec({ data }) {
+      sessionStorage.setItem(this.$route.path, JSON.stringify(this.searchQuery));
       this.$router.push({ path: `/selfShop/spec/${data._id}` });
     },
     // 查询其他信息