Procházet zdrojové kódy

提交产品 物品导出功能

PC-202503171525\Administrator před 1 rokem
rodič
revize
d241af0ecc

+ 12 - 0
src/api/material/list.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request';
+import {download} from "@/utils/file";
 
 // 获取列表
 export async function getGroupPage(data) {
@@ -130,3 +131,14 @@ export async function getQualityTemplate(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+
+// 导出
+export async function exportFile(data) {
+  const res = await request.post(
+    '/main/category/export',data,{
+      responseType: 'blob'
+    }
+  );
+  download(res.data,'产品/物品数据.xlsx')
+}

+ 31 - 3
src/views/material/product/components/index-data.vue

@@ -22,6 +22,7 @@
         </div>
 
         <el-button v-else type="primary" size="small" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
+        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
         <el-button size="small" :disabled="selection.length == 0" icon="el-icon-thumb" class="ele-btn-icon"
           @click="moveTo()">
           设置采购员
@@ -172,7 +173,8 @@
 import {
   getMaterialList,
   removeMaterial,
-  importCategorySparePart
+  importCategorySparePart,
+  exportFile
 } from '@/api/material/list.js';
 
 import { getBomGetById } from '@/api/material/BOM.js';
@@ -281,7 +283,7 @@ export default {
         total: 0
       },
       bomShow: false,
-
+      whereData:{},
       pageShow: false,
 
       // 表格列配置
@@ -566,12 +568,25 @@ export default {
         ...where,
         categoryLevelId: this.currentId
       });
+      this.whereData = {
+        pageNum: page,
+        size: limit,
+        ...this.sort,
+        ...where,
+        categoryLevelId: this.currentId
+      };
       let a = await labs;
 
       return labs;
     },
     /* 刷新表格 */
     reload(where) {
+      let labs = {
+        page: 1,
+        where: where,
+        categoryLevelId: this.currentId
+      }
+      this.whereData = labs;
       this.$refs.table.reload({
         page: 1,
         where: where,
@@ -698,7 +713,20 @@ export default {
 
     uploadFile() {
       this.$refs.importDialogRef.open();
-    }
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+
+      exportFile(this.whereData);
+      console.log(this.whereData, 'whereForm')
+
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+      importTemplate(this.whereForm).then(res => {
+        this.$message.success("模板下载成功");
+      });
+    },
   },
   watch: {
     // 监听物料组id变化