Przeglądaj źródła

新增 上传磅单

wangzhihui 4 lat temu
rodzic
commit
a575cf432d
1 zmienionych plików z 79 dodań i 0 usunięć
  1. 79 0
      src/views/voyage/voyageDetail.vue

+ 79 - 0
src/views/voyage/voyageDetail.vue

@@ -481,6 +481,29 @@
       </div>
     </div>
   </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="https://interface.huihenduo.com.cn/hhd-pat/voyage/uploadVoyageWayBill"
+          list-type="picture-card"
+          :on-preview="handlePictureCardPreview"
+          :on-remove="handleRemovePoundBill"
+          :data="poundParams"
+          :on-success="poundBillUploadSuccess"
+          :file-list="poundBill"
+          :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 v-if="medias.length" class="medias-content df ffw">
@@ -621,6 +644,13 @@ export default {
             url: i.viewUrl,
           });
         }
+
+        for (let i of res.data.result.poundBills) {
+          poundBill.value.push({
+            ...i,
+            url: i.viewUrl,
+          });
+        }
         for (let i of medias.value) {
           previewSrcList.value.push(i.downloadUrl);
         }
@@ -927,8 +957,53 @@ export default {
 
     let billParams = ref({
       voyageId: route.query.id,
+      type: 1,
     });
 
+    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: "取消删除",
+          });
+        });
+    }
+    let poundBill = ref([]);
+
+    function poundBillUploadSuccess(response, file, list) {
+      list[list.length - 1] = {
+        ...response.result,
+        url: response.result.viewUrl,
+      };
+      console.log(list);
+      poundBill.value = list;
+    }
+
+    let poundParams = ref({
+      voyageId: route.query.id,
+      type: 2,
+    });
     async function calExpectedArrivalTime() {
       let res = await api.calExpectedArrivalTime({
         voyageId: route.query.id,
@@ -997,6 +1072,10 @@ export default {
       voyageBill,
       billUploadSuccess,
       billParams,
+      handleRemovePoundBill,
+      poundBill,
+      poundBillUploadSuccess,
+      poundParams,
       calExpectedArrivalTime,
     };
   },