Procházet zdrojové kódy

更新 船东详情

wangzhihui před 4 roky
rodič
revize
fdd581c2b1
1 změnil soubory, kde provedl 114 přidání a 38 odebrání
  1. 114 38
      src/views/shipOwnerManage/shipOwnerDetail.vue

+ 114 - 38
src/views/shipOwnerManage/shipOwnerDetail.vue

@@ -173,26 +173,31 @@
           :on-remove="handleRemoveShip"
           :data="shipParams"
           :on-success="shipUploadSuccess"
-          :file-list="shipfileList"
-          :limit="2"
+          :file-list="shipFileList"
+          :limit="10"
           :disabled="unchangeableShip"
         >
           <i class="el-icon-plus"></i>
         </el-upload>
       </div>
     </div>
+    <div class="df aic jcfe">
+      <el-button v-if="unchangeableShip" type="primary" @click="change(0)">
+        修改
+      </el-button>
+      <el-button v-if="!unchangeableShip" @click="cancelChange(0)">
+        取消
+      </el-button>
+      <el-button
+        v-if="!unchangeableShip"
+        type="primary"
+        @click="submitChange(0)"
+      >
+        提交
+      </el-button>
+    </div>
   </div>
-  <div class="df aic jcfe">
-    <el-button v-if="unchangeableShip" type="primary" @click="change(0)">
-      修改
-    </el-button>
-    <el-button v-if="!unchangeableShip" @click="cancelChange(0)">
-      取消
-    </el-button>
-    <el-button v-if="!unchangeableShip" type="primary" @click="submitChange(0)">
-      提交
-    </el-button>
-  </div>
+
   <el-dialog v-model="dialogVisible" title="图片预览" width="30%">
     <el-image
       :src="dialogImageUrl"
@@ -261,23 +266,26 @@ export default {
           userId,
           userName,
         };
-
-        idFrontFile.value = [
-          {
-            url: idcardFrontViewUrl,
-            idcardFrontDownloadUrl,
-            idcardFrontFileKey,
-            idcardFrontViewUrl,
-          },
-        ];
-        idBackFile.value = [
-          {
-            url: idcardBackViewUrl,
-            idcardBackDownloadUrl,
-            idcardBackFileKey,
-            idcardBackViewUrl,
-          },
-        ];
+        idFrontFile.value = idcardFrontFileKey
+          ? [
+              {
+                url: idcardFrontViewUrl,
+                idcardFrontDownloadUrl,
+                idcardFrontFileKey,
+                idcardFrontViewUrl,
+              },
+            ]
+          : [];
+        idBackFile.value = idcardBackFileKey
+          ? [
+              {
+                url: idcardBackViewUrl,
+                idcardBackDownloadUrl,
+                idcardBackFileKey,
+                idcardBackViewUrl,
+              },
+            ]
+          : [];
 
         shipDetail.value = {
           breadth,
@@ -288,8 +296,14 @@ export default {
           shipId,
           shipname,
           tonnage,
-          shipCerts,
         };
+        shipFileList.value = [];
+        for (let i of shipCerts) {
+          shipFileList.value.push({
+            ...i,
+            url: i.viewUrl,
+          });
+        }
       } else {
         ElNotification({
           type: "error",
@@ -389,15 +403,76 @@ export default {
 
     async function submitChange(type) {
       if (type) {
-        console.log(userDetail.value);
-        console.log(idFrontFile.value);
-        console.log(idBackFile.value);
+        let postData = {
+          ...userDetail.value,
+          idcardFrontDownloadUrl:
+            idFrontFile.value[0]?.response?.result?.downloadUrl ||
+            idFrontFile.value[0]?.idcardFrontDownloadUrl ||
+            "",
+          idcardFrontFileKey:
+            idFrontFile.value[0]?.response?.result?.key ||
+            idFrontFile.value[0]?.idcardFrontFileKey ||
+            "",
+          idcardFrontViewUrl:
+            idFrontFile.value[0]?.response?.result?.viewUrl ||
+            idFrontFile.value[0]?.idcardFrontViewUrl ||
+            "",
+          idcardBackDownloadUrl:
+            idBackFile.value[0]?.response?.result?.downloadUrl ||
+            idBackFile.value[0]?.idcardBackDownloadUrl ||
+            "",
+          idcardBackFileKey:
+            idBackFile.value[0]?.response?.result?.key ||
+            idBackFile.value[0]?.idcardBackFileKey ||
+            "",
+          idcardBackViewUrl:
+            idBackFile.value[0]?.response?.result?.viewUrl ||
+            idBackFile.value[0]?.idcardBackViewUrl ||
+            "",
+        };
+        let res = await api.updateUserDetail(postData);
+        if (res.data.status == 0) {
+          ElNotification({
+            type: "success",
+            title: res.data.msg,
+          });
+          unchangeableShipOwner.value = true;
+        } else {
+          ElNotification({
+            type: "error",
+            title: res.data.msg,
+          });
+          console.log(res);
+        }
       } else {
+        let shipCerts = [];
+        for (let i of shipFileList.value) {
+          shipCerts.push({
+            fileKey: i?.response?.result?.key || i?.fileKey,
+            viewUrl: i?.response?.result?.viewUrl || i?.viewUrl,
+            downloadUrl: i?.response?.result?.downloadUrl || i?.downloadUrl,
+          });
+        }
+        let postData = {
+          ...shipDetail.value,
+          shipCerts,
+        };
+        let res = await api.updateShip(postData);
+        console.log(res);
+        if (res.data.status == 0) {
+          ElNotification({
+            type: "success",
+            title: res.data.msg,
+          });
+          unchangeableShip.value = true;
+        } else {
+          ElNotification({
+            type: "error",
+            title: res.data.msg,
+          });
+          console.log(res);
+        }
       }
-
-      return;
-      let res = await api.updateUserDetail(data);
-      console.log(res);
     }
     onMounted(() => {
       getUserDetail();
@@ -425,6 +500,7 @@ export default {
       router,
       idFrontFile,
       idBackFile,
+      shipFileList,
       // uploadUrl,
     };
   },