Pārlūkot izejas kodu

feat(shipManage): 优化船员信息管理功能

- 为 CrewInfo 组件添加删除船员功能
- 实现船员体检表下载功能
- 优化船员信息展示和修改界面
- 添加 /api 前缀以通过代理进行请求
wzg 11 mēneši atpakaļ
vecāks
revīzija
4148b41634

+ 22 - 2
src/components/CrewInfo.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <el-button type="primary" @click="handleClick">
+    <el-button type="primary" @click="handleClick" :text="isText">
       {{ btnText }}
     </el-button>
     <el-dialog
@@ -121,9 +121,17 @@
             v-if="crewForm.crewExamRecViewUrl"
             type="primary"
             class="mr20"
+            @click="
+              downloadBlobFile(
+                crewForm.crewExamRecViewUrl,
+                {},
+                crewForm.crewName + '健康检查表'
+              )
+            "
           >
             下载船员体检表
           </el-button>
+          <div v-else>暂无</div>
           <el-upload
             v-if="!disabled"
             :action="store.state.baseurl + '/ship/crew/uploadCert'"
@@ -150,13 +158,15 @@
 import { ref } from "vue";
 import store from "@/store";
 import api from "../apis/fetch";
+import downloadBlobFile from "utils/downloadBlobFile";
 const props = defineProps({
   btnText: {
     type: String,
     default: "新增船员",
   },
+
   crewId: {
-    type: String,
+    type: [String, Number],
     default: "",
   },
   shipCode: {
@@ -175,6 +185,10 @@ const props = defineProps({
     type: Boolean,
     default: false,
   },
+  isText: {
+    type: Boolean,
+    default: false,
+  },
 });
 const emit = defineEmits(["onSubmit"]);
 const dialogVisible = ref(false);
@@ -262,7 +276,13 @@ const handleSubmit = () => {
         shipCode: props.shipCode,
         shipCrewId: props.crewId,
       });
+
       if (data.status === 0) {
+        ElNotification.success({
+          title: "成功",
+          duration: 2000,
+          message: data.msg,
+        });
         emit("onSubmit");
         dialogVisible.value = false;
       } else {

+ 7 - 3
src/utils/downloadBlobFile.js

@@ -1,9 +1,10 @@
 import axios from "axios";
-function downloadBlobFile(url, data, name, type) {
+
+function downloadBlobFile(url, data, name, type = "post") {
   return new Promise((resolve, reject) => {
     axios({
-      method: type,
-      url,
+      method: "get",
+      url: `/api${url}`, // 添加 /api 前缀以通过代理进行请求
       responseType: "blob",
       data,
     })
@@ -24,10 +25,13 @@ function downloadBlobFile(url, data, name, type) {
         });
       })
       .catch((e) => {
+        console.error("下载文件失败", e);
         reject({
           status: 1,
+          message: "下载文件失败",
         });
       });
   });
 }
+
 export default downloadBlobFile;

+ 33 - 1
src/views/shipManage/shipDetail.vue

@@ -57,7 +57,7 @@
             btnText="修改"
             @onSubmit="getCrewList"
           ></CrewInfo>
-          <el-button type="danger" @click="deleteCrew(scope.row)">
+          <el-button type="danger" @click="deleteCrew(scope.row.id)">
             删除
           </el-button>
         </div>
@@ -318,6 +318,38 @@ async function auditAbnormalShip(mediaId) {
     });
   }
 }
+
+async function deleteCrew(shipCrewId) {
+  ElMessageBox.confirm("是否删除该船员信息?", "提示", {
+    confirmButtonText: "确定",
+    cancelButtonText: "取消",
+    type: "warning",
+  })
+    .then(async () => {
+      let { data } = await api.deleteCrew({
+        shipCrewId,
+        shipCode: route.query.shipCode,
+      });
+      if (data.status === 0) {
+        ElMessage({
+          message: data.msg,
+          type: "success",
+        });
+        getCrewList();
+      } else {
+        ElMessage({
+          message: data.msg,
+          type: "error",
+        });
+      }
+    })
+    .catch(() => {
+      ElMessage({
+        type: "info",
+        message: "已取消删除",
+      });
+    });
+}
 onMounted(() => {
   getShipDetail(route.query.shipCode);
 });

+ 12 - 0
src/views/workStation/certsManage.vue

@@ -102,7 +102,19 @@
           </el-table-column>
           <el-table-column align="center" label="详情" min-width="120">
             <template #default="scope">
+              <CrewInfo
+                v-if="certType == 6"
+                class="mr10"
+                :shipCode="route.query.shipCode"
+                :shipname="scope.row.shipname"
+                :crewId="scope.row.id"
+                :crewInfo="scope.row"
+                btnText="查看"
+                :isText="true"
+                disabled
+              ></CrewInfo>
               <el-button
+                v-else
                 type="primary"
                 text
                 @click="

+ 8 - 0
vite.config.js

@@ -38,5 +38,13 @@ export default defineConfig({
   },
   server: {
     port: 22222,
+    proxy: {
+      "/api": {
+        target:
+          "https://hhd-shipping-formal-1255802371.cos.ap-shanghai.myqcloud.com/", // 替换为你的后端域名
+        changeOrigin: true,
+        rewrite: (path) => path.replace(/^\/api/, ""),
+      },
+    },
   },
 });