fix price

This commit is contained in:
2026-06-25 00:13:03 +03:30
parent 78ce8ad4b4
commit edffc5df76
5 changed files with 35 additions and 3 deletions
+7 -2
View File
@@ -174,7 +174,7 @@ import SettingValueField from './SettingValueField.vue'
import SettingCard from './SettingCard.vue'
import { refreshAppModeMenu } from '@/router'
import { useUserStore } from '@/store/userStore'
import { setStoreModeFromSettings } from '@/utils/config'
import { applyBannerEnabledFromRows, setBannerEnabledFromSettings, setStoreModeFromSettings } from '@/utils/config'
import {
EDITABLE_SETTING_GROUPS,
SYSTEM_SETTING_GROUPS,
@@ -420,7 +420,9 @@ async function initConfig() {
(isSystemMode.value
? await getSystemConfiguration()
: await getEditableConfiguration()) ?? []
if (!isSystemMode.value) {
if (isSystemMode.value) {
applyBannerEnabledFromRows(baseData.value)
} else {
const storeRow = baseData.value.find((row) => row.key === 'is_store')
if (storeRow) {
setStoreModeFromSettings(isSwitchOn(storeRow.value))
@@ -531,6 +533,9 @@ async function saveSettingRow(row: Const) {
setStoreModeFromSettings(isSwitchOn(value))
refreshMenuAfterStoreChange()
}
if (row.key === 'banner_enabled' && isSystemMode.value) {
setBannerEnabledFromSettings(isSwitchOn(value))
}
savedFlashIds.value.add(id)
if (saveTimers.has(id)) clearTimeout(saveTimers.get(id))
saveTimers.set(
@@ -4,7 +4,11 @@ import { usePrice } from '@core/utils/usePrice'
const SOURCE_LABELS: Record<string, string> = {
zaarbox: 'تابلو Zaarbox',
legacy: 'فید قدیمی'
legacy: 'فید قدیمی',
montzar: 'منتظر',
main_product: 'محصول اصلی',
database_last: 'آخرین قیمت DB',
store: 'فروشگاه'
}
export const storePriceColumns: BaseTableColumn[] = [
+2
View File
@@ -25,6 +25,7 @@ import BasicMenu from '@/components/BasicMenu/index.vue'
import { useRouterStore } from '@core/stores/router'
import { useUserStore } from '@/store/userStore'
import { isDeployAdmin } from '@/utils/deployAdmin'
import { bannerEnabledSetting } from '@/utils/config'
import { get } from 'lodash'
import type { RouteRecordRaw } from 'vue-router'
@@ -36,6 +37,7 @@ const menu = computed(() => {
const children = get(item, 'children[0].children', []) as RouteRecordRaw[]
return children
.filter((child) => !child.meta?.hideMenu)
.filter((child) => child.name !== 'banners' || bannerEnabledSetting.value)
.filter(
(child) =>
!child.meta?.deployAdminOnly || isDeployAdmin(userStore.userInfo?.mobile)
+6
View File
@@ -1,6 +1,7 @@
import type { RouteRecordRaw } from 'vue-router'
import { isDeployAdmin } from '@/utils/deployAdmin'
import { useUserStore } from '@/store/userStore'
import { bannerEnabledSetting } from '@/utils/config'
const Setting: RouteRecordRaw = {
name: 'settings',
@@ -67,6 +68,11 @@ const Setting: RouteRecordRaw = {
icon: 'vuesax-linear:image',
title: 'بنرها',
order: 3
},
beforeEnter() {
if (!bannerEnabledSetting.value) {
return { name: 'configuration' }
}
}
},
{
+15
View File
@@ -1,3 +1,4 @@
import { ref } from 'vue'
import { setCachedMainMetal } from '@/utils/metalLabels'
export function getConfigApp(key: string) {
@@ -12,6 +13,9 @@ export function getConfigApp(key: string) {
let storeModeFromSettings: boolean | null = null
let settingsBootstrapped = false
/** reactive — برای فیلتر منوی «بنرها» در پیکربندی */
export const bannerEnabledSetting = ref(false)
function isSwitchOn(value: string | undefined | null): boolean {
const v = (value ?? '').trim().toLowerCase()
return v === 'true' || v === '1' || v === 'yes'
@@ -21,6 +25,15 @@ export function setStoreModeFromSettings(value: boolean): void {
storeModeFromSettings = value
}
export function setBannerEnabledFromSettings(value: boolean): void {
bannerEnabledSetting.value = value
}
export function applyBannerEnabledFromRows(rows: Array<{ key?: string; value?: string | null }>) {
const row = rows.find((item) => item.key === 'banner_enabled')
setBannerEnabledFromSettings(row ? isSwitchOn(row.value) : false)
}
async function bootstrapSettingsFromApi(): Promise<void> {
if (settingsBootstrapped) return
@@ -33,11 +46,13 @@ async function bootstrapSettingsFromApi(): Promise<void> {
const mainWalletRow = list.find((item) => item.key === 'main_wallet_products')
const mainMetalRow = list.find((item) => item.key === 'main_metal')
storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false
applyBannerEnabledFromRows(list)
setCachedMainMetal(mainMetalRow?.value)
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
setCachedMainWalletProductIds(parseMainWalletProductIds(mainWalletRow?.value))
} catch {
storeModeFromSettings = false
setBannerEnabledFromSettings(false)
setCachedMainMetal(null)
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
setCachedMainWalletProductIds([])