diff --git a/components.d.ts b/components.d.ts index 3057c17..11049e1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,12 +10,23 @@ declare module 'vue' { Application: typeof import('./src/components/Application/Application.vue')['default'] BasicModal: typeof import('./src/components/Modal/BasicModal.vue')['default'] DataHeader: typeof import('./src/components/DataHeader/index.vue')['default'] + NAvatar: typeof import('naive-ui')['NAvatar'] NButton: typeof import('naive-ui')['NButton'] + NCard: typeof import('naive-ui')['NCard'] NCheckbox: typeof import('naive-ui')['NCheckbox'] + NCollapse: typeof import('naive-ui')['NCollapse'] + NCollapseItem: typeof import('naive-ui')['NCollapseItem'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] + NDatePicker: typeof import('naive-ui')['NDatePicker'] NDialogProvider: typeof import('naive-ui')['NDialogProvider'] + NDivider: typeof import('naive-ui')['NDivider'] + NDropdown: typeof import('naive-ui')['NDropdown'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] + NGi: typeof import('naive-ui')['NGi'] + NGrid: typeof import('naive-ui')['NGrid'] + NGridItem: typeof import('naive-ui')['NGridItem'] + NImage: typeof import('naive-ui')['NImage'] NInput: typeof import('naive-ui')['NInput'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] diff --git a/src/store/modules/final.ts b/src/store/modules/final.ts index 629deec..e0b3ddb 100644 --- a/src/store/modules/final.ts +++ b/src/store/modules/final.ts @@ -82,29 +82,24 @@ export const useFinalStore = defineStore({ }, // 获取系统配置信息 async fetchConfig() { - const response = await getConfig() - console.log("response.data----------", response.data); - this.setSystemConfig(response.data) - return response.data + // const response = await getConfig() + // console.log("response.data----------", response.data); + // this.setSystemConfig(response.data) + // return response.data + let list: any = {}; + let tempAsideMap = cloneDeep(asideMap); + Object.keys(tempAsideMap).map(key => { + list[key] = "Y"; + }); + console.log("setSystemConfig---------------", list); + this.setSystemConfig(list); + return list }, // // 获取终审个性化配置 - // async fetchCustomConfig() { - // const res = await getFilter(1) - // const { data } = res - // const list = data && data.searchcount ? data.searchcount.split(',') : []; - // console.log("listkey---------------", list); - // this.customConfig = list - // return list - // }, - // 获取终审个性化配置 async fetchCustomConfig() { - let list: any = []; - let tempAsideMap = cloneDeep(asideMap); - Object.keys(tempAsideMap).map(key => { - if(!tempAsideMap[key].isDefaultFilter) { - list.push(key); - } - }); + const res = await getFilter(1) + const { data } = res + const list = data && data.searchcount ? data.searchcount.split(',') : []; console.log("listkey---------------", list); this.customConfig = list return list diff --git a/src/views/final/aside/Aside.vue b/src/views/final/aside/Aside.vue index 79c70cd..fef3aef 100644 --- a/src/views/final/aside/Aside.vue +++ b/src/views/final/aside/Aside.vue @@ -36,6 +36,7 @@ const showItems = shallowRef<{ key: string; config: AsideEntity }[]>([]); const initAsideValueRef = ref(null); // 所有左侧模块的值(初始值) const customObjRef = ref(null); // 获取高级筛选获取的值 const customTempObjRef = ref(null); // 获取高级筛选获取的值(作对比) +const configFilterRef = ref([]); // 获取排序的值 initAsideValueRef.value = cloneDeep(asideMap); @@ -113,36 +114,128 @@ onBeforeMount(async () => { nextTick(()=>{ finalStore.$subscribe(() => { + // const customConfig = finalStore.getCustomConfig; + // console.log("customConfig订阅aside---------------", customConfig); + // if (customConfig === null) return; + + // const showKeys: string[] = [...customConfig]; + // // const defaultKeys = Object.keys(asideMap).filter( + // // (key) => asideMap[key].isDefaultFilter + // // ); + // // showKeys.unshift(...defaultKeys); + + // Object.keys(asideMap).forEach((key) => { + // // 设置显示的或者默认显示的 + // if (key.startsWith("iz")) + // asideVisible[key] = + // asideMap[key] && (showKeys.includes(key) || asideMap[key].isDefaultFilter); + // }); + + // const items = showKeys.reduce((acc, key) => { + // if (asideMap[key]) { + // const config = { + // key, + // config: asideMap[key], + // }; + // return [...acc, config]; + // } else { + // return acc; + // } + // }, []); + // console.log("showItems111111111---------------", items); + // showItems.value = items; + const config = finalStore.getSystemConfig; const customConfig = finalStore.getCustomConfig; - console.log("customConfig111111111---------------", customConfig); - if (customConfig === null) return; - - const showKeys: string[] = [...customConfig]; - const defaultKeys = Object.keys(asideMap).filter( - (key) => asideMap[key].isDefaultFilter - ); - showKeys.unshift(...defaultKeys); - - Object.keys(asideMap).forEach((key) => { - // 设置显示的或者默认显示的 - if (key.startsWith("iz")) - asideVisible[key] = - asideMap[key] && (showKeys.includes(key) || asideMap[key].isDefaultFilter); + if ( + configFilterRef.value.length > 0 && + isEqual(configFilterRef.value, finalStore.getFilterConfig) && + customObjRef.value && + isEqual(customObjRef.value, customTempObjRef.value) + ) { + return; + } + if (config == null || customConfig == null) return; + // console.log("config", config, "customConfig", customConfig); + /* rao + const showKeys = [...customConfig].filter(key => !asideMap[key].isDefaultFilter)// 获取customConfig 非isDefaultFilter的选项 + const defaultKeys = Object.keys(asideMap).filter(key => asideMap[key].isDefaultFilter)// 获取asideMap isDefaultFilter的选项 + showKeys.unshift(...defaultKeys) + */ + + let sortKeyList: any = []; + finalStore.getFilterConfig.map((item: any) => { + sortKeyList.push(item?.id); }); + const showKeys = [...sortKeyList]; + Object.keys(config).forEach((key) => { + if (key.startsWith("iz") && asideMap[key] !== undefined) + asideVisible[key] = + (showKeys.includes(key) || asideMap[key].isDefaultFilter) && config[key] === "Y"; + }); + if (customObjRef.value) { + // 赋值 + Object.keys(customObjRef.value).map((key) => { + if (asideMap.hasOwnProperty(key)) { + const str = key.toLowerCase(); + // console.log("customObjRef.value[str]1111111111111", customObjRef.value[str]); + if (str == "izsimilarity") { + if (typeof customObjRef.value[str] == "string") { + customObjRef.value[str] = customObjRef.value[str].split(","); + } + asideValue[key] = customObjRef.value[str]; // 赋值 + console.log("相似度2222222222", asideValue[key]); + } else if (str == "izyear") { + if (typeof customObjRef.value[str] == "string") { + let time = customObjRef.value[str].split("-"); + time[0] = new Date(time[0]).getTime(); + time[1] = new Date(time[1]).getTime(); + customObjRef.value[str] = time; + } + asideValue[key] = customObjRef.value[str]; // 赋值 + console.log("时间2222222222", asideValue[key]); + } else if (customObjRef.value[str]) { + console.log("customObjRef.value[str]222222", customObjRef.value[str]); + // let list = customObjRef.value[str].split(','); + // console.log("list222222", list); + if (typeof customObjRef.value[str] == "string") { + customObjRef.value[str] = customObjRef.value[str].split(","); + asideValue[key] = customObjRef.value[str]; // 赋值 + }else { + asideValue[key] = customObjRef.value[str]; // 赋值 + } + } else { + asideValue[key] = null; + } + // asideMap[str].defaultValue = customObjRef.value[str];// 赋值 + } + }); + customTempObjRef.value = customObjRef.value; + console.log("asideValue直接处理后的结果", asideValue); + console.log("customTempObjRef.value", customTempObjRef.value); + let tempobj = cloneDeep(asideValue); + console.log("tempObj", tempobj); + finalStore.setAsideValue(tempobj); + } + // console.log("showKeys", showKeys); const items = showKeys.reduce((acc, key) => { - if (asideMap[key]) { - const config = { - key, - config: asideMap[key], + const currentData = asideMap[key]; + const render = currentData?.render; + if (render !== false) { + const str = key?.toLowerCase(); + + const o = { + key: str, + config: asideMap[str], }; - return [...acc, config]; + return [...acc, o]; } else { return acc; } }, []); - console.log("showItems111111111---------------", items); + console.log("showItems=================================", items); showItems.value = items; + configFilterRef.value = finalStore.getFilterConfig; }); }) @@ -197,9 +290,9 @@ function editFilter(filter: any) { modal.edit(filter); } -watch(asideValue, (newVal) => { - finalStore.setAsideValue(newVal); -}); +// watch(asideValue, (newVal) => { +// finalStore.setAsideValue(newVal); +// }); const inputChange = (keyword) => { emit("inputChange", keyword); @@ -214,6 +307,21 @@ const handleOk = (item: any) => { filterHandler(""); } }; + +function updateComponent(key, e) { + console.log("跟新值", key, e); + console.log("tempAsideValue跟新值", finalStore.getAsideValue, asideValue); + // let tempAsideValue = finalStore.getAsideValue || asideValue; + let tempobj = cloneDeep(asideValue); + console.log(tempobj, "tempobj"); + tempobj[key] = e; + console.log(tempobj, "tempobj After"); + customObjRef.value = tempobj; + // asideValue = Object.assign({}, asideValue, tempobj); + console.log("asideValue跟新值", tempobj); + finalStore.setAsideValue(tempobj); +} +