admin big changes

This commit is contained in:
2026-06-13 17:38:35 +03:30
parent 213ef1a1b7
commit 0c404ee3e1
14 changed files with 188 additions and 276 deletions
+30 -49
View File
@@ -14,16 +14,6 @@
</a-input>
<div class="settings-toolbar__filters">
<label class="settings-filter-field">
<span class="settings-filter-field__label">وضعیت</span>
<a-select
v-model:value="filterActive"
allow-clear
placeholder="همه"
class="settings-filter-field__control"
:options="statusFilterOptions"
/>
</label>
<label class="settings-filter-field">
<span class="settings-filter-field__label">نوع فیلد</span>
<a-select
@@ -80,7 +70,6 @@
:saving="isSaving(row.id)"
:saved-flash="isSavedFlash(row.id)"
@update:value="onValueChange(row, $event)"
@update:is-active="onActiveChange(row, $event)"
/>
</a-col>
</a-row>
@@ -187,11 +176,6 @@ import {
const settingTypeOptions = SETTING_TYPE_OPTIONS
const statusFilterOptions = [
{ value: 'active', label: 'فعال' },
{ value: 'inactive', label: 'غیرفعال' }
]
const typeSelectOptions = SETTING_TYPE_OPTIONS.map((t) => ({
value: t.key,
label: t.value
@@ -202,11 +186,6 @@ const drafts = ref<Record<number, string>>({})
const addConfigVisible = ref(false)
const search = ref('')
const filterType = ref<string | undefined>()
const filterActive = ref<string | undefined>()
function isRowActive(row: Const): boolean {
return row.is_active !== false && row.is_active !== 0
}
const savingIds = ref<Set<number>>(new Set())
const savedFlashIds = ref<Set<number>>(new Set())
@@ -249,8 +228,6 @@ function isEditable(row: Const): boolean {
function matchesFilter(row: Const): boolean {
const q = search.value.trim().toLowerCase()
if (filterActive.value === 'active' && !isRowActive(row)) return false
if (filterActive.value === 'inactive' && isRowActive(row)) return false
if (filterType.value) {
const t = resolveSettingFieldType(row)
if (t !== filterType.value) return false
@@ -297,16 +274,29 @@ const SETTING_GROUPS: Array<{
id: 'general',
title: 'عمومی و اطلاعات اپ',
icon: 'vuesax-linear:home-2',
match: (k) => /^(name_|app_|admin_|server_|bace_|key$|color_|logo_|title_pwa|title_fav|metal_type|unit$)/.test(k)
match: (k) => /^(name_fa|app_url|admin_url|metal_type|unit$|open_register|auto_active_customer|is_store)/.test(k)
},
{
id: 'chart',
title: 'نمودار قیمت',
icon: 'vuesax-linear:chart-2',
match: (k) => /^chart_/.test(k)
},
{
id: 'pricing',
title: 'قیمت‌گذاری و کارمزدها',
title: 'قیمت‌گذاری و تابلو',
icon: 'vuesax-linear:dollar-circle',
match: (k) =>
/^(fee_|buy_fee|sell_fee|min_|referral_|gift_for|price_provider|zaarbox_api_url|chart_id)/.test(k) ||
/^(fee_|buy_fee|sell_fee|min_|price_provider|zaarbox_|main_product$|show_last_price|close_price|startDay|endDay)/.test(k) ||
k.includes('charge_percentage')
},
{
id: 'referral',
title: 'معرف، پاداش و ثبت‌نام',
icon: 'vuesax-linear:people',
match: (k) =>
/^(referral_|gift_for|register_referral|register_jibit|has_page_earn_money|jibit_verification)/.test(k)
},
{
id: 'montzar',
title: 'سرویس همکار (montzar)',
@@ -315,22 +305,22 @@ const SETTING_GROUPS: Array<{
},
{
id: 'features',
title: 'ویژگی‌ها و صفحات',
title: 'ویژگی‌ها و اعلان‌ها',
icon: 'vuesax-linear:menu',
match: (k) =>
/^(has_page_|has_chat|display_montzar|close_price|startDay|endDay|auto_active|open_register|charge_notif|group_sms|show_last_price|product_update|product_auto_close|is_store|store_status)/.test(k)
match: (k) => /^(charge_notif|group_sms|main_wallet_products|price_from_nasiryan)/.test(k)
},
{
id: 'integrations',
title: 'اتصالات خارجی و درگاه‌ها',
icon: 'vuesax-linear:card',
match: (k) => /^(tahesab_|payping_|jibit_|telegram_|bale_|liman_|support_messenger|external_order|profit_gold)/.test(k)
match: (k) =>
/^(tahesab_|payping_|telegram_|bale_|support_messenger|external_order|profit_gold|node_)/.test(k)
},
{
id: 'misc',
title: 'سایر تنظیمات (متفرقه)',
title: 'سایر تنظیمات',
icon: 'vuesax-linear:more-circle',
match: () => true // catch-all
match: () => true
}
]
@@ -434,12 +424,6 @@ function onValueChange(row: Const, value: string) {
scheduleSave(row)
}
async function onActiveChange(row: Const, isActive: boolean) {
if (row.id == null) return
if (isRowActive(row) === isActive) return
await persistRow(row, { isActive })
}
function scheduleSave(row: Const) {
const id = row.id!
if (!debouncedSave.has(id)) {
@@ -457,21 +441,18 @@ async function persistRowValue(id: number) {
await saveSettingRow(row)
}
async function persistRow(row: Const, overrides?: { isActive?: boolean }) {
await saveSettingRow(row, overrides)
async function persistRow(row: Const) {
await saveSettingRow(row)
}
async function saveSettingRow(row: Const, overrides?: { isActive?: boolean }) {
async function saveSettingRow(row: Const) {
if (row.id == null) return
const id = row.id
const type = resolveSettingFieldType(row)
const raw = drafts.value[id] ?? row.value ?? ''
const value = formatValueForSave(raw, type)
const isActive =
overrides?.isActive !== undefined ? overrides.isActive : isRowActive(row)
if (overrides?.isActive === undefined && value === (row.value ?? '')) return
const value = formatValueForSave(raw, type, row.key)
if (value === (row.value ?? '')) return
savingIds.value.add(id)
savedFlashIds.value.delete(id)
@@ -482,12 +463,12 @@ async function saveSettingRow(row: Const, overrides?: { isActive?: boolean }) {
key: row.key,
value,
description: row.description ?? '',
is_active: isActive,
is_active: true,
title_fa: row.title_fa ?? '',
type
})
row.value = value
row.is_active = isActive
row.is_active = true
drafts.value[id] = value
if (row.key === 'is_store') {
setStoreModeFromSettings(isSwitchOn(value))
@@ -536,7 +517,7 @@ async function ok() {
const payload = {
key: form.value.key,
value: formatValueForSave(form.value.value ?? '', type),
value: formatValueForSave(form.value.value ?? '', type, form.value.key),
description,
is_active: form.value.is_active,
title_fa: form.value.title_fa ?? '',