|
|
@ -22,6 +22,8 @@ import type { AsideEntity } from "@/config/aside";
|
|
|
|
import { asideMap } from "@/config/final";
|
|
|
|
import { asideMap } from "@/config/final";
|
|
|
|
import type { AsideConfig } from "/#/api";
|
|
|
|
import type { AsideConfig } from "/#/api";
|
|
|
|
import emitter from "@/utils/mitt";
|
|
|
|
import emitter from "@/utils/mitt";
|
|
|
|
|
|
|
|
import { cloneDeep, isEqual } from "lodash-es";
|
|
|
|
|
|
|
|
import { getFilterList } from "@/api/home/main";
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(["inputChange"]);
|
|
|
|
const emit = defineEmits(["inputChange"]);
|
|
|
|
const finalStore = useFinal();
|
|
|
|
const finalStore = useFinal();
|
|
|
@ -40,6 +42,9 @@ Object.keys(asideMap).forEach((key) => {
|
|
|
|
const filterModalRef:any = ref(null);
|
|
|
|
const filterModalRef:any = ref(null);
|
|
|
|
const newFilterModalRef = ref(null);
|
|
|
|
const newFilterModalRef = ref(null);
|
|
|
|
const customModalRef = ref(null);
|
|
|
|
const customModalRef = ref(null);
|
|
|
|
|
|
|
|
const customObjRef = ref<any>(null); // 获取高级筛选获取的值
|
|
|
|
|
|
|
|
const customTempObjRef = ref<any>(null); // 获取高级筛选获取的值(作对比)
|
|
|
|
|
|
|
|
const configFilterRef = ref<any>([]); // 获取排序的值
|
|
|
|
const AdvanceFilterRef: any = ref(null);
|
|
|
|
const AdvanceFilterRef: any = ref(null);
|
|
|
|
|
|
|
|
|
|
|
|
function showModal(modalRef: any) {
|
|
|
|
function showModal(modalRef: any) {
|
|
|
@ -61,6 +66,7 @@ mousetrap.bind("[", collapseHandler);
|
|
|
|
onMounted(() => {
|
|
|
|
onMounted(() => {
|
|
|
|
nextTick(() => {
|
|
|
|
nextTick(() => {
|
|
|
|
computeSlideHeight();
|
|
|
|
computeSlideHeight();
|
|
|
|
|
|
|
|
// let tempAsideValue = cloneDeep(asideValue);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -96,40 +102,96 @@ function computeSlideHeight() {
|
|
|
|
useWindowSizeFn(computeSlideHeight, 280);
|
|
|
|
useWindowSizeFn(computeSlideHeight, 280);
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
onBeforeMount(async () => {
|
|
|
|
|
|
|
|
finalStore.fetchConfig();
|
|
|
|
finalStore.fetchCustomConfig();
|
|
|
|
finalStore.fetchCustomConfig();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
finalStore.$subscribe(() => {
|
|
|
|
nextTick(()=>{
|
|
|
|
const customConfig = finalStore.getCustomConfig;
|
|
|
|
finalStore.$subscribe(() => {
|
|
|
|
|
|
|
|
const config = finalStore.getConfig;
|
|
|
|
if (customConfig === null) return;
|
|
|
|
const customConfig = finalStore.getCustomConfig;
|
|
|
|
|
|
|
|
console.log("customConfig", customConfig, config);
|
|
|
|
const showKeys: string[] = [...customConfig];
|
|
|
|
console.log("configFilterRef", configFilterRef.value, finalStore.getFilterConfig);
|
|
|
|
const defaultKeys = Object.keys(asideMap).filter(
|
|
|
|
console.log("customObjRef", customObjRef.value, customTempObjRef.value);
|
|
|
|
(key) => asideMap[key].isDefaultFilter
|
|
|
|
if (
|
|
|
|
);
|
|
|
|
configFilterRef.value.length > 0 &&
|
|
|
|
showKeys.unshift(...defaultKeys);
|
|
|
|
isEqual(configFilterRef.value, finalStore.getFilterConfig) &&
|
|
|
|
|
|
|
|
customObjRef.value &&
|
|
|
|
Object.keys(asideMap).forEach((key) => {
|
|
|
|
isEqual(customObjRef.value, customTempObjRef.value)
|
|
|
|
// 设置显示的或者默认显示的
|
|
|
|
) {
|
|
|
|
if (key.startsWith("iz"))
|
|
|
|
return;
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
if (config == null || customConfig == null) return;
|
|
|
|
|
|
|
|
// console.log("config", config, "customConfig", customConfig);
|
|
|
|
showItems.value = items;
|
|
|
|
/* 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();
|
|
|
|
|
|
|
|
if (str == "izsimilarity") {
|
|
|
|
|
|
|
|
if (typeof customObjRef.value[str] == "string") {
|
|
|
|
|
|
|
|
customObjRef.value[str] = customObjRef.value[str].split(",");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
asideValue[key] = customObjRef.value[str]; // 赋值
|
|
|
|
|
|
|
|
} 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]; // 赋值
|
|
|
|
|
|
|
|
} else if (str != "izsimilarity" && str != "izyear" && customObjRef.value[str]) {
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const items = showKeys.reduce((acc, 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, o];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
console.log("showItems=================================", items);
|
|
|
|
|
|
|
|
showItems.value = items;
|
|
|
|
|
|
|
|
configFilterRef.value = finalStore.getFilterConfig;
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
watch(asideVisible, (newVal) => {
|
|
|
|
watch(asideVisible, (newVal) => {
|
|
|
@ -159,7 +221,20 @@ function scrollHandler(key: string) {
|
|
|
|
element?.scrollIntoView(true);
|
|
|
|
element?.scrollIntoView(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function filterHandler(searchId: string) {
|
|
|
|
async function filterHandler(searchId: string) {
|
|
|
|
|
|
|
|
const res = await getFilterList({ userSearchId: searchId });
|
|
|
|
|
|
|
|
if (res.code == "OK") {
|
|
|
|
|
|
|
|
let obj = res.data;
|
|
|
|
|
|
|
|
customObjRef.value = res.data;
|
|
|
|
|
|
|
|
let showKeys: any[] = [];
|
|
|
|
|
|
|
|
Object.keys(obj).map((key) => {
|
|
|
|
|
|
|
|
if (asideMap.hasOwnProperty(key)) {
|
|
|
|
|
|
|
|
showKeys.push(key);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// console.log(showKeys);
|
|
|
|
|
|
|
|
finalStore.setCustomConfig(showKeys);
|
|
|
|
|
|
|
|
}
|
|
|
|
emitter.emit("filter-final", searchId);
|
|
|
|
emitter.emit("filter-final", searchId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -169,6 +244,20 @@ function editFilter(filter: any) {
|
|
|
|
modal.edit(filter);
|
|
|
|
modal.edit(filter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
watch(asideValue, (newVal) => {
|
|
|
|
watch(asideValue, (newVal) => {
|
|
|
|
finalStore.setAsideValue(newVal);
|
|
|
|
finalStore.setAsideValue(newVal);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -225,9 +314,10 @@ const handleOk = (item: any) => {
|
|
|
|
:is="item.config.component"
|
|
|
|
:is="item.config.component"
|
|
|
|
v-for="(item, index) in showItems"
|
|
|
|
v-for="(item, index) in showItems"
|
|
|
|
:id="item.key"
|
|
|
|
:id="item.key"
|
|
|
|
:key="index"
|
|
|
|
:key="item.key"
|
|
|
|
v-model:value="asideValue[item.key]"
|
|
|
|
v-model:value="asideValue[item.key]"
|
|
|
|
:label="item.config.label"
|
|
|
|
:label="item.config.label"
|
|
|
|
|
|
|
|
@update:value="(e) => updateComponent(item.key, e)"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 筛选 -->
|
|
|
|
<!-- 筛选 -->
|
|
|
|