Просмотр исходного кода

库存台账新增导出功能并优化工具栏布局

yusheng 9 месяцев назад
Родитель
Сommit
24ce14faf2

+ 17 - 1
src/api/system/file/index.js

@@ -105,4 +105,20 @@ export async function downLoadTemplateNew(url,fileName) {
   console.log(res.data,'***********');
   console.log(res.data,'***********');
   download(res.data, fileName);
   download(res.data, fileName);
 
 
-}
+}
+
+/**
+ * 导出
+ */
+export async function exportTable(data) {
+  const res = await request.post(
+    data.api,
+    data.data,
+    {
+      responseType: 'blob'
+    }
+  );
+  console.log(res.data, '***********');
+  download(res.data, data.fileName+'.xlsx');
+
+}

+ 41 - 0
src/components/upload/exportButton.vue

@@ -0,0 +1,41 @@
+<template>
+  <el-button
+    type="primary"
+    size="small"
+    icon="el-icon-download"
+    @click="exportFn"
+    >导出</el-button
+  >
+</template>
+
+<script>
+  import { exportTable } from '@/api/system/file/index.js';
+  export default {
+    props: {
+      apiUrl: '',
+      fileName: '',
+      params: {
+        default: () => {
+          return {};
+        }
+      }
+    },
+    //注册组件
+    data() {
+      return {};
+    },
+
+    created() {},
+    methods: {
+      exportFn() {
+        exportTable({
+          api: this.apiUrl,
+          fileName: this.fileName,
+          data:this.params
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss"></style>

+ 18 - 7
src/views/warehouseManagement/stockLedger/components/item-list.vue

@@ -23,7 +23,9 @@
     >
     >
       <!-- 表头工具栏 -->
       <!-- 表头工具栏 -->
       <template v-slot:toolbar="{ row }">
       <template v-slot:toolbar="{ row }">
-        <el-button
+
+        <div class="upload">
+                  <el-button
           v-if="selectedDime == 3"
           v-if="selectedDime == 3"
           size="small"
           size="small"
           :disabled="checkRadioData.length == 0"
           :disabled="checkRadioData.length == 0"
@@ -34,7 +36,6 @@
           打印条码
           打印条码
         </el-button>
         </el-button>
 
 
-        <div class="upload">
           <!-- <el-upload
           <!-- <el-upload
             v-if="!isLoading"
             v-if="!isLoading"
             :show-file-list="false"
             :show-file-list="false"
@@ -54,6 +55,7 @@
               >
               >
             </slot>
             </slot>
           </el-upload> -->
           </el-upload> -->
+        
           <el-button
           <el-button
             type="primary"
             type="primary"
             size="small"
             size="small"
@@ -62,6 +64,12 @@
             @click="uploadFile"
             @click="uploadFile"
             >导入</el-button
             >导入</el-button
           >
           >
+          <exportButton
+            fileName="库存台账"
+            apiUrl="/wms/statement/exportStockExcel"
+            :params="params"
+            v-if="selectedDime == 2"
+          ></exportButton>
         </div>
         </div>
 
 
         <!-- <el-button
         <!-- <el-button
@@ -237,10 +245,11 @@
 
 
   import { qualityStatus, qualityResults } from '@/utils/dict/index';
   import { qualityStatus, qualityResults } from '@/utils/dict/index';
   import { parameterGetByCode } from '@/api/sys/index.js';
   import { parameterGetByCode } from '@/api/sys/index.js';
+  import exportButton from '@/components/upload/exportButton.vue';
 
 
   export default {
   export default {
     mixins: [tabMixins],
     mixins: [tabMixins],
-    components: { ItemSearch, print, allot, importDialog },
+    components: { ItemSearch, print, allot, importDialog, exportButton },
     props: {
     props: {
       // 机构id
       // 机构id
       organizationId: [Number, String],
       organizationId: [Number, String],
@@ -257,6 +266,7 @@
     },
     },
     data() {
     data() {
       return {
       return {
+        params: {},
         moudleName: 'stock',
         moudleName: 'stock',
         qualityStatus,
         qualityStatus,
         qualityResults,
         qualityResults,
@@ -721,11 +731,12 @@
               ...order
               ...order
             };
             };
           }
           }
-          const data = storageApi.getPackingList({
+          this.params = {
             ...params,
             ...params,
             pageNum: page,
             pageNum: page,
             size: limit
             size: limit
-          });
+          };
+          const data = storageApi.getPackingList( this.params);
           return data;
           return data;
         }
         }
       },
       },
@@ -841,8 +852,8 @@
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
   .upload {
   .upload {
-    display: inline-block;
-    width: 100px;
+    display:flex;
+    width: 100%;
     margin-left: 10px;
     margin-left: 10px;
   }
   }
 </style>
 </style>