store 3
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
import useAxios from '@core/utils/useAxios'
|
||||||
|
import type { Category, CategoryInput } from '@/model/category'
|
||||||
|
|
||||||
|
export type CategoryListParams = {
|
||||||
|
active?: number
|
||||||
|
select_only?: boolean
|
||||||
|
search?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCategories = async (params?: CategoryListParams) =>
|
||||||
|
await useAxios.get<Category[]>('/admin/categories', { params })
|
||||||
|
|
||||||
|
export const updateCategory = async (id: number, payload: Partial<CategoryInput>) =>
|
||||||
|
await useAxios.put<Category>(`/admin/categories/${id}`, payload)
|
||||||
|
|
||||||
|
export const syncCategoriesFromProducts = async () =>
|
||||||
|
await useAxios.post<{ message: string; created: number; items: Category[] }>(
|
||||||
|
'/admin/categories/sync-from-products'
|
||||||
|
)
|
||||||
|
|
||||||
|
export const changeCategoryActive = async (id: number, active: 0 | 1) =>
|
||||||
|
await useAxios.get(`/admin/categories/${id}/active/${active}`)
|
||||||
@@ -30,6 +30,8 @@ const init = async () => {
|
|||||||
await userStore.getMyInfo()
|
await userStore.getMyInfo()
|
||||||
await initStoreModeFromSettings()
|
await initStoreModeFromSettings()
|
||||||
setupRoutes(['*'])
|
setupRoutes(['*'])
|
||||||
|
const { refreshAppModeMenu } = await import('@/router')
|
||||||
|
refreshAppModeMenu()
|
||||||
//setupRoutes(['project'])
|
//setupRoutes(['project'])
|
||||||
/*router.removeRoute('usersMain')
|
/*router.removeRoute('usersMain')
|
||||||
router.removeRoute('users')*/
|
router.removeRoute('users')*/
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
export interface Category {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
active: boolean | number
|
||||||
|
show_in_filter: boolean | number
|
||||||
|
show_in_select: boolean | number
|
||||||
|
sort_order: number
|
||||||
|
created_at?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CategoryInput {
|
||||||
|
name: string
|
||||||
|
active?: number
|
||||||
|
show_in_filter?: number
|
||||||
|
show_in_select?: number
|
||||||
|
sort_order?: number
|
||||||
|
}
|
||||||
@@ -100,7 +100,7 @@ import { useStaticApiListsStore } from '@/store/staticApisStore'
|
|||||||
import OtpInput from 'vue3-otp-input'
|
import OtpInput from 'vue3-otp-input'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { setupRoutes } from '@/router'
|
import { setupRoutes } from '@/router'
|
||||||
import {getConfigApp} from "@/utils/config";
|
import { getConfigApp, initStoreModeFromSettings } from '@/utils/config'
|
||||||
|
|
||||||
//define emit
|
//define emit
|
||||||
const emits = defineEmits(['enter'])
|
const emits = defineEmits(['enter'])
|
||||||
@@ -160,7 +160,10 @@ const onUserPassFormFinish = async () => {
|
|||||||
await setToken(access_token)
|
await setToken(access_token)
|
||||||
}
|
}
|
||||||
await userStore.getMyInfo()
|
await userStore.getMyInfo()
|
||||||
|
await initStoreModeFromSettings()
|
||||||
setupRoutes(['*'], router)
|
setupRoutes(['*'], router)
|
||||||
|
const { refreshAppModeMenu } = await import('@/router')
|
||||||
|
refreshAppModeMenu()
|
||||||
// const info = await getMyInformation()
|
// const info = await getMyInformation()
|
||||||
// await setMyInfo(JSON.stringify(info))
|
// await setMyInfo(JSON.stringify(info))
|
||||||
// emits('enter')
|
// emits('enter')
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ import { loading } from '@/utils'
|
|||||||
import { getEditableConfiguration, setConfiguration } from '@/api/configuration'
|
import { getEditableConfiguration, setConfiguration } from '@/api/configuration'
|
||||||
import SettingValueField from './SettingValueField.vue'
|
import SettingValueField from './SettingValueField.vue'
|
||||||
import SettingCard from './SettingCard.vue'
|
import SettingCard from './SettingCard.vue'
|
||||||
|
import { refreshAppModeMenu } from '@/router'
|
||||||
import { setStoreModeFromSettings } from '@/utils/config'
|
import { setStoreModeFromSettings } from '@/utils/config'
|
||||||
import {
|
import {
|
||||||
SETTING_TYPE_OPTIONS,
|
SETTING_TYPE_OPTIONS,
|
||||||
@@ -416,6 +417,7 @@ async function initConfig() {
|
|||||||
const storeRow = baseData.value.find((row) => row.key === 'is_store')
|
const storeRow = baseData.value.find((row) => row.key === 'is_store')
|
||||||
if (storeRow) {
|
if (storeRow) {
|
||||||
setStoreModeFromSettings(isSwitchOn(storeRow.value))
|
setStoreModeFromSettings(isSwitchOn(storeRow.value))
|
||||||
|
refreshAppModeMenu()
|
||||||
}
|
}
|
||||||
syncDraftsFromBase()
|
syncDraftsFromBase()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -489,6 +491,7 @@ async function saveSettingRow(row: Const, overrides?: { isActive?: boolean }) {
|
|||||||
drafts.value[id] = value
|
drafts.value[id] = value
|
||||||
if (row.key === 'is_store') {
|
if (row.key === 'is_store') {
|
||||||
setStoreModeFromSettings(isSwitchOn(value))
|
setStoreModeFromSettings(isSwitchOn(value))
|
||||||
|
refreshAppModeMenu()
|
||||||
}
|
}
|
||||||
savedFlashIds.value.add(id)
|
savedFlashIds.value.add(id)
|
||||||
if (saveTimers.has(id)) clearTimeout(saveTimers.get(id))
|
if (saveTimers.has(id)) clearTimeout(saveTimers.get(id))
|
||||||
|
|||||||
@@ -79,7 +79,13 @@ import {
|
|||||||
unwrapApiRecord
|
unwrapApiRecord
|
||||||
} from '@/utils/file'
|
} from '@/utils/file'
|
||||||
import { normalizeProductOrderLimitForm, validateProductOrderLimitForm } from '@/utils/productOrderLimit'
|
import { normalizeProductOrderLimitForm, validateProductOrderLimitForm } from '@/utils/productOrderLimit'
|
||||||
import { buildCategorySelectItems, isMeltedTradeGroup, resolveMeltedPriceSource } from '@/utils/productCategories'
|
import {
|
||||||
|
buildCategorySelectItems,
|
||||||
|
isMeltedTradeGroup,
|
||||||
|
PRODUCT_CATEGORY_ABSHODE,
|
||||||
|
resolveMeltedPriceSource
|
||||||
|
} from '@/utils/productCategories'
|
||||||
|
import { getCategories } from '@/api/category'
|
||||||
|
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
@@ -122,7 +128,13 @@ const metalItems: Array<Item> = [
|
|||||||
{ key: 2, value: 'نقره' },
|
{ key: 2, value: 'نقره' },
|
||||||
{ key: 3, value: 'مس' },
|
{ key: 3, value: 'مس' },
|
||||||
]
|
]
|
||||||
const categorySelectItems = computed(() => buildCategorySelectItems(metalItems))
|
const storeCategorySelectItems = ref<Array<{ key: string; value: string }>>([])
|
||||||
|
const categorySelectItems = computed(() => {
|
||||||
|
if (isStoreApp() && storeCategorySelectItems.value.length) {
|
||||||
|
return storeCategorySelectItems.value
|
||||||
|
}
|
||||||
|
return buildCategorySelectItems(metalItems)
|
||||||
|
})
|
||||||
const priceItems: Array<Item> = [
|
const priceItems: Array<Item> = [
|
||||||
{ key: 0, value: 'متغیر' },
|
{ key: 0, value: 'متغیر' },
|
||||||
{ key: 1, value: 'ثابت' }
|
{ key: 1, value: 'ثابت' }
|
||||||
@@ -185,8 +197,28 @@ watch(addUserVisible, (visible) => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void refreshLivePrices()
|
void refreshLivePrices()
|
||||||
|
void loadStoreCategories()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function loadStoreCategories() {
|
||||||
|
if (!isStoreApp()) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
const rows = await getCategories({ select_only: true })
|
||||||
|
const metalHint = metalItems.map((item) => item.value).join('، ')
|
||||||
|
storeCategorySelectItems.value = rows.map((category) => ({
|
||||||
|
key: category.name,
|
||||||
|
value:
|
||||||
|
category.name === PRODUCT_CATEGORY_ABSHODE
|
||||||
|
? `${category.name} (${metalHint})`
|
||||||
|
: category.name
|
||||||
|
}))
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
storeCategorySelectItems.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stopPricePolling()
|
stopPricePolling()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flex h-full min-h-0 flex-col gap-4 p-4">
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<BaseButton :loading="syncing" @click="handleSync">
|
||||||
|
همگامسازی از محصولات
|
||||||
|
</BaseButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a-spin :spinning="loading">
|
||||||
|
<a-table
|
||||||
|
:columns="columns"
|
||||||
|
:data-source="items"
|
||||||
|
:pagination="false"
|
||||||
|
row-key="id"
|
||||||
|
size="middle"
|
||||||
|
class="min-h-0 flex-1"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'active'">
|
||||||
|
<a-switch
|
||||||
|
:checked="asBool(record.active)"
|
||||||
|
checked-children="فعال"
|
||||||
|
un-checked-children="مخفی"
|
||||||
|
@change="(checked: boolean) => toggleField(record, 'active', checked)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'show_in_filter'">
|
||||||
|
<a-switch
|
||||||
|
:checked="asBool(record.show_in_filter)"
|
||||||
|
@change="(checked: boolean) => toggleField(record, 'show_in_filter', checked)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'show_in_select'">
|
||||||
|
<a-switch
|
||||||
|
:checked="asBool(record.show_in_select)"
|
||||||
|
@change="(checked: boolean) => toggleField(record, 'show_in_select', checked)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'sort_order'">
|
||||||
|
<BasicInput
|
||||||
|
class="!w-16"
|
||||||
|
type="number"
|
||||||
|
v-model:value="record.sort_order"
|
||||||
|
@blur="() => saveSortOrder(record)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-spin>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import type { TableColumnType } from 'ant-design-vue'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { getCategories, syncCategoriesFromProducts, updateCategory } from '@/api/category'
|
||||||
|
import type { Category } from '@/model/category'
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const syncing = ref(false)
|
||||||
|
const items = ref<Category[]>([])
|
||||||
|
|
||||||
|
const columns: TableColumnType<Category>[] = [
|
||||||
|
{ title: 'نام دسته', dataIndex: 'name', key: 'name' },
|
||||||
|
{
|
||||||
|
title: 'نمایش محصولات در اپ',
|
||||||
|
key: 'active',
|
||||||
|
width: 160,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تب فیلتر اپ',
|
||||||
|
key: 'show_in_filter',
|
||||||
|
width: 120,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'سلکت افزودن محصول',
|
||||||
|
key: 'show_in_select',
|
||||||
|
width: 150,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'ترتیب',
|
||||||
|
key: 'sort_order',
|
||||||
|
width: 90,
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
/** پیشفرض: روشن — فقط صفر یا false یعنی خاموش */
|
||||||
|
function asBool(value: boolean | number | undefined | null) {
|
||||||
|
return value !== false && value !== 0
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchList() {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
items.value = await getCategories()
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
message.error('خطا در دریافت دستهبندیها')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleField(record: Category, field: 'active' | 'show_in_filter' | 'show_in_select', checked: boolean) {
|
||||||
|
const prev = record[field]
|
||||||
|
record[field] = checked ? 1 : 0
|
||||||
|
try {
|
||||||
|
await updateCategory(record.id, { [field]: checked ? 1 : 0 })
|
||||||
|
message.success('ذخیره شد')
|
||||||
|
} catch (e) {
|
||||||
|
record[field] = prev
|
||||||
|
console.error(e)
|
||||||
|
message.error('خطا در ذخیره')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveSortOrder(record: Category) {
|
||||||
|
const order = Number(record.sort_order)
|
||||||
|
if (Number.isNaN(order)) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
await updateCategory(record.id, { sort_order: order })
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
message.error('خطا در ذخیره ترتیب')
|
||||||
|
await fetchList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function syncList(showMessage = false) {
|
||||||
|
syncing.value = true
|
||||||
|
try {
|
||||||
|
const res = await syncCategoriesFromProducts()
|
||||||
|
items.value = res.items ?? (await getCategories())
|
||||||
|
if (showMessage) {
|
||||||
|
message.success(res.message || 'همگامسازی انجام شد')
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
if (showMessage) {
|
||||||
|
message.error('خطا در همگامسازی')
|
||||||
|
} else {
|
||||||
|
await fetchList()
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
syncing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSync() {
|
||||||
|
await syncList(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void syncList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -18,10 +18,12 @@
|
|||||||
import BasicMenu from '@/components/BasicMenu/index.vue'
|
import BasicMenu from '@/components/BasicMenu/index.vue'
|
||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import { get } from 'lodash'
|
import { get } from 'lodash'
|
||||||
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
const routerStore = useRouterStore()
|
const routerStore = useRouterStore()
|
||||||
const menu = computed(() => {
|
const menu = computed(() => {
|
||||||
const item = routerStore.routes.find((item) => item.name === 'products')
|
const item = routerStore.routes.find((item) => item.name === 'products')
|
||||||
return get(item, 'children[0].children', [])
|
const children = get(item, 'children[0].children', []) as RouteRecordRaw[]
|
||||||
|
return children.filter((child) => !child.meta?.hideMenu)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -21,22 +21,13 @@
|
|||||||
import BasicMenu from '@/components/BasicMenu/index.vue'
|
import BasicMenu from '@/components/BasicMenu/index.vue'
|
||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import { get } from 'lodash'
|
import { get } from 'lodash'
|
||||||
//import Nature from '@/pages/menuPages/setting/limitedOrder/index.vue'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
//s import test from './limitedOrder'
|
|
||||||
//import Budget from '@/pages/menuPages/setting/budget/index.vue'
|
|
||||||
//import ProjectType from '@/pages/menuPages/setting/projectType/index.vue'
|
|
||||||
//import DocumentType from '@/pages/menuPages/setting/documentType/index.vue'
|
|
||||||
// import Management from '@/pages/menuPages/setting/management/index.vue'
|
|
||||||
//import Accessibility from '@/pages/menuPages/setting/accessibility/index.vue'
|
|
||||||
//import SubmitProcess from '@/pages/menuPages/setting/submitProcess/index.vue'
|
|
||||||
//import documentGroup from '@/pages/menuPages/setting/documentGroup/index.vue'
|
|
||||||
//import userType from '@/pages/menuPages/setting/userType/index.vue'
|
|
||||||
|
|
||||||
const routerStore = useRouterStore()
|
const routerStore = useRouterStore()
|
||||||
const menu = computed(() => {
|
const menu = computed(() => {
|
||||||
const item = routerStore.routes.find((item) => item.name === 'settings')
|
const item = routerStore.routes.find((item) => item.name === 'settings')
|
||||||
//console.log('aaaa', get(item, 'children[0].children', []))
|
const children = get(item, 'children[0].children', []) as RouteRecordRaw[]
|
||||||
return get(item, 'children[0].children', [])
|
return children.filter((child) => !child.meta?.hideMenu)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+83
-53
@@ -3,9 +3,72 @@
|
|||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import type { Router, RouteRecordRaw } from 'vue-router'
|
import type { Router, RouteRecordRaw } from 'vue-router'
|
||||||
import { getConfigApp, isStoreApp } from '@/utils/config'
|
import { getConfigApp, isStoreApp } from '@/utils/config'
|
||||||
|
import { cloneDeep } from 'lodash'
|
||||||
//const _router = useRouter()
|
//const _router = useRouter()
|
||||||
//import { cloneDeep } from 'lodash'
|
//import { cloneDeep } from 'lodash'
|
||||||
|
|
||||||
|
function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
||||||
|
const store = isStoreApp()
|
||||||
|
|
||||||
|
if (!route.children?.length) return
|
||||||
|
|
||||||
|
for (const child of route.children) {
|
||||||
|
if (child.name === 'giftCardMain' && child.meta) {
|
||||||
|
child.meta.title = store ? 'کارت هدیه و تخفیف' : 'کارت هدیه'
|
||||||
|
child.meta.hideMenu = !store && appName !== 'garoosi'
|
||||||
|
}
|
||||||
|
if (child.name === 'discounts' && child.meta) {
|
||||||
|
child.meta.hideMenu = store || appName !== 'goldsun'
|
||||||
|
}
|
||||||
|
if (child.name === 'banners' && child.meta) {
|
||||||
|
child.meta.hideMenu = appName !== 'garoosi'
|
||||||
|
}
|
||||||
|
if (child.name === 'productsMain_categories' && child.meta) {
|
||||||
|
child.meta.hideMenu = !store
|
||||||
|
}
|
||||||
|
applyAppModeMeta(child, appName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterRoutesByApp(routes: RouteRecordRaw, appName: string | null) {
|
||||||
|
if (!routes.children) return
|
||||||
|
|
||||||
|
routes.children = routes.children.filter((item) => {
|
||||||
|
if (item.name === 'discounts' && (isStoreApp() || appName !== 'goldsun')) return false
|
||||||
|
if (item.name === 'banners' && appName !== 'garoosi') return false
|
||||||
|
if (item.name === 'authentication' && appName !== 'garoosi') return false
|
||||||
|
if (item.name === 'giftCardMain' && !isStoreApp() && appName !== 'garoosi') return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
routes.children.forEach((child) => filterRoutesByApp(child, appName))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** بعد از تغییر is_store — منو را از روتهای تازه (clone) دوباره میسازد */
|
||||||
|
export function refreshAppModeMenu() {
|
||||||
|
const routerStore = useRouterStore()
|
||||||
|
const modules = import.meta.glob<any>('./routes/*.ts', { eager: true })
|
||||||
|
const appName = getConfigApp('name')
|
||||||
|
|
||||||
|
const preserved = routerStore.routes.filter(
|
||||||
|
(route) => route.name === 'notFound' || route.name === 'factor'
|
||||||
|
)
|
||||||
|
|
||||||
|
const dynamicRoutes: RouteRecordRaw[] = []
|
||||||
|
for (const modulesKey in modules) {
|
||||||
|
const sourceRoute: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
||||||
|
if (!sourceRoute) continue
|
||||||
|
|
||||||
|
const route = cloneDeep(sourceRoute)
|
||||||
|
applyAppModeMeta(route, appName)
|
||||||
|
filterRoutesByApp(route, appName)
|
||||||
|
dynamicRoutes.push(route)
|
||||||
|
}
|
||||||
|
|
||||||
|
routerStore.routes = [...preserved, ...dynamicRoutes]
|
||||||
|
}
|
||||||
|
|
||||||
export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
||||||
//console.log('this is permission', permissionsKeys)
|
//console.log('this is permission', permissionsKeys)
|
||||||
//console.log('this is use router', _router)
|
//console.log('this is use router', _router)
|
||||||
@@ -23,42 +86,11 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
|||||||
(item.meta?.permissionsKey && permissionsKeys.includes(item.meta?.permissionsKey))
|
(item.meta?.permissionsKey && permissionsKeys.includes(item.meta?.permissionsKey))
|
||||||
)
|
)
|
||||||
for (const route of routes.children) {
|
for (const route of routes.children) {
|
||||||
/*if (!route.children || (route.children && route.children.length == 0)) {
|
|
||||||
//path.push(route.name)
|
|
||||||
//return
|
|
||||||
continue
|
|
||||||
}*/
|
|
||||||
/*if (routes.children) {
|
|
||||||
}*/
|
|
||||||
walkInRoutes(route)
|
walkInRoutes(route)
|
||||||
/*if (route.children && route.children.length > 0) {
|
|
||||||
path.push(route.name)
|
|
||||||
const res = walkInRoutes(route.children)
|
|
||||||
if (!res) {
|
|
||||||
path.pop()
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterRoutesByApp(routes: RouteRecordRaw) {
|
|
||||||
if (!routes.children) return
|
|
||||||
routes.children = routes.children.filter((item) => {
|
|
||||||
|
|
||||||
if (item.name === 'discounts' && (isStoreApp() || appName !== 'goldsun')) return false
|
|
||||||
if (item.name === 'banners' && appName !== 'garoosi') return false
|
|
||||||
if (item.name === 'authentication' && appName !== 'garoosi') return false
|
|
||||||
if (item.name === 'giftCardMain' && !isStoreApp() && appName !== 'garoosi') return false
|
|
||||||
|
|
||||||
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
routes.children.forEach((child) => filterRoutesByApp(child))
|
|
||||||
}
|
|
||||||
|
|
||||||
routerStore.routes = [
|
routerStore.routes = [
|
||||||
{
|
{
|
||||||
path: '/:pathMatch(.*)*',
|
path: '/:pathMatch(.*)*',
|
||||||
@@ -79,33 +111,31 @@ export function setupRoutes(permissionsKeys: string[], router?: Router) {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
for (const modulesKey in modules) {
|
for (const modulesKey in modules) {
|
||||||
// console.log(modulesKey)
|
const sourceRoute: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
||||||
const route: RouteRecordRaw | undefined = modules[modulesKey].default ?? undefined
|
if (!sourceRoute) continue
|
||||||
if (route) {
|
|
||||||
if (permissionsKeys.length && permissionsKeys[0] == '*') {
|
const route = cloneDeep(sourceRoute)
|
||||||
filterRoutesByApp(route)
|
|
||||||
|
if (permissionsKeys.length && permissionsKeys[0] == '*') {
|
||||||
|
applyAppModeMeta(route, appName)
|
||||||
|
filterRoutesByApp(route, appName)
|
||||||
|
routerStore.routes.push(route)
|
||||||
|
if (router) {
|
||||||
|
router.addRoute(route)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (
|
||||||
|
!route?.meta?.permissionsKey ||
|
||||||
|
(route.meta.permissionsKey && permissionsKeys.includes(route.meta.permissionsKey))
|
||||||
|
) {
|
||||||
|
walkInRoutes(route)
|
||||||
|
applyAppModeMeta(route, appName)
|
||||||
|
filterRoutesByApp(route, appName)
|
||||||
routerStore.routes.push(route)
|
routerStore.routes.push(route)
|
||||||
if (router) {
|
if (router) {
|
||||||
router.addRoute(route)
|
router.addRoute(route)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (
|
|
||||||
!route?.meta?.permissionsKey ||
|
|
||||||
(route.meta.permissionsKey && permissionsKeys.includes(route.meta.permissionsKey))
|
|
||||||
) {
|
|
||||||
walkInRoutes(route)
|
|
||||||
filterRoutesByApp(route)
|
|
||||||
routerStore.routes.push(route)
|
|
||||||
if (router) {
|
|
||||||
router.addRoute(route)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(router)
|
|
||||||
//console.log('this is store', routerStore.routes)
|
|
||||||
/* if (router) {
|
|
||||||
console.log('this is router routes', router.getRoutes())
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,13 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
import { getConfigApp, isStoreApp } from '@/utils/config'
|
|
||||||
|
|
||||||
const Orders: RouteRecordRaw = {
|
/** ریدایرکت آدرس قدیمی — منو زیر پیکربندی است */
|
||||||
|
const GiftCard: RouteRecordRaw = {
|
||||||
name: 'giftCard',
|
name: 'giftCard',
|
||||||
path: '/giftCard',
|
path: '/giftCard',
|
||||||
component: () => import('@core/layouts/BasicLayout.vue'),
|
|
||||||
redirect: { name: 'giftCardMain' },
|
redirect: { name: 'giftCardMain' },
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'vuesax-linear:gift',
|
hideMenu: true
|
||||||
permissionsKey: 'giftCard',
|
}
|
||||||
title: isStoreApp() ? 'کارت هدیه و تخفیف' : 'کارت هدیه',
|
|
||||||
disabled: false,
|
|
||||||
hideMenu: !isStoreApp() && getConfigApp('name') != 'garoosi',
|
|
||||||
hideChildren: true,
|
|
||||||
order: 7
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
name: 'giftCardMain',
|
|
||||||
path: '',
|
|
||||||
component: () => import('@/pages/menuPages/giftCards/index.vue'),
|
|
||||||
meta: {
|
|
||||||
permissionsKey: 'project',
|
|
||||||
icon: 'vuesax-linear:empty-wallet-time',
|
|
||||||
order: 3,
|
|
||||||
title: isStoreApp() ? 'کارت هدیه و تخفیف' : 'کارت هدیه',
|
|
||||||
disabled: false,
|
|
||||||
hideMenu: false
|
|
||||||
//hideChildren: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Orders
|
export default GiftCard
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ const Products: RouteRecordRaw = {
|
|||||||
icon: 'vuesax-linear:save-2',
|
icon: 'vuesax-linear:save-2',
|
||||||
title: 'بایگانی'
|
title: 'بایگانی'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'productsMain_categories',
|
||||||
|
path: 'categories',
|
||||||
|
component: () => import('@/pages/menuPages/products/categories/index.vue'),
|
||||||
|
meta: {
|
||||||
|
icon: 'vuesax-linear:category',
|
||||||
|
title: 'دستهبندیها',
|
||||||
|
hideMenu: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
import { getConfigApp, isStoreApp } from '@/utils/config'
|
|
||||||
const Setting: RouteRecordRaw = {
|
const Setting: RouteRecordRaw = {
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
@@ -62,6 +61,27 @@ const Setting: RouteRecordRaw = {
|
|||||||
title: 'هشدار قیمت'
|
title: 'هشدار قیمت'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'smsMain',
|
||||||
|
path: 'sms',
|
||||||
|
component: () => import('@/pages/menuPages/sms/index.vue'),
|
||||||
|
meta: {
|
||||||
|
permissionsKey: 'sms',
|
||||||
|
icon: 'vuesax-linear:sms',
|
||||||
|
title: 'پیامکها'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'giftCardMain',
|
||||||
|
path: 'giftCard',
|
||||||
|
component: () => import('@/pages/menuPages/giftCards/index.vue'),
|
||||||
|
meta: {
|
||||||
|
permissionsKey: 'project',
|
||||||
|
icon: 'vuesax-linear:gift',
|
||||||
|
title: 'کارت هدیه',
|
||||||
|
hideMenu: true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'discounts',
|
name: 'discounts',
|
||||||
path: 'discounts',
|
path: 'discounts',
|
||||||
@@ -70,7 +90,7 @@ const Setting: RouteRecordRaw = {
|
|||||||
permissionsKey: 'discounts',
|
permissionsKey: 'discounts',
|
||||||
icon: 'vuesax-linear:discount-shape',
|
icon: 'vuesax-linear:discount-shape',
|
||||||
title: 'تخفیفات',
|
title: 'تخفیفات',
|
||||||
hideMenu: isStoreApp() || getConfigApp('name') !== 'goldsun'
|
hideMenu: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,7 +110,7 @@ const Setting: RouteRecordRaw = {
|
|||||||
meta: {
|
meta: {
|
||||||
icon: 'vuesax-linear:image',
|
icon: 'vuesax-linear:image',
|
||||||
title: 'بنرها',
|
title: 'بنرها',
|
||||||
hideMenu: getConfigApp('name') !== "garoosi"
|
hideMenu: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,35 +1,13 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
|
|
||||||
const Orders: RouteRecordRaw = {
|
/** ریدایرکت آدرس قدیمی — منو زیر پیکربندی است */
|
||||||
|
const Sms: RouteRecordRaw = {
|
||||||
name: 'sms',
|
name: 'sms',
|
||||||
path: '/sms',
|
path: '/sms',
|
||||||
component: () => import('@core/layouts/BasicLayout.vue'),
|
|
||||||
redirect: { name: 'smsMain' },
|
redirect: { name: 'smsMain' },
|
||||||
meta: {
|
meta: {
|
||||||
icon: 'vuesax-linear:sms',
|
hideMenu: true
|
||||||
permissionsKey: 'sms',
|
}
|
||||||
title: 'پیامک ها',
|
|
||||||
disabled: false,
|
|
||||||
hideMenu: false,
|
|
||||||
hideChildren: true,
|
|
||||||
order: 9
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
name: 'smsMain',
|
|
||||||
path: '',
|
|
||||||
component: () => import('@/pages/menuPages/sms/index.vue'),
|
|
||||||
meta: {
|
|
||||||
permissionsKey: 'sms',
|
|
||||||
icon: 'vuesax-linear:setting',
|
|
||||||
order: 3,
|
|
||||||
title: 'پیامک ها',
|
|
||||||
disabled: false,
|
|
||||||
hideMenu: false
|
|
||||||
//hideChildren: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Orders
|
export default Sms
|
||||||
|
|||||||
Reference in New Issue
Block a user