ly 1 anno fa
parent
commit
cc519a75cf

+ 2 - 1
src/api/tool/file.js

@@ -56,7 +56,8 @@ export function uploadFile(file) {
     method: 'post',
     data: file,
     headers: {
-      'Content-Type': 'multipart/form-data'
+      'Content-Type': 'multipart/form-data',
+      'repeatSubmit': false,
     }
   })
 }

+ 1 - 0
src/utils/request.js

@@ -125,6 +125,7 @@ export function download(url, params, filename, config) {
     transformRequest: [(params) => { return tansParams(params) }],
     headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
     responseType: 'blob',
+    timeout: 1000000,
     ...config
   }).then(async (data) => {
     const isLogin = await blobValidate(data);

+ 52 - 34
src/views/business/financial/contract/form.vue

@@ -143,7 +143,7 @@
               <el-form-item label="收款金额:" required>
                 <el-input-number v-if="editStatus" style="width: 100%" v-model.trim="form.arriveAmount" size="small"
                   placeholder="收款金额" :clearable="true" :precision="2" controls-position="right" :controls="false"
-                  @change="amountChange"  disabled/>
+                  @change="amountChange" disabled />
                 <span v-else>{{ form.arriveAmount }}</span>
               </el-form-item>
             </el-col>
@@ -314,6 +314,7 @@
   import CustomerFormCom from "@/components/CustomerFormCom";
   import { formatDate } from "@/utils/index";
   import { ref } from "vue";
+  import match from "@/utils/match";
   import useUserStore from "@/store/modules/user";
   const { proxy } = getCurrentInstance();
   const baseUrl = import.meta.env.VITE_APP_BASE_API;
@@ -384,7 +385,7 @@
   const isFullscreen = ref(false);
   const webHost = import.meta.env.VITE_APP_BASE_API;
   const data = reactive({
-    form: reactive({}), 
+    form: reactive({}),
     rules: {},
     timeOptions: { start: "08:30", step: "00:15", end: "18:30" },
   });
@@ -441,41 +442,58 @@
   }
 
   /** 提交按钮 */
-  async  function submitForm() {
-
+  async function submitForm() {
     // 应收款金额  和明细比较 如果大于应收内容 提示 当前的合同提过的收款申请总金额超过当前合同金额,不可提交,如有需要请跟财务人员联系
-
     const res = await getCollectionDetail(form.value.contractId);
-    const amount = res.data + form.value.arriveAmount;
-    if (amount > form.value.contractAmount) {
-      proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
-      return;
+    if (res.data == null || res.data.length == 0) {
+      const amount = form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return;
+      }
+      form.value.details.forEach(item => {
+        if (item.amount < item.arriveAmount) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+          return;
+        }
+      });
+    } else {
+      const countAmount= res.data.map((item) => item.arriveAmount).reduce((total, number) => {
+        return total + number;
+      });
+      const amount = countAmount + form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return;
+      }
+      form.value.details.forEach(item => {
+        if (item.amount < match.add(item.arriveAmount, item.arrived)) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+          return;
+        }
+      });
     }
-    // getCollectionDetail(form.value.contractId).then((res) => {
-    //  let amount = res.data + form.value.arriveAmount;
-    //   if (amount > form.value.contractAmount) {
-    //         proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,如有需要请跟财务人员联系");
-    //         return;
+
+
+
+    // if (form.value.arriveAmount > form.value.contractAmount) {
+    //   proxy.$modal.msgError("实际收款金额不能大于合同收款金额");
+    //   return;
+    // }
+    // proxy.$refs["orderRef"].validate((valid) => {
+    //   if (valid && detailValid()) {
+    //     const formValue = form.value;
+    //     saveCollection(formValue).then((res) => {
+    //       if (res.code === 200) {
+    //         archiveInput.value.collectionStatus = 1;
+    //         setCollectionStatus(archiveInput.value);
+    //         proxy.$message.success("保存成功");
+    //       }
+    //       cancel();
+    //       getList.value();
+    //     });
     //   }
-    //   })
-    if (form.value.arriveAmount > form.value.contractAmount) {
-      proxy.$modal.msgError("实际收款金额不能大于合同收款金额");
-      return;
-    }
-    proxy.$refs["orderRef"].validate((valid) => {
-      if (valid && detailValid()) {
-        const formValue = form.value;
-        saveCollection(formValue).then((res) => {
-          if (res.code === 200) {
-            archiveInput.value.collectionStatus = 1;
-            setCollectionStatus(archiveInput.value);
-            proxy.$message.success("保存成功");
-          }
-          cancel();
-          getList.value();
-        });
-      }
-    });
+    // });
   }
 
   function detailValid() {
@@ -575,7 +593,7 @@
       for (let i = 0; i < form.value.details.length; i++) {
         amount = amount + form.value.details[i].arriveAmount;
       }
-      nextTick(() =>{
+      nextTick(() => {
         form.value.arriveAmount = amount;
       })
     }