fix bug
This commit is contained in:
@@ -24,6 +24,7 @@ export interface Product{
|
|||||||
open_sell: boolean
|
open_sell: boolean
|
||||||
show: boolean
|
show: boolean
|
||||||
show_in_assets?: boolean
|
show_in_assets?: boolean
|
||||||
|
use_last_price_if_zero?: boolean
|
||||||
title: string
|
title: string
|
||||||
updated_at: string
|
updated_at: string
|
||||||
methodOption: number
|
methodOption: number
|
||||||
|
|||||||
@@ -40,13 +40,14 @@ export const cols: BaseTableColumn[] = [
|
|||||||
// className: 'column-money'
|
// className: 'column-money'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'نام قلک',
|
title: 'نام محصول',
|
||||||
dataIndex: 'fund.title',
|
dataIndex: 'product.title',
|
||||||
key: 'fund.title',
|
key: 'product.title',
|
||||||
type: 'Text'
|
type: 'Text',
|
||||||
|
customRender: (record: any) => record.record?.product?.title ?? '-'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'موجودی طلا',
|
title: 'موجودی',
|
||||||
dataIndex: 'gold',
|
dataIndex: 'gold',
|
||||||
key: 'gold',
|
key: 'gold',
|
||||||
type: 'Number'
|
type: 'Number'
|
||||||
|
|||||||
@@ -46,6 +46,12 @@
|
|||||||
<div class="text-xs text-gray-500">
|
<div class="text-xs text-gray-500">
|
||||||
مثبت = گرانتر، منفی = ارزانتر نسبت به قیمت مرجع.
|
مثبت = گرانتر، منفی = ارزانتر نسبت به قیمت مرجع.
|
||||||
</div>
|
</div>
|
||||||
|
<a-form-item label="قیمت صفر از provider" name="use_last_price_if_zero" class="!mb-0">
|
||||||
|
<a-switch v-model:checked="form.use_last_price_if_zero" />
|
||||||
|
<span class="mr-2 text-xs text-gray-500">
|
||||||
|
اگر provider قیمت نداد (صفر)، با آخرین قیمت ذخیرهشده معامله شود
|
||||||
|
</span>
|
||||||
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="meltedPriceOption === 'app'" class="flex flex-col gap-2">
|
<div v-if="meltedPriceOption === 'app'" class="flex flex-col gap-2">
|
||||||
<div class="md:flex justify-between items-center">
|
<div class="md:flex justify-between items-center">
|
||||||
@@ -113,6 +119,12 @@
|
|||||||
<div class="text-xs text-gray-500">
|
<div class="text-xs text-gray-500">
|
||||||
مثبت = گرانتر، منفی = ارزانتر نسبت به قیمت اتوماتیک. مثلاً ۵ یعنی ۵٪ بالاتر از مرجع.
|
مثبت = گرانتر، منفی = ارزانتر نسبت به قیمت اتوماتیک. مثلاً ۵ یعنی ۵٪ بالاتر از مرجع.
|
||||||
</div>
|
</div>
|
||||||
|
<a-form-item label="قیمت صفر از provider" name="use_last_price_if_zero" class="!mb-0">
|
||||||
|
<a-switch v-model:checked="form.use_last_price_if_zero" />
|
||||||
|
<span class="mr-2 text-xs text-gray-500">
|
||||||
|
اگر provider قیمت نداد (صفر)، با آخرین قیمت ذخیرهشده معامله شود
|
||||||
|
</span>
|
||||||
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -280,6 +280,7 @@ async function edit(record: Product) {
|
|||||||
|
|
||||||
form.value = normalizeProductOrderLimitForm({
|
form.value = normalizeProductOrderLimitForm({
|
||||||
...productData,
|
...productData,
|
||||||
|
show_in_assets: productData.show_in_assets ?? false,
|
||||||
price_offset_percent: productData.price_offset_percent ?? 0,
|
price_offset_percent: productData.price_offset_percent ?? 0,
|
||||||
direct_price: productData.direct_price ?? 0,
|
direct_price: productData.direct_price ?? 0,
|
||||||
auto_open_at: start.isValid() ? start : dayjs('00:00:00', 'HH:mm:ss'),
|
auto_open_at: start.isValid() ? start : dayjs('00:00:00', 'HH:mm:ss'),
|
||||||
@@ -320,7 +321,8 @@ function resetData() {
|
|||||||
file_id: undefined,
|
file_id: undefined,
|
||||||
file: undefined,
|
file: undefined,
|
||||||
order_limit_enabled: false,
|
order_limit_enabled: false,
|
||||||
show_in_assets: true,
|
show_in_assets: false,
|
||||||
|
use_last_price_if_zero: false,
|
||||||
min_order_cash: undefined,
|
min_order_cash: undefined,
|
||||||
max_order_cash: undefined,
|
max_order_cash: undefined,
|
||||||
auto_open_at: dayjs('00:00:00', 'HH:mm:ss'),
|
auto_open_at: dayjs('00:00:00', 'HH:mm:ss'),
|
||||||
|
|||||||
@@ -56,12 +56,24 @@ export type ProductEditorPricePreview =
|
|||||||
| { status: 'ready'; amount: number; source: string }
|
| { status: 'ready'; amount: number; source: string }
|
||||||
| { status: 'empty'; message: string }
|
| { status: 'empty'; message: string }
|
||||||
|
|
||||||
|
function resolveStoredFallbackPrice(
|
||||||
|
storedPrice: number | null | undefined,
|
||||||
|
useLastPriceIfZero: boolean | undefined
|
||||||
|
): number {
|
||||||
|
if (!useLastPriceIfZero) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number(storedPrice) || 0
|
||||||
|
}
|
||||||
|
|
||||||
export function computeProductEditorPricePreview(input: {
|
export function computeProductEditorPricePreview(input: {
|
||||||
form: {
|
form: {
|
||||||
group_type?: string
|
group_type?: string
|
||||||
price?: number | null
|
price?: number | null
|
||||||
reading_method?: string | null
|
reading_method?: string | null
|
||||||
price_offset_percent?: number | null
|
price_offset_percent?: number | null
|
||||||
|
use_last_price_if_zero?: boolean | null
|
||||||
}
|
}
|
||||||
methodOption: string
|
methodOption: string
|
||||||
meltedPriceOption: MeltedPriceSource
|
meltedPriceOption: MeltedPriceSource
|
||||||
@@ -99,11 +111,17 @@ export function computeProductEditorPricePreview(input: {
|
|||||||
return { status: 'empty', message: '' }
|
return { status: 'empty', message: '' }
|
||||||
}
|
}
|
||||||
const { base, profit } = normalizeReferenceBase(entry)
|
const { base, profit } = normalizeReferenceBase(entry)
|
||||||
return {
|
const liveAmount = adjustedProductPrice(base, profit, offsetPercent)
|
||||||
status: 'ready',
|
if (liveAmount > 0) {
|
||||||
amount: adjustedProductPrice(base, profit, offsetPercent),
|
return { status: 'ready', amount: liveAmount, source: entry.name }
|
||||||
source: entry.name
|
|
||||||
}
|
}
|
||||||
|
const fallback = resolveStoredFallbackPrice(
|
||||||
|
input.form.price,
|
||||||
|
input.form.use_last_price_if_zero ?? false
|
||||||
|
)
|
||||||
|
return fallback > 0
|
||||||
|
? { status: 'ready', amount: fallback, source: 'آخرین قیمت ذخیرهشده' }
|
||||||
|
: { status: 'empty', message: 'قیمت provider صفر است' }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.methodOption === '1') {
|
if (input.methodOption === '1') {
|
||||||
@@ -121,9 +139,15 @@ export function computeProductEditorPricePreview(input: {
|
|||||||
return { status: 'empty', message: '' }
|
return { status: 'empty', message: '' }
|
||||||
}
|
}
|
||||||
const { base, profit } = normalizeReferenceBase(entry)
|
const { base, profit } = normalizeReferenceBase(entry)
|
||||||
return {
|
const liveAmount = adjustedProductPrice(base, profit, offsetPercent)
|
||||||
status: 'ready',
|
if (liveAmount > 0) {
|
||||||
amount: adjustedProductPrice(base, profit, offsetPercent),
|
return { status: 'ready', amount: liveAmount, source: entry.name }
|
||||||
source: entry.name
|
|
||||||
}
|
}
|
||||||
|
const fallback = resolveStoredFallbackPrice(
|
||||||
|
input.form.price,
|
||||||
|
input.form.use_last_price_if_zero ?? false
|
||||||
|
)
|
||||||
|
return fallback > 0
|
||||||
|
? { status: 'ready', amount: fallback, source: 'آخرین قیمت ذخیرهشده' }
|
||||||
|
: { status: 'empty', message: 'قیمت provider صفر است' }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user