소스 검색

库存查询excel导出

cz 1 년 전
부모
커밋
a3ad420c86

+ 1 - 8
src/views/product/material/index.vue

@@ -10,14 +10,7 @@
                :selectConfig="selectConfig" :table-events="{
           //element talbe事件都能传
           select: select,
-        }" :action-list="[
-          props.selectStatus
-            ? {}
-            : {
-                text: 'Excel导入',
-                action: () => openExcel(),
-                disabled: false,
-              },
+        }" :action-list="[ 
           props.selectStatus
             ? {}
             : {

+ 0 - 5
src/views/product/product/index.vue

@@ -12,11 +12,6 @@
           select: select,
         }" :action-list="[
           {
-            text: 'Excel导入',
-            action: () => openExcel(),
-            disabled: false,
-          },
-          {
             text: '添加产品',
             action: () => openModal('add'),
             disabled: false,

+ 0 - 5
src/views/product/product/index2.vue

@@ -12,11 +12,6 @@
           select: select,
         }" :action-list="[
           {
-            text: 'Excel导入',
-            action: () => openExcel(),
-            disabled: false,
-          },
-          {
             text: '添加产品',
             action: () => openModal('add'),
             disabled: false,

+ 26 - 1
src/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index.vue

@@ -283,8 +283,33 @@ const checkTheFlow = (item) => {
     },
   });
 };
+
 const deriveExcel = () => {
-  console.log("deriveExcel");
+  let queryParams = proxy.deepClone(sourceList.value.pagination);
+  queryParams.pageNum = 1;
+  queryParams.pageSize = 9999;
+  proxy.postTwo("/stock/excelExport", queryParams).then((res) => {
+    exportData(res, "库存查询.xlsx");
+  });
+};
+
+const exportData = (res, name) => {
+  const content = res;
+  const blob = new Blob([content], { type: "application/ms-excel" });
+  const fileName = name;
+  if ("download" in document.createElement("a")) {
+    // 非IE下载
+    const elink = document.createElement("a");
+    elink.download = fileName;
+    elink.style.display = "none";
+    elink.href = URL.createObjectURL(blob);
+    document.body.appendChild(elink);
+    elink.click();
+    URL.revokeObjectURL(elink.href); // 释放URL 对象
+    document.body.removeChild(elink);
+  } else {
+    navigator.msSaveBlob(blob, fileName);
+  }
 };
 // const clickSelect = (item) => {
 //   proxy.$emit("select", item);