Ver Fonte

新增 保险单上传

wzh há 4 anos atrás
pai
commit
fd84f944b6
1 ficheiros alterados com 108 adições e 1 exclusões
  1. 108 1
      src/views/voyage/voyageDetail.vue

+ 108 - 1
src/views/voyage/voyageDetail.vue

@@ -502,6 +502,29 @@
       </div>
     </el-card>
   </div>
+  <div class="container-title">保险单列表</div>
+  <div class="line-container-p24">
+    <div class="line" style="margin-bottom: 60px">
+      <div class="info-line">
+        <div class="info-line-title">上传保险单</div>
+        <el-upload
+          drag
+          multiple
+          :action="this.$store.state.wayBillUrl"
+          list-type="picture-card"
+          :on-preview="handlePictureCardPreview"
+          :on-remove="handleRemovePolicy"
+          :data="policyParams"
+          :on-success="policyUploadSuccess"
+          :file-list="policyFileList"
+          :limit="10"
+        >
+          <div class="upload-plus-icon">+</div>
+          <div class="upload-text">拖拽或点击上传</div>
+        </el-upload>
+      </div>
+    </div>
+  </div>
   <div class="container-title">运单列表</div>
   <div class="line-container-p24">
     <div class="line" style="margin-bottom: 60px">
@@ -694,7 +717,12 @@ export default {
         voyage.value = res.data.result.voyage;
         medias.value = res.data.result.medias;
         certs.value.initCerts(res.data.result.shipAudits);
-
+        for (let i of res.data.result.policys) {
+          policyFileList.value.push({
+            ...i,
+            url: i.viewUrl,
+          });
+        }
         for (let i of res.data.result.waybills) {
           voyageBill.value.push({
             ...i,
@@ -1024,6 +1052,81 @@ export default {
       dialogImageUrl.value = file.url;
     }
 
+    async function handleRemovePolicy(file, list) {
+      let cache = _.cloneDeep(policyFileList.value);
+      console.log(cache);
+      ElMessageBox.confirm("确认删除保险单?", "Warning", {
+        confirmButtonText: "删除",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          let { id } = file;
+          let res = await api.deleteWaybill({
+            id,
+          });
+          if (res.data.status == 0) {
+            ElMessage({
+              message: "删除成功!",
+              type: "success",
+            });
+            policyFileList.value = list;
+          }
+        })
+        .catch(() => {
+          policyFileList.value = cache;
+          ElMessage({
+            type: "info",
+            message: "取消删除",
+          });
+        });
+    }
+    let policyFileList = ref([]);
+
+    function policyUploadSuccess(response, file, list) {
+      list[list.length - 1] = {
+        ...response.result,
+        url: response.result.viewUrl,
+      };
+      console.log(list);
+      policyFileList.value = list;
+    }
+
+    let policyParams = ref({
+      voyageId: route.query.id,
+      type: 3,
+    });
+
+    async function handleRemovePoundBill(file, list) {
+      let cache = _.cloneDeep(poundBill.value);
+      console.log(cache);
+      ElMessageBox.confirm("确认删除磅单?", "Warning", {
+        confirmButtonText: "删除",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          let { id } = file;
+          let res = await api.deleteWaybill({
+            id,
+          });
+          if (res.data.status == 0) {
+            ElMessage({
+              message: "删除成功!",
+              type: "success",
+            });
+            poundBill.value = list;
+          }
+        })
+        .catch(() => {
+          poundBill.value = cache;
+          ElMessage({
+            type: "info",
+            message: "取消删除",
+          });
+        });
+    }
+
     async function handleRemoveBill(file, list) {
       let cache = _.cloneDeep(voyageBill.value);
       console.log(cache);
@@ -1265,6 +1368,10 @@ export default {
       getupdatePoundBillList,
       updatePoundBillList,
       exportDischargeExcel,
+      handleRemovePolicy,
+      policyParams,
+      policyUploadSuccess,
+      policyFileList,
     };
   },
 };