Browse Source

工作台、价格目录代码优化

002390 1 năm trước cách đây
mục cha
commit
7c5f6f713e

+ 0 - 4
src/views/purchase/catalogue/columns.js

@@ -196,10 +196,6 @@ export default function useColumns() {
         referName: "CUSTOMER_PARAM",
         valueKey: "name",
         clearable: true,
-        // dataMapping: {
-        //   customer: "id",
-        //   customerName: "name",
-        // },
       }
     },
     {

+ 52 - 81
src/views/purchase/workSpace/index.vue

@@ -48,7 +48,6 @@
       </div>
 
       <el-table
-        v-loading="loading"
         :data="tableList"
         fit
         :cell-style="{ borderColor: '#c0c0c0' }"
@@ -95,23 +94,20 @@
         </el-table-column>
       </el-table>
 
-      <el-pagination
-        background
-        @size-change="handleSizeChange"
-        @current-change="handleCurrentChange"
-        :current-page="queryParams.pageNum"
-        :page-sizes="[10, 20, 50, 100, 200, 500]"
-        :page-size="20"
-        layout="total, sizes, prev, pager, next, jumper"
-        :total="total"
-      >
-      </el-pagination>
+      <pagination
+        :total="page.total"
+        :page.sync="page.pageNum"
+        :limit.sync="page.pageSize"
+        @pagination="getList({ ...page, ...queryParams })"
+        style="height: 32px; padding: 0 !important; flex: 1; overflow-x: auto"
+      />
 
       <el-card class="box-card" style="margin-top: 10px">
         <div slot="header" class="clearfix" style="line-height: 38px">
           <span>单据概述</span>
         </div>
         <el-table
+          v-loading="loading"
           :data="sonTableList"
           fit
           :cell-style="{ borderColor: '#c0c0c0' }"
@@ -160,17 +156,13 @@
           </el-table-column>
         </el-table>
 
-        <el-pagination
-          background
-          @size-change="sonSizeChange"
-          @current-change="sonCurrentChange"
-          :current-page="sonQuery.pageNum"
-          :page-sizes="[10, 20, 50, 100, 200, 500]"
-          :page-size="10"
-          layout="total, sizes, prev, pager, next, jumper"
+        <pagination
           :total="sonTotal"
-        >
-        </el-pagination>
+          :page.sync="sonQuery.pageNum"
+          :limit.sync="sonQuery.pageSize"
+          @pagination="getDetailList(checkRow)"
+          style="height: 32px; padding: 0 !important; flex: 1; overflow-x: auto"
+        />
       </el-card>
     </el-card>
   </div>
@@ -189,12 +181,12 @@ export default {
     ElDictTag: () => import("@/components/DictTag/index.vue"),
   },
   data() {
+    const page = this.$init.page();
     return {
+      page: page,
       queryParams: {
         modelIds: [],
         docSubject: "",
-        pageNum: 1,
-        pageSize: 20,
       },
       loading: false,
       tableList: [],
@@ -216,51 +208,45 @@ export default {
     };
   },
   created() {
-    this.getList(this.queryParams);
+    this.resetList();
   },
   methods: {
-    getList(params) {
-      getWorkSpaceList(params)
-        .then((res) => {
-          if (res.code === 200) {
-            this.tableList = res.rows;
-            this.total = res.total;
-          }
-        })
-        .then(() => {
-          this.loading = false;
-        })
-        .catch((err) => {
-          this.loading = false;
-        });
+    async getList(params) {
+      try {
+        this.$modal.loading("加载中...");
+        let { code, rows, total } = await getWorkSpaceList(params);
+        if (code === 200) {
+          this.tableList = rows;
+          // this.total = res.total;
+          this.page.total = total;
+        }
+      } catch (error) {
+      } finally {
+        this.$modal.closeLoading();
+      }
     },
     searchList() {
-      this.getList(this.queryParams);
+      let { page, queryParams } = this;
+      this.getList({ ...page, ...queryParams });
     },
     resetList() {
       this.queryParams = {
         modelIds: [],
         docSubject: "",
-        pageNum: 1,
-        pageSize: 20,
       };
+      this.page = this.$init.page();
       this.searchList();
     },
     handleSelectionChange(selection) {
-      console.log("选中", selection);
       this.ids = selection;
-      // console.log('选中数组', this.ids.join())
     },
     doubleClick(row) {
-      // this.$refs.tables.toggleRowSelection(row);
       this.rowSelect(row);
     },
     rowSelect(row, column, event) {
-      // console.log('行信息', row)
       // this.recordIndex = this.tableList.findIndex((value, index ,arr) => {
       //   return value.billCode == row.billCode
       // })
-      // console.log('下标:', this.recordIndex)
       // this.check(row)
       // 选择行存储便于子表分页
       this.checkRow = row;
@@ -488,41 +474,26 @@ export default {
           this.sonTableList = [];
         });
     },
-    handleSizeChange(val) {
-      this.queryParams.pageSize = val;
-      this.getList(this.queryParams);
-    },
-    handleCurrentChange(val) {
-      this.queryParams.pageNum = val;
-      this.getList(this.queryParams);
-    },
-    sonSizeChange(val) {
-      this.sonQuery.pageSize = val;
-      this.getDetailList(this.checkRow);
-    },
-    sonCurrentChange(val) {
-      this.sonQuery.pageNum = val;
-      this.getDetailList(this.checkRow);
-    },
+   
     // 获取单据概述列表
-    getDetailList(row) {
-      this.$modal.loading("加载中...");
-      let param = {
-        billCode: row.billCode,
-        type: row.type,
-        ...this.sonQuery,
-      };
-      getWorkDetailList(param)
-        .then((res) => {
-          if (res.code === 200) {
-            this.sonTableList = res.rows;
-            this.sonTotal = res.total;
-            this.$modal.closeLoading();
-          }
-        })
-        .catch((err) => {
-          this.$modal.closeLoading();
-        });
+    async getDetailList(row) {
+      try {
+        this.loading = true;
+        let param = {
+          billCode: row.billCode,
+          type: row.type,
+          ...this.sonQuery,
+        };
+        let { code, rows, total } = await getWorkDetailList(param);
+        if (code === 200) {
+          this.sonTableList = rows;
+          this.sonTotal = total;
+        }
+      } catch (error) {
+      } finally {
+        this.loading = false;
+      }
+      
     },
   },
 };