修改自定义历史数据的处理逻辑

v1.1.0
于肖磊 2024-11-14 16:48:01 +08:00
parent b8cdc5844d
commit 4b229b9a0f
3 changed files with 90 additions and 85 deletions

View File

@ -51,8 +51,9 @@
</template>
</template>
<script setup lang="ts">
import { isEmpty } from 'lodash';
import { isEmpty, cloneDeep } from 'lodash';
import { common_img_computer, common_styles_computer } from '@/utils';
import { source_list } from '@/config/const/custom';
const props = defineProps({
value: {
@ -74,6 +75,21 @@ const state = reactive({
// 使toRefs
const { form, new_style } = toRefs(state);
onBeforeMount(() => {
if (!Object.keys(form.value.data_source_content).includes('data_auto_list') && !Object.keys(form.value.data_source_content).includes('data_list')) {
const data = cloneDeep(form.value.data_source_content);
const new_list = cloneDeep(source_list[form.value.data_source as keyof typeof source_list]);
if (!isEmpty(new_list)) {
form.value.data_source_content = new_list;
} else {
form.value.data_source_content = cloneDeep(source_list['common']);
}
if (!isEmpty(data)) {
form.value.data_source_content.data_list = [ data ];
}
}
});
const custom_height = computed(() => form.value.height * scale.value + 'px');
const div_width = ref(0);
const scale = ref(1);

View File

@ -66,6 +66,7 @@ import ArticleAPI from '@/api/article';
import BrandAPI from '@/api/brand';
import { commonStore, DataSourceStore } from '@/store';
import { get_math } from '@/utils';
import { source_list } from '@/config/const/custom';
const common_store = commonStore();
const data_source_store = DataSourceStore();
@ -111,19 +112,6 @@ const getCustominit = () => {
};
onBeforeMount(() => {
//
if (!Object.keys(form.data_source_content).includes('data_auto_list') && !Object.keys(form.data_source_content).includes('data_list')) {
const data = cloneDeep(form.data_source_content);
const new_list = cloneDeep(source_list[form.data_source as keyof typeof source_list]);
if (!isEmpty(new_list)) {
form.data_source_content = new_list;
} else {
form.data_source_content = cloneDeep(source_list['common']);
}
if (!isEmpty(data)) {
form.data_source_content.data_list = [ data ];
}
}
if (!data_source_store.is_data_source_api) {
data_source_store.set_is_data_source_api(true);
getCustominit();
@ -185,76 +173,6 @@ const accomplish = () => {
//#region
//
const url_value_dialog_visible = ref(false);
const source_list = {
goods: {
// id
data_ids: [],
//
data_list: [],
//
data_auto_list: [],
//
data_type: '0',
//
keyword: '',
//
category_ids: [],
//
brand_ids: [],
//
number: 4,
//
order_by_type: '0',
//
order_by_rule: '0',
},
article: {
// id
data_ids: [],
//
data_list: [],
//
data_auto_list: [],
data_type: '0',
//
keyword: '',
number: 4,
order_by_type: '0',
order_by_rule: '0',
//
is_cover: '0',
// id
category_ids: [],
},
brand: {
// id
data_ids: [],
//
data_list: [],
//
data_auto_list: [],
//
data_type: '0',
//
keyword: '',
//
category_ids: [],
//
number: 4,
//
order_by_type: '0',
//
order_by_rule: '0',
},
common: {
// id
data_ids: [],
//
data_list: [],
//
data_auto_list: [],
}
};
const changeDataSource = (key: string) => {
const type_data = options.value.filter((item) => item.type == key);
processing_data(key);

View File

@ -3,7 +3,8 @@ interface content {
data_ids: Array<string>;
data_list: Array<object>;
data_auto_list: Array<object>;
}interface defaultSearch {
}
interface defaultSearch {
content: {
height: number;
data_source: string;
@ -14,6 +15,76 @@ interface content {
common_style: object;
};
}
export const source_list = {
goods: {
// 存放手动输入的id
data_ids: [],
// 手动输入
data_list: [],
// 自动
data_auto_list: [],
// 商品类型
data_type: '0',
// 关键字
keyword: '',
// 商品分类
category_ids: [],
// 品牌
brand_ids: [],
// 显示数量
number: 4,
// 排序类型
order_by_type: '0',
// 排序规则
order_by_rule: '0',
},
article: {
// 存放手动输入的id
data_ids: [],
// 手动输入
data_list: [],
// 自动
data_auto_list: [],
data_type: '0',
// 关键字
keyword: '',
number: 4,
order_by_type: '0',
order_by_rule: '0',
// 文章封面
is_cover: '0',
// 分类id
category_ids: [],
},
brand: {
// 存放手动输入的id
data_ids: [],
// 手动输入
data_list: [],
// 自动
data_auto_list: [],
// 商品类型
data_type: '0',
// 关键字
keyword: '',
// 商品分类
category_ids: [],
// 显示数量
number: 4,
// 排序类型
order_by_type: '0',
// 排序规则
order_by_rule: '0',
},
common: {
// 存放手动输入的id
data_ids: [],
// 手动输入
data_list: [],
// 自动
data_auto_list: [],
}
};
const defaultSearch: defaultSearch = {
content: {
// 自定义内容高度