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