fix bug of add banner

This commit is contained in:
2026-07-05 12:05:18 +02:00
parent bcf7b2f0ae
commit 86e6c3c16f
2 changed files with 16 additions and 16 deletions
-3
View File
@@ -10,7 +10,6 @@ export {}
declare module '@vue/runtime-core' {
export interface GlobalComponents {
_index: typeof import('./src/core/components/_sample/_index.vue')['default']
AAlert: typeof import('ant-design-vue/es')['Alert']
AAvatar: typeof import('ant-design-vue/es')['Avatar']
ABadge: typeof import('ant-design-vue/es')['Badge']
AButton: typeof import('ant-design-vue/es')['Button']
@@ -38,9 +37,7 @@ declare module '@vue/runtime-core' {
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
AModal: typeof import('ant-design-vue/es')['Modal']
APagination: typeof import('ant-design-vue/es')['Pagination']
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
APopover: typeof import('ant-design-vue/es')['Popover']
ARadio: typeof import('ant-design-vue/es')['Radio']
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
ARow: typeof import('ant-design-vue/es')['Row']
+16 -13
View File
@@ -79,10 +79,21 @@ const typeList = ref([
{lable: 'بدون رویداد', value: null},
])
let content = ''
function parseBannerList(value: string | null | undefined): IBenefits[] {
if (!value) return []
try {
const parsed = JSON.parse(value)
return Array.isArray(parsed) ? parsed : []
} catch {
return []
}
}
function addRow() {
benefitsList.value.push({icon: null, show: true, caption: null, link: null, typeClick: null ,modalText:null})
if (!Array.isArray(benefitsList.value)) {
benefitsList.value = []
}
benefitsList.value.push({icon: null, show: true, caption: null, link: null, typeClick: null, modalText: null})
}
function removeRow(index: number) {
@@ -116,17 +127,9 @@ onMounted(async () => {
try {
const res = await getHeaderBannerConst()
if (res) {
if (res.length > 0) {
id = res[0].id || res[0].const_id || null
if (res[0].value) {
benefitsList.value = JSON.parse(res[0].value)
}
} else {
benefitsList.value = JSON.parse(res.value)
}
console.log(benefitsList.value)
if (res?.length > 0) {
id = res[0].id || res[0].const_id || null
benefitsList.value = parseBannerList(res[0].value)
}
} catch (error) {
console.error('خطا در دریافت بنرها:', error)