|
|
@@ -286,11 +286,6 @@
|
|
|
|
|
|
|
|
|
</el-table>
|
|
|
-
|
|
|
- <!-- 空状态 -->
|
|
|
- <div v-if="paymentInfoList.length === 0" style="text-align: center; padding: 40px; color: #999;">
|
|
|
- 暂无付款信息
|
|
|
- </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-tab-pane>
|
|
|
@@ -1221,6 +1216,7 @@ import { InvoiceTypeVO } from '@/api/system/invoiceType/types';
|
|
|
import { listBank as listSystemBank } from '@/api/system/bank';
|
|
|
import { BankVO as SystemBankVO } from '@/api/system/bank/types';
|
|
|
import { listByIds } from '@/api/system/oss';
|
|
|
+import { debugSupplyAreaFlow } from '@/utils/supplyAreaDebug';
|
|
|
|
|
|
const route = useRoute();
|
|
|
const router = useRouter();
|
|
|
@@ -1305,7 +1301,7 @@ const supplyAreaOptions = ref<any[]>([]); // 供货区域选项(从接口获
|
|
|
const savedAreaData = ref<any[]>([]); // 已保存的供货区域数据
|
|
|
const cascaderProps = {
|
|
|
multiple: true,
|
|
|
- checkStrictly: true, // 改为 true,允许选择任意级别
|
|
|
+ checkStrictly: false, // 改为 false,确保父子级联动正确
|
|
|
value: 'areaCode',
|
|
|
label: 'areaName',
|
|
|
children: 'children',
|
|
|
@@ -1321,7 +1317,7 @@ const regionCascaderProps = {
|
|
|
};
|
|
|
|
|
|
// 详细地址级联选择器相关
|
|
|
-const regionOptions = ref<any[]>([]); // 省市区级联选择器选项
|
|
|
+const regionOptions = ref<any[]>([]); // 省市区级联选择器选项(使用前端组件库数据)
|
|
|
const selectedOfficeRegion = ref<string[]>([]); // 选中的省市区代码数组
|
|
|
|
|
|
// 品牌相关数据
|
|
|
@@ -1678,7 +1674,7 @@ const handlePersonImageConfirm = (files: any[]) => {
|
|
|
/** 初始化省市区级联选择器数据 */
|
|
|
const initRegionOptions = async () => {
|
|
|
try {
|
|
|
- // 使用 element-china-area-data 提供的地区数据
|
|
|
+ // 基本信息地址选择使用前端组件库数据(简单快速)
|
|
|
regionOptions.value = regionData;
|
|
|
console.log('省市区数据加载完成:', regionOptions.value.length);
|
|
|
} catch (e) {
|
|
|
@@ -2360,39 +2356,39 @@ const getSupplyAreaList = async () => {
|
|
|
// 保存原始数据,用于编辑时回显
|
|
|
savedAreaData.value = res.data || res.rows || [];
|
|
|
|
|
|
- // 处理返回的数据,按层级组织
|
|
|
+ // 处理返回的数据,按层级组织显示
|
|
|
const areaData = savedAreaData.value;
|
|
|
|
|
|
- // 第一步:先收集所有省份
|
|
|
- const provinceMap: any = {};
|
|
|
+ // 按省份分组
|
|
|
+ const provinceMap = new Map<string, { province: string; cities: string[] }>();
|
|
|
+
|
|
|
+ // 先处理省份
|
|
|
areaData.forEach((area: any) => {
|
|
|
- if (area.level === '1' || area.level === 1) {
|
|
|
- provinceMap[area.areaCode] = {
|
|
|
- province: area.areaName,
|
|
|
- city: ''
|
|
|
- };
|
|
|
+ if (area.level === 1 || area.level === '1') {
|
|
|
+ if (!provinceMap.has(area.areaCode)) {
|
|
|
+ provinceMap.set(area.areaCode, {
|
|
|
+ province: area.areaName,
|
|
|
+ cities: []
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 第二步:将城市添加到对应的省份
|
|
|
+ // 再处理城市
|
|
|
areaData.forEach((area: any) => {
|
|
|
- if (area.level === '2' || area.level === 2) {
|
|
|
+ if (area.level === 2 || area.level === '2') {
|
|
|
const parentCode = area.parentCode;
|
|
|
- if (provinceMap[parentCode]) {
|
|
|
- // 将城市添加到省份的城市列表中
|
|
|
- if (provinceMap[parentCode].city) {
|
|
|
- provinceMap[parentCode].city += ',' + area.areaName;
|
|
|
- } else {
|
|
|
- provinceMap[parentCode].city = area.areaName;
|
|
|
- }
|
|
|
+ if (provinceMap.has(parentCode)) {
|
|
|
+ provinceMap.get(parentCode)!.cities.push(area.areaName);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 转换为数组
|
|
|
- supplyAreaList.value = Object.values(provinceMap).filter((item: any) =>
|
|
|
- item.province || item.city
|
|
|
- );
|
|
|
+ // 转换为显示格式
|
|
|
+ supplyAreaList.value = Array.from(provinceMap.values()).map(item => ({
|
|
|
+ province: item.province,
|
|
|
+ city: item.cities.join(', ') || '' // 用逗号分隔多个城市
|
|
|
+ }));
|
|
|
|
|
|
console.log('供货区域列表:', supplyAreaList.value);
|
|
|
console.log('保存的原始数据:', savedAreaData.value);
|
|
|
@@ -2405,27 +2401,53 @@ const getSupplyAreaList = async () => {
|
|
|
const handleEditSupplyArea = async () => {
|
|
|
supplyAreaDialogVisible.value = true;
|
|
|
|
|
|
+ // 调试:打印完整的调试信息
|
|
|
+ if (import.meta.env.DEV) {
|
|
|
+ debugSupplyAreaFlow(supplyAreaOptions.value, savedAreaData.value, []);
|
|
|
+ }
|
|
|
+
|
|
|
// 根据已保存的数据回显选中状态
|
|
|
if (savedAreaData.value && savedAreaData.value.length > 0) {
|
|
|
const selectedPaths: any[] = [];
|
|
|
|
|
|
- // 遍历已保存的数据,构建级联选择器需要的路径格式
|
|
|
+ // 按省份分组处理
|
|
|
+ const provinceMap = new Map<string, string[]>();
|
|
|
+
|
|
|
+ // 先收集所有省份和对应的城市
|
|
|
savedAreaData.value.forEach((area: any) => {
|
|
|
- if (area.level === '2') {
|
|
|
- // 市级数据,需要找到对应的省份
|
|
|
- const province = savedAreaData.value.find((p: any) =>
|
|
|
- p.level === '1' && p.areaCode === area.parentCode
|
|
|
- );
|
|
|
-
|
|
|
- if (province) {
|
|
|
- // 构建路径 [省代码, 市代码]
|
|
|
- selectedPaths.push([province.areaCode, area.areaCode]);
|
|
|
+ if (area.level === 1 || area.level === '1') {
|
|
|
+ // 省份级别
|
|
|
+ if (!provinceMap.has(area.areaCode)) {
|
|
|
+ provinceMap.set(area.areaCode, []);
|
|
|
}
|
|
|
+ } else if (area.level === 2 || area.level === '2') {
|
|
|
+ // 城市级别,找到对应的省份
|
|
|
+ const parentCode = area.parentCode;
|
|
|
+ if (!provinceMap.has(parentCode)) {
|
|
|
+ provinceMap.set(parentCode, []);
|
|
|
+ }
|
|
|
+ provinceMap.get(parentCode)!.push(area.areaCode);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 构建级联选择器需要的路径格式
|
|
|
+ provinceMap.forEach((cityCodes, provinceCode) => {
|
|
|
+ if (cityCodes.length === 0) {
|
|
|
+ // 只选择了省份,没有选择城市
|
|
|
+ selectedPaths.push([provinceCode]);
|
|
|
+ } else {
|
|
|
+ // 选择了省份下的城市
|
|
|
+ cityCodes.forEach(cityCode => {
|
|
|
+ selectedPaths.push([provinceCode, cityCode]);
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
selectedSupplyAreas.value = selectedPaths;
|
|
|
+ console.log('=== 供货区域回显 ===');
|
|
|
console.log('回显的选中路径:', selectedPaths);
|
|
|
+ console.log('原始保存的数据:', savedAreaData.value);
|
|
|
+ console.log('省份映射:', Array.from(provinceMap.entries()));
|
|
|
} else {
|
|
|
selectedSupplyAreas.value = [];
|
|
|
}
|
|
|
@@ -2473,6 +2495,9 @@ const handleSupplyAreaSubmit = async () => {
|
|
|
supplyAreaSubmitLoading.value = true;
|
|
|
|
|
|
let id = route.query.id as string;
|
|
|
+ // 判断是否为供应商自己编辑(没有URL参数id,使用userStore.supplierId)
|
|
|
+ const isSupplierSelfEdit = !id && userStore.supplierId;
|
|
|
+
|
|
|
if (!id && userStore.supplierId) {
|
|
|
id = String(userStore.supplierId);
|
|
|
}
|
|
|
@@ -2481,17 +2506,21 @@ const handleSupplyAreaSubmit = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ console.log('=== 提交供货区域 ===');
|
|
|
+ console.log('选中的路径:', selectedSupplyAreas.value);
|
|
|
+
|
|
|
// 构建 areaList 数组
|
|
|
const areaList = buildAreaList(selectedSupplyAreas.value);
|
|
|
console.log('构建的 areaList:', areaList);
|
|
|
|
|
|
// 从选中的路径中提取区域信息(用于显示)
|
|
|
const regionData = extractRegionData(selectedSupplyAreas.value);
|
|
|
+ console.log('提取的区域数据:', regionData);
|
|
|
|
|
|
// 保存区域代码(用于下次编辑时回显)
|
|
|
const regionCodes = regionData.districtCodes.join(',');
|
|
|
|
|
|
- const submitData = {
|
|
|
+ const submitData: any = {
|
|
|
supplierId: id,
|
|
|
supplyNo: detailData.value.supplierNo,
|
|
|
areaList: areaList, // 传递 areaList 数组
|
|
|
@@ -2499,10 +2528,16 @@ const handleSupplyAreaSubmit = async () => {
|
|
|
city: regionData.cities,
|
|
|
supplyRegions: regionCodes
|
|
|
};
|
|
|
+
|
|
|
+ // 供应商自己编辑时添加 supplyStatus=4
|
|
|
+ if (isSupplierSelfEdit) {
|
|
|
+ submitData.supplyStatus = "4";
|
|
|
+ console.log('供应商自己编辑,添加 supplyStatus=4');
|
|
|
+ }
|
|
|
|
|
|
console.log('提交的数据:', submitData);
|
|
|
|
|
|
- await addArea(submitData as any);
|
|
|
+ await addArea(submitData);
|
|
|
|
|
|
// 更新本地数据
|
|
|
(detailData.value as any).province = regionData.provinces;
|
|
|
@@ -2510,15 +2545,11 @@ const handleSupplyAreaSubmit = async () => {
|
|
|
(detailData.value as any).district = '';
|
|
|
(detailData.value as any).supplyRegions = regionCodes;
|
|
|
|
|
|
- // 更新供货区域列表显示
|
|
|
- supplyAreaList.value = [{
|
|
|
- province: regionData.provinces,
|
|
|
- city: regionData.cities,
|
|
|
- district: ''
|
|
|
- }];
|
|
|
-
|
|
|
ElMessage({ message: '保存成功', type: 'info' });
|
|
|
supplyAreaDialogVisible.value = false;
|
|
|
+
|
|
|
+ // 重新获取供货区域列表以刷新显示
|
|
|
+ await getSupplyAreaList();
|
|
|
} catch (e) {
|
|
|
console.error('保存供货区域失败:', e);
|
|
|
ElMessage.error('保存失败');
|
|
|
@@ -2534,26 +2565,28 @@ const extractRegionData = (selectedPaths: any[]) => {
|
|
|
const cityCodes: string[] = [];
|
|
|
|
|
|
selectedPaths.forEach(path => {
|
|
|
- if (Array.isArray(path) && path.length >= 2) {
|
|
|
- const [provinceCode, cityCode] = path;
|
|
|
-
|
|
|
- // 保存城市代码
|
|
|
- if (cityCode) {
|
|
|
- cityCodes.push(cityCode);
|
|
|
- }
|
|
|
+ if (Array.isArray(path)) {
|
|
|
+ const provinceCode = path[0];
|
|
|
+ const cityCode = path[1];
|
|
|
|
|
|
- // 查找对应的名称
|
|
|
- const provinceName = findRegionName(provinceCode, supplyAreaOptions.value);
|
|
|
+ // 查找省份信息
|
|
|
const province = supplyAreaOptions.value.find(p => p.areaCode === provinceCode);
|
|
|
- const cityName = province && cityCode ? findRegionName(cityCode, province.children || []) : '';
|
|
|
-
|
|
|
+ const provinceName = province ? province.areaName : '';
|
|
|
+
|
|
|
if (provinceName) {
|
|
|
if (!provinceMap.has(provinceName)) {
|
|
|
provinceMap.set(provinceName, new Set());
|
|
|
}
|
|
|
|
|
|
- if (cityName) {
|
|
|
- provinceMap.get(provinceName)!.add(cityName);
|
|
|
+ // 如果有城市代码,处理城市
|
|
|
+ if (cityCode) {
|
|
|
+ cityCodes.push(cityCode);
|
|
|
+ const city = province?.children?.find((c: any) => c.areaCode === cityCode);
|
|
|
+ const cityName = city ? city.areaName : '';
|
|
|
+
|
|
|
+ if (cityName) {
|
|
|
+ provinceMap.get(provinceName)!.add(cityName);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2565,7 +2598,11 @@ const extractRegionData = (selectedPaths: any[]) => {
|
|
|
|
|
|
provinceMap.forEach((citySet, provinceName) => {
|
|
|
provinces.push(provinceName);
|
|
|
- cities.push(Array.from(citySet).join(','));
|
|
|
+ if (citySet.size > 0) {
|
|
|
+ cities.push(Array.from(citySet).join(','));
|
|
|
+ } else {
|
|
|
+ cities.push(''); // 如果只选择了省份,城市为空
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
@@ -2585,62 +2622,49 @@ const findRegionName = (code: string, regions: any[]): string => {
|
|
|
/** 构建 areaList 数组 */
|
|
|
const buildAreaList = (selectedPaths: any[]) => {
|
|
|
const areaList: any[] = [];
|
|
|
- const provinceMap = new Map<string, Set<string>>(); // 省份代码 -> 城市代码集合
|
|
|
const addedProvinces = new Set<string>(); // 已添加的省份
|
|
|
+ const addedCities = new Set<string>(); // 已添加的城市
|
|
|
|
|
|
console.log('选中的路径:', selectedPaths);
|
|
|
|
|
|
- // 第一步:收集所有选中的省份和城市
|
|
|
selectedPaths.forEach(path => {
|
|
|
if (Array.isArray(path)) {
|
|
|
const provinceCode = path[0];
|
|
|
const cityCode = path[1];
|
|
|
|
|
|
- if (!provinceMap.has(provinceCode)) {
|
|
|
- provinceMap.set(provinceCode, new Set());
|
|
|
- }
|
|
|
+ // 查找省份信息
|
|
|
+ const province = supplyAreaOptions.value.find(p => p.areaCode === provinceCode);
|
|
|
|
|
|
- // 如果有城市代码,添加到集合中
|
|
|
- if (cityCode) {
|
|
|
- provinceMap.get(provinceCode)!.add(cityCode);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- console.log('省份映射:', Array.from(provinceMap.entries()));
|
|
|
-
|
|
|
- // 第二步:构建 areaList 数组
|
|
|
- provinceMap.forEach((cityCodes, provinceCode) => {
|
|
|
- // 查找省份信息
|
|
|
- const province = supplyAreaOptions.value.find(p => p.areaCode === provinceCode);
|
|
|
-
|
|
|
- if (province) {
|
|
|
- // 添加省份(每个省份只添加一次)
|
|
|
- if (!addedProvinces.has(provinceCode)) {
|
|
|
- areaList.push({
|
|
|
- areaCode: province.areaCode,
|
|
|
- areaName: province.areaName,
|
|
|
- level: 1
|
|
|
- });
|
|
|
- addedProvinces.add(provinceCode);
|
|
|
- }
|
|
|
-
|
|
|
- // 添加该省份下所有选中的城市
|
|
|
- cityCodes.forEach(cityCode => {
|
|
|
- const city = province.children?.find((c: any) => c.areaCode === cityCode);
|
|
|
-
|
|
|
- if (city) {
|
|
|
+ if (province) {
|
|
|
+ // 添加省份(每个省份只添加一次)
|
|
|
+ if (!addedProvinces.has(provinceCode)) {
|
|
|
areaList.push({
|
|
|
- areaCode: city.areaCode,
|
|
|
- areaName: city.areaName,
|
|
|
- parentCode: province.areaCode, // 使用省份的 areaCode 作为 parentCode
|
|
|
- level: 2
|
|
|
+ areaCode: province.areaCode,
|
|
|
+ areaName: province.areaName,
|
|
|
+ level: 1
|
|
|
});
|
|
|
+ addedProvinces.add(provinceCode);
|
|
|
}
|
|
|
- });
|
|
|
+
|
|
|
+ // 如果有城市代码,添加城市
|
|
|
+ if (cityCode) {
|
|
|
+ const city = province.children?.find((c: any) => c.areaCode === cityCode);
|
|
|
+
|
|
|
+ if (city && !addedCities.has(cityCode)) {
|
|
|
+ areaList.push({
|
|
|
+ areaCode: city.areaCode,
|
|
|
+ areaName: city.areaName,
|
|
|
+ parentCode: province.areaCode,
|
|
|
+ level: 2
|
|
|
+ });
|
|
|
+ addedCities.add(cityCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ console.log('构建的 areaList:', areaList);
|
|
|
return areaList;
|
|
|
};
|
|
|
|