Forráskód Böngészése

新增 信息导入;更新 下载参数

wzh 3 éve
szülő
commit
85fbf02986

+ 8 - 1
src/main.js

@@ -1,6 +1,7 @@
 import { createApp } from "vue";
 import ElementPlus from "element-plus";
 import "element-plus/dist/index.css";
+import zhCn from "element-plus/es/locale/lang/zh-cn";
 import App from "./App.vue";
 import router from "./router";
 import store from "./store";
@@ -62,4 +63,10 @@ app.directive("auth", {
   },
 });
 
-app.use(router).use(ElementPlus).use(store).mount("#app");
+app
+  .use(router)
+  .use(ElementPlus, {
+    locale: zhCn,
+  })
+  .use(store)
+  .mount("#app");

+ 2 - 2
src/utils/downloadBlobFile.js

@@ -1,5 +1,5 @@
 import axios from "axios";
-function downloadBlobFile(url, data, name, type) {
+function downloadBlobFile(url, data, name, type, fileType) {
   return new Promise((resolve, reject) => {
     axios({
       method: type,
@@ -9,7 +9,7 @@ function downloadBlobFile(url, data, name, type) {
     })
       .then((res) => {
         let blob = new Blob([res.data], {
-          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
+          type: fileType,
         });
         let downloadElement = document.createElement("a");
         let href = window.URL.createObjectURL(blob); // 创建下载的链接

+ 4 - 2
src/views/voyage/voyageDetail.vue

@@ -1198,7 +1198,8 @@ async function downloadExcel() {
     `${url.baseurl}/voyage/exportExcel`,
     { voyageId: route.query.id },
     "船舶跟踪表",
-    "post"
+    "post",
+    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
   );
   if (res) {
     isLoadingExcel.value = false;
@@ -1211,7 +1212,8 @@ async function exportDischargeExcel() {
     `${url.baseurl}/voyage/exportDischargeExcel`,
     { voyageId: route.query.id },
     "卸货记录表",
-    "post"
+    "post",
+    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
   );
   if (res) {
     isDischargeLoadingExcel.value = false;

+ 81 - 8
src/views/voyage/voyageList.vue

@@ -65,14 +65,51 @@
       <!-- <div class="cargo-owner-add" @click="voyageAddDialogVisible = true">
         添加航次
       </div> -->
-      <el-button
-        v-auth="'DOWNLOADFYDI'"
-        type="primary"
-        size="medium"
-        @click="downloadFYDI"
-        >下载FYDI指数</el-button
-      >
+      <div>
+        <el-button
+          type="primary"
+          size="medium"
+          class="mr20"
+          @click="showExportModal('卸货信息')"
+          >导出卸货信息</el-button
+        >
+        <el-button
+          type="primary"
+          size="medium"
+          class="mr20"
+          @click="showExportModal('航次信息')"
+          >导出航次信息</el-button
+        >
+        <el-button
+          v-auth="'DOWNLOADFYDI'"
+          type="primary"
+          size="medium"
+          @click="downloadFYDI"
+          >下载FYDI指数</el-button
+        >
+      </div>
     </div>
+    <el-dialog
+      v-model="exportModalVisable"
+      :title="exportModalTitle"
+      width="200px"
+    >
+      <div class="df aic jcsb">
+        <div class="df aic">
+          <div class="mr20">请选择月份:</div>
+          <el-date-picker
+            v-model="currentMonth"
+            type="month"
+            placeholder="请选择年月"
+            value-format="YYYYMM"
+            :disabled="isLoadingZip"
+          />
+        </div>
+        <el-button type="primary" @click="exportZip" :loading="isLoadingZip"
+          >导出{{ exportModalTitle }}</el-button
+        >
+      </div>
+    </el-dialog>
     <el-dialog v-model="voyageAddDialogVisible" title="添加航次">
       <el-form
         :rules="rules"
@@ -308,6 +345,8 @@ import md5 from "md5";
 import api from "../../apis/fetch";
 import _ from "lodash";
 import { subTimeStr } from "../../utils/utils";
+import downloadBlobFile from "../../utils/downloadBlobFile";
+import url from "../../apis/config";
 
 let currentPage = ref(1);
 let term = ref("");
@@ -621,7 +660,6 @@ function resetAddVoyageForm() {
 }
 
 let sortradio = ref(0);
-let isLoadingExcel = ref(false);
 async function downloadFYDI() {
   let res0 = await api.getFYFIDownloadUrl({
     loginAccountId: localStorage.loginAccountId,
@@ -633,6 +671,41 @@ async function downloadFYDI() {
   a.click();
 }
 
+let exportModalVisable = ref(false);
+let exportModalTitle = ref("");
+let currentMonth = ref("");
+
+function showExportModal(type) {
+  exportModalVisable.value = true;
+  exportModalTitle.value = type;
+}
+
+let isLoadingZip = ref(false);
+
+async function exportZip() {
+  if (!currentMonth.value) return;
+
+  isLoadingZip.value = true;
+  let res = await downloadBlobFile(
+    `${url.baseurl}${
+      exportModalTitle.value == "卸货信息"
+        ? "/voyage/exportMultDischargeExcel"
+        : "/voyage/exportMultExcel"
+    }`,
+    { loginAccountId: localStorage.loginAccountId, date: currentMonth.value },
+    `${exportModalTitle.value}${currentMonth.value}`,
+    "post",
+    "application/zip"
+  );
+  ElNotification({
+    title: "导出成功!",
+    type: "success",
+  });
+  isLoadingZip.value = false;
+  currentMonth.value = "";
+  exportModalVisable.value = false;
+}
+
 onMounted(() => {
   getVoyageList();
 });