admin big changes
This commit is contained in:
@@ -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<Item> = [
|
||||
{ key: 2, value: 'نقره' },
|
||||
{ key: 3, value: 'مس' },
|
||||
]
|
||||
const storeCategorySelectItems = ref<Array<{ key: string; value: string }>>([])
|
||||
const categorySelectItems = computed(() => {
|
||||
if (isStoreApp() && storeCategorySelectItems.value.length) {
|
||||
return storeCategorySelectItems.value
|
||||
}
|
||||
return buildCategorySelectItems(metalItems)
|
||||
})
|
||||
const apiCategorySelectItems = ref<Array<{ key: string; value: string }>>([])
|
||||
const categorySelectItems = computed(() => apiCategorySelectItems.value)
|
||||
const priceItems: Array<Item> = [
|
||||
{ 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<string, any>, productId?: num
|
||||
}
|
||||
|
||||
async function edit(record: Product) {
|
||||
await loadCategorySelectItems()
|
||||
addUserVisible.value = true
|
||||
editId = record.id
|
||||
let productData = cloneDeep(record) as Record<string, any>
|
||||
@@ -333,6 +319,7 @@ async function add() {
|
||||
editId = undefined
|
||||
addUserVisible.value = true
|
||||
resetData()
|
||||
await loadCategorySelectItems()
|
||||
}
|
||||
|
||||
function resetData() {
|
||||
|
||||
Reference in New Issue
Block a user