diff --git a/components.d.ts b/components.d.ts index 575c671..2220fd1 100644 --- a/components.d.ts +++ b/components.d.ts @@ -15,13 +15,16 @@ declare module '@vue/runtime-core' { AButton: typeof import('ant-design-vue/es')['Button'] ACard: typeof import('ant-design-vue/es')['Card'] ACheckbox: typeof import('ant-design-vue/es')['Checkbox'] + ACol: typeof import('ant-design-vue/es')['Col'] AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider'] ADivider: typeof import('ant-design-vue/es')['Divider'] ADrawer: typeof import('ant-design-vue/es')['Drawer'] ADropdown: typeof import('ant-design-vue/es')['Dropdown'] + AEmpty: typeof import('ant-design-vue/es')['Empty'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] AInput: typeof import('ant-design-vue/es')['Input'] + AInputNumber: typeof import('ant-design-vue/es')['InputNumber'] AInputPassword: typeof import('ant-design-vue/es')['InputPassword'] ALayout: typeof import('ant-design-vue/es')['Layout'] ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent'] @@ -36,6 +39,7 @@ declare module '@vue/runtime-core' { 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'] ASelect: typeof import('ant-design-vue/es')['Select'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASpin: typeof import('ant-design-vue/es')['Spin'] diff --git a/src/api/configuration.ts b/src/api/configuration.ts index ab593f4..3b003d3 100644 --- a/src/api/configuration.ts +++ b/src/api/configuration.ts @@ -1,7 +1,7 @@ -import type { Const } from '@/model/const' -import useAxios from '@core/utils/useAxios' +import type { Const } from '@/model/configuration' +import useAxios from "@core/utils/useAxios" export const setConfiguration = async (obj: Const) => await useAxios.post(`/admin/get_settings`, obj) export const getConfiguration = async () => - await useAxios.get>(`/admin/get_settings`) \ No newline at end of file + await useAxios.get>(`/admin/get_settings`, { params: { editable_only: 1 } }) \ No newline at end of file diff --git a/src/components/BasicShowContext.vue b/src/components/BasicShowContext.vue index a564639..206bbda 100644 --- a/src/components/BasicShowContext.vue +++ b/src/components/BasicShowContext.vue @@ -4,7 +4,7 @@
{{ props.title }}
-
+
diff --git a/src/model/configuration.ts b/src/model/configuration.ts index 1d837d2..7fc52ad 100644 --- a/src/model/configuration.ts +++ b/src/model/configuration.ts @@ -3,17 +3,10 @@ export interface Const { key?: string value?: string | undefined description?: string - type: string - title_fa: string -} - -export interface SupportLink { - show_to_users_goftino: string - show_to_users_eitaa: string - show_to_users_telegram: string - show_to_users_whatsapp: string - show_to_users_bale: string - show_to_users_phone: string + title_fa?: string + type?: string + is_active: boolean | number + can_edit?: number | boolean } export interface itemConfig { diff --git a/src/pages/menuPages/configuration/SettingCard.vue b/src/pages/menuPages/configuration/SettingCard.vue new file mode 100644 index 0000000..07787b8 --- /dev/null +++ b/src/pages/menuPages/configuration/SettingCard.vue @@ -0,0 +1,185 @@ + + + + + diff --git a/src/pages/menuPages/configuration/SettingValueField.vue b/src/pages/menuPages/configuration/SettingValueField.vue new file mode 100644 index 0000000..e08b85e --- /dev/null +++ b/src/pages/menuPages/configuration/SettingValueField.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/src/pages/menuPages/configuration/index.vue b/src/pages/menuPages/configuration/index.vue index 86e0426..05c0fb4 100644 --- a/src/pages/menuPages/configuration/index.vue +++ b/src/pages/menuPages/configuration/index.vue @@ -1,69 +1,158 @@ - \ No newline at end of file + diff --git a/src/pages/menuPages/configuration/settingTypes.ts b/src/pages/menuPages/configuration/settingTypes.ts new file mode 100644 index 0000000..fcf1d8d --- /dev/null +++ b/src/pages/menuPages/configuration/settingTypes.ts @@ -0,0 +1,147 @@ +import type { Const } from '@/model/configuration' + +export type SettingFieldType = 'text' | 'number' | 'switch' | 'select' | 'longtext' + +export const SETTING_TYPE_OPTIONS = [ + { key: 'text', value: 'متن کوتاه' }, + { key: 'number', value: 'عدد' }, + { key: 'switch', value: 'روشن/خاموش' }, + { key: 'select', value: 'انتخابی' }, + { key: 'longtext', value: 'متن بلند' } +] + +const KEY_TYPE_FALLBACK: Record = { + price_provider: 'select', + referral_id: 'select', + payping_gateway_name: 'select', + text_rule: 'longtext', + text_about: 'longtext', + fee_service_charge_percentage: 'number', + fee_single: 'number', + buy_fee: 'number', + sell_fee: 'number', + fee_cash: 'number', + min_withdraw: 'number', + min_first_buy: 'number', + minimum_sell: 'number', + gift_for_referrer: 'number', + gift_for_referral: 'number', + referral_bonus_amount: 'text', + referral_count_for_gift: 'number', + montzar_product_id: 'number', + balance_report_exclude_customer_id: 'number', + jibit_verification: 'switch', + register_jibit_verify: 'switch', + open_register: 'switch', + auto_active_customer: 'switch', + close_price: 'switch', + montzar_price: 'switch', + main_product_price: 'switch', + tabanGohar_price: 'switch', + show_last_price: 'switch', + send_to_tahesab: 'switch', + profit_gold_api_enabled: 'switch', + payping_round_toman: 'switch', + payping_strict_failed_withdraw: 'switch', + has_page_earn_money: 'switch', + has_page_fund: 'switch', + has_page_permission: 'switch', + has_page_price_trigger: 'switch', + has_page_physical_gold: 'switch', + has_chat: 'switch', + charge_notif: 'switch', + group_sms: 'switch', + display_montzar: 'switch', + credit: 'switch', + credit_daily: 'switch', + credit_error_in_orders: 'switch', + credit_rial_dynamic: 'switch', + open_closed_messages: 'switch', + new_style_create_order: 'switch', + new_style_admin_layout: 'switch', + register: 'switch', + sharh: 'switch', + multi_source: 'switch', + get_orders_pdf: 'switch', + get_orders_excel: 'switch', + auto_order_buy_sell: 'switch', + invite_link: 'switch', + montzar_closed: 'switch', + montzar_open_buy: 'switch', + montzar_open_sell: 'switch', + is_requaire_referral: 'switch', + product_update_price_on_list: 'switch', + product_auto_close_open_on_list: 'switch', + payping_fin_sync_enabled: 'switch', + external_order_api_enabled: 'switch', + store_status: 'select', + credit_rial_price_unit: 'select', + node_client_id: 'text', + node_shared_secret: 'text' +} + +const SELECT_OPTIONS_BY_KEY: Record = { + price_provider: 'montzar,zaarbox,main_product,taban_gohar', + referral_id: 'required,', + payping_gateway_name: 'sepal,', + credit_rial_price_unit: 'gram,mesghal,unit', + store_status: 'باز,بسته' +} + +export function resolveSettingFieldType(row: Pick): SettingFieldType { + const raw = (row.type || '').trim().toLowerCase() + if (['text', 'number', 'switch', 'select', 'longtext'].includes(raw)) { + return raw as SettingFieldType + } + if (row.key && KEY_TYPE_FALLBACK[row.key]) { + return KEY_TYPE_FALLBACK[row.key] + } + return 'text' +} + +/** گزینه‌های select: اول از description (با | یا کاما)، بعد از نقشه کلید */ +export function parseSelectOptions( + row: Pick +): Array<{ key: string; value: string }> { + const preset = row.key ? SELECT_OPTIONS_BY_KEY[row.key] : '' + let source = preset || row.description || '' + + if (source.includes('|')) { + source = source.split('|').pop() || '' + } + + const opts = source.split(',').map((s) => s.trim()) + return opts.map((opt) => ({ + key: opt, + value: opt === '' ? '(خالی)' : opt + })) +} + +export function isSwitchOn(value: string | undefined): boolean { + const v = (value ?? '').trim().toLowerCase() + return v === 'true' || v === '1' || v === 'yes' +} + +export function switchToString(checked: boolean): string { + return checked ? 'true' : 'false' +} + +export function formatValueForSave(value: string, type: SettingFieldType): string { + if (type === 'switch') { + return switchToString(isSwitchOn(value)) + } + if (type === 'number') { + return value === '' ? '0' : String(value).replace(/,/g, '') + } + return value ?? '' +} + +export function helpText(row: Const): string { + const desc = (row.description || '').trim() + if (!desc) return '' + if (resolveSettingFieldType(row) === 'select' && desc.includes(',')) { + const parts = desc.split('|') + return parts.length > 1 ? parts[0].trim() : '' + } + return desc +} diff --git a/src/pages/menuPages/setting/index.vue b/src/pages/menuPages/setting/index.vue index 9d123a3..4591970 100644 --- a/src/pages/menuPages/setting/index.vue +++ b/src/pages/menuPages/setting/index.vue @@ -1,7 +1,7 @@