数据模块优化:实现goodsIDs和dataIDs的处理

在数据模块的组件中,goods_list和data_list属性现在将仅保存从后端获取的相关ID。这些ID将分别存储在新的goods_ids和data_ids属性中,以简化前端处理。该更改旨在提高数据处理效率,并为后续流程如预览和保存提供更简洁的数据结构。
v1.0.0
sws 2024-09-05 16:48:13 +08:00
parent bb65290daf
commit 7b19f1c7e5
3 changed files with 17 additions and 10 deletions

View File

@ -97,6 +97,7 @@ const data_content = {
heading_title: '主标题',
subtitle: '副标题',
goods_list:[],
goods_ids: '',
is_show: ['title', 'price'],
images_list:[
{

View File

@ -8,6 +8,7 @@ interface DefaultCoupon {
title: string;
desc: string;
data_list: object[];
data_ids: string;
};
style: {
price_color: string;
@ -41,6 +42,7 @@ const defaultCoupoin: DefaultCoupon = {
// 只有主题4用到
desc: '领券下单·享购物优惠',
data_list: [],
data_ids: '',
},
style: {
price_color: '#FF3830',

View File

@ -116,6 +116,7 @@ const init = () => {
DiyAPI.getInit({ id: get_id() }).then((res: any) => {
if (res.data) {
form.value = form_data_transfor_diy_data(res.data);
console.log(form.value);
} else {
is_empty.value = true;
}
@ -131,13 +132,6 @@ const init = () => {
//
const common_init = () => {
CommonAPI.getInit().then((res: any) => {
// article_category ----
// attachment_category ----
// brand_category; ----
// brand_list ----
// goods_category ----
// module_list ----
//page_link_list ----
common_store.set_common(res.data);
api_count.value += 1;
loading_event(api_count.value);
@ -159,16 +153,26 @@ const preview = () => {
console.log('预览');
};
const save = () => {
formmat_form_data(form.value);
save_formmat_form_data(form.value);
};
const save_close = () => {
formmat_form_data(form.value, true);
save_formmat_form_data(form.value, true);
};
const formmat_form_data = (data: diy_data_item, close: boolean = false) => {
const save_formmat_form_data = (data: diy_data_item, close: boolean = false) => {
const clone_form = cloneDeep(data);
clone_form.header.show_tabs = '1';
clone_form.footer.show_tabs = '0';
const new_array = ['goods-list', 'goods-tabs', 'article-list', 'article-tabs', 'coupon'];
clone_form.diy_data = clone_form.diy_data.map((item: any) => {
if (new_array.includes(item.key)) {
item.com_data.content.data_ids = item.com_data.content.data_list.map((item: any) => item.data.id).join(',') || '';
item.com_data.content.data_list = [];
} else if (item.key == 'data-magic') {
item.com_data.content.data_magic_list.map((item1: any) => {
item1.goods_ids = item.goods_list.map((item2: any) => item2.data.id).join(',') || '';
item1.goods_list = [];
});
}
return {
...item,
show_tabs: '0',