|
@@ -34,7 +34,6 @@ const responseHandle = useResponseHandle();
|
|
|
|
|
|
const Uploadsuccess = ({ results, header }) => {
|
|
const Uploadsuccess = ({ results, header }) => {
|
|
loading.value = true;
|
|
loading.value = true;
|
|
-
|
|
|
|
if (results.length === 0) {
|
|
if (results.length === 0) {
|
|
ElMessage.error("表格无有效数据!");
|
|
ElMessage.error("表格无有效数据!");
|
|
loading.value = false;
|
|
loading.value = false;
|
|
@@ -63,9 +62,7 @@ const Uploadsuccess = ({ results, header }) => {
|
|
for (const v1 of results) {
|
|
for (const v1 of results) {
|
|
const b = Object.values(v1);
|
|
const b = Object.values(v1);
|
|
let model = {};
|
|
let model = {};
|
|
- b.forEach((si, sii) => {
|
|
|
|
- model["value" + sii] = si + "";
|
|
|
|
- });
|
|
|
|
|
|
+ b.forEach((si, sii) => { model["value" + sii] = si + ""; });
|
|
tableData.value.push(model);
|
|
tableData.value.push(model);
|
|
row.value = row.value + 1;
|
|
row.value = row.value + 1;
|
|
}
|
|
}
|
|
@@ -83,13 +80,16 @@ const Uploadsuccess = ({ results, header }) => {
|
|
data.push(obj);
|
|
data.push(obj);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+
|
|
const typeErrors: string[] = [];
|
|
const typeErrors: string[] = [];
|
|
const checkErrors: string[] = [];
|
|
const checkErrors: string[] = [];
|
|
const codeErrors: string[] = [];
|
|
const codeErrors: string[] = [];
|
|
const numberErrors: string[] = [];
|
|
const numberErrors: string[] = [];
|
|
const priceErrors: string[] = [];
|
|
const priceErrors: string[] = [];
|
|
|
|
+ const fullyElectionicPriceErrors: string[] = [];
|
|
|
|
|
|
- const openDateErrors: string[] = [];
|
|
|
|
|
|
+
|
|
|
|
+ const openDateErrors: string[] = [];
|
|
const now = dayjs(new Date()).format('YYYY-MM-DD');
|
|
const now = dayjs(new Date()).format('YYYY-MM-DD');
|
|
|
|
|
|
data.forEach((row, index) => {
|
|
data.forEach((row, index) => {
|
|
@@ -109,25 +109,29 @@ const Uploadsuccess = ({ results, header }) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(row.open_time && !dayjs(row.open_time).isSame(dayjs(now)) && !dayjs(row.open_time).isBefore(dayjs(now))){
|
|
|
|
|
|
+ const isFullyElectionic = row.invoiceType === 'fully_digitalized_special_electronic' || row.invoiceType === 'fully_digitalized_normal_electronic'
|
|
|
|
+
|
|
|
|
+ if(!row.open_time || (row.open_time && !dayjs(row.open_time).isSame(dayjs(now)) && !dayjs(row.open_time).isBefore(dayjs(now)))){
|
|
openDateErrors.push(String(index + 1))
|
|
openDateErrors.push(String(index + 1))
|
|
}
|
|
}
|
|
|
|
|
|
const reg = /^\d+(\.\d+)?$/;
|
|
const reg = /^\d+(\.\d+)?$/;
|
|
|
|
|
|
- if (!reg.test(row.invoiceCode)) {
|
|
|
|
|
|
+ if (!reg.test(row.invoiceCode) && !isFullyElectionic) {
|
|
codeErrors.push(String(index + 1));
|
|
codeErrors.push(String(index + 1));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
if (!reg.test(row.invoiceNumber)) {
|
|
if (!reg.test(row.invoiceNumber)) {
|
|
numberErrors.push(String(index + 1));
|
|
numberErrors.push(String(index + 1));
|
|
}
|
|
}
|
|
|
|
|
|
- if (!reg.test(row.inv_subtotal_amount) || Number(row.inv_subtotal_amount) < 0) {
|
|
|
|
|
|
+ if ((!reg.test(row.inv_subtotal_amount) || Number(row.inv_subtotal_amount) < 0) && !isFullyElectionic) {
|
|
priceErrors.push(String(index + 1));
|
|
priceErrors.push(String(index + 1));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ((!reg.test(row.inv_total) || Number(row.inv_total) < 0) && isFullyElectionic) {
|
|
|
|
+ fullyElectionicPriceErrors.push(String(index + 1));
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
if (typeErrors.length > 0) {
|
|
if (typeErrors.length > 0) {
|
|
@@ -180,10 +184,20 @@ const Uploadsuccess = ({ results, header }) => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (fullyElectionicPriceErrors.length > 0) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ type: "error",
|
|
|
|
+ message: `第 ${fullyElectionicPriceErrors.join(",")} 行,发票税后金额必须为数字且不能是负数`
|
|
|
|
+ });
|
|
|
|
+ loading.value = false;
|
|
|
|
+ tableData.value = [];
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (openDateErrors.length > 0) {
|
|
if (openDateErrors.length > 0) {
|
|
ElMessage({
|
|
ElMessage({
|
|
type: "error",
|
|
type: "error",
|
|
- message: `第 ${openDateErrors.join(",")} 行,开票日期不能超过当前日期`
|
|
|
|
|
|
+ message: `第 ${openDateErrors.join(",")} 行,开票日期不能为空且不能超过当前日期`
|
|
});
|
|
});
|
|
loading.value = false;
|
|
loading.value = false;
|
|
tableData.value = [];
|
|
tableData.value = [];
|
|
@@ -198,7 +212,6 @@ const handleSubmit = async () => {
|
|
try {
|
|
try {
|
|
if (loading.value) return;
|
|
if (loading.value) return;
|
|
loading.value = true;
|
|
loading.value = true;
|
|
-
|
|
|
|
const data = [];
|
|
const data = [];
|
|
|
|
|
|
tableData.value.forEach((key, index) => {
|
|
tableData.value.forEach((key, index) => {
|
|
@@ -212,91 +225,12 @@ const handleSubmit = async () => {
|
|
data.push(obj);
|
|
data.push(obj);
|
|
});
|
|
});
|
|
|
|
|
|
- const typeErrors: string[] = [];
|
|
|
|
- const checkErrors: string[] = [];
|
|
|
|
- const codeErrors: string[] = [];
|
|
|
|
- const numberErrors: string[] = [];
|
|
|
|
- const priceErrors: string[] = [];
|
|
|
|
-
|
|
|
|
data.forEach((row, index) => {
|
|
data.forEach((row, index) => {
|
|
const source = row.invoiceType.trim();
|
|
const source = row.invoiceType.trim();
|
|
const target = cg_inv_type_list.find(({ label }) => label === source);
|
|
const target = cg_inv_type_list.find(({ label }) => label === source);
|
|
-
|
|
|
|
- if (!target) {
|
|
|
|
- typeErrors.push(String(index + 1));
|
|
|
|
- } else {
|
|
|
|
- row.invoiceType = target.value;
|
|
|
|
-
|
|
|
|
- if (
|
|
|
|
- (target.value === "normal" || target.value === "electronic") &&
|
|
|
|
- !row.checkNumber
|
|
|
|
- ) {
|
|
|
|
- checkErrors.push(String(index + 1));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const reg = /^\d+(\.\d+)?$/;
|
|
|
|
-
|
|
|
|
- if (!reg.test(row.invoiceCode)) {
|
|
|
|
- codeErrors.push(String(index + 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (!reg.test(row.invoiceNumber)) {
|
|
|
|
- numberErrors.push(String(index + 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!reg.test(row.inv_subtotal_amount) || Number(row.inv_subtotal_amount) < 0) {
|
|
|
|
- priceErrors.push(String(index + 1));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ row.invoiceType = target.value;
|
|
});
|
|
});
|
|
|
|
|
|
- if (typeErrors.length > 0) {
|
|
|
|
- ElMessage({
|
|
|
|
- type: "error",
|
|
|
|
- message: createInvErrorMessage(typeErrors.join(","))
|
|
|
|
- });
|
|
|
|
- loading.value = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (checkErrors.length > 0) {
|
|
|
|
- ElMessage({
|
|
|
|
- type: "error",
|
|
|
|
- message: `第 ${checkErrors.join(",")} 行,校验码不能为空。`
|
|
|
|
- });
|
|
|
|
- loading.value = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (codeErrors.length > 0) {
|
|
|
|
- ElMessage({
|
|
|
|
- type: "error",
|
|
|
|
- message: `第 ${codeErrors.join(",")} 行,发票代码必须为数字。`
|
|
|
|
- });
|
|
|
|
- loading.value = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (numberErrors.length > 0) {
|
|
|
|
- ElMessage({
|
|
|
|
- type: "error",
|
|
|
|
- message: `第 ${numberErrors.join(",")} 行,发票号码必须为数字。`
|
|
|
|
- });
|
|
|
|
- loading.value = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (priceErrors.length > 0) {
|
|
|
|
- ElMessage({
|
|
|
|
- type: "error",
|
|
|
|
- message: `第 ${priceErrors.join(",")} 行,发票税前金额必须为数字且不能是负数`
|
|
|
|
- });
|
|
|
|
- loading.value = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
|
|
const buyers = data.map(({ supplierNo }) => supplierNo);
|
|
const buyers = data.map(({ supplierNo }) => supplierNo);
|
|
const setBuyers = [...new Set(buyers)];
|
|
const setBuyers = [...new Set(buyers)];
|
|
@@ -316,6 +250,10 @@ const handleSubmit = async () => {
|
|
}
|
|
}
|
|
|
|
|
|
data.forEach(item => {
|
|
data.forEach(item => {
|
|
|
|
+ const isFullyElectionic = item.invoiceType === 'fully_digitalized_special_electronic' || item.invoiceType === 'fully_digitalized_normal_electronic'
|
|
|
|
+ if(isFullyElectionic){ item.inv_subtotal_amount = item.inv_total }
|
|
|
|
+
|
|
|
|
+ delete item['inv_total']
|
|
delete item["supplierNo"];
|
|
delete item["supplierNo"];
|
|
delete item["supplierName"];
|
|
delete item["supplierName"];
|
|
delete item["companyName"];
|
|
delete item["companyName"];
|