Browse Source

单证管理

lxf 2 years ago
parent
commit
8eda610838
1 changed files with 184 additions and 15 deletions
  1. 184 15
      src/views/salesMange/shipmentMange/document/index.vue

+ 184 - 15
src/views/salesMange/shipmentMange/document/index.vue

@@ -14,6 +14,14 @@
           },
         ]"
         @get-list="getList">
+        <template #acceptCode="{ item }">
+          <div>
+            <div v-if="item.acceptCode">{{ item.acceptCode }}</div>
+            <div v-else>
+              <el-button @click="clickAddAcceptCode(item)" type="warning">填写</el-button>
+            </div>
+          </div>
+        </template>
       </byTable>
     </div>
 
@@ -76,6 +84,33 @@
         <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
       </template>
     </el-dialog>
+
+    <el-dialog title="货运详情" v-if="openAddAcceptCode" v-model="openAddAcceptCode" width="600" v-loading="loadingTwo">
+      <byForm :formConfig="formConfigTwo" :formOption="formOption" v-model="formDataTwo.data" :rules="rulesTwo" ref="submitTwo">
+        <template #departureTime>
+          <div>
+            <el-date-picker v-model="formData.data.departureTime" type="datetime" placeholder="请选择起运时间" value-format="YYYY-MM-DD HH:mm:ss" />
+          </div>
+        </template>
+        <template #file>
+          <div style="width: 100%">
+            <el-upload
+              v-model:fileList="fileList"
+              action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
+              :data="uploadData"
+              multiple
+              :before-upload="uploadFile"
+              :on-preview="onPreviewFile">
+              <el-button>选择</el-button>
+            </el-upload>
+          </div>
+        </template>
+      </byForm>
+      <template #footer>
+        <el-button @click="openAddAcceptCode = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitTwoForm()" size="large">确 定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -121,21 +156,21 @@ const config = computed(() => {
       attrs: {
         label: "主合同编号",
         prop: "code",
-        "min-width": 200,
+        width: 200,
       },
     },
     {
       attrs: {
         label: "货运详情",
-        prop: "acceptCode",
-        "min-width": 200,
+        slot: "acceptCode",
+        width: 200,
       },
     },
     {
       attrs: {
         label: "查看单证",
-        prop: "createTime",
-        "min-width": 200,
+        slot: "toView",
+        width: 140,
       },
     },
     {
@@ -186,16 +221,6 @@ const config = computed(() => {
   ];
 });
 const getDict = () => {
-  proxy.post("/packDetail/page", { pageNum: 1, pageSize: 999, shipmentStatus: 1 }).then((res) => {
-    if (res.rows && res.rows.length > 0) {
-      shipmentList.value = res.rows.map((item) => {
-        return {
-          label: item.contract,
-          value: item.id,
-        };
-      });
-    }
-  });
   proxy.post("/areaInfo/list", { parentId: "0" }).then((res) => {
     countryData.value = res;
   });
@@ -235,6 +260,9 @@ const formConfig = computed(() => {
       label: "出货主合同",
       required: true,
       data: shipmentList.value,
+      fn: (val) => {
+        changeContract(val);
+      },
     },
     {
       type: "slot",
@@ -269,12 +297,53 @@ const rules = ref({
   price: [{ required: true, message: "请输入单价", trigger: "blur" }],
 });
 const openModal = () => {
+  proxy.post("/packShipment/list", {}).then((res) => {
+    if (res && res.length > 0) {
+      shipmentList.value = res.map((item) => {
+        return {
+          ...item,
+          label: item.contractCode,
+          value: item.contractId,
+        };
+      });
+    } else {
+      shipmentList.value = [];
+    }
+  });
   formData.data = {
     documentsProductList: [],
   };
   loadingDialog.value = false;
   dialogVisible.value = true;
 };
+const changeContract = (val) => {
+  if (val) {
+    let data = shipmentList.value.filter((item) => item.value === val);
+    if (data && data.length > 0) {
+      proxy.post("/packShipment/productDetailList", { packDetailIds: data[0].packDetailIds }).then((res) => {
+        if (res && res.length > 0) {
+          formData.data.documentsProductList = res.map((item) => {
+            return {
+              productId: item.productId,
+              describe: item.remark,
+              subDescribe: item.subDescription,
+              customsCode: item.customsCode,
+              quantity: item.quantity,
+              price: item.price,
+              type: item.type,
+            };
+          });
+        } else {
+          formData.data.documentsProductList = [];
+        }
+      });
+    } else {
+      formData.data.documentsProductList = [];
+    }
+  } else {
+    formData.data.documentsProductList = [];
+  }
+};
 const submitForm = () => {
   submit.value.handleSubmit(() => {
     loadingDialog.value = true;
@@ -285,6 +354,106 @@ const submitForm = () => {
           type: "success",
         });
         dialogVisible.value = false;
+        sourceList.value.pagination.pageNum = 1;
+        getList();
+      },
+      (err) => {
+        console.log(err);
+        loadingDialog.value = false;
+      }
+    );
+  });
+};
+const openAddAcceptCode = ref(true);
+const loadingTwo = ref(false);
+const submitTwo = ref(null);
+const fileList = ref([]);
+const uploadData = ref({});
+const formDataTwo = reactive({
+  data: {
+    documentsId: "",
+  },
+});
+const formConfigTwo = computed(() => {
+  return [
+    {
+      type: "input",
+      prop: "acceptCarriage",
+      label: "承运方",
+      itemType: "text",
+      itemWidth: 40,
+    },
+    {
+      type: "input",
+      prop: "code",
+      label: "单号",
+      itemType: "text",
+      itemWidth: 60,
+    },
+    {
+      type: "slot",
+      prop: "departureTime",
+      slotName: "departureTime",
+      label: "起运时间",
+    },
+    {
+      type: "input",
+      prop: "remark",
+      label: "备注",
+      itemType: "textarea",
+    },
+    {
+      type: "slot",
+      prop: "file",
+      slotName: "file",
+      label: "上传附件",
+    },
+  ];
+});
+const rulesTwo = ref({
+  acceptCarriage: [{ required: true, message: "请输入承运方", trigger: "blur" }],
+  code: [{ required: true, message: "请输入承运单号", trigger: "blur" }],
+  departureTime: [{ required: true, message: "请选择起运时间", trigger: "change" }],
+});
+const clickAddAcceptCode = (item) => {
+  formDataTwo.data = {
+    documentsId: item.id,
+  };
+  fileList.value = [];
+  openAddAcceptCode.value = true;
+};
+const uploadFile = async (file) => {
+  const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
+  uploadData.value = res.uploadBody;
+  file.id = res.id;
+  file.fileName = res.fileName;
+  file.fileUrl = res.fileUrl;
+  return true;
+};
+const onPreviewFile = (file) => {
+  window.open(file.raw.fileUrl, "_blank");
+};
+const submitTwoForm = () => {
+  submitTwo.value.handleSubmit(() => {
+    if (fileList.value && fileList.value.length > 0) {
+      formDataTwo.data.fileList = fileList.value.map((item) => {
+        return {
+          id: item.raw.id,
+          fileName: item.raw.fileName,
+          fileUrl: item.raw.fileUrl,
+        };
+      });
+    } else {
+      formDataTwo.data.fileList = [];
+    }
+    loadingDialog.value = true;
+    proxy.post("/documentsTransport/add", formDataTwo.data).then(
+      () => {
+        ElMessage({
+          message: "提交成功",
+          type: "success",
+        });
+        dialogVisible.value = false;
         getList();
       },
       (err) => {