修改数据处理

This commit is contained in:
于肖磊
2026-06-05 12:03:04 +08:00
parent 816c2bf26f
commit a619a5d6ab
5 changed files with 59 additions and 50 deletions

View File

@ -51,6 +51,17 @@ const props = defineProps({
default: false,
},
});
const modelValue = defineModel({ type: Object, default: {} });
const table_data = ref<pageLinkList[]>([]);
const new_table_data = ref<pageLinkList[]>([]);
const search_value = ref('');
const template_selection = ref('');
const resetFields = () => {
template_selection.value = '';
search_value.value = '';
table_data.value = common_store.common.goods_category;
new_table_data.value = common_store.common.goods_category;
};
watch(
() => props.loadStamp,
(val, oldVal) => {
@ -65,16 +76,6 @@ watch(
resetFields();
},
);
const modelValue = defineModel({ type: Object, default: {} });
const table_data = ref<pageLinkList[]>([]);
const new_table_data = ref<pageLinkList[]>([]);
const search_value = ref('');
const resetFields = () => {
template_selection.value = '';
search_value.value = '';
table_data.value = common_store.common.goods_category;
new_table_data.value = common_store.common.goods_category;
};
// 筛选
const handle_search = () => {
// 根据关键词过滤new_table_data数据,如果==父级 显示父级和父级下的所有子级数据,
@ -121,8 +122,6 @@ const filterData = (input: string, data: pageLinkList[]) => {
return result;
};
const template_selection = ref('');
const row_click = (row: any) => {
let new_data: pageLinkList[] = [];
// 多级数组转换一级数组

View File

@ -91,21 +91,6 @@ watch(
on_submit();
}
);
watch(
() => props.loadStamp,
(val, oldVal) => {
if (!val || val === oldVal) return;
init();
},
{ immediate: true },
);
watch(
() => props.reset,
() => {
reset_data();
custom_type_active.value = 0;
},
);
const emit = defineEmits(['update:link', 'type']);
const reset_data = () => {
@ -127,6 +112,25 @@ const init = () => {
goods_category_data.value = common_store.common.goods_category;
brand_data.value = common_store.common.brand_list;
};
watch(
() => props.loadStamp,
(val, oldVal) => {
if (!val || val === oldVal) return;
init();
},
);
onMounted(() => {
if (props.loadStamp > 0) {
init();
}
});
watch(
() => props.reset,
() => {
reset_data();
custom_type_active.value = 0;
},
);
const custom_type = [
{ id: 0, name: '商品分类' },
{ id: 1, name: '品牌' },

View File

@ -32,8 +32,6 @@
</div>
</template>
<script lang="ts" setup>
import { useLinkPickerLoad } from '@/hooks/use-link-picker-load';
import { toRef } from 'vue';
import { commonStore } from '@/store';
const common_store = commonStore();
const props = defineProps({
@ -53,24 +51,11 @@ const props = defineProps({
},
});
watch(
() => props.loadStamp,
(val, oldVal) => {
if (!val || val === oldVal) return;
resetFields();
},
{ immediate: true },
);
watch(
() => props.reset,
() => {
resetFields();
},
);
const modelValue = defineModel({ type: Array, default: [] });
const search_value = ref('');
const base_data = ref<pageLinkList[]>([]);
const new_base_data = ref<pageLinkList[]>([]);
const menu_active = ref('');
const resetFields = () => {
menu_active.value = '';
search_value.value = '';
@ -86,6 +71,20 @@ const resetFields = () => {
new_base_data.value = [];
}
};
watch(
() => props.loadStamp,
(val, oldVal) => {
if (!val || val === oldVal) return;
resetFields();
},
{ immediate: true },
);
watch(
() => props.reset,
() => {
resetFields();
},
);
const handle_search = () => {
// 根据关键词过滤new_base_data数据,如果==父级 显示父级和父级下的所有子级数据,
@ -117,7 +116,6 @@ const filterData = (input: string, data: pageLinkList[]) => {
return result;
};
const menu_active = ref('');
const emit = defineEmits(['update:link']);
const menu_link_event = (item: any) => {
if (item.page == menu_active.value) {

View File

@ -66,10 +66,10 @@
<link-plugins-live v-model="link_value" :select-is-url="selectIsUrl" :multiple="multiple" :reset="reset_compontent" :load-stamp="load_stamp"></link-plugins-live>
</template>
<template v-else-if="link_select == 'plugins_groupbuy'">
<link-plugins-groupbuy v-model="link_value" :select-is-url="selectIsUrl" :multiple="multiple" :reset="reset_compontent" :load-stamp="load_stamp"></link-plugins-groupbuy>
<link-plugins-groupbuy :key="`plugins_groupbuy-${load_stamp}`" v-model="link_value" :select-is-url="selectIsUrl" :multiple="multiple" :reset="reset_compontent" :load-stamp="load_stamp"></link-plugins-groupbuy>
</template>
<template v-else-if="link_select == 'plugins_bargain'">
<link-plugins-bargain v-model="link_value" :select-is-url="selectIsUrl" :multiple="multiple" :reset="reset_compontent" :load-stamp="load_stamp"></link-plugins-bargain>
<link-plugins-bargain :key="`plugins_bargain-${load_stamp}`" v-model="link_value" :select-is-url="selectIsUrl" :multiple="multiple" :reset="reset_compontent" :load-stamp="load_stamp"></link-plugins-bargain>
</template>
<template v-else-if="!isEmpty(link_url)">
<!-- 商品页面 -->
@ -147,7 +147,7 @@ watch(dialogVisible, (visible) => {
if (visible) {
load_stamp.value += 1;
}
});
}, { flush: 'sync' });
const custom_link_type = ref(props.type);
const base_data = ref<any[]>([]);
watch(

View File

@ -1,4 +1,4 @@
import { nextTick, ref, watch, type Ref } from 'vue';
import { nextTick, onMounted, ref, watch, type Ref } from 'vue';
/**
* 链接选择弹窗列表加载:打开时拉取一次,关闭仅重置表单;避免分页初始事件重复请求
@ -27,15 +27,23 @@ export function useLinkPickerLoad(options: {
});
};
/** destroy-on-close 下子组件挂载时 loadStamp 可能尚未递增,挂载后再补一次拉取 */
onMounted(() => {
nextTick(() => {
if (options.loadStamp.value > 0) {
loadFirstPage();
}
});
});
watch(
options.loadStamp,
() => options.loadStamp.value,
(val, oldVal) => {
if (!val || val === oldVal) {
return;
}
loadFirstPage();
},
{ immediate: true },
);
watch(options.resetFlag, () => {