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

更新 新增船舶

王智慧 3 éve
szülő
commit
6743ed1ec6
1 módosított fájl, 24 hozzáadás és 20 törlés
  1. 24 20
      src/components/ShipInfo.vue

+ 24 - 20
src/components/ShipInfo.vue

@@ -181,7 +181,7 @@
           :disabled="disabled"
           :fileList="item.certs"
           @onUploadFileList="uploadSuccess($event, index)"
-          @onRemoveFileList="removeCert($event, index)"
+          @onRemoveFileList="removeSuccess($event, index)"
         ></Uploader>
       </div>
       <div
@@ -231,26 +231,20 @@ let addParams = ref({
   loginAccountId: localStorage.loginAccountId,
 });
 
-function uploadSuccess(list, index) {
-  console.log(list);
-  if (list.length) {
-    let { url, response } = list[0];
-    if (response) {
-      let { downloadUrl, viewUrl, key: fileKey } = response.result;
-      props.shipInfos[currentIndex.value].shipCerts[index].certs.push({
-        url,
-        downloadUrl,
-        viewUrl,
-        fileKey,
-      });
-    } else {
-      props.shipInfos[currentIndex.value].shipCerts[index].certs = list;
-    }
-  } else {
-    props.shipInfos[currentIndex.value].shipCerts[index].certs = [];
+// function uploadSuccess(list, index) {
+function uploadSuccess({ response, file, list }, index) {
+  if (response.status == 0) {
+    let { key, fileKey, viewUrl, downloadUrl, id } = response.result;
+    props.shipInfos[currentIndex.value].shipCerts[index].certs.push({
+      fileKey: fileKey || key,
+      viewUrl,
+      downloadUrl,
+      id,
+      url: viewUrl,
+    });
   }
 }
-async function removeCert({ file, list }, index) {
+async function removeSuccess({ file, list }, index) {
   if (props.shipInfos[currentIndex.value].code) {
     let { data } = await api.deleteShipCert({ shipCertId: file.id });
     if (data.status == 0) {
@@ -259,6 +253,17 @@ async function removeCert({ file, list }, index) {
         type: "success",
       });
     }
+  } else {
+    let dataList = [];
+    for (let i of list) {
+      dataList.push({
+        fileKey: i.response.result.key,
+        downloadUrl: i.response.result.downloadUrl,
+        viewUrl: i.response.result.viewUrl,
+        url: i.response.result.viewUrl,
+      });
+    }
+    props.shipInfos[currentIndex.value].shipCerts[index].certs = dataList;
   }
 }
 
@@ -368,7 +373,6 @@ function cancelAdd() {
 }
 
 async function submit() {
-  console.log(props.shipInfos[currentIndex.value]);
   let res = await api.addShip({
     ...props.shipInfos[currentIndex.value],
     shipOwnerId: props.shipOwnerId,