conflict-nuxt-4/app/pages/index.vue
Baghi330 7892a7cefb 1
2026-02-14 10:41:53 +03:30

140 lines
3.8 KiB
Vue
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<Header
:tabs="headerTabs"
v-model:active-tab="activeTabKey"
:is-sidebar-collapsed="isSidebarCollapsed"
:unread-notifications="unreadNotifications"
@tab-change="handleTabChange"
:headerSchema="headerSchema"
/>
<component
:is="currentComponent"
v-if="currentComponent"
:activeTabKey="activeTabKey"
:listConflicts="listConflicts"
/>
</div>
</template>
<script setup>
definePageMeta({
name: "DashboardBasePage",
layout: "dashboard-layout",
});
import { ref, onMounted } from "vue";
import tabBarData from "@/json/tab-bar/data-entry/dataEntry.json";
import { defineAsyncComponent } from "vue";
const route = useRoute();
const { $http: httpService } = useNuxtApp();
// Stateهای Header
const isSidebarCollapsed = ref(false);
const unreadNotifications = ref(5);
const headerTabs = ref([]);
const listConflicts = ref([]);
headerTabs.value = tabBarData.tabs;
const activeTabKey = ref(tabBarData.tabs[0]?.key || "");
// const contentSchema = computed(() => ({
// items: items.value,
// }));
const tabComponents = {
MainList: defineAsyncComponent(
() => import("~/components/lazy-load/data-entry/MainList.vue"),
),
RelationEdit: defineAsyncComponent(
() => import("~/components/lazy-load/data-entry/RelationEdit.vue"),
),
RuleEdit: defineAsyncComponent(
() => import("~/components/lazy-load/data-entry/RuleEdit.vue"),
),
// "DataEntryFarhangestan": defineAsyncComponent(() => import("~/components/lazy-load/data-entry/DataEntryFarhangestan.vue")),
// "DataEntryMirbagheri": defineAsyncComponent(() => import("~/components/lazy-load/data-entry/DataEntryMirbagheri.vue")),
// ...
};
const currentComponent = computed(() => {
if (activeTabKey.value == "MainList") {
return tabComponents.MainList;
} else if (activeTabKey.value === "RelationEdit") {
return tabComponents.RelationEdit;
} else if (activeTabKey.value === "RuleEdit") {
return tabComponents.RuleEdit;
}
});
// تابع مدیریت تغییر تب
const handleTabChange = (tab) => {
// منطق تغییر مسیر یا لود داده
switch (tab.id) {
case "dashboard":
break;
case "analytics":
break;
case "users":
break;
case "settings":
break;
default:
}
};
const headerSchema = ref({});
headerSchema.value = {
breadcrumb: true,
logo: false,
};
const pagination = ref({
total: 0,
page: 1,
limit: 10,
});
const getListConflict = async (textSearch = "", filterExtended = "") => {
const offset = (pagination.value.page - 1) * pagination.value.limit;
const limit = pagination.value.limit;
let tabFilter = "";
let mode_url = "elp";
let index_key = "qaconflict";
// if (props.activeTabKey === "mirbagheri") {
// tabFilter = "&f_au=استاد سید محمد مهدی میرباقری";
// mode_url = "elp_db";
// } else if (props.activeTabKey === "monir") {
// tabFilter = "&f_au=سید منیر الدین حسینی الهاشمی(ره)";
// mode_url = "elp_db";
// }
// let allFilters = tabFilter + filterPanel.value;
const request = utilGetSearchRequest(
index_key,
textSearch,
"normal",
mode_url,
tabFilter,
filterExtended,
offset,
limit,
);
request.payload_full["search_fields"] = [
"branch",
"title",
"subtitle",
"author",
];
try {
const res = await httpService.postRequest(
request.url,
request.payload_full,
);
console.log("res", res);
listConflicts.value = res;
} catch (err) {
console.error("خطا در دریافت داده:", err);
}
};
onMounted(() => {
getListConflict();
activeTabKey.value = headerTabs.value[0]?.id || "";
});
</script>