fix bug of add banner
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user