product modal changes
This commit is contained in:
@@ -300,7 +300,7 @@ import { isSwitchOn } from '@/pages/menuPages/configuration/settingTypes'
|
|||||||
import type { last } from '@/model/price'
|
import type { last } from '@/model/price'
|
||||||
import type { MethodePrices } from '@/model/product'
|
import type { MethodePrices } from '@/model/product'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
import { usesMeltedPriceEditor } from '@/utils/productCategories'
|
||||||
import { computeProductEditorPricePreview } from '@/utils/productEditorPrice'
|
import { computeProductEditorPricePreview } from '@/utils/productEditorPrice'
|
||||||
import { resolveTradeWeightUnit, weightFieldLabelForUnit } from '@/utils/weightUnit'
|
import { resolveTradeWeightUnit, weightFieldLabelForUnit } from '@/utils/weightUnit'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
@@ -330,7 +330,7 @@ const props = defineProps<{
|
|||||||
const isStore = ref(Boolean(props.isStore))
|
const isStore = ref(Boolean(props.isStore))
|
||||||
|
|
||||||
const tradeWeightUnit = ref('گرم')
|
const tradeWeightUnit = ref('گرم')
|
||||||
const isMeltedCategory = computed(() => isMeltedTradeGroup(props.form.group_type))
|
const isMeltedCategory = computed(() => usesMeltedPriceEditor(props.form))
|
||||||
|
|
||||||
const showUnitField = computed(() => isMeltedCategory.value || props.weightOption === '1')
|
const showUnitField = computed(() => isMeltedCategory.value || props.weightOption === '1')
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ import {
|
|||||||
import { normalizeProductOrderLimitForm, validateProductOrderLimitForm } from '@/utils/productOrderLimit'
|
import { normalizeProductOrderLimitForm, validateProductOrderLimitForm } from '@/utils/productOrderLimit'
|
||||||
import {
|
import {
|
||||||
isMeltedTradeGroup,
|
isMeltedTradeGroup,
|
||||||
resolveMeltedPriceSource
|
resolveMeltedPriceSource,
|
||||||
|
usesMeltedPriceEditor,
|
||||||
} from '@/utils/productCategories'
|
} from '@/utils/productCategories'
|
||||||
import { syncAndLoadCategories } from '@/utils/categorySelect'
|
import { syncAndLoadCategories } from '@/utils/categorySelect'
|
||||||
import { getConfiguration } from '@/api/configuration'
|
import { getConfiguration } from '@/api/configuration'
|
||||||
@@ -309,8 +310,16 @@ async function edit(record: Product) {
|
|||||||
|
|
||||||
methodOption.value = productData.reading_method ? '2' : '1'
|
methodOption.value = productData.reading_method ? '2' : '1'
|
||||||
meltedPriceOption.value = resolveMeltedPriceSource(productData)
|
meltedPriceOption.value = resolveMeltedPriceSource(productData)
|
||||||
if (isMeltedTradeGroup(productData.group_type)) {
|
if (usesMeltedPriceEditor(productData)) {
|
||||||
methodOption.value = '1'
|
methodOption.value = '1'
|
||||||
|
if (
|
||||||
|
!isMeltedTradeGroup(productData.group_type)
|
||||||
|
&& !productData.reading_method
|
||||||
|
&& Number(productData.direct_price) !== 1
|
||||||
|
&& Number(productData.price) > 0
|
||||||
|
) {
|
||||||
|
meltedPriceOption.value = 'fixed'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
weightOption.value = Number(productData.amount) > 0 ? '1' : '2'
|
weightOption.value = Number(productData.amount) > 0 ? '1' : '2'
|
||||||
if (weightOption.value === '2' && !isMeltedTradeGroup(productData.group_type)) {
|
if (weightOption.value === '2' && !isMeltedTradeGroup(productData.group_type)) {
|
||||||
@@ -438,10 +447,12 @@ async function saveProduct() {
|
|||||||
loading.value = false
|
loading.value = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isMeltedTradeGroup(payload.group_type)) {
|
if (usesMeltedPriceEditor(payload)) {
|
||||||
payload.amount = 1
|
if (isMeltedTradeGroup(payload.group_type)) {
|
||||||
if (!editId) {
|
payload.amount = 1
|
||||||
payload.trade_by_quantity = true
|
if (!editId) {
|
||||||
|
payload.trade_by_quantity = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
payload.direct_price = meltedPriceOption.value === 'fixed' ? 1 : 0
|
payload.direct_price = meltedPriceOption.value === 'fixed' ? 1 : 0
|
||||||
payload.cash_fee_buy = payload.cash_fee_buy ?? 0
|
payload.cash_fee_buy = payload.cash_fee_buy ?? 0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
import { isMeltedTradeGroup, usesMeltedPriceEditor } from '@/utils/productCategories'
|
||||||
|
|
||||||
function isBlank(value: unknown) {
|
function isBlank(value: unknown) {
|
||||||
return value === undefined || value === null || value === ''
|
return value === undefined || value === null || value === ''
|
||||||
@@ -22,7 +22,7 @@ export function validateProductSubmitInput(input: {
|
|||||||
}): string | null {
|
}): string | null {
|
||||||
const { form, methodOption, weightOption, meltedPriceOption, isEdit } = input
|
const { form, methodOption, weightOption, meltedPriceOption, isEdit } = input
|
||||||
const groupType = String(form.group_type ?? '')
|
const groupType = String(form.group_type ?? '')
|
||||||
const melted = isMeltedTradeGroup(groupType)
|
const melted = usesMeltedPriceEditor(form)
|
||||||
|
|
||||||
if (!String(form.title ?? '').trim()) {
|
if (!String(form.title ?? '').trim()) {
|
||||||
return 'عنوان محصول الزامی است'
|
return 'عنوان محصول الزامی است'
|
||||||
|
|||||||
@@ -27,6 +27,22 @@ export function isMeltedTradeGroup(groupType?: string | null) {
|
|||||||
return group === PRODUCT_CATEGORY_ABSHODE || group === LEGACY_GROUP_KATOD
|
return group === PRODUCT_CATEGORY_ABSHODE || group === LEGACY_GROUP_KATOD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** ادیتور قیمت آبشدهای — کاتد/آبشده یا معامله مقداری (trade_by_quantity) */
|
||||||
|
export function usesMeltedPriceEditor(input?: {
|
||||||
|
group_type?: string | null
|
||||||
|
trade_by_quantity?: boolean | number | null
|
||||||
|
} | null) {
|
||||||
|
if (!input) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMeltedTradeGroup(input.group_type)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return input.trade_by_quantity === true || Number(input.trade_by_quantity) === 1
|
||||||
|
}
|
||||||
|
|
||||||
export type MeltedPriceSource = 'app' | 'fixed' | 'reference'
|
export type MeltedPriceSource = 'app' | 'fixed' | 'reference'
|
||||||
|
|
||||||
export function resolveMeltedPriceSource(product?: {
|
export function resolveMeltedPriceSource(product?: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { last } from '@/model/price'
|
import type { last } from '@/model/price'
|
||||||
import type { MethodePrices } from '@/model/product'
|
import type { MethodePrices } from '@/model/product'
|
||||||
import type { MeltedPriceSource } from '@/utils/productCategories'
|
import type { MeltedPriceSource } from '@/utils/productCategories'
|
||||||
import { isMeltedTradeGroup } from '@/utils/productCategories'
|
import { usesMeltedPriceEditor } from '@/utils/productCategories'
|
||||||
|
|
||||||
const GOLD_DOT_REFERENCE_NAME = 'گلد دات ای از آبشده - رسمی - نقد فردا'
|
const GOLD_DOT_REFERENCE_NAME = 'گلد دات ای از آبشده - رسمی - نقد فردا'
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ export function computeProductEditorPricePreview(input: {
|
|||||||
appLastPrice?: (Partial<last> & { price?: number; last_historical?: number }) | null
|
appLastPrice?: (Partial<last> & { price?: number; last_historical?: number }) | null
|
||||||
}): ProductEditorPricePreview {
|
}): ProductEditorPricePreview {
|
||||||
const offsetPercent = Number(input.form.price_offset_percent ?? 0)
|
const offsetPercent = Number(input.form.price_offset_percent ?? 0)
|
||||||
const melted = isMeltedTradeGroup(input.form.group_type)
|
const melted = usesMeltedPriceEditor(input.form)
|
||||||
|
|
||||||
if (melted) {
|
if (melted) {
|
||||||
if (input.meltedPriceOption === 'fixed') {
|
if (input.meltedPriceOption === 'fixed') {
|
||||||
|
|||||||
Reference in New Issue
Block a user