import { ElMessage, ElMessageBox } from 'element-plus';

const useCostMoreHook = (id: string) => {
    const ids = ref([]);
    const handleCostionChange = (val: any[]) => {
        ids.value = val.map(item => item[id] as any);
    };
    const dialogShow = ref(false);
    const handlerCost = async (data: any) => {
        const selectItems = data.filter(m => m.calculationFormula.includes('·'));
        if (selectItems.length > 0) {
            ElMessage({
                message: '所选数据中含有全局参数字段，无法生成费用',
                type: 'error',
                plain: true,
            });
            dialogShow.value = false;
        } else {
            dialogShow.value = true;
        }
    };
    return { dialogShow, ids, handlerCost, handleCostionChange };
};

export default useCostMoreHook;
