浏览代码

refactor(toolManage): 重构船舶认证配置功能

- 优化图片上传逻辑,使用箭头函数传递额外参数
- 简化更新介绍内容的函数调用,直接传递整个对象
- 移除多余的 console.log 语句
- 优化上传成功后的处理逻辑,更新状态并显示通知
wzg 10 月之前
父节点
当前提交
3c7d41e6cb
共有 1 个文件被更改,包括 17 次插入27 次删除
  1. 17 27
      src/views/toolManage/shipOwnerWeappConfig.vue

+ 17 - 27
src/views/toolManage/shipOwnerWeappConfig.vue

@@ -24,7 +24,9 @@
             "
             :show-file-list="false"
             :data="{ configType: 1 }"
-            :on-success="uploadCertSuccess"
+            :on-success="
+              (res) => uploadCertSuccess(res, certOperationIntroduce)
+            "
           >
             <el-button type="primary">
               {{ certOperationIntroduce.imageUrl ? "重新" : "" }}上传图片
@@ -43,12 +45,7 @@
           <div class="df jcfe">
             <el-button
               type="primary"
-              @click="
-                updateShipIntroduceContent(
-                  1,
-                  certOperationIntroduce.textContent
-                )
-              "
+              @click="updateShipIntroduceContent(1, certOperationIntroduce)"
             >
               更新证书办理服务介绍
             </el-button>
@@ -87,7 +84,7 @@
             "
             :show-file-list="false"
             :data="{ configType: 2 }"
-            :on-success="uploadCertSuccess"
+            :on-success="(res) => uploadCertSuccess(res, legalAidIntroduce)"
           >
             <el-button type="primary">
               {{ legalAidIntroduce.imageUrl ? "重新" : "" }}上传图片
@@ -106,12 +103,7 @@
           <div class="df jcfe">
             <el-button
               type="primary"
-              @click="
-                updateShipIntroduceContent(
-                  2,
-                  certOperationIntroduce.textContent
-                )
-              "
+              @click="updateShipIntroduceContent(2, legalAidIntroduce)"
             >
               更新法律援助服务介绍
             </el-button>
@@ -143,7 +135,7 @@
             "
             :show-file-list="false"
             :data="{ configType: 3 }"
-            :on-success="uploadCertSuccess"
+            :on-success="(res) => uploadCertSuccess(res, lawyerIntroduce)"
           >
             <el-button type="primary">
               {{ lawyerIntroduce.imageUrl ? "重新" : "" }}上传图片
@@ -163,12 +155,7 @@
           <div class="df jcfe">
             <el-button
               type="primary"
-              @click="
-                updateShipIntroduceContent(
-                  3,
-                  certOperationIntroduce.textContent
-                )
-              "
+              @click="updateShipIntroduceContent(3, lawyerIntroduce)"
             >
               更新律师/团队介绍
             </el-button>
@@ -193,7 +180,6 @@ const shipCertOperationList = ref([]);
 
 async function getShipIntroduceInfo() {
   let { data } = await api.getShipIntroduceInfo();
-  console.log(data.result);
   if (data.status === 0) {
     certOperationIntroduce.value = data.result.certOperationIntroduce;
     lawyerIntroduce.value = data.result.lawyerIntroduce;
@@ -210,8 +196,6 @@ async function getShipCertOperationList() {
     currentPage: 1,
     size: 100,
   });
-  console.log(data.result);
-
   if (data.status === 0) {
     shipCertOperationList.value = data.result;
   } else {
@@ -219,8 +203,14 @@ async function getShipCertOperationList() {
   }
 }
 
-function uploadCertSuccess(res) {
+function uploadCertSuccess(res, target) {
+  console.log(res, target);
   if (res.status === 0) {
+    target.imageUrl = res.result;
+    ElNotification.success({
+      title: "成功",
+      message: res.msg,
+    });
   } else {
     ElNotification.error({
       title: "失败",
@@ -230,10 +220,10 @@ function uploadCertSuccess(res) {
 }
 function deleteShipCertOperation() {}
 function modifyShipCertOperation() {}
-async function updateShipIntroduceContent(configType, textContent) {
+async function updateShipIntroduceContent(configType, target) {
   let { data } = await api.updateShipIntroduceContent({
     configType,
-    textContent,
+    textContent: target.textContent,
   });
   if (data.status === 0) {
     ElNotification.success({