diff --git a/src/pages/menuPages/configuration/SettingCard.vue b/src/pages/menuPages/configuration/SettingCard.vue
index 07787b8..b78d73c 100644
--- a/src/pages/menuPages/configuration/SettingCard.vue
+++ b/src/pages/menuPages/configuration/SettingCard.vue
@@ -3,24 +3,13 @@
class="setting-card"
:class="{
'setting-card--readonly': readonly,
- 'setting-card--saving': saving,
- 'setting-card--inactive': !isActive && fieldType !== 'switch'
+ 'setting-card--saving': saving
}"
>
🔒
{{ title }}
-
- فعال
- غیرفعال
-
کلید: {{ settingKey }}
{{ help }}
@@ -62,7 +51,6 @@ const props = defineProps<{
const emit = defineEmits<{
'update:value': [value: string]
- 'update:isActive': [value: boolean]
}>()
const settingKey = computed(() => props.row.key ?? '')
@@ -74,12 +62,6 @@ const fieldType = computed
(() =>
resolveSettingFieldType({ key: props.row.key, type: props.row.type })
)
-const isActive = computed(() => props.row.is_active !== false && props.row.is_active !== 0)
-
-function onActiveChange(checked: boolean) {
- emit('update:isActive', checked)
-}
-
const help = computed(() => helpText(props.row))
@@ -108,11 +90,6 @@ const help = computed(() => helpText(props.row))
border-color: #91caff;
}
- &--inactive {
- opacity: 0.72;
- background: #fafafa;
- }
-
&__head {
flex-shrink: 0;
}
@@ -123,11 +100,6 @@ const help = computed(() => helpText(props.row))
gap: 6px;
}
- &__active-switch {
- margin-right: auto;
- flex-shrink: 0;
- }
-
&__lock {
flex-shrink: 0;
font-size: 13px;
diff --git a/src/pages/menuPages/configuration/SettingValueField.vue b/src/pages/menuPages/configuration/SettingValueField.vue
index e20b99b..1d652be 100644
--- a/src/pages/menuPages/configuration/SettingValueField.vue
+++ b/src/pages/menuPages/configuration/SettingValueField.vue
@@ -6,8 +6,8 @@
:disabled="disabled"
@change="onSwitchChange"
>
- فعال
- غیرفعال
+ {{ labels.on }}
+ {{ labels.off }}
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
import {
- isSwitchOn,
parseSelectOptions,
resolveSettingFieldType,
- switchToString,
+ resolveSwitchChecked,
+ switchLabels,
+ switchValueFromChecked,
type SettingFieldType
} from './settingTypes'
@@ -101,10 +102,12 @@ const selectItems = computed(() =>
})
)
-const switchChecked = computed(() => isSwitchOn(props.modelValue))
+const labels = computed(() => switchLabels(props.settingKey))
+
+const switchChecked = computed(() => resolveSwitchChecked(props.settingKey, props.modelValue))
function onSwitchChange(checked: boolean) {
- emit('update:value', switchToString(checked))
+ emit('update:value', switchValueFromChecked(props.settingKey, checked))
}
function onSelectChange(val: string | undefined) {
diff --git a/src/pages/menuPages/configuration/index.vue b/src/pages/menuPages/configuration/index.vue
index be5f49e..b09b179 100644
--- a/src/pages/menuPages/configuration/index.vue
+++ b/src/pages/menuPages/configuration/index.vue
@@ -14,16 +14,6 @@
@@ -67,30 +55,26 @@
import type { TableInput } from '@core/type/baseTable'
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
-import { cols } from '../hooks/priceColumns'
import { storePriceColumns } from '../hooks/storePriceColumns'
import { usePrefix } from '@core/composable/usePrefix'
-import { getPriceSyncLogTable, getPriceTable } from '@/api/price'
-import { isStoreApp } from '@/utils/config'
+import { getPriceSyncLogTable } from '@/api/price'
import PriceMobileCardList from './PriceMobileCardList.vue'
import { isMobile } from '@core/utils/is'
-import { computed } from 'vue'
+import type { PriceSyncLog } from '@/model/priceSyncLog'
-const props = defineProps<{ syncing?: boolean }>()
+defineProps<{ syncing?: boolean }>()
const [submit, reload] = useBaseTable()
const mobileListRef = ref Promise }>(null)
-const emits = defineEmits(['delete', 'edit', 'add', 'info', 'detail', 'sync'])
+const emits = defineEmits(['detail', 'sync'])
-const isStore = computed(() => isStoreApp())
const { prefixCls } = usePrefix('pophoverstatus')
-const tblProps = computed(() => ({
- columns: isStore.value ? storePriceColumns : cols,
- api: (params: TableInput) =>
- isStore.value ? getPriceSyncLogTable(params) : getPriceTable(params)
-}))
+const tblProps = {
+ columns: storePriceColumns,
+ api: (params: TableInput) => getPriceSyncLogTable(params)
+}
async function fetch() {
await Promise.allSettled([reload(), mobileListRef.value?.fetch?.() as Promise])
diff --git a/src/pages/menuPages/pricing/index.vue b/src/pages/menuPages/pricing/index.vue
index 23c6051..3a632ea 100644
--- a/src/pages/menuPages/pricing/index.vue
+++ b/src/pages/menuPages/pricing/index.vue
@@ -6,74 +6,28 @@
ref="table"
class="h-full w-full"
:syncing="syncing"
- @add="add"
@detail="openDetail"
@sync="handleSync"
/>
-
-
-
-
-
آیا مطمئن به تغییر قیمت می باشید؟
-
-
-
-
-
-
-
-
-
-
معادل {{ usePrice(form.price / 10, true, 'تومان') }}
-
-
-
-
-
diff --git a/src/pages/menuPages/products/base/index.vue b/src/pages/menuPages/products/base/index.vue
index 0696550..1bd35ce 100644
--- a/src/pages/menuPages/products/base/index.vue
+++ b/src/pages/menuPages/products/base/index.vue
@@ -80,12 +80,10 @@ import {
} from '@/utils/file'
import { normalizeProductOrderLimitForm, validateProductOrderLimitForm } from '@/utils/productOrderLimit'
import {
- buildCategorySelectItems,
isMeltedTradeGroup,
- PRODUCT_CATEGORY_ABSHODE,
resolveMeltedPriceSource
} from '@/utils/productCategories'
-import { getCategories } from '@/api/category'
+import { syncAndLoadCategories } from '@/utils/categorySelect'
dayjs.extend(customParseFormat)
@@ -128,13 +126,8 @@ const metalItems: Array- = [
{ key: 2, value: 'نقره' },
{ key: 3, value: 'مس' },
]
-const storeCategorySelectItems = ref>([])
-const categorySelectItems = computed(() => {
- if (isStoreApp() && storeCategorySelectItems.value.length) {
- return storeCategorySelectItems.value
- }
- return buildCategorySelectItems(metalItems)
-})
+const apiCategorySelectItems = ref>([])
+const categorySelectItems = computed(() => apiCategorySelectItems.value)
const priceItems: Array
- = [
{ key: 0, value: 'متغیر' },
{ key: 1, value: 'ثابت' }
@@ -197,25 +190,17 @@ watch(addUserVisible, (visible) => {
onMounted(() => {
void refreshLivePrices()
- void loadStoreCategories()
+ void loadCategorySelectItems()
})
-async function loadStoreCategories() {
- if (!isStoreApp()) return
-
+async function loadCategorySelectItems() {
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
- }))
+ apiCategorySelectItems.value = await syncAndLoadCategories({ metalHint })
} catch (err) {
console.error(err)
- storeCategorySelectItems.value = []
+ apiCategorySelectItems.value = []
+ message.error('خطا در دریافت دستهبندیها')
}
}
@@ -285,6 +270,7 @@ async function setProductIndexImage(record: Record, productId?: num
}
async function edit(record: Product) {
+ await loadCategorySelectItems()
addUserVisible.value = true
editId = record.id
let productData = cloneDeep(record) as Record
@@ -333,6 +319,7 @@ async function add() {
editId = undefined
addUserVisible.value = true
resetData()
+ await loadCategorySelectItems()
}
function resetData() {
diff --git a/src/router/index.ts b/src/router/index.ts
index 5b274ce..41414ba 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -11,7 +11,7 @@ function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
const store = isStoreApp()
if (route.name === 'pricing' && route.meta) {
- route.meta.title = store ? 'تاریخچه قیمت' : 'قیمت گذاری'
+ route.meta.title = 'تاریخچه قیمت'
}
if (!route.children?.length) return
@@ -27,11 +27,8 @@ function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
if (child.name === 'banners' && child.meta) {
child.meta.hideMenu = appName !== 'garoosi'
}
- if (child.name === 'productsMain_categories' && child.meta) {
- child.meta.hideMenu = !store
- }
if (child.name === 'pricingMain' && child.meta) {
- child.meta.title = store ? 'تاریخچه قیمت' : 'قیمت گذاری'
+ child.meta.title = 'تاریخچه قیمت'
}
applyAppModeMeta(child, appName)
}
diff --git a/src/router/routes/products.ts b/src/router/routes/products.ts
index 1d94be7..b5078bc 100644
--- a/src/router/routes/products.ts
+++ b/src/router/routes/products.ts
@@ -54,8 +54,7 @@ const Products: RouteRecordRaw = {
component: () => import('@/pages/menuPages/products/categories/index.vue'),
meta: {
icon: 'vuesax-linear:category',
- title: 'دستهبندیها',
- hideMenu: true
+ title: 'دستهبندیها'
}
}
]
diff --git a/src/utils/categorySelect.ts b/src/utils/categorySelect.ts
new file mode 100644
index 0000000..ae0892d
--- /dev/null
+++ b/src/utils/categorySelect.ts
@@ -0,0 +1,32 @@
+import { getCategories, syncCategoriesFromProducts } from '@/api/category'
+import type { Category } from '@/model/category'
+import { PRODUCT_CATEGORY_ABSHODE } from '@/utils/productCategories'
+
+export type CategorySelectItem = { key: string; value: string }
+
+export function mapCategoriesToSelectItems(
+ rows: Category[],
+ metalHint = 'طلا، نقره، مس'
+): CategorySelectItem[] {
+ return rows.map((category) => ({
+ key: category.name,
+ value:
+ category.name === PRODUCT_CATEGORY_ABSHODE
+ ? `${category.name} (${metalHint})`
+ : category.name
+ }))
+}
+
+/** همان منبع جدول دستهبندیها — قبل از خواندن، همگامسازی میکند */
+export async function syncAndLoadCategories(options?: {
+ selectOnly?: boolean
+ metalHint?: string
+}): Promise {
+ await syncCategoriesFromProducts()
+
+ const rows = await getCategories(
+ options?.selectOnly ? { select_only: true } : undefined
+ )
+
+ return mapCategoriesToSelectItems(rows, options?.metalHint)
+}
diff --git a/src/utils/productCategories.ts b/src/utils/productCategories.ts
index 0f8f807..a832acb 100644
--- a/src/utils/productCategories.ts
+++ b/src/utils/productCategories.ts
@@ -7,6 +7,9 @@ export const UNIFIED_PRODUCT_CATEGORIES = [
'گوی',
'سکه',
'سکه پارسیان',
+ 'شمش',
+ 'شمش ونوس',
+ 'شمش برنا',
'مس',
'نقره',
] as const