|
@@ -578,6 +578,8 @@ import { InvoiceTypeVO } from '@/api/system/invoiceType/types';
|
|
|
import { listBank as listSystemBank } from '@/api/system/bank';
|
|
import { listBank as listSystemBank } from '@/api/system/bank';
|
|
|
import { BankVO as SystemBankVO } from '@/api/system/bank/types';
|
|
import { BankVO as SystemBankVO } from '@/api/system/bank/types';
|
|
|
import { getInfoTemporary, addInfoTemporary } from '@/api/supplier/infoTemporary';
|
|
import { getInfoTemporary, addInfoTemporary } from '@/api/supplier/infoTemporary';
|
|
|
|
|
+import { addErpSupplierInfo, updateErpSupplierInfo } from '@/api/supplier/erpSupplierInfo';
|
|
|
|
|
+import { ErpSupplierInfoForm } from '@/api/supplier/erpSupplierInfo/types';
|
|
|
import { getChinaArea } from '@/api/system/addressarea/index';
|
|
import { getChinaArea } from '@/api/system/addressarea/index';
|
|
|
import download from '@/plugins/download';
|
|
import download from '@/plugins/download';
|
|
|
import { listQualification } from '@/api/supplier/qualification';
|
|
import { listQualification } from '@/api/supplier/qualification';
|
|
@@ -1070,7 +1072,7 @@ const handleGetBusinessInfo = async () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/** 保存数据 */
|
|
/** 保存数据 */
|
|
|
-const handleSave = async () => {
|
|
|
|
|
|
|
+const handleSave = async (erpSupplierInfoForm?: ErpSupplierInfoForm) => {
|
|
|
try {
|
|
try {
|
|
|
// 验证必填字段
|
|
// 验证必填字段
|
|
|
if (!detailData.value.ownedCompany) {
|
|
if (!detailData.value.ownedCompany) {
|
|
@@ -1170,6 +1172,9 @@ const handleSave = async () => {
|
|
|
isBasicInfoSaved.value = true;
|
|
isBasicInfoSaved.value = true;
|
|
|
detailData.value.id = newId;
|
|
detailData.value.id = newId;
|
|
|
|
|
|
|
|
|
|
+ // 保存ERP供应商信息
|
|
|
|
|
+ await saveErpSupplierInfo(erpSupplierInfoForm, newId);
|
|
|
|
|
+
|
|
|
// 重新加载供应商详情以获取完整信息(包括supplierNo)
|
|
// 重新加载供应商详情以获取完整信息(包括supplierNo)
|
|
|
try {
|
|
try {
|
|
|
const detailRes = await getInfo(newId);
|
|
const detailRes = await getInfo(newId);
|
|
@@ -1193,6 +1198,8 @@ const handleSave = async () => {
|
|
|
} else {
|
|
} else {
|
|
|
// 编辑模式,直接刷新当前数据
|
|
// 编辑模式,直接刷新当前数据
|
|
|
if (detailData.value.id) {
|
|
if (detailData.value.id) {
|
|
|
|
|
+ // 保存ERP供应商信息
|
|
|
|
|
+ await saveErpSupplierInfo(erpSupplierInfoForm, detailData.value.supplierId);
|
|
|
await getDetail();
|
|
await getDetail();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1201,6 +1208,24 @@ const handleSave = async () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/** 保存ERP供应商信息 */
|
|
|
|
|
+const saveErpSupplierInfo = async (erpSupplierInfoForm: ErpSupplierInfoForm | undefined, supplierId: string | number) => {
|
|
|
|
|
+ if (!erpSupplierInfoForm || !supplierId) return;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const erpData: ErpSupplierInfoForm = {
|
|
|
|
|
+ ...erpSupplierInfoForm,
|
|
|
|
|
+ supplierId
|
|
|
|
|
+ };
|
|
|
|
|
+ if (erpData.id) {
|
|
|
|
|
+ await updateErpSupplierInfo(erpData);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ await addErpSupplierInfo(erpData);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('保存ERP供应商信息失败:', e);
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
/** 初始化省市区级联选择器数据 */
|
|
/** 初始化省市区级联选择器数据 */
|
|
|
const initRegionOptions = async () => {
|
|
const initRegionOptions = async () => {
|
|
|
try {
|
|
try {
|
|
@@ -1297,8 +1322,10 @@ const getDetail = async () => {
|
|
|
// 新增模式
|
|
// 新增模式
|
|
|
isAddMode.value = true;
|
|
isAddMode.value = true;
|
|
|
if (id) {
|
|
if (id) {
|
|
|
- // 如果有ID,说明基础信息已保存
|
|
|
|
|
|
|
+ // 如果有ID,说明基础信息已保存,加载已有数据
|
|
|
isBasicInfoSaved.value = true;
|
|
isBasicInfoSaved.value = true;
|
|
|
|
|
+ const res = await getInfo(id);
|
|
|
|
|
+ detailData.value = res.data;
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
} else if (mode === 'edit' && id) {
|
|
} else if (mode === 'edit' && id) {
|
|
@@ -2660,7 +2687,7 @@ const getAddressList = async () => {
|
|
|
const id = route.query.id as string;
|
|
const id = route.query.id as string;
|
|
|
|
|
|
|
|
// add状态不查询地址列表(新增时没有地址)
|
|
// add状态不查询地址列表(新增时没有地址)
|
|
|
- if (!id || isAddMode.value) {
|
|
|
|
|
|
|
+ if (!id || (isAddMode.value && !isBasicInfoSaved.value)) {
|
|
|
addressList.value = [];
|
|
addressList.value = [];
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|