Procházet zdrojové kódy

新增 卸货记录磅单上传及修改

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

+ 118 - 21
src/views/voyage/voyageDetail.vue

@@ -329,7 +329,7 @@
         margin-bottom: 40px;
       "
     >
-      <el-form :inline="true" :model="formInline" style="margin-bottom: 20px">
+      <el-form :inline="true" :model="formInline">
         <el-form-item label="卸货时间">
           <el-date-picker
             class="info-line-text"
@@ -353,7 +353,17 @@
           </el-button>
         </el-form-item>
       </el-form>
-      <el-table :data="dischagreList" stripe :disabled="disabledStatus">
+      <div class="info-line">
+        <Uploader
+          :actionUrl="this.$store.state.wayBillUrl"
+          :uploaderId="'pound'"
+          :params="poundParams"
+          @onSendFileList="getPoundBillList"
+          :fileList="poundBillList"
+          limit="1"
+        ></Uploader>
+      </div>
+      <el-table :data="dischargeList" stripe :disabled="disabledStatus">
         <el-table-column
           type="index"
           label="序号"
@@ -372,6 +382,32 @@
           min-width="120"
           align="center"
         ></el-table-column>
+        <el-table-column label="磅单" min-width="150" align="center">
+          <template v-slot="scope">
+            <!-- <el-button
+              @click="previewPoundBill(scope.row.viewUrl, scope.$index)"
+              type="danger"
+              size="small"
+            >
+              查看
+            </el-button> -->
+            <el-image
+              v-if="scope.row.viewUrl"
+              style="width: 50px; height: 50px"
+              :src="scope.row.viewUrl"
+              fit="contain"
+              :preview-src-list="previewPoundList"
+            ></el-image>
+            <el-button
+              v-else
+              @click="showUpdateDischarge(scope.row, scope.$index)"
+              type="primary"
+              size="small"
+            >
+              上传
+            </el-button>
+          </template>
+        </el-table-column>
         <el-table-column label="操作" min-width="150" align="center">
           <template v-slot="scope">
             <el-button
@@ -420,6 +456,15 @@
             ></el-input>
           </el-form-item>
         </el-form>
+        <Uploader
+          :actionUrl="this.$store.state.wayBillUrl"
+          isVisiable
+          :uploaderId="'updatePound'"
+          :params="updatePoundParams"
+          @onSendFileList="getupdatePoundBillList"
+          :fileList="updatePoundBillList"
+          limit="1"
+        ></Uploader>
         <template #footer>
           <el-button @click="cancelUpdateDischarge">取消</el-button>
           <el-button
@@ -471,7 +516,7 @@
       </div>
     </div>
   </div>
-  <div class="container-title">磅单列表</div>
+  <!-- <div class="container-title">磅单列表</div>
   <div class="line-container-p24">
     <div class="line" style="margin-bottom: 60px">
       <div class="info-line">
@@ -493,7 +538,7 @@
         </el-upload>
       </div>
     </div>
-  </div>
+  </div> -->
   <div class="container-title">船舶证书</div>
   <div class="line-container-p24">
     <Certs ref="certs"></Certs>
@@ -646,13 +691,6 @@ 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);
         }
@@ -673,12 +711,20 @@ 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 res = await api.addDischarge({
         ...formInline.value,
         voyageId: route.query.id,
       });
       if (res.data.status == 0) {
         getDischargeList(1);
+        poundBillList.value = [];
         formInline.value = {};
       } else {
         console.log(res);
@@ -689,7 +735,7 @@ export default {
         id,
       });
       if (res.data.status == 0) {
-        dischagreList.value.splice(index, 1);
+        dischargeList.value.splice(index, 1);
         ElNotification({
           type: "success",
           title: res.data.msg,
@@ -704,7 +750,7 @@ export default {
     }
     async function exportExcel() {}
     let dischargeCurrentPage = ref(1);
-    let dischagreList = ref([]);
+    let dischargeList = ref([]);
     let formInline = ref({});
     async function getDischargeList(type) {
       let res = await api.getDischargeList({
@@ -713,7 +759,12 @@ export default {
         size: 10,
       });
       if (res.data.status == 0) {
-        dischagreList.value = res.data.result;
+        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);
@@ -723,12 +774,24 @@ export default {
     let updateDischargeDialog = ref(false);
     let currentUpdateIndex = ref(-1);
     async function updateDischarge() {
-      let res = await api.updateDischarge({
+      let postData = {
         ...updateForm.value,
+      };
+      if (updatePoundBillList.value.length) {
+        if (updatePoundBillList.value[0].id) {
+          postData.voyageFileId = updatePoundBillList.value[0].id;
+        } else {
+          postData.voyageFileId =
+            updatePoundBillList.value[0].response.result.id;
+        }
+      } else {
+        postData.voyageFileId = 0;
+      }
+      let res = await api.updateDischarge({
+        ...postData,
       });
-
       if (res.data.status == 0) {
-        dischagreList.value[currentUpdateIndex.value] = res.data.result;
+        getDischargeList();
         cancelUpdateDischarge();
         ElNotification({
           type: "success",
@@ -744,16 +807,24 @@ export default {
     }
     function showUpdateDischarge(item, index) {
       updateDischargeDialog.value = true;
+
+      let { id, dischargeTons, dischargeTime, voyageFileId, viewUrl } = item;
+      if (viewUrl) {
+        updatePoundBillList.value[0] = { id, url: viewUrl };
+      }
+
       updateForm.value = {
-        ...item,
+        id,
+        dischargeTons,
+        dischargeTime,
+        voyageFileId,
       };
-      delete updateForm.value.createTime;
-      delete updateForm.value.voyageId;
       currentUpdateIndex.value = index;
     }
     function cancelUpdateDischarge() {
       updateDischargeDialog.value = false;
       updateForm.value = {};
+      updatePoundBillList.value = [];
       currentUpdateIndex.value = -1;
     }
     let mapId = ref(`map${route.query.id}`);
@@ -1017,6 +1088,11 @@ export default {
           });
         });
     }
+    function getPoundBillList(list) {
+      poundBillList.value = list;
+    }
+    let poundBillList = ref([]);
+
     let poundBill = ref([]);
 
     function poundBillUploadSuccess(response, file, list) {
@@ -1027,6 +1103,20 @@ export default {
       console.log(list);
       poundBill.value = list;
     }
+    function previewPoundBill(url) {
+      console.log(url);
+    }
+
+    let updatePoundParams = ref({
+      voyageId: route.query.id,
+      type: 2,
+    });
+    let updatePoundBillList = ref([]);
+    function getupdatePoundBillList(list) {
+      updatePoundBillList.value = list;
+    }
+
+    let previewPoundList = ref([]);
 
     let poundParams = ref({
       voyageId: route.query.id,
@@ -1117,7 +1207,7 @@ export default {
       deleteDischarge,
       exportExcel,
       dischargeCurrentPage,
-      dischagreList,
+      dischargeList,
       getDischargeList,
       updateDischarge,
       total,
@@ -1141,6 +1231,13 @@ export default {
       calExpectedArrivalTime,
       cancelVoyage,
       mapId,
+      getPoundBillList,
+      poundBillList,
+      previewPoundBill,
+      previewPoundList,
+      updatePoundParams,
+      getupdatePoundBillList,
+      updatePoundBillList,
     };
   },
 };