+
+
+
+ قیمت لحظهای:
+
+ {{ usePrice(livePricePreview.amount) }}
+
+
+ {{ livePricePreview.message }}
+
+
+ مبنا: {{ livePricePreview.source }}
+
+ — تعدیل {{ form.price_offset_percent }}٪
+
+
+
+
بروزرسانی
-
- {{ usePrice(livePricePreview.amount) }}
-
-
- {{ livePricePreview.message }}
-
-
- {{ livePricePreview.message }}
-
-
- مبنا: {{ livePricePreview.source }}
-
- — تعدیل {{ form.price_offset_percent }}٪
-
-
pricesData: MethodePrices[]
- pricesLoading: boolean
appLastPrice: (last & { price?: number }) | null
- appPriceLoading: boolean
categoryItems: any[]
metalItems: any[]
priceItems: any[]
@@ -268,9 +268,7 @@ const livePricePreview = computed(() =>
methodOption: props.methodOption,
meltedPriceOption: props.meltedPriceOption as 'app' | 'fixed' | 'reference',
pricesData: props.pricesData,
- appLastPrice: props.appLastPrice,
- pricesLoading: props.pricesLoading,
- appPriceLoading: props.appPriceLoading
+ appLastPrice: props.appLastPrice
})
)
diff --git a/src/pages/menuPages/products/base/index.vue b/src/pages/menuPages/products/base/index.vue
index 7ea6684..73ce627 100644
--- a/src/pages/menuPages/products/base/index.vue
+++ b/src/pages/menuPages/products/base/index.vue
@@ -24,9 +24,7 @@
:activeKey="activeKey_"
:pricesList="pricesList"
:pricesData="pricesData"
- :pricesLoading="pricesLoading"
:appLastPrice="appLastPrice"
- :appPriceLoading="appPriceLoading"
:categoryItems="categorySelectItems"
:metalItems="metalItems"
:priceItems="priceItems"
@@ -129,9 +127,7 @@ const priceItems: Array- = [
]
const pricesData = ref([])
-const pricesLoading = ref(false)
const appLastPrice = ref<(last & { price?: number }) | null>(null)
-const appPriceLoading = ref(false)
let pricePollTimer: ReturnType | undefined
const pricesList = computed(() =>
@@ -142,25 +138,19 @@ const pricesList = computed(() =>
)
async function fetchPrices() {
- pricesLoading.value = true
try {
pricesData.value = await methodePrices()
} catch (err) {
console.error(err)
- } finally {
- pricesLoading.value = false
}
}
async function fetchAppPrice() {
- appPriceLoading.value = true
try {
appLastPrice.value = await getLastPrice()
} catch (err) {
console.error(err)
appLastPrice.value = null
- } finally {
- appPriceLoading.value = false
}
}
diff --git a/src/utils/productEditorPrice.ts b/src/utils/productEditorPrice.ts
index 43ce29a..7d16092 100644
--- a/src/utils/productEditorPrice.ts
+++ b/src/utils/productEditorPrice.ts
@@ -55,7 +55,6 @@ export function resolveAppBasePrice(lastPrice?: Partial & { price?: number
export type ProductEditorPricePreview =
| { status: 'ready'; amount: number; source: string }
| { status: 'empty'; message: string }
- | { status: 'loading'; message: string }
export function computeProductEditorPricePreview(input: {
form: {
@@ -68,8 +67,6 @@ export function computeProductEditorPricePreview(input: {
meltedPriceOption: MeltedPriceSource
pricesData: MethodePrices[]
appLastPrice?: (Partial & { price?: number }) | null
- pricesLoading?: boolean
- appPriceLoading?: boolean
}): ProductEditorPricePreview {
const offsetPercent = Number(input.form.price_offset_percent ?? 0)
const melted = isMeltedTradeGroup(input.form.group_type)
@@ -83,12 +80,9 @@ export function computeProductEditorPricePreview(input: {
}
if (input.meltedPriceOption === 'app') {
- if (input.appPriceLoading) {
- return { status: 'loading', message: 'در حال دریافت قیمت اپ...' }
- }
const base = resolveAppBasePrice(input.appLastPrice)
if (base <= 0) {
- return { status: 'empty', message: 'قیمت اپ در دسترس نیست' }
+ return { status: 'empty', message: '' }
}
return {
status: 'ready',
@@ -100,12 +94,9 @@ export function computeProductEditorPricePreview(input: {
if (!input.form.reading_method) {
return { status: 'empty', message: 'مرجع قیمت را انتخاب کنید' }
}
- if (input.pricesLoading) {
- return { status: 'loading', message: 'در حال دریافت قیمت مرجع...' }
- }
const entry = findMethodPriceEntry(input.pricesData, input.form.reading_method)
if (!entry) {
- return { status: 'empty', message: 'مرجع قیمت یافت نشد' }
+ return { status: 'empty', message: '' }
}
const { base, profit } = normalizeReferenceBase(entry)
return {
@@ -125,12 +116,9 @@ export function computeProductEditorPricePreview(input: {
if (!input.form.reading_method) {
return { status: 'empty', message: 'مرجع قیمت را انتخاب کنید' }
}
- if (input.pricesLoading) {
- return { status: 'loading', message: 'در حال دریافت قیمت مرجع...' }
- }
const entry = findMethodPriceEntry(input.pricesData, input.form.reading_method)
if (!entry) {
- return { status: 'empty', message: 'مرجع قیمت یافت نشد' }
+ return { status: 'empty', message: '' }
}
const { base, profit } = normalizeReferenceBase(entry)
return {