Procházet zdrojové kódy

更新 磅单上传交互

wzh před 4 roky
rodič
revize
566e5b2a77
1 změnil soubory, kde provedl 28 přidání a 32 odebrání
  1. 28 32
      src/views/voyage/voyageDetail.vue

+ 28 - 32
src/views/voyage/voyageDetail.vue

@@ -398,7 +398,7 @@
               type="primary"
               size="small"
             >
-              {{ scope.row.viewUrl ? "查看" : "上传" }}
+              {{ scope.row.files ? "查看" : "上传" }}
             </el-button>
           </template>
         </el-table-column>
@@ -685,18 +685,16 @@ export default {
     let coordinates = ref([]);
     let previewSrcList = ref([]);
 
-    async function getVoyageDetail(type) {
+    async function getVoyageDetail() {
       let res = await api.getVoyageDetail({
         type: localStorage.userType,
         voyageId: route.query.id,
       });
       if (res.data.status == 0) {
-        if (type) {
-          ElNotification({
-            type: "success",
-            title: res.data.msg,
-          });
-        }
+        ElNotification({
+          type: "success",
+          title: res.data.msg,
+        });
 
         coordinates.value = res.data.result.coordinates;
         voyage.value = res.data.result.voyage;
@@ -734,15 +732,16 @@ export default {
     async function addDischarge() {
       if (!formInline.value.dischargeTime || !formInline.value.dischargeTons)
         return;
-      if (
-        poundBillList.value.length &&
-        poundBillList.value[0].response.result.id
-      ) {
-        formInline.value.voyageFileId =
-          poundBillList.value[0].response.result.id;
+      let arr = [];
+
+      if (poundBillList.value.length) {
+        for (let i of poundBillList.value) {
+          arr.push(i.response.result.id);
+        }
       }
       let res = await api.addDischarge({
         ...formInline.value,
+        voyageFileIds: arr.join(","),
         voyageId: route.query.id,
       });
       if (res.data.status == 0) {
@@ -775,7 +774,7 @@ export default {
     let dischargeCurrentPage = ref(1);
     let dischargeList = ref([]);
     let formInline = ref({});
-    async function getDischargeList(type) {
+    async function getDischargeList() {
       let res = await api.getDischargeList({
         voyageId: route.query.id,
         currentPage: dischargeCurrentPage.value,
@@ -783,11 +782,6 @@ export default {
       });
       if (res.data.status == 0) {
         dischargeList.value = res.data.result;
-        for (let i of dischargeList.value) {
-          if (i.viewUrl) {
-            previewPoundList.value.push(i.viewUrl);
-          }
-        }
         total.value = res.data.total;
       } else {
         console.log(res);
@@ -800,15 +794,14 @@ export default {
       let postData = {
         ...updateForm.value,
       };
+      let arr = [];
       if (updatePoundBillList.value.length) {
-        if (updatePoundBillList.value[0].id) {
-          postData.voyageFileId = updatePoundBillList.value[0].id;
-        } else {
-          postData.voyageFileId =
-            updatePoundBillList.value[0].response.result.id;
+        for (let i of updatePoundBillList.value) {
+          arr.push(i.id || i.response.result.id);
         }
+        postData.voyageFileIds = arr.join(",");
       } else {
-        postData.voyageFileId = 0;
+        postData.voyageFileIds = "";
       }
       let res = await api.updateDischarge({
         ...postData,
@@ -830,17 +823,18 @@ export default {
     }
     function showUpdateDischarge(item, index) {
       updateDischargeDialog.value = true;
+      updatePoundBillList.value = [];
 
-      let { id, dischargeTons, dischargeTime, voyageFileId, viewUrl } = item;
-      if (viewUrl) {
-        updatePoundBillList.value[0] = { id, url: viewUrl };
+      let { id, dischargeTons, dischargeTime, voyageId, files } = item;
+      if (files && files.length) {
+        for (let i of files)
+          updatePoundBillList.value.push({ id: i.id, url: i.viewUrl });
       }
 
       updateForm.value = {
         id,
         dischargeTons,
         dischargeTime,
-        voyageFileId,
       };
       currentUpdateIndex.value = index;
     }
@@ -1187,6 +1181,7 @@ export default {
         });
     }
     function getPoundBillList(list) {
+      console.log(list);
       poundBillList.value = list;
     }
     let poundBillList = ref([]);
@@ -1211,6 +1206,7 @@ export default {
     });
     let updatePoundBillList = ref([]);
     function getupdatePoundBillList(list) {
+      console.log(list);
       updatePoundBillList.value = list;
     }
 
@@ -1290,8 +1286,8 @@ export default {
     }
 
     onMounted(() => {
-      getVoyageDetail(1);
-      getDischargeList(1);
+      getVoyageDetail();
+      getDischargeList();
     });
     return {
       certs,