|
@@ -58,6 +58,7 @@
|
|
const { deptList, currentId } = storeToRefs(useShopInfoStore());
|
|
const { deptList, currentId } = storeToRefs(useShopInfoStore());
|
|
const { close: closeTab } = useTabs();
|
|
const { close: closeTab } = useTabs();
|
|
const isSubmit = ref(false);
|
|
const isSubmit = ref(false);
|
|
|
|
+ const uploadId = ref<any>();
|
|
const formSchema: FormSchema[] = [
|
|
const formSchema: FormSchema[] = [
|
|
{
|
|
{
|
|
field: 'name',
|
|
field: 'name',
|
|
@@ -180,25 +181,34 @@
|
|
}
|
|
}
|
|
async function getQueryData(id) {
|
|
async function getQueryData(id) {
|
|
const res = await queryById({ siteId: id });
|
|
const res = await queryById({ siteId: id });
|
|
- if (!res.siteCategoryRuleDTOS) {
|
|
|
|
|
|
+ if (!res.appSitePlaceCuDTO || !res.appSiteCategoryRuleDTOS) {
|
|
isUpdate.value = false;
|
|
isUpdate.value = false;
|
|
} else {
|
|
} else {
|
|
isUpdate.value = true;
|
|
isUpdate.value = true;
|
|
- console.log(res, '打印');
|
|
|
|
- const categoryIdList = res.siteCategoryRuleDTOS.map((it) => it.categoryId);
|
|
|
|
- const formData = res.siteCategoryRuleDTOS.map((it) => reverseTransformData(it.appSiteRuleDTOList));
|
|
|
|
|
|
+ const categoryIdList = res.appSiteCategoryRuleDTOS.map((it) => it.categoryId);
|
|
|
|
+ const newDATA: any = [];
|
|
|
|
+ const categoryId: any = [];
|
|
|
|
+ res.appSiteCategoryRuleDTOS.map((it) => {
|
|
|
|
+ newDATA.push(
|
|
|
|
+ ...it.appSiteRuleTimeFormDTOList.map((its) => {
|
|
|
|
+ categoryId.push({ [it.categoryId]: its.id });
|
|
|
|
+ return { ...reverseTransformData([...its.appSiteRuleDTOList]) };
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+ });
|
|
const filed = {
|
|
const filed = {
|
|
categoryId: categoryIdList,
|
|
categoryId: categoryIdList,
|
|
buyLimit: res.appSitePlaceCuDTO.buyLimit,
|
|
buyLimit: res.appSitePlaceCuDTO.buyLimit,
|
|
earlyRefundTime: res.appSitePlaceCuDTO.earlyRefundTime,
|
|
earlyRefundTime: res.appSitePlaceCuDTO.earlyRefundTime,
|
|
reminder: res.appSitePlaceCuDTO.reminder,
|
|
reminder: res.appSitePlaceCuDTO.reminder,
|
|
};
|
|
};
|
|
|
|
+ const newData = mergeSameKeys(newDATA);
|
|
|
|
+ uploadId.value = mergeSameKeysIds(categoryId);
|
|
categoryIdList.forEach((it, idx) => {
|
|
categoryIdList.forEach((it, idx) => {
|
|
- filed[it] = formData[idx][it];
|
|
|
|
- filed[`inventory${idx}`] = res.siteCategoryRuleDTOS[idx].count;
|
|
|
|
|
|
+ filed[it] = newData[it];
|
|
|
|
+ filed[`inventory${idx}`] = res.appSiteCategoryRuleDTOS[idx].count;
|
|
});
|
|
});
|
|
setFieldsValue(filed);
|
|
setFieldsValue(filed);
|
|
- console.log(filed, 'filed');
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
async function getBusinessData() {
|
|
async function getBusinessData() {
|
|
@@ -220,7 +230,6 @@
|
|
async function save() {
|
|
async function save() {
|
|
const form = await getFieldsValue();
|
|
const form = await getFieldsValue();
|
|
await validate();
|
|
await validate();
|
|
- // console.log(validateInventoryFields(form));
|
|
|
|
if (!validateInventoryFields(form)) return message.error('请填写完整包场时间');
|
|
if (!validateInventoryFields(form)) return message.error('请填写完整包场时间');
|
|
const categoryList = form.categoryId.split(',');
|
|
const categoryList = form.categoryId.split(',');
|
|
const newObj = {
|
|
const newObj = {
|
|
@@ -236,9 +245,8 @@
|
|
categoryId: it,
|
|
categoryId: it,
|
|
count: form[`inventory${idx}`],
|
|
count: form[`inventory${idx}`],
|
|
appSiteRuleTimeFormDTOList: appSiteRuleTimeFormDTOList.map((formDtoList, index) => {
|
|
appSiteRuleTimeFormDTOList: appSiteRuleTimeFormDTOList.map((formDtoList, index) => {
|
|
- console.log(index, '当前循环');
|
|
|
|
-
|
|
|
|
return {
|
|
return {
|
|
|
|
+ id: uploadId.value ? uploadId.value[it][index] : null,
|
|
startTime: formDtoList.time[0],
|
|
startTime: formDtoList.time[0],
|
|
endTime: formDtoList.time[1],
|
|
endTime: formDtoList.time[1],
|
|
appSiteRuleDTOList: transformData([appSiteRuleTimeFormDTOList[index]], it),
|
|
appSiteRuleDTOList: transformData([appSiteRuleTimeFormDTOList[index]], it),
|
|
@@ -247,8 +255,8 @@
|
|
};
|
|
};
|
|
}),
|
|
}),
|
|
};
|
|
};
|
|
- console.log(newObj, '打印');
|
|
|
|
isSubmit.value = true;
|
|
isSubmit.value = true;
|
|
|
|
+ // return;
|
|
try {
|
|
try {
|
|
await saveOrUpdate(newObj, isUpdate.value);
|
|
await saveOrUpdate(newObj, isUpdate.value);
|
|
isSubmit.value = false;
|
|
isSubmit.value = false;
|
|
@@ -366,6 +374,7 @@
|
|
});
|
|
});
|
|
function reverseTransformData(transformedData: TransformedItem[]): Record<string, OriginalItem[]> {
|
|
function reverseTransformData(transformedData: TransformedItem[]): Record<string, OriginalItem[]> {
|
|
const groupedByTime: Record<string, TransformedItem[]> = {};
|
|
const groupedByTime: Record<string, TransformedItem[]> = {};
|
|
|
|
+ console.log(transformedData, 'transformedData');
|
|
|
|
|
|
// 首先按时间分组数据
|
|
// 首先按时间分组数据
|
|
transformedData.forEach((item) => {
|
|
transformedData.forEach((item) => {
|
|
@@ -406,14 +415,42 @@
|
|
// 添加每天的价格信息
|
|
// 添加每天的价格信息
|
|
categoryItems.forEach((item) => {
|
|
categoryItems.forEach((item) => {
|
|
const dayKey = `day${item.dayOfWeek}` as keyof OriginalItem;
|
|
const dayKey = `day${item.dayOfWeek}` as keyof OriginalItem;
|
|
- originalItem[dayKey] = item.sellingPrice;
|
|
|
|
- originalItem[`dayId${item.dayOfWeek}`] = item.batchuuid;
|
|
|
|
|
|
+ originalItem[dayKey] = Number(item.sellingPrice);
|
|
});
|
|
});
|
|
|
|
|
|
result[categoryId].push(originalItem);
|
|
result[categoryId].push(originalItem);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ function mergeSameKeys(data: Record<string, any[]>[]): Record<string, any[]> {
|
|
|
|
+ const result: Record<string, any[]> = {};
|
|
|
|
+
|
|
|
|
+ data.forEach((item) => {
|
|
|
|
+ Object.keys(item).forEach((key) => {
|
|
|
|
+ if (!result[key]) {
|
|
|
|
+ result[key] = [];
|
|
|
|
+ }
|
|
|
|
+ // 合并数组
|
|
|
|
+ result[key] = [...result[key], ...item[key]];
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ function mergeSameKeysIds(data: Record<string, string>[]): Record<string, string[]> {
|
|
|
|
+ const result: Record<string, string[]> = {};
|
|
|
|
+
|
|
|
|
+ data.forEach((item) => {
|
|
|
|
+ Object.keys(item).forEach((key) => {
|
|
|
|
+ if (!result[key]) {
|
|
|
|
+ result[key] = [];
|
|
|
|
+ }
|
|
|
|
+ result[key].push(item[key]);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|