Browse Source

Merge branch '采购计划导出' into 测试

lxf 1 year ago
parent
commit
b8d551aafe
1 changed files with 35 additions and 0 deletions
  1. 35 0
      src/views/group/oa/exporting-procurement-plan/index.vue

+ 35 - 0
src/views/group/oa/exporting-procurement-plan/index.vue

@@ -0,0 +1,35 @@
+<template>
+  <el-card class="box-card">
+    <div style="padding: 10px 0">上传导出模板进行导出采购计划文件</div>
+    <el-upload :show-file-list="false" action="##" :http-request="giveawayServerLog">
+      <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
+    </el-upload>
+  </el-card>
+</template>
+
+<script setup>
+import { ElMessage } from "element-plus";
+import moment from "moment";
+
+const { proxy } = getCurrentInstance();
+const giveawayServerLog = (params) => {
+  let file = params.file;
+  let formFile = new FormData();
+  formFile.append("file", file);
+  proxy.postUploadAndDownloadFile("/purchase/purchasePlanExportExcel", formFile).then((res) => {
+    if (res.type === "application/json") {
+      const fileReader = new FileReader();
+      fileReader.onloadend = () => {
+        const jsonData = JSON.parse(fileReader.result);
+        ElMessage({ message: jsonData.msg, type: "error" });
+      };
+      fileReader.readAsText(res);
+    } else {
+      ElMessage({ message: "操作成功", type: "success" });
+      proxy.downloadFile(res, "采购计划-" + moment().format("yyyy-MM-DD") + ".xlsx");
+    }
+  });
+};
+</script>
+
+<style lang="scss" scoped></style>