|
@@ -4,7 +4,7 @@ import { ElMessage } from "element-plus";
|
|
|
import { execlUpload } from "/@/components/execlUpload";
|
|
|
import { httpBatchimport } from "/@/api/purchase/ticketReturn";
|
|
|
import { useResponseHandle } from "/@/hooks";
|
|
|
-import { result } from "lodash-unified";
|
|
|
+import { useCompany } from "/@/hooks/core/useCompany";
|
|
|
|
|
|
import {
|
|
|
initheaders,
|
|
@@ -19,6 +19,8 @@ const tableData = ref([]);
|
|
|
const columnsConfig = columns();
|
|
|
const emit = defineEmits(["onSuccess"]);
|
|
|
|
|
|
+const { currentCompany } = useCompany();
|
|
|
+
|
|
|
const responseHandle = useResponseHandle();
|
|
|
|
|
|
const Uploadsuccess = ({ results, header }) => {
|
|
@@ -49,16 +51,15 @@ const Uploadsuccess = ({ results, header }) => {
|
|
|
tableData.value = [];
|
|
|
|
|
|
try {
|
|
|
- results.forEach(v1 => {
|
|
|
+ for (const v1 of results) {
|
|
|
const b = Object.values(v1);
|
|
|
let model = {};
|
|
|
b.forEach((si, sii) => {
|
|
|
model["value" + sii] = si + "";
|
|
|
});
|
|
|
tableData.value.push(model);
|
|
|
- });
|
|
|
+ }
|
|
|
loading.value = false;
|
|
|
- console.log(result);
|
|
|
} catch (err) {
|
|
|
return err;
|
|
|
}
|
|
@@ -71,6 +72,7 @@ const handleSubmit = async () => {
|
|
|
const data = [];
|
|
|
const errorStatus = [];
|
|
|
const errorHp = [];
|
|
|
+ const errorDz = [];
|
|
|
|
|
|
tableData.value.forEach((key, index) => {
|
|
|
const obj: Record<string, string> = {};
|
|
@@ -88,23 +90,25 @@ const handleSubmit = async () => {
|
|
|
} else if (prop === "hpNo") {
|
|
|
if (!value) errorHp.push(index + 1);
|
|
|
obj[prop] = value;
|
|
|
+ } else if (prop === "payNo") {
|
|
|
+ if (!value) errorDz.push(index + 1);
|
|
|
+ obj[prop] = value;
|
|
|
} else {
|
|
|
obj[prop] = value;
|
|
|
}
|
|
|
-
|
|
|
- delete obj["supplierNo"];
|
|
|
- delete obj["payNo"];
|
|
|
}
|
|
|
data.push(obj);
|
|
|
});
|
|
|
|
|
|
- console.log(errorStatus);
|
|
|
+ const buyers = data.map(({ companyNo }) => companyNo);
|
|
|
+ const setBuyers = [...new Set(buyers)];
|
|
|
|
|
|
if (errorStatus.length > 0) {
|
|
|
ElMessage.error(
|
|
|
`第 ${errorStatus.join(",")} 行审核状态格式不正确,应该为'通过',或'驳回'`
|
|
|
);
|
|
|
loading.value = false;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if (errorHp.length > 0) {
|
|
@@ -112,15 +116,38 @@ const handleSubmit = async () => {
|
|
|
`第 ${errorHp.join(",")} 行格式不正确,回票申请编号为必填项`
|
|
|
);
|
|
|
loading.value = false;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- console.log(data);
|
|
|
+ if (errorDz.length > 0) {
|
|
|
+ ElMessage.error(`第 ${errorDz.join(",")} 行格式不正确,对账编号为必填项`);
|
|
|
+ loading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (setBuyers.length > 1) {
|
|
|
+ ElMessage.error("买方公司编码不一致");
|
|
|
+ loading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (setBuyers[0] !== currentCompany.value.companyNo) {
|
|
|
+ ElMessage.error("买方公司编码与当前选择的公司不一致");
|
|
|
+ loading.value = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ data.forEach(item => {
|
|
|
+ delete item["payNo"];
|
|
|
+ delete item["companyNo"];
|
|
|
+ });
|
|
|
|
|
|
const { code, message } = await httpBatchimport({
|
|
|
list: data
|
|
|
});
|
|
|
|
|
|
loading.value = false;
|
|
|
+
|
|
|
responseHandle({
|
|
|
code,
|
|
|
message,
|
|
@@ -142,7 +169,7 @@ defineExpose({
|
|
|
<template>
|
|
|
<el-dialog
|
|
|
v-model="visible"
|
|
|
- title="导入表格数据"
|
|
|
+ title="批量导入认证结果"
|
|
|
width="1040px"
|
|
|
top="8vh"
|
|
|
center
|