소스 검색

feat(ship): 添加船员和船舶认证功能

- 在 fetch.js 中新增认证船员和船舶的 API 接口
- 在 ShipInfo.vue 和 shipOwnerDetail.vue 中添加认证状态展示和认证按钮
- 实现船员和船舶认证的逻辑,包括弹窗确认、API 调用和结果处理
wzg 7 달 전
부모
커밋
becc4b4644
3개의 변경된 파일89개의 추가작업 그리고 8개의 파일을 삭제
  1. 8 0
      src/apis/fetch.js
  2. 39 0
      src/components/ShipInfo.vue
  3. 42 8
      src/views/shipOwnerManage/shipOwnerDetail.vue

+ 8 - 0
src/apis/fetch.js

@@ -460,4 +460,12 @@ export default {
   getShipOwnerCertTypeSelect() {
     return $http("/shipOwner/cert/post/select");
   },
+
+  // 认证船员
+  authShipOwner(data) {
+    return $http("/shipOwner/hhd/auth", data);
+  },
+  authShip(data) {
+    return $http("/ship/hhd/auth", data);
+  },
 };

+ 39 - 0
src/components/ShipInfo.vue

@@ -68,6 +68,25 @@
       </div>
     </div>
     <div class="line-container-p24">
+      <div class="line">
+        <div class="info-line">
+          <div class="info-line-title">认证状态</div>
+          <el-tag
+            v-if="shipInfos[currentIndex].hhdAuthStatus === 1"
+            type="success"
+            size="large"
+          >
+            已认证
+          </el-tag>
+          <el-button
+            v-if="shipInfos[currentIndex].hhdAuthStatus === 0"
+            type="primary"
+            @click="authShip()"
+          >
+            船员认证
+          </el-button>
+        </div>
+      </div>
       <div class="line">
         <div class="info-line">
           <div class="info-line-title">
@@ -329,6 +348,7 @@ import _ from "lodash";
 import store from "../store";
 import { useRoute } from "vue-router";
 import router from "../router";
+import { confirm } from "../utils/utils";
 const route = useRoute();
 const props = defineProps({
   certsId: {
@@ -584,6 +604,25 @@ async function getProvinceSelect() {
     provinceOptions.value = [];
   }
 }
+
+async function authShip() {
+  if (!(await confirm("确认认证船舶?"))) return;
+  let { data } = await api.authShip({
+    shipCode: route.query.shipCode,
+  });
+  if (data.status === 0) {
+    ElMessage({
+      type: "success",
+      message: data.msg,
+    });
+    props.shipInfos[currentIndex.value].hhdAuthStatus = 1;
+  } else {
+    ElMessage({
+      type: "error",
+      message: data.msg,
+    });
+  }
+}
 defineExpose({
   initCerts,
   getShipCerts,

+ 42 - 8
src/views/shipOwnerManage/shipOwnerDetail.vue

@@ -29,25 +29,39 @@
             ></el-input>
           </el-form-item>
         </el-col>
+        <el-col :span="8" v-if="route.query.shipOwnerId">
+          <el-form-item label="认证状态" prop="userPhone">
+            <el-tag v-if="hhdAuthStatus === 1" type="success" size="large">
+              已认证
+            </el-tag>
+            <el-button
+              v-if="hhdAuthStatus === 0"
+              type="primary"
+              @click="authShipOwner()"
+            >
+              船员认证
+            </el-button>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row :gutter="20">
         <el-col :span="8">
-          <el-form-item label="船员手机号" prop="userPhone">
+          <el-form-item label="船员身份证号">
             <el-input
-              v-model="shipOwnerForm.userPhone"
+              v-model="shipOwnerForm.idcardNo"
               placeholder="请输入"
               :disabled="!!shipOwnerForm.shipOwnerId && !isEditingBasicInfo"
-              @blur="handlePhoneBlur"
               class="w200"
             ></el-input>
           </el-form-item>
         </el-col>
-      </el-row>
-      <el-row :gutter="20">
         <el-col :span="8">
-          <el-form-item label="船员身份证号">
+          <el-form-item label="船员手机号" prop="userPhone">
             <el-input
-              v-model="shipOwnerForm.idcardNo"
+              v-model="shipOwnerForm.userPhone"
               placeholder="请输入"
               :disabled="!!shipOwnerForm.shipOwnerId && !isEditingBasicInfo"
+              @blur="handlePhoneBlur"
               class="w200"
             ></el-input>
           </el-form-item>
@@ -846,7 +860,7 @@ function handlePostChange(value) {
     postOptions.value.find((item) => item.key === value)?.value || "";
   shipOwnerForm.value.certificate.postRole = postText;
 }
-
+const hhdAuthStatus = ref(0);
 async function getShipOwnerDetail(shipOwnerId) {
   let { data } = await api.getShipOwnerDetail({
     shipOwnerId,
@@ -854,6 +868,7 @@ async function getShipOwnerDetail(shipOwnerId) {
 
   if (data.status === 0 && data.result) {
     // 处理基本信息
+    hhdAuthStatus.value = data.result.hhdAuthStatus || 0;
     shipOwnerForm.value = {
       shipOwnerId: data.result.id,
       userName: data.result.userName,
@@ -1496,6 +1511,25 @@ async function shipDetail(shipCode) {
   });
 }
 
+async function authShipOwner() {
+  if (!(await confirm("确定认证船员吗?"))) return;
+  let { data } = await api.authShipOwner({
+    shipOwnerId: router.query.shipOwnerId,
+  });
+  if (data.status == 0) {
+    ElMessage({
+      type: "success",
+      message: data.msg,
+    });
+    getShipOwnerDetail(route.query.shipOwnerId);
+  } else {
+    ElMessage({
+      type: "error",
+      message: data.msg,
+    });
+  }
+}
+
 // 初始化数据
 onMounted(async () => {
   // 获取证书类型数据