export interface LocalShowList_intf {
    label?: string;
    key: string;
    isFixed?: boolean;
    isActive?: boolean;
    isLinked?: boolean;
    // 用于多语言 设置 对应locales对象
    labelLanguage?: string;
    [key: string]: any;
}
import { ref } from 'vue';

// 用于处理搜索条件
const useListFormItem = (props: LocalShowList_intf[]) => {
    const formItems = ref<LocalShowList_intf[]>();
    formItems.value = props.slice();

    const DeepCloneFromItem = JSON.parse(JSON.stringify(formItems.value));
    //   queryParam是搜索方案点击后存储的搜索条件
    const handleSearchCase = (queryParam: any) => {
        const showFormItems: any = [];
        const queryParamKeys = Object.keys(queryParam);
        DeepCloneFromItem.forEach((item: LocalShowList_intf) => {
            if (queryParamKeys.includes(item.key)) {
                showFormItems.push(item);
            }
        });
        formItems.value = showFormItems;
    };

    return {
        formItems,
        DeepCloneFromItem,
        handleSearchCase,
    };
};

export default useListFormItem;
