Compare commits
30
Commits
4d8d35c37d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa61e570d0 | ||
|
|
87c35c3101 | ||
|
|
a778aad7bc | ||
|
|
e0e2b6daa5 | ||
|
|
379995e0ab | ||
|
|
c9b7876734 | ||
|
|
29904adf02 | ||
|
|
ec92e288ad | ||
|
|
3df3164e0b | ||
|
|
dfc6f8dc64 | ||
|
|
88271dba2a | ||
|
|
e5b3d0c931 | ||
|
|
2927d64c64 | ||
|
|
d067551d37 | ||
|
|
8a4f95da7d | ||
|
|
7e869902d6 | ||
|
|
8004dd52b3 | ||
|
|
7ff90b05d0 | ||
|
|
3c56672a27 | ||
|
|
2d5e8da2cb | ||
|
|
0f60c1e1a5 | ||
|
|
3fc62ba100 | ||
|
|
9ef381f00e | ||
|
|
e0b89223ac | ||
|
|
dec36cc31e | ||
|
|
7c95f1f9d6 | ||
|
|
11f60f205a | ||
|
|
62a6a91455 | ||
|
|
6ab14313dd | ||
|
|
ba12569b97 |
Vendored
+3
@@ -92,11 +92,14 @@ declare module '@vue/runtime-core' {
|
||||
PargarRetryModal: typeof import('./src/components/PargarRetryModal.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
ShayeganChargeAlertHost: typeof import('./src/components/ShayeganChargeAlertHost.vue')['default']
|
||||
ShayeganCustomerRegisterModal: typeof import('./src/components/ShayeganCustomerRegisterModal.vue')['default']
|
||||
SmsCreditWidget: typeof import('./src/components/SmsCreditWidget.vue')['default']
|
||||
SmsNegativeBalanceHost: typeof import('./src/components/SmsNegativeBalanceHost.vue')['default']
|
||||
SmsNegativeBalanceModal: typeof import('./src/components/SmsNegativeBalanceModal.vue')['default']
|
||||
SubscriptionExpiryHost: typeof import('./src/components/SubscriptionExpiryHost.vue')['default']
|
||||
SubscriptionExpiryModal: typeof import('./src/components/SubscriptionExpiryModal.vue')['default']
|
||||
TahesabDocSyncProgress: typeof import('./src/components/TahesabDocSyncProgress.vue')['default']
|
||||
TahesabRetryModal: typeof import('./src/components/TahesabRetryModal.vue')['default']
|
||||
ThemeMenuSection: typeof import('./src/core/components/ThemeMenuSection.vue')['default']
|
||||
ThemeToggle: typeof import('./src/core/components/ThemeToggle.vue')['default']
|
||||
|
||||
+13
@@ -2,7 +2,9 @@
|
||||
<AConfigProvider direction="rtl">
|
||||
<RouterView />
|
||||
<CustomerImportProgress />
|
||||
<TahesabDocSyncProgress />
|
||||
<GroupSmsSendProgress />
|
||||
<ShayeganChargeAlertHost />
|
||||
</AConfigProvider>
|
||||
</template>
|
||||
|
||||
@@ -12,8 +14,11 @@ import { message } from 'ant-design-vue'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import { initDarkmode } from '@core/stores/darkmode'
|
||||
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
||||
import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue'
|
||||
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
||||
import ShayeganChargeAlertHost from '@/components/ShayeganChargeAlertHost.vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
@@ -64,7 +69,15 @@ watch(latestIncomingNotification, (payload) => {
|
||||
|
||||
onMounted(async () => {
|
||||
await config.getConfigData()
|
||||
void useTahesabDocSyncStore().hydrate()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => userStore.userInfo?.id,
|
||||
(id) => {
|
||||
if (id) void useTahesabDocSyncStore().hydrate()
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
|
||||
@@ -10,6 +10,9 @@ export type CategoryListParams = {
|
||||
export const getCategories = async (params?: CategoryListParams) =>
|
||||
await useAxios.get<Category[]>('/admin/categories', { params })
|
||||
|
||||
export const createCategory = async (payload: CategoryInput) =>
|
||||
await useAxios.post<Category>('/admin/categories', payload)
|
||||
|
||||
export const updateCategory = async (id: number, payload: Partial<CategoryInput>) =>
|
||||
await useAxios.put<Category>(`/admin/categories/${id}`, payload)
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
|
||||
export interface CopperConvertRequestRow {
|
||||
id: number
|
||||
status: 'pending' | 'approved' | 'rejected' | string
|
||||
source: string
|
||||
customer_name: string
|
||||
customer_mobile: string
|
||||
asset_unit: string
|
||||
consumed_amount: number
|
||||
leftover_amount: number
|
||||
source_unit_price: number
|
||||
wire15_rings: number
|
||||
wire15_unit_price: number
|
||||
wire25_rings: number
|
||||
wire25_unit_price: number
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
export const getCopperConvertRequests = () =>
|
||||
useAxios.get<CopperConvertRequestRow[]>('/admin/copper-convert-request')
|
||||
|
||||
export const approveCopperConvertRequest = (id: number) =>
|
||||
useAxios.post(`/admin/copper-convert-request/${id}/approve`)
|
||||
|
||||
export const rejectCopperConvertRequest = (id: number) =>
|
||||
useAxios.post(`/admin/copper-convert-request/${id}/reject`)
|
||||
@@ -7,8 +7,33 @@ import type {Giftcard, GiftcardInput} from "@/model/giftCard";
|
||||
export const getGiftCardTable = async (params: TableInput) =>
|
||||
await useAxios.post<Array<Giftcard>>('/admin/giftcard/table', params)
|
||||
|
||||
export interface GiftCardCodesUsageSummary {
|
||||
total_codes: number
|
||||
used_codes: number
|
||||
unused_codes: number
|
||||
active_codes: number
|
||||
expired_codes: number
|
||||
}
|
||||
|
||||
export type GiftCardCodesUsageReportResponse = {
|
||||
rows: Record<string, unknown>[]
|
||||
summary?: GiftCardCodesUsageSummary
|
||||
query?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export const getGiftCardCodesUsageReport = async (params: TableInput) =>
|
||||
await useAxios.post<GiftCardCodesUsageReportResponse>(
|
||||
'/admin/giftcard/codes-usage-report',
|
||||
params,
|
||||
)
|
||||
|
||||
export const createGiftCard = async (obj: GiftcardInput) =>
|
||||
await useAxios.post<Giftcard>(`/admin/giftcard/generate`, obj)
|
||||
|
||||
export const updateGiftCard = async (id: number, obj: GiftcardInput) =>
|
||||
await useAxios.put<Giftcard>(`/admin/giftcard/${id}`, obj)
|
||||
|
||||
export const deleteGiftCard = async (id: number) => await useAxios.delete(`/admin/giftcard/${id}`)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ export const changeSellActiveProduct = async (id?: number) => {
|
||||
export const changeActiveProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/active/${id}`)
|
||||
}
|
||||
export const changeShowOnTvProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/show_on_tv/${id}`)
|
||||
}
|
||||
export const changeVisibilityProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/hide/${id}`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import type { TableInput, TableOutput } from '@core/type/baseTable'
|
||||
|
||||
export interface ShayeganRecord {
|
||||
id?: number | null
|
||||
customer_id?: number | null
|
||||
customer?: {
|
||||
id?: number
|
||||
name?: string
|
||||
fname?: string
|
||||
lname?: string
|
||||
mobile?: string
|
||||
moshtari_code?: string
|
||||
} | null
|
||||
order_id?: number | null
|
||||
withdraw_id?: number | null
|
||||
amount?: number | null
|
||||
desc?: string | null
|
||||
type?: string | null
|
||||
sync_status?: 'pending' | 'success' | 'failed' | 'timeout' | string
|
||||
sync_log?: string | null
|
||||
shayegan_number?: string | null
|
||||
shayegan_guid?: string | null
|
||||
endpoint?: string | null
|
||||
created_at?: string | null
|
||||
}
|
||||
|
||||
export const shayeganHealth = async () =>
|
||||
await useAxios.get<{
|
||||
ok: boolean
|
||||
message?: string
|
||||
http_status?: number | null
|
||||
timeout?: boolean
|
||||
body?: unknown
|
||||
}>('/admin/shayegan/health')
|
||||
|
||||
export const shayeganTable = async (params: TableInput) =>
|
||||
await useAxios.post<TableOutput<ShayeganRecord>>('/admin/shayegan/table', params)
|
||||
|
||||
export const shayeganShow = async (id: number | string) =>
|
||||
await useAxios.get<ShayeganRecord>(`/admin/shayegan/${id}`)
|
||||
|
||||
export const shayeganRetry = async (id: number | string, force = false) =>
|
||||
await useAxios.post<{ ok: boolean; message?: string; row?: ShayeganRecord }>(
|
||||
`/admin/shayegan/${id}/retry`,
|
||||
{ force }
|
||||
)
|
||||
|
||||
export const registerCustomerInShayegan = async (customerId: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string }>(
|
||||
`/admin/customer/${customerId}/shayegan/register`
|
||||
)
|
||||
|
||||
export interface ShayeganInboundChargeRecord {
|
||||
id: number
|
||||
customer_id?: number | null
|
||||
customer_tafsil?: string | null
|
||||
shayegan_number?: string | null
|
||||
amount: number
|
||||
description?: string | null
|
||||
source?: string
|
||||
status: 'pending' | 'approved' | 'rejected'
|
||||
approved_at?: string | null
|
||||
rejected_at?: string | null
|
||||
reject_reason?: string | null
|
||||
customer?: {
|
||||
id: number
|
||||
name?: string
|
||||
fname?: string
|
||||
lname?: string
|
||||
mobile?: string
|
||||
n_code?: string
|
||||
moshtari_code?: string
|
||||
} | null
|
||||
approver?: {
|
||||
id: number
|
||||
name?: string
|
||||
} | null
|
||||
created_at?: string | null
|
||||
}
|
||||
|
||||
export const getPendingShayeganCharges = async () =>
|
||||
await useAxios.get<{ ok: boolean; charges: ShayeganInboundChargeRecord[] }>(
|
||||
'/admin/shayegan/charges/pending'
|
||||
)
|
||||
|
||||
export const getShayeganChargesTable = async (params: TableInput & { status?: string }) =>
|
||||
await useAxios.post<TableOutput<ShayeganInboundChargeRecord>>(
|
||||
'/admin/shayegan/charges/table',
|
||||
params
|
||||
)
|
||||
|
||||
export const approveShayeganCharge = async (id: number | string) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; charge?: ShayeganInboundChargeRecord }>(
|
||||
`/admin/shayegan/charges/${id}/approve`
|
||||
)
|
||||
|
||||
export const rejectShayeganCharge = async (id: number | string, reason?: string) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; charge?: ShayeganInboundChargeRecord }>(
|
||||
`/admin/shayegan/charges/${id}/reject`,
|
||||
{ reason }
|
||||
)
|
||||
|
||||
export const syncShayeganCharges = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; new_count?: number }>(
|
||||
'/admin/shayegan/charges/sync'
|
||||
)
|
||||
|
||||
+57
-1
@@ -34,11 +34,31 @@ export const getTahesabDetail = async (id: number) =>
|
||||
export const retryTahesabSanad = async (id: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`)
|
||||
|
||||
export interface TahesabDocSyncState {
|
||||
running: boolean
|
||||
finished: boolean
|
||||
stopped: boolean
|
||||
stage?: 'docs' | 'customers_out' | 'customers_in'
|
||||
percent: number
|
||||
total: number
|
||||
processed: number
|
||||
success: number
|
||||
failed: number
|
||||
current: string
|
||||
errors: { label?: string; error?: string }[]
|
||||
doc_total?: number
|
||||
doc_success?: number
|
||||
doc_failed?: number
|
||||
started_at?: string | null
|
||||
finished_at?: string | null
|
||||
}
|
||||
|
||||
export interface TahesabPendingSummary {
|
||||
failed_rows: number
|
||||
missing_withdraws: number
|
||||
missing_orders: number
|
||||
total: number
|
||||
doc_sync?: TahesabDocSyncState
|
||||
}
|
||||
|
||||
export interface TahesabSyncAllResult {
|
||||
@@ -71,6 +91,34 @@ export const syncAllTahesabPending = async (limit = 80, customerId?: number) =>
|
||||
...(customerId ? { customer_id: customerId } : {})
|
||||
})
|
||||
|
||||
export const startTahesabDocSync = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/doc-sync/start'
|
||||
)
|
||||
|
||||
export const stopTahesabDocSync = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/doc-sync/stop'
|
||||
)
|
||||
|
||||
export const resetTahesabLocalDocs = async () =>
|
||||
await useAxios.post<{
|
||||
ok: boolean
|
||||
message: string
|
||||
cleared: number
|
||||
summary: TahesabPendingSummary
|
||||
}>('/admin/tahesab/doc-sync/reset-local')
|
||||
|
||||
export const startTahesabCustomerOutbound = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/customer-sync/outbound/start'
|
||||
)
|
||||
|
||||
export const startTahesabCustomerInbound = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/customer-sync/inbound/start'
|
||||
)
|
||||
|
||||
export const registerCustomerInTahesab = async (customerId: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
|
||||
`/admin/customer/${customerId}/tahesab/register`
|
||||
@@ -129,6 +177,7 @@ export interface CustomerSyncStatus {
|
||||
last_page: number
|
||||
total: number
|
||||
}
|
||||
doc_sync?: TahesabDocSyncState
|
||||
}
|
||||
|
||||
export const getCustomerSyncStatus = async (params?: {
|
||||
@@ -205,13 +254,20 @@ export interface TahesabWalletSyncResult {
|
||||
/** همگامسازی مانده یک مشتری با تهحساب */
|
||||
export const syncCustomerWalletFromTahesab = async (
|
||||
customerId: number,
|
||||
opts?: { overwrite?: boolean; keep?: boolean; ask_if_conflict?: boolean; always_ask?: boolean }
|
||||
opts?: {
|
||||
overwrite?: boolean
|
||||
keep?: boolean
|
||||
push_to_tahesab?: boolean
|
||||
ask_if_conflict?: boolean
|
||||
always_ask?: boolean
|
||||
}
|
||||
) =>
|
||||
await useAxios.post<TahesabWalletSyncResult>(
|
||||
`/admin/customer/${customerId}/tahesab/sync-wallet`,
|
||||
{
|
||||
overwrite: opts?.overwrite ?? false,
|
||||
keep: opts?.keep ?? false,
|
||||
push_to_tahesab: opts?.push_to_tahesab ?? false,
|
||||
ask_if_conflict: opts?.ask_if_conflict ?? true,
|
||||
always_ask: opts?.always_ask ?? false,
|
||||
}
|
||||
|
||||
@@ -28,6 +28,12 @@ export const exportWithdrawReport = async (params: TableInput & { flow_type?: st
|
||||
export const completeWithdraw = async (params: Withdraw) =>
|
||||
await useAxios.post<boolean>('/admin/wallet/withdraw/complete', params)
|
||||
|
||||
export const approveDeposit = async (params: { id: number; tracked_number?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/approve', params)
|
||||
|
||||
export const rejectDeposit = async (params: { id: number; reject_reason?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/reject', params)
|
||||
|
||||
export const updateSts = async (id: number, sts: Object) => {
|
||||
return await useAxios.put(`/admin/wallet/withdraw/${id}`, sts)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import { defineProps } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
interface Prop {
|
||||
menu: RouteRecordRaw[]
|
||||
@@ -30,7 +31,7 @@ interface Prop {
|
||||
const router = useRouter()
|
||||
|
||||
function handleClickMenu(item: RouteRecordRaw) {
|
||||
//debugger
|
||||
if (!confirmMenuAccess(item.name)) return
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<AMenu
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:selectedKeys="selectedKeys"
|
||||
:style="{ width: props.width }"
|
||||
:mode="props.mode"
|
||||
:theme="resolvedTheme"
|
||||
@@ -49,10 +49,13 @@ const props = withDefaults(defineProps<Prop>(), {
|
||||
})
|
||||
|
||||
const resolvedTheme = computed(() => props.theme ?? menuTheme.value)
|
||||
onMounted(() => {
|
||||
selectedKeys.value = [router.currentRoute.value.name as string]
|
||||
//emits('onChange', '1')
|
||||
})
|
||||
watch(
|
||||
() => router.currentRoute.value.name,
|
||||
(name) => {
|
||||
selectedKeys.value = name ? [String(name)] : []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -29,7 +29,7 @@ import BasicMobileOverflowMenu from '@/components/BasicMobileOverflowMenu.vue'
|
||||
import { sortBy } from 'lodash'
|
||||
import { computed } from 'vue'
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
import { hasLandingSetting, supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
const BOTTOM_NAV_PRIORITY: (string | symbol)[] = ['dashboard', 'customers', 'orders', 'transactions']
|
||||
|
||||
@@ -44,6 +44,7 @@ const allMenuItems = computed(() =>
|
||||
if (item.name === 'support' || item.meta?.permissionsKey === 'support') {
|
||||
return supportChatMenuEnabledSetting.value
|
||||
}
|
||||
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||
return true
|
||||
}),
|
||||
(item) => item.meta?.order
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<div v-if="activeCharges.length > 0" class="shayegan-alert-container">
|
||||
<transition-group name="slide-down" tag="div" class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="charge in activeCharges"
|
||||
:key="charge.id"
|
||||
class="shayegan-charge-card shadow-lg"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="bell-icon-pulse flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-600">
|
||||
<Icon icon="vuesax-bold:notification-bing" size="20" />
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-bold text-gray-800 text-sm">
|
||||
واریزی جدید از سیستم حسابداری شایگان
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-0.5">
|
||||
سند شایگان: {{ charge.shayegan_number || '-' }} · تفصیلی: {{ charge.customer_tafsil || charge.customer?.moshtari_code || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="text-gray-400 hover:text-gray-600 p-1 text-sm rounded cursor-pointer border-0 bg-transparent"
|
||||
title="بستن موقت"
|
||||
@click="dismissCharge(charge.id)"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="my-2.5 rounded-md bg-amber-50/80 p-2.5 text-sm text-amber-900 border border-amber-200">
|
||||
حساب شخص <b>{{ charge.customer?.name || 'نامشخص' }}</b> از طریق پنل حسابداری مقدار <b>{{ formatPrice(charge.amount) }} ریال</b> شارژ شد
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between gap-2 pt-1 border-t border-gray-100">
|
||||
<div class="text-[11px] text-gray-400">
|
||||
{{ formatTime(charge.created_at) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a-button
|
||||
size="small"
|
||||
type="primary"
|
||||
class="!bg-emerald-600 !border-emerald-600 hover:!bg-emerald-700 text-white font-medium"
|
||||
:loading="approvingId === charge.id"
|
||||
@click="handleApprove(charge)"
|
||||
>
|
||||
تأیید و شارژ کیف پول
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
danger
|
||||
:disabled="approvingId === charge.id"
|
||||
@click="handleReject(charge)"
|
||||
>
|
||||
رد
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
class="text-xs text-gray-500"
|
||||
@click="goToAccountingTab"
|
||||
>
|
||||
لیست کامل
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import {
|
||||
getPendingShayeganCharges,
|
||||
approveShayeganCharge,
|
||||
rejectShayeganCharge,
|
||||
type ShayeganInboundChargeRecord
|
||||
} from '@/api/shayegan'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const activeCharges = ref<ShayeganInboundChargeRecord[]>([])
|
||||
const dismissedIds = ref<number[]>([])
|
||||
const approvingId = ref<number | null>(null)
|
||||
let pollTimer: any = null
|
||||
|
||||
function formatPrice(val: number) {
|
||||
return usePrice(val, true, '')
|
||||
}
|
||||
|
||||
function formatTime(dt?: string | null) {
|
||||
return dt ? toJalali(dt) : ''
|
||||
}
|
||||
|
||||
function dismissCharge(id: number) {
|
||||
if (!dismissedIds.value.includes(id)) {
|
||||
dismissedIds.value.push(id)
|
||||
}
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== id)
|
||||
}
|
||||
|
||||
async function fetchPending() {
|
||||
if (!userStore.userInfo?.id) return
|
||||
try {
|
||||
const res = await getPendingShayeganCharges()
|
||||
if (res && res.ok && Array.isArray(res.charges)) {
|
||||
// فقط مواردی که هنوز dismiss نشدهاند یا تازه آمدهاند
|
||||
activeCharges.value = res.charges.filter(c => !dismissedIds.value.includes(c.id))
|
||||
}
|
||||
} catch {
|
||||
// خطای شبکه را بیصدا نادیده میگیریم تا مزاحم کاربر نشود
|
||||
}
|
||||
}
|
||||
|
||||
async function handleApprove(charge: ShayeganInboundChargeRecord) {
|
||||
approvingId.value = charge.id
|
||||
try {
|
||||
const res = await approveShayeganCharge(charge.id)
|
||||
if (res && res.ok) {
|
||||
message.success(res.message || `کیف پول شخص ${charge.customer?.name} با موفقیت شارژ شد.`)
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== charge.id)
|
||||
} else {
|
||||
message.error(res?.message || 'خطا در تایید شارژ')
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در تایید شارژ و افزایش کیف پول')
|
||||
} finally {
|
||||
approvingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function handleReject(charge: ShayeganInboundChargeRecord) {
|
||||
Modal.confirm({
|
||||
title: 'رد واریزی شایگان',
|
||||
content: `آیا از رد واریزی ${formatPrice(charge.amount)} ریالی برای ${charge.customer?.name || 'مشتری'} اطمینان دارید؟`,
|
||||
okText: 'بله، رد شود',
|
||||
cancelText: 'انصراف',
|
||||
okType: 'danger',
|
||||
async onOk() {
|
||||
try {
|
||||
const res = await rejectShayeganCharge(charge.id)
|
||||
if (res && res.ok) {
|
||||
message.info(res.message || 'واریزی رد شد.')
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== charge.id)
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در رد شارژ')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goToAccountingTab() {
|
||||
router.push({
|
||||
path: '/menu/accounting',
|
||||
query: { tab: 'shayegan-charges' }
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void fetchPending()
|
||||
// چک کردن خودکار هر ۳۰ ثانیه
|
||||
pollTimer = setInterval(fetchPending, 30000)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (pollTimer) clearInterval(pollTimer)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => userStore.userInfo?.id,
|
||||
(id) => {
|
||||
if (id) void fetchPending()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.shayegan-alert-container {
|
||||
position: fixed;
|
||||
top: 1.5rem;
|
||||
left: 1.5rem;
|
||||
z-index: 9999;
|
||||
max-width: 440px;
|
||||
width: calc(100vw - 3rem);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.shayegan-charge-card {
|
||||
pointer-events: auto;
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-right: 4px solid #f59e0b;
|
||||
border-radius: 0.75rem;
|
||||
padding: 1rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.bell-icon-pulse {
|
||||
animation: pulse-ring 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse-ring {
|
||||
0% {
|
||||
transform: scale(0.95);
|
||||
box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
|
||||
}
|
||||
70% {
|
||||
transform: scale(1);
|
||||
box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
|
||||
}
|
||||
100% {
|
||||
transform: scale(0.95);
|
||||
box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.slide-down-enter-active,
|
||||
.slide-down-leave-active {
|
||||
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.slide-down-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
|
||||
.slide-down-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-model:visible="visible"
|
||||
title="ثبت مشتری در شایگان"
|
||||
ok-text="ثبت در شایگان"
|
||||
:loading="loading"
|
||||
width="32rem"
|
||||
@ok="confirm"
|
||||
@close="visible = false"
|
||||
>
|
||||
<div class="space-y-3 text-sm">
|
||||
<div v-for="item in items" :key="item.label" class="flex justify-between gap-3 border-b border-gray-100 pb-2">
|
||||
<span class="text-gray-500">{{ item.label }}</span>
|
||||
<span class="text-left break-all">{{ item.value ?? '-' }}</span>
|
||||
</div>
|
||||
<p class="m-0 text-xs leading-5" style="color: var(--admin-text-secondary)">
|
||||
با تأیید، حساب تفصیلی با معین تنظیمشده در «حسابداری شایگان» ساخته میشود و کد در پروفایل مشتری ذخیره میگردد.
|
||||
</p>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import { message } from 'ant-design-vue/es'
|
||||
import { registerCustomerInShayegan } from '@/api/shayegan'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
customerId?: number
|
||||
customerName?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}>()
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const items = computed(() => [
|
||||
{ label: 'نام مشتری', value: props.customerName },
|
||||
{ label: 'شناسه مشتری', value: props.customerId },
|
||||
])
|
||||
|
||||
async function confirm() {
|
||||
if (!props.customerId) return
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await registerCustomerInShayegan(props.customerId)
|
||||
if (!result.ok) {
|
||||
message.error(result.message || 'ثبت مشتری ناموفق بود')
|
||||
return
|
||||
}
|
||||
message.success(result.message || 'مشتری در شایگان ثبت شد')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,803 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="cip-fade">
|
||||
<div
|
||||
v-if="store.visible && !store.minimized"
|
||||
class="cip-overlay"
|
||||
@click.self="store.active ? store.minimize() : null"
|
||||
>
|
||||
<div class="cip-modal" :class="store.finished ? `cip-modal--${outcomeInfo.tone}` : null">
|
||||
<div class="cip-modal__head">
|
||||
<div class="cip-modal__title">
|
||||
<Icon :icon="headIcon" :size="18" />
|
||||
<span>{{ headTitle }}</span>
|
||||
</div>
|
||||
<div class="cip-modal__head-actions">
|
||||
<button
|
||||
v-if="store.active"
|
||||
class="cip-icon-btn"
|
||||
title="کوچک کردن"
|
||||
@click="store.minimize()"
|
||||
>
|
||||
<Icon icon="vuesax-linear:minus" :size="18" />
|
||||
</button>
|
||||
<button v-else class="cip-icon-btn" title="بستن" @click="store.dismiss()">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="store.active" class="cip-modal__body">
|
||||
<div class="cip-counter">
|
||||
<span class="cip-counter__done">{{ store.state.processed }}</span>
|
||||
<span class="cip-counter__sep">/</span>
|
||||
<span class="cip-counter__total">{{ store.state.total }}</span>
|
||||
</div>
|
||||
<div class="cip-counter__label">{{ runningLabel }}</div>
|
||||
<div class="cip-track">
|
||||
<div class="cip-track__fill" :style="{ width: store.percent + '%' }" />
|
||||
</div>
|
||||
<div class="cip-percent">{{ store.percent }}٪</div>
|
||||
<div v-if="etaLabel" class="cip-eta">{{ etaLabel }}</div>
|
||||
<div class="cip-current">
|
||||
<a-spin size="small" />
|
||||
<span class="cip-current__name">{{ store.state.current || '...' }}</span>
|
||||
</div>
|
||||
<div class="cip-stats">
|
||||
<div class="cip-stat cip-stat--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="14" />
|
||||
{{ store.state.success }} موفق
|
||||
</div>
|
||||
<div v-if="store.state.failed" class="cip-stat cip-stat--fail">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
{{ store.state.failed }} ناموفق
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="cip-modal__body cip-report">
|
||||
<div class="cip-report__hero" :class="`cip-report__hero--${outcomeInfo.tone}`">
|
||||
<Icon :icon="outcomeInfo.icon" :size="34" />
|
||||
</div>
|
||||
<div class="cip-report__title">{{ outcomeInfo.text }}</div>
|
||||
<div class="cip-report__subtitle">{{ reportSubtitle }}</div>
|
||||
<div class="cip-report__cards">
|
||||
<div class="cip-rcard cip-rcard--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.success }}</div>
|
||||
<div class="cip-rcard__label">{{ doneCardLabel }}</div>
|
||||
</div>
|
||||
<div class="cip-rcard" :class="store.state.failed ? 'cip-rcard--fail' : 'cip-rcard--muted'">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.failed }}</div>
|
||||
<div class="cip-rcard__label">به خطا خورد</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="store.state.errors.length" class="cip-report__errors">
|
||||
<div class="cip-report__errors-head">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
جزئیات خطا ({{ store.state.errors.length }})
|
||||
</div>
|
||||
<div class="cip-report__errors-list">
|
||||
<div v-for="(e, i) in store.state.errors" :key="i" class="cip-erow">
|
||||
<span class="cip-erow__name">{{ e.label }}</span>
|
||||
<span class="cip-erow__msg">{{ e.error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cip-modal__foot">
|
||||
<a-button v-if="store.active" danger size="small" @click="store.stop()">توقف</a-button>
|
||||
<a-button v-if="store.active" size="small" @click="store.minimize()">کوچک کردن</a-button>
|
||||
<a-button v-if="store.finished" type="primary" size="small" @click="store.dismiss()">
|
||||
بستن گزارش
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<Transition name="cip-slide">
|
||||
<button
|
||||
v-if="store.visible && store.minimized"
|
||||
class="cip-mini tds-mini"
|
||||
:class="store.finished ? `cip-mini--${outcomeInfo.tone}` : null"
|
||||
@click="store.expand()"
|
||||
>
|
||||
<span class="cip-mini__ring">
|
||||
<svg viewBox="0 0 36 36" class="cip-mini__svg">
|
||||
<circle class="cip-mini__bg" cx="18" cy="18" r="15.5" />
|
||||
<circle class="cip-mini__fg" cx="18" cy="18" r="15.5" :style="ringStyle" />
|
||||
</svg>
|
||||
<span class="cip-mini__pct">
|
||||
<template v-if="store.finished">
|
||||
<Icon :icon="outcomeInfo.icon" :size="16" />
|
||||
</template>
|
||||
<template v-else>{{ store.percent }}</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="cip-mini__text">
|
||||
<span class="cip-mini__title">
|
||||
<template v-if="store.finished">{{ outcomeInfo.text }}</template>
|
||||
<template v-else>{{ runningMiniTitle }}</template>
|
||||
</span>
|
||||
<span class="cip-mini__count">
|
||||
<template v-if="store.finished">
|
||||
{{ store.state.success }} موفق · {{ store.state.failed }} خطا
|
||||
</template>
|
||||
<template v-else>{{ store.state.processed }} از {{ store.state.total }}</template>
|
||||
</span>
|
||||
<span v-if="store.active && etaLabel" class="cip-mini__eta">{{ etaLabel }}</span>
|
||||
</span>
|
||||
<span class="cip-mini__bar">
|
||||
<span class="cip-mini__bar-fill" :style="{ width: store.percent + '%' }" />
|
||||
</span>
|
||||
</button>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
|
||||
const store = useTahesabDocSyncStore()
|
||||
|
||||
const runStartedAt = ref<number | null>(null)
|
||||
const runStartProcessed = ref(0)
|
||||
const tick = ref(Date.now())
|
||||
let tickTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
function formatEta(seconds: number): string {
|
||||
if (!Number.isFinite(seconds) || seconds <= 0) return 'بهزودی'
|
||||
const rounded = Math.ceil(seconds)
|
||||
if (rounded < 60) return `حدود ${rounded} ثانیه`
|
||||
const mins = Math.ceil(rounded / 60)
|
||||
if (mins < 60) return `حدود ${mins} دقیقه`
|
||||
const hours = Math.floor(mins / 60)
|
||||
const remMins = mins % 60
|
||||
if (remMins === 0) return `حدود ${hours} ساعت`
|
||||
return `حدود ${hours} ساعت و ${remMins} دقیقه`
|
||||
}
|
||||
|
||||
function resetEtaClock() {
|
||||
runStartedAt.value = Date.now()
|
||||
runStartProcessed.value = store.state.processed
|
||||
}
|
||||
|
||||
function startTick() {
|
||||
if (tickTimer) return
|
||||
tickTimer = setInterval(() => {
|
||||
tick.value = Date.now()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function stopTick() {
|
||||
if (!tickTimer) return
|
||||
clearInterval(tickTimer)
|
||||
tickTimer = null
|
||||
}
|
||||
|
||||
watch(
|
||||
() => store.active,
|
||||
(active) => {
|
||||
if (active) {
|
||||
resetEtaClock()
|
||||
startTick()
|
||||
return
|
||||
}
|
||||
runStartedAt.value = null
|
||||
stopTick()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
() => store.state.stage,
|
||||
() => {
|
||||
if (store.active) resetEtaClock()
|
||||
},
|
||||
)
|
||||
|
||||
const etaLabel = computed(() => {
|
||||
void tick.value
|
||||
if (!store.active) return ''
|
||||
|
||||
const { processed, total } = store.state
|
||||
const remaining = Math.max(0, total - processed)
|
||||
if (remaining <= 0) return 'در حال اتمام…'
|
||||
if (!runStartedAt.value) return ''
|
||||
|
||||
const deltaProcessed = processed - runStartProcessed.value
|
||||
const elapsedSec = (Date.now() - runStartedAt.value) / 1000
|
||||
if (deltaProcessed < 2 || elapsedSec < 4) {
|
||||
return 'در حال محاسبه زمان باقیمانده…'
|
||||
}
|
||||
|
||||
const secPerItem = elapsedSec / deltaProcessed
|
||||
return `تخمین باقیمانده: ${formatEta(secPerItem * remaining)}`
|
||||
})
|
||||
|
||||
const stage = computed(() => store.stage)
|
||||
|
||||
function outcomeMap() {
|
||||
if (stage.value === 'customers_in') {
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ورود مشتریان تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ورود مشتریان ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان وارد نشدند', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ورود متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:import', text: 'ورود از تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
if (stage.value === 'customers_out') {
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ثبت مشتریان تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ثبت مشتریان ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان ثبت نشدند', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ثبت متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:profile-2user', text: 'ثبت در تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ارسال سندها تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ارسال سندها ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی سندها به خطا خورد', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ارسال متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:document-upload', text: 'ارسال سند به تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
|
||||
const outcomeInfo = computed(() => outcomeMap()[store.outcome])
|
||||
const runningIcon = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'vuesax-linear:import'
|
||||
if (stage.value === 'customers_out') return 'vuesax-linear:profile-2user'
|
||||
return 'vuesax-linear:document-upload'
|
||||
})
|
||||
const headIcon = computed(() => (store.finished ? outcomeInfo.value.icon : runningIcon.value))
|
||||
const headTitle = computed(() => {
|
||||
if (store.finished) {
|
||||
if (stage.value === 'customers_in') return 'گزارش ورود مشتریان'
|
||||
if (stage.value === 'customers_out') return 'گزارش ثبت مشتریان'
|
||||
return 'گزارش ارسال سندها'
|
||||
}
|
||||
if (stage.value === 'customers_in') return 'ورود مشتریان از تهحساب'
|
||||
if (stage.value === 'customers_out') return 'ثبت مشتریان در تهحساب'
|
||||
return 'ارسال سندها به تهحساب'
|
||||
})
|
||||
const runningLabel = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'در حال وارد کردن مشتریان از تهحساب…'
|
||||
if (stage.value === 'customers_out') return 'در حال ثبت مشتریان پنل در تهحساب…'
|
||||
return 'در حال ارسال سندها به تهحساب…'
|
||||
})
|
||||
const runningMiniTitle = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'ورود از تهحساب'
|
||||
if (stage.value === 'customers_out') return 'ثبت مشتری در تهحساب'
|
||||
return 'ارسال سند به تهحساب'
|
||||
})
|
||||
const unit = computed(() => (stage.value === 'docs' ? 'سند' : 'مشتری'))
|
||||
const doneCardLabel = computed(() => (stage.value === 'docs' ? 'ارسال شد' : 'ثبت شد'))
|
||||
const reportSubtitle = computed(() => {
|
||||
const docs = store.state.doc_total
|
||||
? `سندها: ${store.state.doc_success} موفق` + (store.state.doc_failed ? `، ${store.state.doc_failed} خطا. ` : '. ')
|
||||
: ''
|
||||
return `${docs}از ${store.state.total} ${unit.value}، ${store.state.processed} مورد پردازش شد`
|
||||
})
|
||||
const RING_CIRC = 2 * Math.PI * 15.5
|
||||
const ringStyle = computed(() => ({
|
||||
strokeDasharray: `${RING_CIRC}`,
|
||||
strokeDashoffset: `${RING_CIRC * (1 - store.percent / 100)}`,
|
||||
}))
|
||||
|
||||
onMounted(() => {
|
||||
void store.hydrate()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopTick()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
/* ─── مدال ─── */
|
||||
.cip-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2200;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
background: rgba(15, 23, 42, 0.55);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.cip-modal {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
border-radius: 16px;
|
||||
background: var(--admin-bg-surface);
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
|
||||
overflow: hidden;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 16px;
|
||||
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0ea5e9 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--ok .cip-modal__head {
|
||||
background: linear-gradient(135deg, #059669 0%, #10b981 100%);
|
||||
}
|
||||
|
||||
&--warn .cip-modal__head {
|
||||
background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
|
||||
}
|
||||
|
||||
&--fail .cip-modal__head {
|
||||
background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&__head-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 20px 18px 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 12px 16px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.32);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
|
||||
&__done {
|
||||
font-size: 38px;
|
||||
color: #7c3aed;
|
||||
}
|
||||
&__sep {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
&__total {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter__label {
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-track {
|
||||
width: 100%;
|
||||
height: 9px;
|
||||
margin-top: 16px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
|
||||
&__fill {
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: linear-gradient(90deg, #7c3aed, #0ea5e9);
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-percent {
|
||||
align-self: flex-end;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-eta {
|
||||
align-self: flex-end;
|
||||
margin-top: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--admin-text-muted);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.cip-current {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
max-width: 100%;
|
||||
|
||||
&__name {
|
||||
font-size: 12px;
|
||||
color: var(--admin-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-stats {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.cip-stat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
padding: 3px 12px;
|
||||
border-radius: 99px;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── گزارش پایانی ─── */
|
||||
.cip-report {
|
||||
padding-top: 22px;
|
||||
|
||||
&__hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.14);
|
||||
color: #059669;
|
||||
}
|
||||
&--warn {
|
||||
background: rgba(245, 158, 11, 0.16);
|
||||
color: #d97706;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.13);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin-top: 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: var(--admin-text);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--admin-text-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
&__errors {
|
||||
width: 100%;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
&__errors-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #dc2626;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
&__errors-list {
|
||||
max-height: 160px;
|
||||
overflow-y: auto;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--admin-border);
|
||||
background: var(--admin-bg-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-rcard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 14px 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&__num {
|
||||
font-size: 26px;
|
||||
font-weight: 800;
|
||||
line-height: 1.1;
|
||||
}
|
||||
&__label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
border-color: rgba(16, 185, 129, 0.25);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.09);
|
||||
border-color: rgba(239, 68, 68, 0.22);
|
||||
color: #dc2626;
|
||||
}
|
||||
&--muted {
|
||||
background: var(--admin-bg-muted);
|
||||
border-color: var(--admin-border);
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-erow {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid var(--admin-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
&__msg {
|
||||
color: #dc2626;
|
||||
text-align: left;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── کوچکشده ─── */
|
||||
.cip-mini {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 2100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 16px 8px 10px;
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-surface);
|
||||
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s, box-shadow 0.15s;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 58px;
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateX(-50%) translateY(1px);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
&__ring {
|
||||
position: relative;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
&__bg {
|
||||
fill: none;
|
||||
stroke: var(--admin-bg-muted);
|
||||
stroke-width: 3.5;
|
||||
}
|
||||
|
||||
&__fg {
|
||||
fill: none;
|
||||
stroke: #7c3aed;
|
||||
stroke-width: 3.5;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.35s ease;
|
||||
}
|
||||
|
||||
&__pct {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
&__text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.3;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-size: 11px;
|
||||
color: var(--admin-text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__eta {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: var(--admin-text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__bar {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
bottom: 3px;
|
||||
height: 2px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__bar-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: #7c3aed;
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
|
||||
/* رنگ بر اساس نتیجه */
|
||||
&--ok {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #10b981;
|
||||
background: #10b981;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
&--warn {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #f59e0b;
|
||||
background: #f59e0b;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
|
||||
&--fail {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #ef4444;
|
||||
background: #ef4444;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tds-mini.cip-mini {
|
||||
top: 112px;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 106px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── انیمیشنها ─── */
|
||||
.cip-fade-enter-active,
|
||||
.cip-fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.cip-fade-enter-from,
|
||||
.cip-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.cip-slide-enter-active,
|
||||
.cip-slide-leave-active {
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
.cip-slide-enter-from,
|
||||
.cip-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(-12px);
|
||||
}
|
||||
</style>
|
||||
@@ -95,7 +95,7 @@
|
||||
>
|
||||
<div class="customer-wallet-balance__detail-group-title">
|
||||
<span class="customer-wallet-balance__group-dot" aria-hidden="true" />
|
||||
<span>{{ metal.label }}</span>
|
||||
<span>{{ minimalMetalLabel(metal) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="line in linesForMetal(metal.metal_id)"
|
||||
@@ -234,9 +234,21 @@ function targetToneClass(target: ChargeTarget) {
|
||||
}
|
||||
}
|
||||
|
||||
function uniqueInventoryCards() {
|
||||
const cards = summary.value?.inventory_cards ?? []
|
||||
const seen = new Set<number>()
|
||||
const unique: WalletInventoryCard[] = []
|
||||
for (const card of cards) {
|
||||
const id = Number(card.product_id)
|
||||
if (!id || seen.has(id)) continue
|
||||
seen.add(id)
|
||||
unique.push(card)
|
||||
}
|
||||
return unique
|
||||
}
|
||||
|
||||
function inventoryCards() {
|
||||
if (!summary.value) return [] as WalletInventoryCard[]
|
||||
return [...(summary.value.inventory_cards ?? []), ...(summary.value.count_products ?? [])]
|
||||
return uniqueInventoryCards()
|
||||
}
|
||||
|
||||
function isCountChargeTarget(target: ChargeTarget) {
|
||||
@@ -310,14 +322,25 @@ function formatCard(card: WalletInventoryCard) {
|
||||
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'گرم'}`
|
||||
}
|
||||
|
||||
function linesForMetal(metalId: number) {
|
||||
const cards = summary.value?.inventory_cards ?? []
|
||||
const countCards = summary.value?.count_products ?? []
|
||||
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
|
||||
function formatMetalGroupTotal(metalId: number, metalCards: WalletInventoryCard[], metal?: WalletMetalTotal) {
|
||||
const allCount = metalCards.length > 0 && metalCards.every((card) => card.display_type === 'count')
|
||||
if (allCount) {
|
||||
const qty = metalCards.reduce((sum, card) => sum + Number(card.quantity ?? 0), 0)
|
||||
return `${qty.toLocaleString('fa-IR')} عدد`
|
||||
}
|
||||
if (metal) {
|
||||
return formatMetalTotal(metal)
|
||||
}
|
||||
return formatMetalDisplayValue(0, metalId)
|
||||
}
|
||||
|
||||
const productLines = [...cards, ...countCards]
|
||||
.filter((card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0)
|
||||
.map((card) => ({
|
||||
function linesForMetal(metalId: number) {
|
||||
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
|
||||
const metalCards = uniqueInventoryCards().filter(
|
||||
(card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0
|
||||
)
|
||||
|
||||
const productLines = metalCards.map((card) => ({
|
||||
key: `card-${card.product_id}`,
|
||||
label: card.title,
|
||||
value: formatCard(card)
|
||||
@@ -325,7 +348,7 @@ function linesForMetal(metalId: number) {
|
||||
|
||||
const lines: Array<{ key: string; label: string; value: string }> = [...productLines]
|
||||
|
||||
if (metal && Number(metal.melted_weight ?? 0) > 0 && !productLines.some((line) => line.label.includes('آبشده'))) {
|
||||
if (metal && Number(metal.melted_weight ?? 0) > 0 && !metalCards.some((card) => card.is_melted || card.is_main_wallet)) {
|
||||
lines.push({
|
||||
key: 'melted',
|
||||
label: 'موجودی آبشده / کیف اصلی',
|
||||
@@ -333,11 +356,11 @@ function linesForMetal(metalId: number) {
|
||||
})
|
||||
}
|
||||
|
||||
if (metal && lines.length > 1) {
|
||||
if (lines.length > 0) {
|
||||
lines.push({
|
||||
key: 'total',
|
||||
label: 'مجموع',
|
||||
value: formatMetalTotal(metal)
|
||||
label: `مجموع ${minimalMetalLabel(metal ?? { metal_id: metalId } as WalletMetalTotal)}`,
|
||||
value: formatMetalGroupTotal(metalId, metalCards, metal)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { allowsPageAction, parsePageAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
export function usePageActionAccess() {
|
||||
const route = useRoute()
|
||||
const userStore = useUserStore()
|
||||
|
||||
function can(actionKey: string) {
|
||||
return allowsPageAction(
|
||||
parsePageAccess(userStore.userInfo?.page_access),
|
||||
userStore.hasFullPageAccess,
|
||||
route.matched.map((item) => item.name),
|
||||
actionKey
|
||||
)
|
||||
}
|
||||
|
||||
return { can }
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
<script setup lang="ts">
|
||||
import { menuIconSize } from '@root/config'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
const router = useRouter()
|
||||
interface Props {
|
||||
@@ -25,6 +26,7 @@ interface Props {
|
||||
const props = withDefaults(defineProps<Props>(), {})
|
||||
|
||||
async function handleClickMenuItem(item: RouteRecordRaw) {
|
||||
if (!confirmMenuAccess(item.name)) return
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AMenu
|
||||
:mode="layoutStore.sideMenu.mode"
|
||||
:theme="menuTheme"
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:selectedKeys="selectedKeys"
|
||||
>
|
||||
<template v-for="item in menu">
|
||||
<BasicSubMenu
|
||||
@@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { ComputedRef } from 'vue'
|
||||
import { sortBy } from 'lodash'
|
||||
import { usePrefix } from '@core/composable/usePrefix'
|
||||
@@ -36,7 +36,7 @@ import BaseMenuItem from '@core/layouts/composnts/BaseMenuItem.vue'
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||
import { useRouterStore } from '@core/stores/router'
|
||||
import { useAdminTheme } from '@core/composable/useAdminTheme'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
import { hasLandingSetting, supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
const { prefixCls } = usePrefix('basic-menu')
|
||||
const layoutStore = useLayoutStore()
|
||||
@@ -45,9 +45,9 @@ const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
||||
const routerStore = useRouterStore()
|
||||
const { menuTheme } = useAdminTheme()
|
||||
|
||||
function syncSelectedKeys() {
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
function walkInRoutes(routes: RouteRecordRaw[]): boolean {
|
||||
for (const route of routes) {
|
||||
if (route.name == currentRoute.name) {
|
||||
path.push(route.name)
|
||||
@@ -56,18 +56,17 @@ function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
if (route.children && route.children.length > 0) {
|
||||
path.push(route.name)
|
||||
const res = walkInRoutes(route.children)
|
||||
if (!res) {
|
||||
path.pop()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
if (!res) path.pop()
|
||||
else return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
walkInRoutes(routerStore.routes)
|
||||
selectedKeys.value = path
|
||||
}
|
||||
|
||||
watch(() => currentRoute.name, syncSelectedKeys, { immediate: true })
|
||||
|
||||
function isSupportMenuRoute(item: RouteRecordRaw): boolean {
|
||||
return item.name === 'support' || item.meta?.permissionsKey === 'support'
|
||||
@@ -79,6 +78,7 @@ const menu: ComputedRef<RouteRecordRaw[]> = computed(() => {
|
||||
}).filter((item) => {
|
||||
if (item.meta?.hideMenu) return false
|
||||
if (isSupportMenuRoute(item)) return supportChatMenuEnabledSetting.value
|
||||
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
showServerUnavailableOverlay,
|
||||
} from '@/utils/serverUnavailable'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { mutationBlockMessage } from '@/utils/adminPageAccess'
|
||||
import { readAdminAccessState } from '@/utils/adminAccessState'
|
||||
//import { isToken } from '@/utils/is'
|
||||
//import router from '@/router'
|
||||
//import { getToken, removeToken } from '@/utils/useUtility'
|
||||
@@ -58,6 +60,18 @@ _axios.interceptors.request.use(
|
||||
//@ts-ignore
|
||||
config.headers['Authorization'] = 'Bearer ' + token
|
||||
}
|
||||
const routeName = readAdminAccessState().routeName
|
||||
if (routeName) {
|
||||
//@ts-ignore
|
||||
config.headers['X-Admin-Page'] = routeName
|
||||
}
|
||||
}
|
||||
const blocked = mutationBlockMessage(String(config.method || 'get'), config.url)
|
||||
if (blocked) {
|
||||
message.warning({ content: blocked, key: 'admin-page-denied' })
|
||||
const error = new Error(blocked) as Error & { pageAccessDenied?: boolean }
|
||||
error.pageAccessDenied = true
|
||||
return Promise.reject(error)
|
||||
}
|
||||
return config
|
||||
},
|
||||
@@ -77,6 +91,15 @@ _axios.interceptors.response.use(
|
||||
return response.data
|
||||
},
|
||||
async function (error) {
|
||||
const deniedText = String(error?.message || '')
|
||||
if (
|
||||
error?.pageAccessDenied ||
|
||||
deniedText === 'شما به این صفحه دسترسی ندارید' ||
|
||||
deniedText === 'شما مجوز ویرایش در این صفحه را ندارید' ||
|
||||
deniedText === 'شما مجوز حذف در این صفحه را ندارید'
|
||||
) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
const router = useRouter()
|
||||
//console.log('this is axios error', error)
|
||||
/* if (error.response.data && error.response.data.code) {
|
||||
@@ -109,7 +132,12 @@ _axios.interceptors.response.use(
|
||||
await router.push({ name: 'login' })
|
||||
} else if (error.response && error.response.status == 403) {
|
||||
if (!error.config?.meta?.silent) {
|
||||
message.error('شما دسترسی لازم برای انجام این عملیات را ندارید (403)')
|
||||
const apiMessage = error.response.data?.message
|
||||
message.error(
|
||||
typeof apiMessage === 'string' && apiMessage.trim()
|
||||
? apiMessage
|
||||
: 'شما دسترسی لازم برای انجام این عملیات را ندارید'
|
||||
)
|
||||
}
|
||||
} else if (error.response && error.response.status == 422) {
|
||||
if (!error.config?.meta?.silent) {
|
||||
|
||||
+29
-1
@@ -14,6 +14,14 @@ import { setupRoutes } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { setupPinia } from '@core/plugins/pinia'
|
||||
import { initStoreModeFromSettings } from '@/utils/config'
|
||||
import { message } from 'ant-design-vue'
|
||||
import {
|
||||
canOpenRoute,
|
||||
firstAllowedInBranch,
|
||||
firstAllowedRouteName,
|
||||
notifyPageDenied
|
||||
} from '@/utils/adminPageAccess'
|
||||
import { setCurrentAdminRoute } from '@/utils/adminAccessState'
|
||||
|
||||
const init = async () => {
|
||||
const app = createApp(App)
|
||||
@@ -57,9 +65,29 @@ const init = async () => {
|
||||
const token = getToken()
|
||||
if (token) {
|
||||
if (to.name == 'login') {
|
||||
return next({ name: 'dashboard' })
|
||||
return next({ name: firstAllowedRouteName() || 'dashboardMain' })
|
||||
}
|
||||
if (canOpenRoute(to.name)) {
|
||||
setCurrentAdminRoute(String(to.name || ''))
|
||||
return next()
|
||||
}
|
||||
const redirectedFrom = to.redirectedFrom?.name
|
||||
if (redirectedFrom) {
|
||||
const branchTarget = firstAllowedInBranch(String(redirectedFrom))
|
||||
if (branchTarget && branchTarget !== String(to.name)) {
|
||||
return next({ name: branchTarget })
|
||||
}
|
||||
}
|
||||
if (from.name && String(from.name) !== 'login') {
|
||||
notifyPageDenied()
|
||||
return next(false)
|
||||
}
|
||||
const first = firstAllowedRouteName()
|
||||
if (first && first !== String(to.name)) {
|
||||
return next({ name: first })
|
||||
}
|
||||
message.warning({ content: 'شما به این صفحه دسترسی ندارید', key: 'admin-page-denied' })
|
||||
return next(false)
|
||||
} else {
|
||||
if (['login', '404'].includes(to.name as string)) {
|
||||
return next()
|
||||
|
||||
+17
-2
@@ -1,6 +1,16 @@
|
||||
export interface GiftcardCustomer {
|
||||
id: number
|
||||
name: string
|
||||
mobile: string
|
||||
}
|
||||
|
||||
export interface Giftcard {
|
||||
id: number
|
||||
customer_id: any
|
||||
name?: string
|
||||
mobile?: string
|
||||
customer?: GiftcardCustomer
|
||||
show_in_app?: number | boolean
|
||||
count: number
|
||||
amount: number
|
||||
total: number
|
||||
@@ -35,9 +45,14 @@ export interface AssignedTo {
|
||||
mobile: string
|
||||
}
|
||||
|
||||
export type GiftCardAssignMode = 'customer' | 'public'
|
||||
|
||||
export interface GiftcardInput {
|
||||
mobile: string
|
||||
name: string
|
||||
assignMode: GiftCardAssignMode
|
||||
customer_id?: number
|
||||
show_in_app?: number
|
||||
mobile?: string
|
||||
name?: string
|
||||
count: number
|
||||
amount: number
|
||||
unit: string
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ export interface last {
|
||||
sell: number
|
||||
buy: number
|
||||
price_last: number
|
||||
/** آخرین مظنه ذخیرهشده در جدول prices — برای fallback محصول */
|
||||
/** آخرین قیمت ذخیرهشده در جدول prices — برای fallback محصول */
|
||||
last_historical?: number
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Const } from '@/model/const'
|
||||
import type { PageAccessMap } from '@/utils/adminPageAccess'
|
||||
|
||||
export interface User {
|
||||
active?: boolean
|
||||
@@ -12,6 +13,7 @@ export interface User {
|
||||
lname?: string
|
||||
mobile?: number
|
||||
name?: string
|
||||
n_code?: string
|
||||
sts?: number
|
||||
token_sms?: string
|
||||
user_type?: string
|
||||
@@ -19,6 +21,8 @@ export interface User {
|
||||
settings?: Const[]
|
||||
sms_billing_enabled?: boolean
|
||||
sms_panel_access?: boolean
|
||||
/** null = دسترسی کامل */
|
||||
page_access?: PageAccessMap | null
|
||||
}
|
||||
|
||||
export interface AddId {
|
||||
|
||||
@@ -84,6 +84,10 @@ export interface Withdraw {
|
||||
date_at?: string
|
||||
sts?: number
|
||||
type?: number
|
||||
receipt?: string | null
|
||||
receipt_url?: string | null
|
||||
deposit_identifier?: string | null
|
||||
reject_reason?: string | null
|
||||
bank_account_id?: number | null
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
{{ m('تراز طلایی (گرم)') }}
|
||||
</div>
|
||||
<div class="bg-blue rounded text-white py-1 flex justify-center items-center">
|
||||
تراز مظنه (ریال)
|
||||
تراز قیمت (ریال)
|
||||
</div>
|
||||
<div class="bg-blue rounded text-white py-1 flex justify-center items-center">
|
||||
تراز افجو
|
||||
@@ -146,7 +146,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="min-w-[100px]">
|
||||
<label class="text-[8px] mb-0"> در مظنه : </label>
|
||||
<label class="text-[8px] mb-0"> در قیمت : </label>
|
||||
<label class="text-[12px] mb-0 text-center">
|
||||
{{ usePrice(order?.price_in_mesghal ?? 0, true, '') }}
|
||||
</label>
|
||||
|
||||
@@ -80,7 +80,7 @@ const rows = computed(() => {
|
||||
{
|
||||
key: 'sood',
|
||||
label: 'سود اختلاف قیمت',
|
||||
hint: 'فاصله مظنه و قیمت مشتری',
|
||||
hint: 'فاصله قیمت و قیمت مشتری',
|
||||
value: sood.value,
|
||||
color: '#10b981',
|
||||
},
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
<span class="font-bold dashboard-text">{{ formatDashboardAmount(item.rial_amount) }} ریال</span>
|
||||
<span class="dashboard-text-muted">←</span>
|
||||
<span class="font-bold dashboard-profit">{{ formatGram(item.gram_amount) }} گرم</span>
|
||||
<span class="dashboard-text-muted text-xs">(مظنه {{ formatDashboardAmount(item.unit_price) }})</span>
|
||||
<span class="dashboard-text-muted text-xs">(قیمت {{ formatDashboardAmount(item.unit_price) }})</span>
|
||||
</div>
|
||||
<div class="dashboard-text-muted mt-0.5 text-[11px]">
|
||||
{{ jalaliDate(item.converted_at) }}
|
||||
@@ -259,7 +259,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="dashboard-profit-split__field">
|
||||
<label>قیمت هر گرم (مظنه)</label>
|
||||
<label>قیمت هر گرم</label>
|
||||
<a-input-number
|
||||
v-model:value="form.unit_price"
|
||||
:min="0"
|
||||
|
||||
@@ -374,7 +374,7 @@ export function useDashboardPage() {
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'مظنه',
|
||||
name: 'قیمت',
|
||||
data: priceSeries.value.map((p) => [p.timestamp, chartPointRial(p.value)]),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -74,7 +74,7 @@ export const dashboardDateMetrics = {
|
||||
),
|
||||
netIncome: help(
|
||||
'شاخص قدیمی: اختلاف قیمت اصلی و پرداختی منهای ارزش هدایا — با «جمع سود معاملات» یکی نیست.',
|
||||
'تراز قیمت−پرداخت = جمع |قیمت اصلی − پرداختی| − (گرم هدیه × مظنه)'
|
||||
'تراز قیمت−پرداخت = جمع |قیمت اصلی − پرداختی| − (گرم هدیه × قیمت)'
|
||||
),
|
||||
totalTradingProfit: help(
|
||||
'همان «جمع سود معاملات» در خلاصه بالا — اختلاف قیمت + کارمزد.',
|
||||
@@ -111,8 +111,8 @@ export const dashboardOrders = {
|
||||
'هر ستون = تعداد سفارش در آن ساعت (جمع چند روز اخیر)'
|
||||
),
|
||||
recent: help(
|
||||
'۱۴ سفارش آخر با جزئیات مظنه و سود.',
|
||||
'مظنه = قیمت پایه | قیمت مشتری = مظنه ± اختلاف قیمت | سود/گرم = همان اختلاف قیمت'
|
||||
'۱۴ سفارش آخر با جزئیات قیمت و سود.',
|
||||
'قیمت = قیمت پایه | قیمت مشتری = قیمت ± اختلاف قیمت | سود/گرم = همان اختلاف قیمت'
|
||||
),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -130,7 +130,7 @@ export const dashboardCustomerMetrics = {
|
||||
|
||||
export const dashboardWallet = help(
|
||||
'مجموع موجودی طلا و ریال همه مشتریان (بدهی اپ به کاربران). این عدد دفتر اکانت همکار نیست.',
|
||||
'ارزش طلا به ریال = جمع گرم × مظنه لحظهای'
|
||||
'ارزش طلا به ریال = جمع گرم × قیمت لحظهای'
|
||||
)
|
||||
|
||||
export const dashboardWalletMetrics = {
|
||||
@@ -142,5 +142,5 @@ export const dashboardWalletMetrics = {
|
||||
'مجموع ریال موجود در کیف همه مشتریان — شارژ/مانده مشتری؛ با ماندهٔ ریالی همکار یکی نیست.',
|
||||
'جمع ریال در کیفها'
|
||||
),
|
||||
goldToCash: help('ارزش ریالی کل طلای مشتریان با مظنه فعلی.', 'جمع گرم × قیمت هر گرم'),
|
||||
goldToCash: help('ارزش ریالی کل طلای مشتریان با قیمت فعلی.', 'جمع گرم × قیمت هر گرم'),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="dashboard-hero__price min-w-0">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<DashboardLabelWithHelp
|
||||
label="مظنه"
|
||||
label="قیمت"
|
||||
:help="heroHelp"
|
||||
size="xs"
|
||||
text-class="text-[11px]"
|
||||
@@ -91,7 +91,7 @@
|
||||
<DashboardStatCard
|
||||
tone="violet"
|
||||
icon="vuesax-linear:chart-2"
|
||||
title="تراز مظنه"
|
||||
title="تراز قیمت"
|
||||
subtitle="میانگین موزون"
|
||||
:value="formatDashboardAmount(balance?.mazanehBalance)"
|
||||
:unit="DASHBOARD_RIAL_UNIT"
|
||||
@@ -187,7 +187,7 @@
|
||||
<div class="mb-3 flex flex-wrap items-start justify-between gap-2">
|
||||
<DashboardSectionHeader
|
||||
class="!mb-0 min-w-0 flex-1"
|
||||
title="نمودار مظنه"
|
||||
title="نمودار قیمت"
|
||||
:help="copy.charts.priceChart"
|
||||
/>
|
||||
<a-radio-group
|
||||
@@ -331,7 +331,7 @@
|
||||
<th class="px-2 py-2 text-right">نوع</th>
|
||||
<th class="px-2 py-2 text-right">مشتری</th>
|
||||
<th class="px-2 py-2 text-right">مقدار</th>
|
||||
<th class="px-2 py-2 text-right">مظنه/گرم</th>
|
||||
<th class="px-2 py-2 text-right">قیمت/گرم</th>
|
||||
<th class="px-2 py-2 text-right">قیمت مشتری</th>
|
||||
<th class="px-2 py-2 text-right">سود اختلاف قیمت/گرم</th>
|
||||
<th class="px-2 py-2 text-right">سود کل اختلاف قیمت</th>
|
||||
@@ -546,7 +546,7 @@ const heroHelp = computed(() =>
|
||||
isCopperMainMetal.value
|
||||
? {
|
||||
description: 'آخرین قیمت پایه هر کیلوگرم مس در سیستم.',
|
||||
formula: 'مظنه بر حسب کیلوگرم نمایش داده میشود؛ مثقال برای مس کاربرد ندارد.',
|
||||
formula: 'قیمت بر حسب کیلوگرم نمایش داده میشود؛ مثقال برای مس کاربرد ندارد.',
|
||||
}
|
||||
: copy.hero
|
||||
)
|
||||
@@ -688,7 +688,7 @@ const walletMetricItems = computed(() => [
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1279px) {
|
||||
/* دسکتاپ باریک: مظنه بالا، دکمهها زیرش در ردیف مرتب — نه قاطی کنار هم */
|
||||
/* دسکتاپ باریک: قیمت بالا، دکمهها زیرش در ردیف مرتب — نه قاطی کنار هم */
|
||||
.dashboard-hero__row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
@@ -101,6 +101,7 @@ import OtpInput from 'vue3-otp-input'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { setupRoutes } from '@/router'
|
||||
import { getConfigApp, initStoreModeFromSettings } from '@/utils/config'
|
||||
import { firstAllowedRouteName } from '@/utils/adminPageAccess'
|
||||
|
||||
//define emit
|
||||
const emits = defineEmits(['enter'])
|
||||
@@ -175,7 +176,12 @@ const onUserPassFormFinish = async () => {
|
||||
}*/
|
||||
//router.removeRoute('usersMain')
|
||||
//router.removeRoute('users')
|
||||
await router.push({ name: 'dashboard' })
|
||||
const landing = firstAllowedRouteName()
|
||||
if (!landing) {
|
||||
message.warning({ content: 'شما به این صفحه دسترسی ندارید', key: 'admin-page-denied' })
|
||||
return
|
||||
}
|
||||
await router.push({ name: landing })
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
/* if (e?.response.status === 422) {
|
||||
|
||||
@@ -31,13 +31,11 @@ function enterTest() {
|
||||
.login-page__toggle {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
inset-inline-start: 16px;
|
||||
z-index: 1001;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 4px 10px 4px 6px;
|
||||
border-radius: 9999px;
|
||||
background: var(--admin-bg-elevated);
|
||||
border: 1px solid var(--admin-border);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.pargar_ref && !row.customer?.pargar_account_id"
|
||||
v-if="can('register') && !row.pargar_ref && !row.customer?.pargar_account_id"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -88,6 +88,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="واریزیهای شایگان" :help="help">
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-2">
|
||||
<a-select
|
||||
v-model:value="statusFilter"
|
||||
size="small"
|
||||
style="width: 140px"
|
||||
placeholder="فیلتر وضعیت"
|
||||
@change="reloadTable"
|
||||
>
|
||||
<a-select-option value="">همه وضعیتها</a-select-option>
|
||||
<a-select-option value="pending">در انتظار تایید</a-select-option>
|
||||
<a-select-option value="approved">تایید شده</a-select-option>
|
||||
<a-select-option value="rejected">رد شده</a-select-option>
|
||||
</a-select>
|
||||
|
||||
<a-button
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="syncLoading"
|
||||
@click="runSyncFromShayegan"
|
||||
>
|
||||
استعلام از شایگان
|
||||
</a-button>
|
||||
|
||||
<a-button size="small" @click="reloadTable">
|
||||
بروزرسانی
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<a-alert
|
||||
v-if="syncMessage"
|
||||
:type="syncOk ? 'success' : 'error'"
|
||||
:message="syncMessage"
|
||||
show-icon
|
||||
closable
|
||||
class="mb-3"
|
||||
@close="syncMessage = ''"
|
||||
/>
|
||||
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit">
|
||||
<template #customer="{ record }">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium text-gray-800">{{ customerLabel(record) }}</span>
|
||||
<span class="text-xs text-gray-400" v-if="record.customer?.mobile">{{ record.customer.mobile }}</span>
|
||||
<span class="text-[11px] text-gray-400" v-if="record.customer_tafsil || record.customer?.moshtari_code">
|
||||
تفصیلی: {{ record.customer_tafsil || record.customer?.moshtari_code }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #status="{ record }">
|
||||
<a-tag :color="statusColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
|
||||
</template>
|
||||
|
||||
<template #ops="{ record }">
|
||||
<div class="flex items-center justify-center gap-1.5" v-if="record.status === 'pending'">
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title><span>تأیید و شارژ کیف پول در بورس مس</span></template>
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
class="!bg-emerald-600 !border-emerald-600 hover:!bg-emerald-700 !px-2"
|
||||
:loading="actionLoadingId === record.id"
|
||||
@click="handleApprove(record)"
|
||||
>
|
||||
تأیید واریزی
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<template #title><span>رد درخواست</span></template>
|
||||
<a-button
|
||||
danger
|
||||
size="small"
|
||||
class="!px-2"
|
||||
:disabled="actionLoadingId === record.id"
|
||||
@click="handleReject(record)"
|
||||
>
|
||||
رد
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
<div v-else class="text-xs text-gray-400 text-center">
|
||||
<span v-if="record.status === 'approved'">
|
||||
واریز شد
|
||||
<div v-if="record.approver?.name" class="text-[11px] text-gray-500">
|
||||
توسط {{ record.approver.name }}
|
||||
</div>
|
||||
</span>
|
||||
<span v-else-if="record.status === 'rejected'">
|
||||
رد شده
|
||||
<div v-if="record.reject_reason" class="text-[11px] text-red-500">
|
||||
{{ record.reject_reason }}
|
||||
</div>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import {
|
||||
getShayeganChargesTable,
|
||||
approveShayeganCharge,
|
||||
rejectShayeganCharge,
|
||||
syncShayeganCharges,
|
||||
type ShayeganInboundChargeRecord
|
||||
} from '@/api/shayegan'
|
||||
|
||||
const help =
|
||||
'واریزیهای ثبت شده در پنل حسابداری شایگان. با زدن دکمه «تأیید واریزی»، کیف پول ریالی مشتری در بورس مس شارژ خواهد شد.'
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const statusFilter = ref('')
|
||||
const syncLoading = ref(false)
|
||||
const syncOk = ref(false)
|
||||
const syncMessage = ref('')
|
||||
const actionLoadingId = ref<number | null>(null)
|
||||
|
||||
const columns = [
|
||||
{ title: 'شناسه', dataIndex: 'id', key: 'id', width: 70, type: 'Number', filterable: false, sortable: false },
|
||||
{
|
||||
title: 'مشتری',
|
||||
dataIndex: 'customer',
|
||||
key: 'customer',
|
||||
slot: 'customer',
|
||||
type: 'Text'
|
||||
},
|
||||
{
|
||||
title: 'مبلغ واریزی (ریال)',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => usePrice(r.record?.amount || 0, true, ' ریال')
|
||||
},
|
||||
{ title: 'شماره سند شایگان', dataIndex: 'shayegan_number', key: 'shayegan_number', type: 'Text' },
|
||||
{ title: 'توضیحات', dataIndex: 'description', key: 'description', type: 'Text' },
|
||||
{
|
||||
title: 'منبع',
|
||||
dataIndex: 'source',
|
||||
key: 'source',
|
||||
type: 'Text',
|
||||
width: 90,
|
||||
customRender: (r: any) => (r.record?.source === 'sync' ? 'استعلام' : 'وبهوک')
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
slot: 'status',
|
||||
type: 'Text',
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: 'تاریخ دریافت',
|
||||
dataIndex: 'created_at',
|
||||
key: 'created_at',
|
||||
type: 'DateTime',
|
||||
filterable: false,
|
||||
customRender: (r: any) => (r.record?.created_at ? toJalali(r.record.created_at) : '-')
|
||||
},
|
||||
{
|
||||
title: 'عملیات',
|
||||
dataIndex: 'ops',
|
||||
key: 'ops',
|
||||
slot: 'ops',
|
||||
width: 150,
|
||||
filterable: false,
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
|
||||
function asTable(res: any, params: TableInput) {
|
||||
if (res?.query) {
|
||||
return {
|
||||
rows: Array.isArray(res.rows) ? res.rows : [],
|
||||
query: {
|
||||
...params,
|
||||
...res.query,
|
||||
filters: res.query.filters ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
const rows = Array.isArray(res)
|
||||
? res
|
||||
: Array.isArray(res?.data)
|
||||
? res.data
|
||||
: Array.isArray(res?.rows)
|
||||
? res.rows
|
||||
: []
|
||||
return {
|
||||
rows,
|
||||
query: {
|
||||
page: Number(res?.current_page ?? params.page ?? 1),
|
||||
limit: Number(res?.per_page ?? params.limit ?? 20),
|
||||
total: Number(res?.total ?? rows.length),
|
||||
filters: params.filters ?? [],
|
||||
search: params.search ?? '',
|
||||
select: params.select ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tblProps = {
|
||||
columns,
|
||||
defaultPageLimit: 20,
|
||||
api: async (params: TableInput) => {
|
||||
try {
|
||||
const mergedParams = {
|
||||
...params,
|
||||
status: statusFilter.value || undefined
|
||||
}
|
||||
return asTable(await getShayeganChargesTable(mergedParams), params)
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || 'خطا در دریافت لیست واریزیهای شایگان')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function customerLabel(record?: ShayeganInboundChargeRecord) {
|
||||
if (record?.customer?.name?.trim()) return record.customer.name.trim()
|
||||
if (record?.customer?.fname || record?.customer?.lname) {
|
||||
const fullName = `${record?.customer?.fname || ''} ${record?.customer?.lname || ''}`.trim()
|
||||
if (fullName) return fullName
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
function statusLabel(status?: string) {
|
||||
switch (status) {
|
||||
case 'approved':
|
||||
return 'تأیید شده'
|
||||
case 'rejected':
|
||||
return 'رد شده'
|
||||
case 'pending':
|
||||
default:
|
||||
return 'در انتظار تأیید'
|
||||
}
|
||||
}
|
||||
|
||||
function statusColor(status?: string) {
|
||||
switch (status) {
|
||||
case 'approved':
|
||||
return 'green'
|
||||
case 'rejected':
|
||||
return 'red'
|
||||
case 'pending':
|
||||
default:
|
||||
return 'orange'
|
||||
}
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
reload()
|
||||
}
|
||||
|
||||
async function runSyncFromShayegan() {
|
||||
syncLoading.value = true
|
||||
syncMessage.value = ''
|
||||
try {
|
||||
const res = await syncShayeganCharges()
|
||||
syncOk.value = !!res?.ok
|
||||
syncMessage.value = res?.message || 'استعلام با موفقیت انجام شد.'
|
||||
if (res?.ok) {
|
||||
message.success(syncMessage.value)
|
||||
reloadTable()
|
||||
} else {
|
||||
message.error(syncMessage.value)
|
||||
}
|
||||
} catch (e: any) {
|
||||
syncOk.value = false
|
||||
syncMessage.value = e?.response?.data?.message || e?.message || 'خطا در استعلام از شایگان'
|
||||
message.error(syncMessage.value)
|
||||
} finally {
|
||||
syncLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleApprove(record: ShayeganInboundChargeRecord) {
|
||||
Modal.confirm({
|
||||
title: 'تأیید واریزی شایگان',
|
||||
content: `آیا تأیید میکنید مبلغ ${usePrice(record.amount, true, ' ریال')} به کیف پول ${customerLabel(record)} در بورس مس واریز شود؟`,
|
||||
okText: 'تأیید و شارژ',
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
actionLoadingId.value = record.id
|
||||
try {
|
||||
const res = await approveShayeganCharge(record.id)
|
||||
if (res && res.ok) {
|
||||
message.success(res.message || 'کیف پول با موفقیت شارژ شد.')
|
||||
reloadTable()
|
||||
} else {
|
||||
message.error(res?.message || 'خطا در شارژ کیف پول')
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در شارژ کیف پول مشتری')
|
||||
} finally {
|
||||
actionLoadingId.value = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleReject(record: ShayeganInboundChargeRecord) {
|
||||
let reasonInput = ''
|
||||
Modal.confirm({
|
||||
title: 'رد واریزی شایگان',
|
||||
content: `آیا از رد واریزی ${usePrice(record.amount, true, ' ریال')} برای ${customerLabel(record)} اطمینان دارید؟`,
|
||||
okText: 'رد درخواست',
|
||||
cancelText: 'انصراف',
|
||||
okType: 'danger',
|
||||
async onOk() {
|
||||
actionLoadingId.value = record.id
|
||||
try {
|
||||
const res = await rejectShayeganCharge(record.id, reasonInput)
|
||||
if (res && res.ok) {
|
||||
message.info(res.message || 'درخواست رد شد.')
|
||||
reloadTable()
|
||||
} else {
|
||||
message.error(res?.message || 'خطا در رد درخواست')
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در رد درخواست')
|
||||
} finally {
|
||||
actionLoadingId.value = null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TahesabDocSyncBox />
|
||||
|
||||
<!-- ─── تبها ─── -->
|
||||
<div class="cs-tabs">
|
||||
<button
|
||||
@@ -103,8 +105,8 @@
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="syncingPanel"
|
||||
:disabled="!status?.panel_only"
|
||||
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_out')"
|
||||
:disabled="!status?.panel_only && !docSyncStore.active"
|
||||
@click="syncAllPanel"
|
||||
>
|
||||
<template #icon><Icon icon="vuesax-linear:send-2" :size="13" /></template>
|
||||
@@ -241,11 +243,15 @@
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
:loading="importStore.active"
|
||||
:disabled="!importableCount"
|
||||
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_in')"
|
||||
:disabled="!importableCount && !docSyncStore.active"
|
||||
@click="importAll"
|
||||
>
|
||||
{{ importStore.active ? 'در حال…' : `وارد کردن همه (${importableCount})` }}
|
||||
{{
|
||||
docSyncStore.active && docSyncStore.stage === 'customers_in'
|
||||
? 'در حال…'
|
||||
: `وارد کردن همه (${importableCount})`
|
||||
}}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -362,7 +368,6 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
getCustomerSyncStatus,
|
||||
syncPanelToTahesab,
|
||||
importFromTahesab,
|
||||
registerCustomerInTahesab,
|
||||
linkTahesabMatchingPhones,
|
||||
@@ -372,12 +377,13 @@ import {
|
||||
type TahesabOnlyCustomer,
|
||||
type SyncPanelResult,
|
||||
} from '@/api/tahesab'
|
||||
import { useCustomerImportStore } from '@/store/customerImportStore'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import ColleagueAccountingAccounts from '@/pages/menuPages/colleagueOrders/components/ColleagueAccountingAccounts.vue'
|
||||
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||
import { accountingTahesabCustomerSyncIntro } from '@/utils/adminHelpCopy'
|
||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||
|
||||
const importStore = useCustomerImportStore()
|
||||
const docSyncStore = useTahesabDocSyncStore()
|
||||
|
||||
// ─── state ───
|
||||
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
|
||||
@@ -505,6 +511,7 @@ async function load(panelPage = 1) {
|
||||
} else {
|
||||
status.value = res
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
panelList.value = res.panel_only_list.data
|
||||
panelPagination.value = {
|
||||
page: res.panel_only_list.current_page,
|
||||
@@ -534,6 +541,7 @@ async function loadTahesab() {
|
||||
} else {
|
||||
status.value = res
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
tahesabOnlyList.value = res.tahesab_only_list?.data ?? []
|
||||
mandeFetched.clear()
|
||||
tahesabFetched.value = true
|
||||
@@ -556,6 +564,7 @@ async function loadPanel(page = 1) {
|
||||
status.value.panel_registered = res.panel_registered
|
||||
status.value.panel_only = res.panel_only
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
panelList.value = res.panel_only_list.data
|
||||
panelPagination.value = {
|
||||
page: res.panel_only_list.current_page,
|
||||
@@ -592,18 +601,15 @@ async function registerOnePanel(customer: PanelOnlyCustomer) {
|
||||
}
|
||||
|
||||
async function syncAllPanel() {
|
||||
syncingPanel.value = true
|
||||
panelSyncResult.value = null
|
||||
showPanelErrors.value = false
|
||||
if (docSyncStore.active) {
|
||||
docSyncStore.expand()
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await syncPanelToTahesab()
|
||||
panelSyncResult.value = res
|
||||
if (res.success) message.success(`${res.success} مشتری ثبت شد`)
|
||||
if (res.failed) message.warning(`${res.failed} مشتری ثبت نشد`)
|
||||
await load(1)
|
||||
panelDone.clear()
|
||||
} catch { message.error('خطا در ارتباط با سرور') }
|
||||
finally { syncingPanel.value = false }
|
||||
await docSyncStore.startOutbound()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ثبت ناموفق بود')
|
||||
}
|
||||
}
|
||||
|
||||
// ─── تب ۲: عملیات ───
|
||||
@@ -695,11 +701,15 @@ async function importSelected() {
|
||||
async function importAll() {
|
||||
const pending = importableList.value
|
||||
if (!pending.length) return
|
||||
if (importStore.active) {
|
||||
importStore.expand()
|
||||
if (docSyncStore.active) {
|
||||
docSyncStore.expand()
|
||||
return
|
||||
}
|
||||
confirmImport(pending, () => importStore.start(pending, 'tahesab'))
|
||||
confirmImport(pending, () => {
|
||||
void docSyncStore.startInbound().catch((e: any) => {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ورود ناموفق بود')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function confirmLinkPhones() {
|
||||
@@ -763,26 +773,21 @@ async function enrichPageMande() {
|
||||
|
||||
watch([tahesabPage, tahesabSearch], () => { void enrichPageMande() })
|
||||
|
||||
// با پیشرفت عملیات سراسری، ردیفهای وارد شده را همینجا هم تیک بزن
|
||||
watch(() => importStore.doneCodes.length, () => {
|
||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
||||
})
|
||||
|
||||
// پس از پایان کامل، آمار و لیست را تازه کن
|
||||
watch(() => importStore.status, async (s, prev) => {
|
||||
if (prev === 'running' && (s === 'done' || s === 'canceled')) {
|
||||
selectedTahesab.clear()
|
||||
if (status.value?.tahesab_only_count != null) {
|
||||
status.value.tahesab_only_count = Math.max(0, status.value.tahesab_only_count - importStore.success)
|
||||
watch(
|
||||
() => docSyncStore.finished,
|
||||
async (done, wasDone) => {
|
||||
if (!done || wasDone) return
|
||||
await load(1)
|
||||
panelDone.clear()
|
||||
if (docSyncStore.stage === 'customers_in') {
|
||||
tahesabFetched.value = false
|
||||
if (activeTab.value === 'tahesab') await loadTahesab()
|
||||
}
|
||||
await loadPanel(panelPagination.value.page)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
load(1)
|
||||
// اگر عملیات سراسری در حال اجراست، ردیفهای انجامشده را همگام کن
|
||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div
|
||||
class="mb-3 flex w-full flex-col gap-2.5 rounded-xl border border-gray-200 bg-gray-50 px-3.5 py-3 sm:flex-row sm:items-center sm:gap-3"
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="m-0 text-sm font-800 text-gray-800">ارسال سندها به تهحساب</p>
|
||||
<p class="mb-0 mt-1 text-xs leading-relaxed text-gray-500">
|
||||
با یک کلیک همهٔ سفارشها و شارژهای جاافتاده یکییکی و با فاصله به تهحساب میروند.
|
||||
بعد از سندها، مشتریان پنلِ بدون کد هم همانجا ثبت میشوند. پیشرفت را میتوانید کوچک کنید.
|
||||
اگر سندها در تهحساب پاک شده، اول وضعیت محلی را بازنشانی کنید.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto">
|
||||
<a-button
|
||||
type="primary"
|
||||
class="!w-full sm:!w-auto"
|
||||
:loading="store.starting || store.active"
|
||||
:disabled="store.active || store.resetting"
|
||||
@click="onStart"
|
||||
>
|
||||
{{ store.active ? 'در حال ارسال…' : 'ارسال همه سندها' }}
|
||||
</a-button>
|
||||
<a-button
|
||||
class="!w-full sm:!w-auto"
|
||||
:loading="store.resetting"
|
||||
:disabled="store.active"
|
||||
@click="onReset"
|
||||
>
|
||||
بازنشانی وضعیت محلی
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { createVNode } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
|
||||
const emit = defineEmits<{ refreshed: [] }>()
|
||||
const store = useTahesabDocSyncStore()
|
||||
|
||||
async function onStart() {
|
||||
try {
|
||||
await store.start()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ارسال ناموفق بود')
|
||||
}
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
Modal.confirm({
|
||||
title: 'بازنشانی وضعیت محلی؟',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content:
|
||||
'سندهایی که پنل آنها را موفق میداند دوباره در صف ارسال میآیند. خودِ تهحساب عوض نمیشود. کد مشتری پنل دست نمیخورد.',
|
||||
okText: 'بازنشانی کن',
|
||||
cancelText: 'انصراف',
|
||||
centered: true,
|
||||
onOk: runReset,
|
||||
})
|
||||
}
|
||||
|
||||
async function runReset() {
|
||||
try {
|
||||
const res = await store.resetLocal()
|
||||
if (!res) return
|
||||
message.success(res.message || 'وضعیت محلی بهروز شد')
|
||||
if (res.summary?.total) {
|
||||
message.info(`${res.summary.total} سند در صف ارسال است — حالا ارسال همه را بزنید`)
|
||||
}
|
||||
emit('refreshed')
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'بازنشانی ناموفق بود')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.tahesab_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.tahesab_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<AdminFieldHelp :text="accountingTahesabBalanceSyncIntro" size="sm" />
|
||||
</div>
|
||||
<p class="tw-bulk__hint">
|
||||
همگام تکی: اول سندها و اختلاف را میبینید، بعد تأیید میکنید. دو مانده جمع نمیشوند.
|
||||
همگام تکی: اول سندها و اختلاف را میبینید، بعد یکی از سه مسیر را تأیید میکنید (تهحساب→اپ، اپ→تهحساب حتی اگر اپ صفر باشد، یا نگه داشتن). دو مانده جمع نمیشوند.
|
||||
همگام همه فقط کیف خالی را مینشاند؛ تداخل برای تصمیم دستی میماند.
|
||||
</p>
|
||||
</div>
|
||||
@@ -154,6 +154,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="decisionVisible"
|
||||
source-label="تهحساب"
|
||||
:allow-push="true"
|
||||
:app-gold="decisionResult?.app_gold"
|
||||
:app-cash="decisionResult?.app_cash"
|
||||
:tahesab-gold="decisionResult?.tahesab_gold"
|
||||
@@ -200,7 +201,7 @@ const failed = ref(0)
|
||||
const errors = ref<TahesabBulkWalletSyncChunk['errors']>([])
|
||||
const decisions = ref<TahesabBulkWalletSyncChunk['decisions']>([])
|
||||
const decidingId = ref<number | null>(null)
|
||||
const decidingMode = ref<'overwrite' | 'keep' | null>(null)
|
||||
const decidingMode = ref<'overwrite' | 'keep' | 'push' | null>(null)
|
||||
|
||||
const search = ref('')
|
||||
const page = ref(1)
|
||||
@@ -209,7 +210,7 @@ const listTotal = ref(0)
|
||||
const listLoading = ref(false)
|
||||
const rows = ref<TahesabWalletLinkedRow[]>([])
|
||||
const syncingId = ref<number | null>(null)
|
||||
const syncingMode = ref<'ask' | 'overwrite' | 'keep' | null>(null)
|
||||
const syncingMode = ref<'ask' | 'overwrite' | 'keep' | 'push' | null>(null)
|
||||
const decisionVisible = ref(false)
|
||||
const decisionCustomerId = ref<number | null>(null)
|
||||
const decisionResult = ref<TahesabWalletSyncResult['result'] | null>(null)
|
||||
@@ -321,7 +322,7 @@ async function openReview(customerId: number) {
|
||||
}
|
||||
}
|
||||
|
||||
async function onReviewDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onReviewDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
const customerId = decisionCustomerId.value
|
||||
decisionVisible.value = false
|
||||
if (!customerId) return
|
||||
@@ -337,22 +338,25 @@ function dismissResult() {
|
||||
showDetails.value = false
|
||||
}
|
||||
|
||||
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
||||
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||
decidingId.value = customerId
|
||||
decidingMode.value = mode
|
||||
try {
|
||||
const res = await syncCustomerWalletFromTahesab(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
decisions.value = decisions.value.filter(d => d.id !== customerId)
|
||||
needsDecision.value = Math.max(0, decisions.value.length)
|
||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||
else message.success(res.message || 'مانده تهحساب اعمال شد')
|
||||
await loadList()
|
||||
} catch {
|
||||
message.error('اعمال تصمیم ناموفق بود')
|
||||
} catch (e: unknown) {
|
||||
const data = (e as { response?: { data?: { message?: string } } })?.response?.data
|
||||
message.error(data?.message || 'اعمال تصمیم ناموفق بود')
|
||||
} finally {
|
||||
decidingId.value = null
|
||||
decidingMode.value = null
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.zarin_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.zarin_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<div class="flex justify-center gap-2">
|
||||
|
||||
<!-- دکمه ۱: اطلاعات کلی (همیشه نمایان) -->
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<!-- دکمه ۲: ثبت مشتری در پرگار (فقط اگر سند هنوز ثبت نشده و مشتری کد ندارد) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
v-if="can('register') && canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<!-- دکمه ۳: ارسال به پرگار (فقط اگر هنوز در پرگار ثبت نشده) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record)"
|
||||
v-if="can('send') && canRetryPargar(record)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -138,6 +138,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingPargarDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="اسناد شایگان" :help="help">
|
||||
<template #extra>
|
||||
<a-button size="small" :loading="healthLoading" @click="runHealth">تست اتصال</a-button>
|
||||
</template>
|
||||
|
||||
<a-alert
|
||||
v-if="healthMessage"
|
||||
:type="healthOk ? 'success' : 'error'"
|
||||
:message="healthMessage"
|
||||
show-icon
|
||||
closable
|
||||
class="mb-2"
|
||||
@close="healthMessage = ''"
|
||||
/>
|
||||
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit">
|
||||
<template #status="{ record }">
|
||||
<a-tag :color="statusColor(record.sync_status)">{{ statusLabel(record.sync_status) }}</a-tag>
|
||||
</template>
|
||||
<template #ops="{ record }">
|
||||
<div class="flex justify-center">
|
||||
<a-tooltip
|
||||
v-if="record.sync_status !== 'success'"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="retry(record)"
|
||||
>
|
||||
<template #title><span>ارسال مجدد</span></template>
|
||||
<Icon icon="vuesax-linear:send-2" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { shayeganHealth, shayeganRetry, shayeganTable } from '@/api/shayegan'
|
||||
|
||||
const help =
|
||||
'وضعیت ارسال به حسابگر. تست اتصال فقط خواندنی است و سند آزمایشی در CYPRSD04 نمیسازد.'
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
customer: 'ثبت مشتری',
|
||||
trade: 'معامله',
|
||||
wallet_cash: 'کیف ریالی',
|
||||
wallet_gold: 'کیف محصول'
|
||||
}
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
success: 'موفق',
|
||||
failed: 'ناموفق',
|
||||
timeout: 'تایماوت',
|
||||
pending: 'در انتظار'
|
||||
}
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const healthLoading = ref(false)
|
||||
const healthOk = ref(false)
|
||||
const healthMessage = ref('')
|
||||
|
||||
const columns = [
|
||||
{ title: 'شناسه', dataIndex: 'id', key: 'id', width: 80, type: 'Number', filterable: false, sortable: false },
|
||||
{
|
||||
title: 'مشتری',
|
||||
dataIndex: 'customer.name',
|
||||
key: 'customer.name',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => customerLabel(r.record)
|
||||
},
|
||||
{
|
||||
title: 'نوع',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => typeLabel(r.record?.type)
|
||||
},
|
||||
{
|
||||
title: 'مبلغ/مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => (r.record?.amount == null || r.record?.amount === '' ? '-' : usePrice(r.record.amount, true, ''))
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'sync_status',
|
||||
key: 'sync_status',
|
||||
slot: 'status',
|
||||
type: 'Text'
|
||||
},
|
||||
{ title: 'شماره شایگان', dataIndex: 'shayegan_number', key: 'shayegan_number', type: 'Text' },
|
||||
{ title: 'توضیح', dataIndex: 'desc', key: 'desc', type: 'Text' },
|
||||
{
|
||||
title: 'زمان',
|
||||
dataIndex: 'created_at',
|
||||
key: 'created_at',
|
||||
type: 'DateTime',
|
||||
filterable: false,
|
||||
customRender: (r: any) => (r.record?.created_at ? toJalali(r.record.created_at) : '-')
|
||||
},
|
||||
{
|
||||
title: 'عملیات',
|
||||
dataIndex: 'ops',
|
||||
key: 'ops',
|
||||
slot: 'ops',
|
||||
width: 110,
|
||||
filterable: false,
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
|
||||
function asTable(res: any, params: TableInput) {
|
||||
if (res?.query) {
|
||||
return {
|
||||
rows: Array.isArray(res.rows) ? res.rows : [],
|
||||
query: {
|
||||
...params,
|
||||
...res.query,
|
||||
filters: res.query.filters ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
const rows = Array.isArray(res)
|
||||
? res
|
||||
: Array.isArray(res?.data)
|
||||
? res.data
|
||||
: Array.isArray(res?.rows)
|
||||
? res.rows
|
||||
: []
|
||||
return {
|
||||
rows,
|
||||
query: {
|
||||
page: Number(res?.current_page ?? params.page ?? 1),
|
||||
limit: Number(res?.per_page ?? params.limit ?? 20),
|
||||
total: Number(res?.total ?? rows.length),
|
||||
filters: params.filters ?? [],
|
||||
search: params.search ?? '',
|
||||
select: params.select ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tblProps = {
|
||||
columns,
|
||||
defaultPageLimit: 20,
|
||||
api: async (params: TableInput) => {
|
||||
try {
|
||||
return asTable(await shayeganTable(params), params)
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || 'خطا در دریافت اسناد شایگان')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function customerLabel(record?: any) {
|
||||
if (record?.customer?.name?.trim()) return record.customer.name.trim()
|
||||
if (record?.customer?.fname || record?.customer?.lname) {
|
||||
const fullName = `${record?.customer?.fname || ''} ${record?.customer?.lname || ''}`.trim()
|
||||
if (fullName) return fullName
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
function typeLabel(type?: string | null) {
|
||||
if (!type) return '-'
|
||||
return TYPE_LABELS[type] ?? type
|
||||
}
|
||||
|
||||
function statusLabel(status?: string | null) {
|
||||
if (!status) return '-'
|
||||
return STATUS_LABELS[status] ?? status
|
||||
}
|
||||
|
||||
function statusColor(status?: string) {
|
||||
if (status === 'success') return 'green'
|
||||
if (status === 'failed') return 'red'
|
||||
if (status === 'timeout') return 'orange'
|
||||
return 'blue'
|
||||
}
|
||||
|
||||
async function runHealth() {
|
||||
healthLoading.value = true
|
||||
healthMessage.value = ''
|
||||
try {
|
||||
const res: any = await shayeganHealth()
|
||||
healthOk.value = !!res?.ok
|
||||
healthMessage.value = res?.message || (res?.ok ? 'اتصال برقرار است' : 'اتصال ناموفق')
|
||||
} catch (e: any) {
|
||||
healthOk.value = false
|
||||
healthMessage.value = e?.response?.data?.message || e?.message || 'خطای تست اتصال'
|
||||
} finally {
|
||||
healthLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function retry(record: any) {
|
||||
const isTimeout = record.sync_status === 'timeout'
|
||||
Modal.confirm({
|
||||
title: 'ارسال مجدد به شایگان',
|
||||
content: isTimeout
|
||||
? 'این سند timeout شده. فقط اگر در حسابگر ثبت نشده، تأیید کنید.'
|
||||
: 'سند دوباره به شایگان ارسال شود؟',
|
||||
okText: 'ارسال',
|
||||
cancelText: 'انصراف',
|
||||
onOk: async () => {
|
||||
try {
|
||||
await shayeganRetry(record.id, isTimeout)
|
||||
message.success('انجام شد')
|
||||
await reload()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'خطا')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function fetch() {
|
||||
await reload()
|
||||
}
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
@@ -6,7 +6,7 @@
|
||||
>
|
||||
<template #extra>
|
||||
<a-button
|
||||
v-if="(pending?.total ?? 0) > 0"
|
||||
v-if="customerId && (pending?.total ?? 0) > 0"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="syncing"
|
||||
@@ -16,6 +16,8 @@
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
<TahesabDocSyncBox v-if="!customerId" @refreshed="onDocSyncRefreshed" />
|
||||
|
||||
<div
|
||||
v-if="(pending?.total ?? 0) > 0"
|
||||
class="mb-3 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900"
|
||||
@@ -77,12 +79,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -91,6 +93,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -109,13 +112,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -125,7 +128,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id"
|
||||
v-if="can('send') && !record.tahesab_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -207,6 +210,7 @@ import { isMobile } from '@core/utils/is'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
|
||||
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||
import {
|
||||
tahesabIssueKindLabel,
|
||||
tahesabStatusLabel
|
||||
@@ -217,6 +221,12 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const docSyncStore = useTahesabDocSyncStore()
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
@@ -386,17 +396,24 @@ function openRegister(record: TahesabRecord) {
|
||||
async function loadPending() {
|
||||
try {
|
||||
pending.value = await getTahesabPendingSummary(props.customerId)
|
||||
docSyncStore.apply(pending.value?.doc_sync)
|
||||
} catch {
|
||||
pending.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function onDocSyncRefreshed() {
|
||||
await loadPending()
|
||||
if (docsView.value === 'failed') await loadFailedDocs()
|
||||
}
|
||||
|
||||
async function loadFailedDocs() {
|
||||
failedLoading.value = true
|
||||
try {
|
||||
const res = await getTahesabPendingDocs(props.customerId, 200)
|
||||
failedRows.value = res.rows || []
|
||||
pending.value = res.summary
|
||||
docSyncStore.apply(res.summary?.doc_sync)
|
||||
} catch {
|
||||
failedRows.value = []
|
||||
} finally {
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -90,6 +90,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -108,13 +109,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -124,7 +125,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id"
|
||||
v-if="can('send') && !record.zarin_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -216,6 +217,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingZarinDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<ATabPane v-if="pargarEnabled" key="pargar" tab="اسناد پرگار" />
|
||||
<ATabPane v-if="pargarEnabled" key="pargar-customer-sync" tab="همگام سازی مشتریان در پرگار" />
|
||||
<ATabPane v-if="pargarEnabled" key="pargar-wallet-sync" tab="مانده کیف پرگار" />
|
||||
<ATabPane v-if="shayeganEnabled" key="shayegan" tab="اسناد شایگان" />
|
||||
<ATabPane v-if="shayeganEnabled" key="shayegan-charges" tab="واریزیهای شایگان" />
|
||||
</ATabs>
|
||||
<tbl v-if="activeTab === 'reports'" ref="table" class="min-h-0 flex-1" />
|
||||
<tahesabTbl v-else-if="tahesabEnabled && activeTab === 'tahesab'" ref="tahesabTable" class="min-h-0 flex-1" />
|
||||
@@ -28,6 +30,8 @@
|
||||
<pargarTbl v-else-if="pargarEnabled && activeTab === 'pargar'" ref="pargarTable" class="min-h-0 flex-1" />
|
||||
<pargarCustomerSync v-else-if="pargarEnabled && activeTab === 'pargar-customer-sync'" class="shrink-0" />
|
||||
<pargarWalletSync v-else-if="pargarEnabled && activeTab === 'pargar-wallet-sync'" class="shrink-0" />
|
||||
<shayeganTbl v-else-if="shayeganEnabled && activeTab === 'shayegan'" ref="shayeganTable" class="min-h-0 flex-1" />
|
||||
<shayeganChargesTab v-else-if="shayeganEnabled && activeTab === 'shayegan-charges'" class="min-h-0 flex-1" />
|
||||
</div>
|
||||
</BasicMainCard>
|
||||
<BasicModal
|
||||
@@ -154,7 +158,8 @@
|
||||
// import BasicInfoModal from '@/components/BasicInfoModal'
|
||||
import { inputLenRules, inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import tbl from './components/table.vue'
|
||||
import tahesabTbl from './components/tahesabTable.vue'
|
||||
import customerSync from './components/TahesabCustomerSync.vue'
|
||||
@@ -162,6 +167,8 @@ import tahesabWalletSync from './components/TahesabWalletBulkSync.vue'
|
||||
import zarinTbl from './components/zarinTable.vue'
|
||||
import zarinCustomerSync from './components/ZarinCustomerSync.vue'
|
||||
import zarinWalletSync from './components/ZarinWalletBulkSync.vue'
|
||||
import shayeganTbl from './components/shayeganTable.vue'
|
||||
import shayeganChargesTab from './components/ShayeganChargesTab.vue'
|
||||
import pargarTbl from './components/pargarTable.vue'
|
||||
import pargarCustomerSync from './components/PargarCustomerSync.vue'
|
||||
import pargarWalletSync from './components/PargarWalletBulkSync.vue'
|
||||
@@ -183,15 +190,26 @@ import type { last } from '@/model/price'
|
||||
import { createOrder } from '@/api/order'
|
||||
import { getCashBalance, getGoldBalance } from '@/components/mobile/utils/wallet'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting } from '@/utils/config'
|
||||
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting, shayeganEnabledSetting } from '@/utils/config'
|
||||
|
||||
//loading
|
||||
const route = useRoute()
|
||||
const loading = ref<boolean>(false)
|
||||
const submitError = ref('')
|
||||
const activeTab = ref<'reports' | 'tahesab' | 'customer-sync' | 'tahesab-wallet-sync' | 'zarin' | 'zarin-customer-sync' | 'zarin-wallet-sync' | 'pargar' | 'pargar-customer-sync' | 'pargar-wallet-sync'>('reports')
|
||||
const activeTab = ref<'reports' | 'tahesab' | 'customer-sync' | 'tahesab-wallet-sync' | 'zarin' | 'zarin-customer-sync' | 'zarin-wallet-sync' | 'pargar' | 'pargar-customer-sync' | 'pargar-wallet-sync' | 'shayegan' | 'shayegan-charges'>((route.query.tab as any) || 'reports')
|
||||
const tahesabEnabled = tahesabEnabledSetting
|
||||
const zarinEnabled = zarinEnabledSetting
|
||||
const pargarEnabled = pargarEnabledSetting
|
||||
const shayeganEnabled = shayeganEnabledSetting
|
||||
|
||||
watch(
|
||||
() => route.query.tab,
|
||||
(tab) => {
|
||||
if (tab && typeof tab === 'string') {
|
||||
activeTab.value = tab as any
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
//define store
|
||||
const store = useStaticApiListsStore()
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('recipients')" placement="bottom">
|
||||
<template #title>گیرندگان</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:profile-2user"
|
||||
@@ -36,7 +36,7 @@
|
||||
@click="emits('recipients', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('readers')" placement="bottom">
|
||||
<template #title>بازدیدکنندگان</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:people"
|
||||
@@ -45,7 +45,7 @@
|
||||
@click="emits('readers', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="!isSystemRecord(record)" placement="bottom">
|
||||
<a-tooltip v-if="can('edit') && !isSystemRecord(record)" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -54,7 +54,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:close-circle' : 'vuesax-linear:tick-circle'"
|
||||
@@ -63,7 +63,7 @@
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -91,6 +91,9 @@ import {
|
||||
APP_NOTIFICATION_SOURCE_TABS,
|
||||
type AppNotificationSourceFilter,
|
||||
} from '@/model/appNotifications'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -18,19 +18,21 @@
|
||||
<div class="truncate font-bold text-slate-800 dark:text-slate-100">{{ item.name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ item.code }}</div>
|
||||
</div>
|
||||
<a-switch :checked="item.is_active" size="small" @change="emits('toggle', item)" />
|
||||
<a-switch v-if="can('toggle')" :checked="item.is_active" size="small" @change="emits('toggle', item)" />
|
||||
</div>
|
||||
<div class="line-clamp-2 text-sm text-slate-600 dark:text-slate-300">{{ item.body }}</div>
|
||||
<div class="flex items-center justify-between text-xs text-gray-500">
|
||||
<span>ارسال {{ Number(item.sent_count ?? 0) }} · ناموفق {{ Number(item.failed_count ?? 0) }}</span>
|
||||
<div class="flex gap-3">
|
||||
<Icon
|
||||
v-if="can('edit')"
|
||||
icon="vuesax-linear:edit"
|
||||
color="#4572E9"
|
||||
class="cursor-pointer"
|
||||
@click="emits('edit', item)"
|
||||
/>
|
||||
<Icon
|
||||
v-if="can('delete')"
|
||||
icon="vuesax-linear:trash"
|
||||
color="#C53030"
|
||||
class="cursor-pointer"
|
||||
@@ -46,11 +48,11 @@
|
||||
|
||||
<BaseTable v-else class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #is_active="{ record }">
|
||||
<a-switch :checked="record.is_active" size="small" @change="emits('toggle', record)" />
|
||||
<a-switch v-if="can('toggle')" :checked="record.is_active" size="small" @change="emits('toggle', record)" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('preview')" placement="bottom">
|
||||
<template #title>اجرای آزمایشی</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:play"
|
||||
@@ -59,7 +61,7 @@
|
||||
@click="emits('runNow', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('log')" placement="bottom">
|
||||
<template #title>لاگ ارسال</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:document-text"
|
||||
@@ -68,7 +70,7 @@
|
||||
@click="emits('sends', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -77,7 +79,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -104,6 +106,9 @@ import { getAutomationsTable } from '@/api/automations'
|
||||
import type { Automation } from '@/model/automations'
|
||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||
import { automationsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="banner-image-upload">
|
||||
<div class="banner-image-upload fix-capture" @pointerdown="ensureGalleryCapture" @click="ensureGalleryCapture">
|
||||
<a-upload
|
||||
v-if="!displayUrl"
|
||||
class="banner-image-upload__zone"
|
||||
class="banner-image-upload__zone fix-capture"
|
||||
name="file"
|
||||
accept="image/*"
|
||||
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
@@ -37,8 +37,9 @@
|
||||
</div>
|
||||
<div class="banner-image-upload__bar">
|
||||
<a-upload
|
||||
class="fix-capture"
|
||||
name="file"
|
||||
accept="image/*"
|
||||
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
@@ -63,11 +64,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch, onMounted, nextTick } from 'vue'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { uploadURL } from '@root/config'
|
||||
import { getToken } from '@/utils'
|
||||
import { fileUrlCandidates, normalizeUploadFileResponse, toAbsoluteFileUrl } from '@/utils/file'
|
||||
import { fixFileCapture } from '@/utils/fixFileCapture'
|
||||
import {
|
||||
createImageBeforeUpload,
|
||||
createImageCustomRequest
|
||||
@@ -89,11 +92,22 @@ const candidateIndex = ref(0)
|
||||
const candidates = computed(() => fileUrlCandidates(props.imageUrl))
|
||||
const displayUrl = computed(() => candidates.value[candidateIndex.value] ?? '')
|
||||
|
||||
function ensureGalleryCapture() {
|
||||
fixFileCapture()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fixFileCapture()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.imageUrl,
|
||||
() => {
|
||||
previewFailed.value = false
|
||||
candidateIndex.value = 0
|
||||
nextTick(() => {
|
||||
fixFileCapture()
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
</div>
|
||||
|
||||
<MobileIconButton
|
||||
v-if="can('toggle')"
|
||||
:icon="item.sts === 2 ? 'vuesax-linear:card-tick' : 'vuesax-linear:card-remove'"
|
||||
:color="item.sts === 2 ? '#16A34A' : '#DC2626'"
|
||||
:size="20"
|
||||
@click="$emit('toggleSts', item)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="can('delete')"
|
||||
icon="vuesax-linear:trash"
|
||||
color="#DC2626"
|
||||
:size="20"
|
||||
@@ -34,6 +36,9 @@
|
||||
import type { Card } from '@/model/card'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
type AccountRow = Card & { sts_str?: string; created_at?: string; customer_id?: number }
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center items-center">
|
||||
<a-tooltip
|
||||
v-if="can('toggle')"
|
||||
:key="record.sts"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -25,7 +26,7 @@
|
||||
:color="record.sts !== 2 ? 'red' : 'green'"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||
<template #title>
|
||||
<span>حذف کارت</span>
|
||||
</template>
|
||||
@@ -63,6 +64,9 @@ import type { Card } from '@/model/card'
|
||||
import AccountMobileCardList from './AccountMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { cardsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
<a-form-item label="شرط اجرا" name="price_condition" :rules="inputRules()">
|
||||
<a-radio-group v-model:value="form.price_condition">
|
||||
<a-radio value="gte">مساوی یا بیشتر از مظنه هدف</a-radio>
|
||||
<a-radio value="lte">مساوی یا کمتر از مظنه هدف</a-radio>
|
||||
<a-radio value="gte">مساوی یا بیشتر از قیمت هدف</a-radio>
|
||||
<a-radio value="lte">مساوی یا کمتر از قیمت هدف</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="مظنه هدف" name="trigger_price" :rules="inputRulesNumber()">
|
||||
<a-form-item label="قیمت هدف" name="trigger_price" :rules="inputRulesNumber()">
|
||||
<BasicInput
|
||||
v-model:value="form.trigger_price"
|
||||
type="price"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -22,7 +22,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||
@@ -31,7 +31,7 @@
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -54,6 +54,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { cols } from '../hooks/conditionalOrdersColumns'
|
||||
import { getConditionalOrdersTable } from '@/api/conditionalOrders'
|
||||
import { conditionalOrdersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export const cols: BaseTableColumn[] = [
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'مظنه هدف',
|
||||
title: 'قیمت هدف',
|
||||
dataIndex: 'trigger_price',
|
||||
key: 'trigger_price',
|
||||
type: 'Number'
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
:value="priceValue"
|
||||
:disabled="disabled"
|
||||
class="w-full"
|
||||
:addon-after="unitLabel || undefined"
|
||||
:formatter="(v: string) => `${v}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
||||
:parser="(v: string) => sanitizeNumericString(v, { allowDecimal: false })"
|
||||
@update:value="onPriceChange"
|
||||
@@ -109,6 +110,7 @@
|
||||
inputmode="numeric"
|
||||
allow-clear
|
||||
class="w-full"
|
||||
:addon-after="unitLabel || undefined"
|
||||
@update:value="onPlainNumberChange"
|
||||
@blur="emit('blur')"
|
||||
/>
|
||||
@@ -144,6 +146,7 @@ import TemplateTextField from './TemplateTextField.vue'
|
||||
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
|
||||
import { hasTemplateField } from './templateFields'
|
||||
import {
|
||||
getSettingUnitLabel,
|
||||
normalizeTimeValue,
|
||||
parseSelectOptions,
|
||||
resolveSettingFieldType,
|
||||
@@ -182,6 +185,8 @@ const fieldType = computed<SettingFieldType>(() =>
|
||||
})
|
||||
)
|
||||
|
||||
const unitLabel = computed(() => getSettingUnitLabel(props.settingKey, fieldType.value))
|
||||
|
||||
const isZaarboxPriceKey = computed(() => props.settingKey === 'zaarbox_price_key')
|
||||
const isMontzarProductId = computed(() => props.settingKey === 'montzar_product_id')
|
||||
const isMainWalletProducts = computed(() => props.settingKey === 'main_wallet_products')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<BasicShowContent :title="pageTitle" :help="configurationPageIntro" class="h-full">
|
||||
<BasicShowContent :title="pageTitle" :help="pageHelp" class="h-full">
|
||||
<div class="settings-toolbar">
|
||||
<a-input
|
||||
v-model:value="search"
|
||||
@@ -207,10 +207,10 @@ import { loading } from '@/utils'
|
||||
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
|
||||
import SettingValueField from './SettingValueField.vue'
|
||||
import SettingCard from './SettingCard.vue'
|
||||
import { configurationPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { configurationPageIntro, websiteSettingsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { refreshAppModeMenu } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings } from '@/utils/config'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setGiftCardEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings, applyHasLandingFromRows, setHasLandingFromSettings } from '@/utils/config'
|
||||
import {
|
||||
EDITABLE_SETTING_GROUPS,
|
||||
SYSTEM_SETTING_GROUPS,
|
||||
@@ -218,6 +218,12 @@ import {
|
||||
OTHER_PAGE_SETTING_MENUS,
|
||||
type SettingGroupDef
|
||||
} from './settingGroups'
|
||||
import {
|
||||
LANDING_SETTING_GROUPS,
|
||||
isLandingContentKey,
|
||||
landingSectionByPrefix,
|
||||
matchesLandingPrefix
|
||||
} from './landingSettings'
|
||||
import {
|
||||
SETTING_TYPE_OPTIONS,
|
||||
formatValueForSave,
|
||||
@@ -233,8 +239,9 @@ import {
|
||||
} from './settingTypes'
|
||||
import { TRADING_HOURS_SETTING_KEY_SET } from './tradingHoursKeys'
|
||||
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' }>(), {
|
||||
mode: 'editable'
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' | 'landing'; landingPrefix?: string }>(), {
|
||||
mode: 'editable',
|
||||
landingPrefix: ''
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -243,11 +250,24 @@ function refreshMenuAfterStoreChange() {
|
||||
}
|
||||
|
||||
const isSystemMode = computed(() => props.mode === 'system')
|
||||
const pageTitle = computed(() => (isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'))
|
||||
const isLandingMode = computed(() => props.mode === 'landing')
|
||||
const pageTitle = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
return landingSectionByPrefix(props.landingPrefix)?.title ?? 'تنظیمات وبسایت'
|
||||
}
|
||||
return isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'
|
||||
})
|
||||
const pageHelp = computed(() => (isLandingMode.value ? websiteSettingsPageIntro : configurationPageIntro))
|
||||
const refreshingSuperAdmin = ref(false)
|
||||
const settingGroups = computed(() =>
|
||||
isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
)
|
||||
const settingGroups = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
const prefix = props.landingPrefix || ''
|
||||
return prefix
|
||||
? LANDING_SETTING_GROUPS.filter((g) => g.id === prefix)
|
||||
: LANDING_SETTING_GROUPS
|
||||
}
|
||||
return isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
})
|
||||
|
||||
const settingTypeOptions = SETTING_TYPE_OPTIONS
|
||||
|
||||
@@ -327,6 +347,13 @@ const filteredRows = computed(() =>
|
||||
(baseData.value || []).filter((row) => {
|
||||
if (row.id == null || !matchesFilter(row)) return false
|
||||
if (!isSettingVisible(row.key)) return false
|
||||
if (isLandingMode.value) {
|
||||
if (!isEditable(row)) return false
|
||||
const prefix = props.landingPrefix || ''
|
||||
if (prefix) return matchesLandingPrefix(row.key || '', prefix)
|
||||
return isLandingContentKey(row.key)
|
||||
}
|
||||
if (isLandingContentKey(row.key)) return false
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (OTHER_PAGE_SETTING_MENUS.has(menu)) return false
|
||||
if (!menu && !isSystemMode.value && TRADING_HOURS_SETTING_KEY_SET.has(row.key || '')) {
|
||||
@@ -486,7 +513,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.mode,
|
||||
() => [props.mode, props.landingPrefix],
|
||||
() => {
|
||||
search.value = ''
|
||||
filterType.value = undefined
|
||||
@@ -608,6 +635,7 @@ async function initConfig() {
|
||||
applyPriceProviderFromRows(baseData.value)
|
||||
applyPriceChannelAccessFromRows(baseData.value)
|
||||
applySupportChatMenuEnabledFromRows(baseData.value)
|
||||
applyHasLandingFromRows(baseData.value)
|
||||
applyGroupSmsFromRows(baseData.value)
|
||||
applyCustomerSpecialPricingFromRows(baseData.value)
|
||||
applyGoldCreditEnabledFromRows(baseData.value)
|
||||
@@ -616,6 +644,7 @@ async function initConfig() {
|
||||
!isSystemMode.value ||
|
||||
!baseData.value.some((row) => row.key === 'price_provider') ||
|
||||
!baseData.value.some((row) => row.key === 'show_to_users_chat') ||
|
||||
!baseData.value.some((row) => row.key === 'has_landing') ||
|
||||
!baseData.value.some((row) => row.key === 'price_channel_access') ||
|
||||
!baseData.value.some((row) => row.key === 'group_sms') ||
|
||||
!baseData.value.some((row) => row.key === 'customer_special_pricing') ||
|
||||
@@ -627,6 +656,7 @@ async function initConfig() {
|
||||
const rows = Array.isArray(all) ? all : []
|
||||
applyPriceProviderFromRows(rows)
|
||||
applySupportChatMenuEnabledFromRows(rows)
|
||||
applyHasLandingFromRows(rows)
|
||||
applyPriceChannelAccessFromRows(rows)
|
||||
applyGroupSmsFromRows(rows)
|
||||
applyCustomerSpecialPricingFromRows(rows)
|
||||
@@ -688,6 +718,11 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
setPriceTriggerEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_gift_card') {
|
||||
setGiftCardEnabledFromSettings(isSwitchOn(value))
|
||||
refreshMenuAfterStoreChange()
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_notification') {
|
||||
setAppNotificationEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
@@ -701,6 +736,14 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'has_landing') {
|
||||
setHasLandingFromSettings(isSwitchOn(value))
|
||||
const list = userStore.userInfo?.settings
|
||||
if (Array.isArray(list)) {
|
||||
const row = list.find((s: any) => s?.key === key)
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'price_channel_access') {
|
||||
setPriceChannelAccessFromSettings(isSwitchOn(value))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
export type LandingSection = {
|
||||
prefix: string
|
||||
title: string
|
||||
icon: string
|
||||
name: string
|
||||
path: string
|
||||
}
|
||||
|
||||
export const LANDING_SETTING_SECTIONS: LandingSection[] = [
|
||||
{ prefix: 'landing_site', title: 'تنظیمات کلی سایت', icon: 'vuesax-linear:global', name: 'websiteLandingSite', path: 'site' },
|
||||
{ prefix: 'landing_header', title: 'هدر و ناوبری', icon: 'vuesax-linear:menu', name: 'websiteLandingHeader', path: 'header' },
|
||||
{ prefix: 'landing_hero', title: 'هیرو', icon: 'vuesax-linear:image', name: 'websiteLandingHero', path: 'hero' },
|
||||
{ prefix: 'landing_live_price', title: 'لیبلهای قیمت لحظهای', icon: 'vuesax-linear:chart-2', name: 'websiteLandingLivePrice', path: 'live-price' },
|
||||
{ prefix: 'landing_calculator', title: 'عنوان ماشین حساب', icon: 'vuesax-linear:calculator', name: 'websiteLandingCalculator', path: 'calculator' },
|
||||
{ prefix: 'landing_feature', title: 'امکانات (چرا نیازی طلا)', icon: 'vuesax-linear:star', name: 'websiteLandingFeature', path: 'feature' },
|
||||
{ prefix: 'landing_steps', title: 'مراحل شروع', icon: 'vuesax-linear:ranking', name: 'websiteLandingSteps', path: 'steps' },
|
||||
{ prefix: 'landing_trust', title: 'اعتماد و مجوزها', icon: 'vuesax-linear:shield-tick', name: 'websiteLandingTrust', path: 'trust' },
|
||||
{ prefix: 'landing_faq', title: 'سوالات متداول', icon: 'vuesax-linear:message-question', name: 'websiteLandingFaq', path: 'faq' },
|
||||
{ prefix: 'landing_buttom_cta', title: 'سکشن پایین صفحه لندینگ برای معرفی', icon: 'vuesax-linear:arrow-down', name: 'websiteLandingBottomCta', path: 'bottom-cta' },
|
||||
{ prefix: 'landing_footer', title: 'فوتر', icon: 'vuesax-linear:document', name: 'websiteLandingFooter', path: 'footer' }
|
||||
]
|
||||
|
||||
export function matchesLandingPrefix(key: string, prefix: string): boolean {
|
||||
return key === prefix || key.startsWith(`${prefix}_`)
|
||||
}
|
||||
|
||||
export function isLandingContentKey(key?: string | null): boolean {
|
||||
return String(key ?? '').trim().startsWith('landing_')
|
||||
}
|
||||
|
||||
export function landingSectionByPrefix(prefix: string): LandingSection | undefined {
|
||||
return LANDING_SETTING_SECTIONS.find((s) => s.prefix === prefix)
|
||||
}
|
||||
|
||||
export const LANDING_SETTING_GROUPS = LANDING_SETTING_SECTIONS.map((section) => ({
|
||||
id: section.prefix,
|
||||
title: section.title,
|
||||
icon: section.icon,
|
||||
match: (key: string) => matchesLandingPrefix(key, section.prefix)
|
||||
}))
|
||||
@@ -15,6 +15,12 @@ export type SettingGroupDef = {
|
||||
|
||||
/** گروههای صفحه تنظیمات عادی (فقط can_edit=1) */
|
||||
export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
{
|
||||
id: 'digipay_installment',
|
||||
title: 'خرید اقساطی دیجیپی',
|
||||
icon: 'vuesax-linear:calendar',
|
||||
match: (k) => k === 'enable_digipay_installment' || k.startsWith('digipay_')
|
||||
},
|
||||
{
|
||||
id: 'general',
|
||||
title: 'عمومی و برند',
|
||||
@@ -158,7 +164,7 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
icon: 'vuesax-linear:people',
|
||||
// فقط فلگهای مالک سوپرادمین — banner/tracking/نمایش محصول در «تنظیمات» عادیاند
|
||||
match: (k) =>
|
||||
/^(enable_automation|enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|enable_gold_credit|permision__enabled|show_to_users_chat)$/.test(
|
||||
/^(enable_automation|enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|enable_gold_credit|permision__enabled|show_to_users_chat|has_landing)$/.test(
|
||||
k
|
||||
)
|
||||
},
|
||||
@@ -265,6 +271,12 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
icon: 'vuesax-linear:document-text',
|
||||
match: (k) => k.startsWith('pargar_') || k === 'send_to_pargar'
|
||||
},
|
||||
{
|
||||
id: 'accounting_shayegan',
|
||||
title: 'حسابداری شایگان',
|
||||
icon: 'vuesax-linear:receipt-item',
|
||||
match: (k) => k.startsWith('shayegan_')
|
||||
},
|
||||
{
|
||||
id: 'price_channel',
|
||||
title: 'ارسال قیمت به کانال',
|
||||
@@ -304,13 +316,23 @@ export function resolveSettingMenu(
|
||||
row: { key?: string; menu?: string | null },
|
||||
groups: SettingGroupDef[]
|
||||
): string {
|
||||
const key = row.key || ''
|
||||
const fromKey = getSettingGroupId(key, groups)
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (menu && groups.some((g) => g.id === menu)) return menu
|
||||
return getSettingGroupId(row.key || '', groups)
|
||||
if (menu && groups.some((g) => g.id === menu)) {
|
||||
// menu= misc اشتباه در DB نباید shayegan_/zarin_/… را از گروه اختصاصی پنهان کند
|
||||
if (menu === 'misc' && fromKey !== 'misc') {
|
||||
return fromKey
|
||||
}
|
||||
|
||||
return menu
|
||||
}
|
||||
|
||||
return fromKey
|
||||
}
|
||||
|
||||
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمیآیند */
|
||||
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites'])
|
||||
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites', 'website_settings'])
|
||||
|
||||
export function getSettingSubsectionId(
|
||||
key: string,
|
||||
|
||||
@@ -207,6 +207,7 @@ export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
|
||||
'jibit_enabled',
|
||||
'permision__enabled',
|
||||
'show_to_users_chat',
|
||||
'has_landing',
|
||||
])
|
||||
|
||||
export function isSuperAdminOwnedSettingKey(key?: string | null): boolean {
|
||||
@@ -324,7 +325,7 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
minimum_sell: 'price',
|
||||
gift_for_referrer: 'number',
|
||||
gift_for_referral: 'number',
|
||||
referral_bonus_amount: 'text',
|
||||
referral_bonus_amount: 'price',
|
||||
montzar_product_id: 'number',
|
||||
montzar_account_zarin: 'text',
|
||||
montzar_account_tahesab: 'text',
|
||||
@@ -429,7 +430,19 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
pargar_item_id_gold: 'number',
|
||||
support_messengers: 'longtext',
|
||||
show_to_users_chat: 'switch',
|
||||
has_landing: 'switch',
|
||||
has_chat: 'switch',
|
||||
landing_site: 'longtext',
|
||||
landing_header: 'longtext',
|
||||
landing_hero: 'longtext',
|
||||
landing_live_price: 'longtext',
|
||||
landing_calculator: 'longtext',
|
||||
landing_feature: 'longtext',
|
||||
landing_steps: 'longtext',
|
||||
landing_trust: 'longtext',
|
||||
landing_faq: 'longtext',
|
||||
landing_buttom_cta: 'longtext',
|
||||
landing_footer: 'longtext',
|
||||
chat_api: 'text',
|
||||
chat_api_key: 'text',
|
||||
chat_upload_url: 'text',
|
||||
@@ -623,6 +636,45 @@ export function formatValueForSave(
|
||||
return value ?? ''
|
||||
}
|
||||
|
||||
/** واحد نمایش روی فیلدهای عددی — شناسه/پورت واحد ندارند */
|
||||
const SETTING_UNIT_BY_KEY: Record<string, string> = {
|
||||
buy_fee: 'ریال',
|
||||
sell_fee: 'ریال',
|
||||
fee_single: 'ریال',
|
||||
fee_conditional_order: 'ریال',
|
||||
min_withdraw: 'ریال',
|
||||
min_deposit: 'ریال',
|
||||
min_first_buy: 'ریال',
|
||||
minimum_sell: 'ریال',
|
||||
price_channel_diff: 'ریال',
|
||||
referral_bonus_amount: 'ریال',
|
||||
gold_credit_penalty_amount: 'ریال / گرم',
|
||||
gift_for_referrer: 'گرم',
|
||||
gift_for_referral: 'گرم',
|
||||
gold_credit_min_balance_gram: 'گرم',
|
||||
change_mesghal: 'گرم',
|
||||
fee_service_charge_percentage: 'درصد (اعشاری)',
|
||||
gold_credit_grace_hours: 'ساعت',
|
||||
gold_credit_default_months: 'ماه',
|
||||
price_channel_min_seconds: 'ثانیه',
|
||||
referral_limit: 'دعوت',
|
||||
fee_free: 'سفارش',
|
||||
}
|
||||
|
||||
export function getSettingUnitLabel(
|
||||
key?: string,
|
||||
type?: SettingFieldType,
|
||||
): string {
|
||||
const k = (key ?? '').trim()
|
||||
if (k && SETTING_UNIT_BY_KEY[k]) {
|
||||
return SETTING_UNIT_BY_KEY[k]
|
||||
}
|
||||
if (type === 'price') {
|
||||
return 'ریال'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function switchLabels(key: string | undefined): { on: string; off: string } {
|
||||
if (key === REFERRAL_REQUIRED_KEY) {
|
||||
return { on: 'اجباری', off: 'اختیاری' }
|
||||
@@ -710,13 +762,13 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
auto_active_customer:
|
||||
'روشن: بعد از ثبتنام، کاربر میتواند وارد اپ شود (بدون تأیید دستی ادمین). خاموش: ورود فقط بعد از فعالسازی دستی شما در پنل. این سوییچ اجازهٔ خرید/فروش نمیدهد — معامله فقط بعد از احراز هویت (is_legal) ممکن است.',
|
||||
close_price:
|
||||
'سوییچ اصلی ساعت کاری. خاموش: محدودیت ساعت اعمال نمیشود — اگر مظنه زنده باشد قیمت نشان داده میشود؛ اگر نباشد با «نمایش آخرین قیمت ذخیرهشده» آخرین قیمت میآید وگرنه «مظنه در دسترس نیست». روشن: فقط داخل بازهٔ یکسان یا برنامهٔ هفتگی همین منطق مظنه اعمال میشود؛ خارج از بازه با سوییچ «نمایش قیمت صفحه اصلی خارج از ساعت کاری» یا پیام «فروشگاه بسته است». خرید/فروش خارج از ساعت همیشه بسته است.',
|
||||
'سوییچ اصلی ساعت کاری. خاموش: محدودیت ساعت اعمال نمیشود — اگر قیمت زنده باشد قیمت نشان داده میشود؛ اگر نباشد با «نمایش آخرین قیمت ذخیرهشده» آخرین قیمت میآید وگرنه «قیمت در دسترس نیست». روشن: فقط داخل بازهٔ یکسان یا برنامهٔ هفتگی همین منطق قیمت اعمال میشود؛ خارج از بازه با سوییچ «نمایش قیمت صفحه اصلی خارج از ساعت کاری» یا پیام «فروشگاه بسته است». خرید/فروش خارج از ساعت همیشه بسته است.',
|
||||
startDay:
|
||||
'ساعت شروع فعالیت روزانه فروشگاه. فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن باشد و برنامه «یکسان برای همه روزها» باشد اعمال میشود.',
|
||||
endDay:
|
||||
'ساعت پایان فعالیت روزانه فروشگاه. فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن باشد و برنامه «یکسان برای همه روزها» باشد اعمال میشود.',
|
||||
show_last_price:
|
||||
'وقتی مظنه زنده نیست (و فروشگاه از نظر ساعت بسته حساب نمیشود): روشن = آخرین قیمت ذخیرهشده نشان داده شود. خاموش = پیام «مظنه در دسترس نیست».',
|
||||
'وقتی قیمت زنده نیست (و فروشگاه از نظر ساعت بسته حساب نمیشود): روشن = آخرین قیمت ذخیرهشده نشان داده شود. خاموش = پیام «قیمت در دسترس نیست».',
|
||||
show_home_price_when_closed:
|
||||
'فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن است و الان خارج از بازه هستید. روشن: آخرین قیمت روی صفحه اصلی نشان داده میشود (معامله بسته میماند). خاموش: پیام «فروشگاه بسته است».',
|
||||
show_gold_ounce_price:
|
||||
@@ -800,7 +852,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
referral_limit:
|
||||
'حداکثر تعداد دعوت مجاز برای هر کاربر. خالی = بدون محدودیت.',
|
||||
referral_bonus_amount:
|
||||
'مبلغ یا مقدار پاداش معرف برای نمایش در پیامکها و متنهای دعوت.',
|
||||
'مبلغ پاداش معرف (ریال) برای نمایش در پیامکها و متنهای دعوت. واحد روی خود فیلد مشخص است.',
|
||||
jibit_verification:
|
||||
'روشن: هنگام ثبت یا ویرایش کارت بانکی، تطبیق با سرویس احراز هویت جیبیت انجام میشود. خاموش: کارت بدون تطبیق جیبیت ثبت میشود.',
|
||||
register_jibit_verify:
|
||||
@@ -832,7 +884,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
montzar_open_sell:
|
||||
'وضعیت واقعی از سرویس خارجی خوانده میشود. روشن: ثبت سفارش فروش از طریق قیمت همکار مجاز است. خاموش: ثبت سفارش فروش از طریق قیمت همکار غیرفعال است.',
|
||||
montzar_order_wait_callback:
|
||||
'روشن (پیشفرض): بعد از ارسال سفارش به همکار، تا کالبک وضعیت (تأیید=۲ / رد=۴ یا ۶) یا استعلام مسیر وضعیت صبر میشود و کیف ثبت نمیشود. خاموش: مثل قبل با همان پاسخ HTTP همکار سفارش قطعی میشود.',
|
||||
'با منبع قیمت همکار، سفارش همیشه تا کالبک یا استعلام وضعیت در انتظار میماند و کیف بعد از تأیید ثبت میشود. خاموش بودن این سوییچ دیگر مسیر قطعی بلافاصله را باز نمیکند. در رد همکار، SMS به ادمینهای دارای ارسال پیامک میرود.',
|
||||
montzar_order_status_path:
|
||||
'مسیر GET روی دامنه همکار (montzar_base_url) برای استعلام وضعیت اگر کالبک نرسید. پیشفرض /server/customer/order — با شماره سفارش همکار میشود /server/customer/order/40000.',
|
||||
montzar_closed:
|
||||
@@ -863,6 +915,19 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
'فقط مواردی که در این لیست ثبت شوند در منوی شناور پشتیبانی اپ مشتری نمایش داده میشوند. برای تماس تلفنی یا پیامک، نوع «تماس تلفنی» / «پیامک» را با شماره اضافه کنید. لیست میتواند خالی باشد؛ اگر چت فعال باشد، پشتیبانی مستقیم به صفحه چت میرود.',
|
||||
show_to_users_chat:
|
||||
'روشن: قابلیت چت پشتیبانی برای این دیپلوی فعال است (منوی ادمین و پیشنیاز نمایش به کاربر). خاموش: چت در ادمین و اپ کاربر مخفی است و سوییچ «چت پشتیبانی» (has_chat) از تنظیمات عادی هم برداشته میشود.',
|
||||
has_landing:
|
||||
'روشن: منوی تنظیمات وبسایت در ادمین و تنظیمات لندینگ برای اپ کاربر فعال است. خاموش: منو مخفی است.',
|
||||
landing_site: 'محتوای تنظیمات کلی لندینگ وبسایت.',
|
||||
landing_header: 'محتوای هدر و ناوبری لندینگ.',
|
||||
landing_hero: 'محتوای سکشن هیرو لندینگ.',
|
||||
landing_live_price: 'لیبلها و متن قیمت لحظهای لندینگ.',
|
||||
landing_calculator: 'عنوان و متن ماشین حساب لندینگ.',
|
||||
landing_feature: 'متن امکانات لندینگ (چرا نیازی طلا).',
|
||||
landing_steps: 'متن مراحل شروع لندینگ.',
|
||||
landing_trust: 'متن اعتماد و مجوزها (بدون اینماد).',
|
||||
landing_faq: 'سوالات متداول لندینگ.',
|
||||
landing_buttom_cta: 'متن دعوت به اقدام پایین صفحه لندینگ.',
|
||||
landing_footer: 'محتوای فوتر لندینگ.',
|
||||
has_chat:
|
||||
'روشن: چت پشتیبانی در اپ مشتری نمایش داده میشود (فقط وقتی show_to_users_chat هم روشن باشد). خاموش: دکمه و صفحه چت برای کاربر مخفی است.',
|
||||
chat_api:
|
||||
@@ -950,7 +1015,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
enable_gold_credit:
|
||||
'روشن: زیرمنوی اعتبار در مشتریان و صفحه اعتبار در اپ مشتری فعال میشود. خاموش: غیرفعال. فقط از سوپرادمین قابل تغییر است.',
|
||||
customer_special_pricing:
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی مظنه و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی قیمت و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
profit_gold_api_enabled:
|
||||
'روشن: محاسبه سود طلا از API خارجی فعال است. خاموش: محاسبه سود از API خارجی انجام نمیشود (حالت پیشفرض اکثر نصبها).',
|
||||
main_wallet_products:
|
||||
@@ -1022,7 +1087,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
zarin_gorohe_kar:
|
||||
'کد gorooheKar هنگام ساخت/جستجوی کار در زرین. اگر چند پنل یک زرین دارند، برای هر پنل گروه کار متفاوت بگذارید.',
|
||||
zarin_name_g:
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون مظنه فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون قیمت فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
zarin_uid_prefix:
|
||||
'پیشوند عددی uid برای جلوگیری از تداخل بین چند پنل روی یک زرین. فقط عدد (مثلاً ۱۱).',
|
||||
zarin_idbank:
|
||||
@@ -1036,7 +1101,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
main_product_price:
|
||||
'تنظیم قدیمی — از «منبع قیمت» استفاده کنید. روشن نگه داشتن توصیه نمیشود.',
|
||||
price_channel_enabled:
|
||||
'روشن: بعد از هر تغییر قیمت، مظنه بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
'روشن: بعد از هر تغییر قیمت، قیمت بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
price_channel_access:
|
||||
'روشن: گروه «ارسال قیمت به کانال» در تنظیمات عادی پنل دیده میشود. خاموش: مخفی است (فقط از تنظیمات پیشرفته).',
|
||||
price_channel_messengers:
|
||||
@@ -1119,6 +1184,8 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
minimum_sell: 'حداقل مبلغ فروش (ریال)',
|
||||
referral_id: 'کد معرف اجباری',
|
||||
referral_bonus_amount: 'مقدار پاداش معرف',
|
||||
gift_for_referrer: 'پاداش معرف',
|
||||
gift_for_referral: 'پاداش معرفشونده',
|
||||
referral_gift_on_first_order: 'پاداش معرف پس از اولین سفارش',
|
||||
referral_gift_buy_from_montzar: 'خرید پاداش معرفی از همکار',
|
||||
open_register: 'ثبتنام باز',
|
||||
@@ -1187,7 +1254,19 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
zarin_idbank: 'کد حساب بانک زرین',
|
||||
support_messengers: 'پیامرسانهای پشتیبانی',
|
||||
show_to_users_chat: 'نمایش چت به کاربران',
|
||||
has_landing: 'لندینگ وبسایت',
|
||||
has_chat: 'چت پشتیبانی',
|
||||
landing_site: 'تنظیمات کلی سایت',
|
||||
landing_header: 'هدر و ناوبری',
|
||||
landing_hero: 'هیرو',
|
||||
landing_live_price: 'لیبلهای قیمت لحظهای',
|
||||
landing_calculator: 'عنوان ماشین حساب',
|
||||
landing_feature: 'امکانات (چرا نیازی طلا)',
|
||||
landing_steps: 'مراحل شروع',
|
||||
landing_trust: 'اعتماد و مجوزها',
|
||||
landing_faq: 'سوالات متداول',
|
||||
landing_buttom_cta: 'سکشن پایین صفحه لندینگ برای معرفی',
|
||||
landing_footer: 'فوتر',
|
||||
chat_api: 'API چت',
|
||||
chat_api_key: 'کلید API چت',
|
||||
chat_upload_url: 'آدرس آپلود فایل چت',
|
||||
@@ -1286,7 +1365,7 @@ export const SETTING_LOCKED_KEYS = new Set([
|
||||
'price_channel_bale_to', 'price_channel_telegram_to', 'price_channel_rubika_to',
|
||||
'unit',
|
||||
'wss_enabled',
|
||||
'show_to_users_chat', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
|
||||
'show_to_users_chat', 'has_landing', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
|
||||
])
|
||||
|
||||
/** قابل ویرایش در پنل عادی — همتراز deploy_settings_const.sql */
|
||||
@@ -1326,6 +1405,8 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
||||
'support_messengers', 'support_messenger_text',
|
||||
'do_send_liman',
|
||||
'has_chat',
|
||||
'landing_site', 'landing_header', 'landing_hero', 'landing_live_price', 'landing_calculator',
|
||||
'landing_feature', 'landing_steps', 'landing_trust', 'landing_faq', 'landing_buttom_cta', 'landing_footer',
|
||||
'text_about', 'text_rule', 'about_software', 'enamad_url', 'enamad_logo',
|
||||
'login_hero_eyebrow', 'login_hero_title',
|
||||
'login_hero_feature_1', 'login_hero_feature_2', 'login_hero_feature_3', 'login_hero_feature_4',
|
||||
@@ -1336,10 +1417,14 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
||||
])
|
||||
|
||||
/** عنوان فارسی — کاتالوگ پنل بر title_fa دیتابیس اولویت دارد */
|
||||
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa'>): string {
|
||||
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa' | 'type'>): string {
|
||||
const key = (row.key ?? '').trim()
|
||||
if (key && KEY_LABEL_FALLBACK[key]) return KEY_LABEL_FALLBACK[key]
|
||||
return row.title_fa?.trim() || key || '—'
|
||||
const base = (key && KEY_LABEL_FALLBACK[key]) ? KEY_LABEL_FALLBACK[key] : (row.title_fa?.trim() || key || '—')
|
||||
const unit = getSettingUnitLabel(key, resolveSettingFieldType(row))
|
||||
if (!unit || base.includes(unit) || base.includes(`(${unit})`)) {
|
||||
return base
|
||||
}
|
||||
return `${base} (${unit})`
|
||||
}
|
||||
|
||||
/** توضیح — کاتالوگ پنل بر description دیتابیس اولویت دارد */
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<MobileCardList
|
||||
v-model:search="search"
|
||||
:loading="loading"
|
||||
:has-more="hasMore"
|
||||
:show-empty="!loading && items.length === 0"
|
||||
empty-text="درخواستی یافت نشد"
|
||||
search-placeholder="جستجو مشتری، موبایل یا وضعیت"
|
||||
show-refresh
|
||||
@search="reload"
|
||||
@refresh="reload"
|
||||
@load-more="loadMore"
|
||||
>
|
||||
<CopperConvertMobileListItem
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:busy="busyId === item.id"
|
||||
:can-edit="can('edit')"
|
||||
@approve="approve(item)"
|
||||
@reject="reject(item)"
|
||||
/>
|
||||
</MobileCardList>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import MobileCardList from '@/components/mobile/MobileCardList.vue'
|
||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
import { fetchCopperConvertTable, useCopperConvertActions } from '../copperConvertTable'
|
||||
import CopperConvertMobileListItem from './CopperConvertMobileListItem.vue'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList({
|
||||
fetchApi: fetchCopperConvertTable
|
||||
})
|
||||
const { busyId, approve, reject } = useCopperConvertActions(reload)
|
||||
|
||||
onMounted(() => {
|
||||
void reload()
|
||||
})
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<MobileCard>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-700 text-gray-900">{{ item.customer_name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ item.customer_mobile || '-' }}</div>
|
||||
</div>
|
||||
<CustomTag class="shrink-0" :text-color="colors.text" :bg-color="colors.bg">
|
||||
{{ item.status_label }}
|
||||
</CustomTag>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
|
||||
<span class="text-gray-600">دارایی: <span class="font-600 text-gray-900">{{ item.source_label }}</span></span>
|
||||
<span class="text-gray-600">واحد: <span class="font-600 text-gray-900">{{ item.asset_unit }}</span></span>
|
||||
<span class="text-gray-600">حلقه ۱.۵: <span class="font-600 text-gray-900">{{ item.wire15_rings }}</span></span>
|
||||
<span class="text-gray-600">حلقه ۲.۵: <span class="font-600 text-gray-900">{{ item.wire25_rings }}</span></span>
|
||||
<span class="text-gray-600">مقدار فروش: <span class="font-600 text-gray-900">{{ item.consumed_amount }}</span></span>
|
||||
<span class="text-gray-600">مانده: <span class="font-600 text-gray-900">{{ item.leftover_amount }}</span></span>
|
||||
</div>
|
||||
|
||||
<div class="text-xs text-gray-400">{{ item.created_label }}</div>
|
||||
|
||||
<div v-if="item.status === 'pending' && canEdit" class="grid grid-cols-2 gap-2">
|
||||
<BaseButton type="primary" size="small" :loading="busy" @click="$emit('approve')">تأیید</BaseButton>
|
||||
<BaseButton size="small" :loading="busy" @click="$emit('reject')">رد</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</MobileCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { statusColors, type CopperConvertTableRow } from '../copperConvertTable'
|
||||
|
||||
const props = defineProps<{
|
||||
item: CopperConvertTableRow
|
||||
busy?: boolean
|
||||
canEdit?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'approve'): void
|
||||
(e: 'reject'): void
|
||||
}>()
|
||||
|
||||
const colors = computed(() => statusColors(props.item.status))
|
||||
</script>
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="درخواست تبدیل" :help="copperConvertPageIntro">
|
||||
<div v-if="!isMobile" class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit">
|
||||
<template #status="{ record }">
|
||||
<div class="flex justify-center">
|
||||
<CustomTag :text-color="statusColors(record.status).text" :bg-color="statusColors(record.status).bg">
|
||||
{{ record.status_label }}
|
||||
</CustomTag>
|
||||
</div>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div v-if="record.status === 'pending' && can('edit')" class="flex justify-center gap-2">
|
||||
<BaseButton type="primary" size="small" :loading="busyId === record.id" @click="approve(record)">
|
||||
تأیید
|
||||
</BaseButton>
|
||||
<BaseButton size="small" :loading="busyId === record.id" @click="reject(record)">رد</BaseButton>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
<CopperConvertMobileCardList v-else />
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { BaseTableColumn } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { copperConvertPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
import CopperConvertMobileCardList from './CopperConvertMobileCardList.vue'
|
||||
import { fetchCopperConvertTable, statusColors, useCopperConvertActions } from '../copperConvertTable'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
const [submit, reload] = useBaseTable()
|
||||
const { busyId, approve, reject } = useCopperConvertActions(reload)
|
||||
|
||||
const columns: BaseTableColumn[] = [
|
||||
{
|
||||
title: 'شناسه',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
type: 'Number',
|
||||
width: 80,
|
||||
sortField: 'id',
|
||||
filterField: 'id'
|
||||
},
|
||||
{
|
||||
title: 'مشتری',
|
||||
dataIndex: 'customer_name',
|
||||
key: 'customer_name',
|
||||
type: 'Text',
|
||||
sortField: 'customer_name',
|
||||
filterField: 'customer_name'
|
||||
},
|
||||
{
|
||||
title: 'موبایل',
|
||||
dataIndex: 'customer_mobile',
|
||||
key: 'customer_mobile',
|
||||
type: 'Text',
|
||||
sortField: 'customer_mobile',
|
||||
filterField: 'customer_mobile'
|
||||
},
|
||||
{
|
||||
title: 'دارایی',
|
||||
dataIndex: 'source_label',
|
||||
key: 'source_label',
|
||||
type: 'Text',
|
||||
sortField: 'source_label',
|
||||
filterField: 'source_label'
|
||||
},
|
||||
{
|
||||
title: 'حلقه ۱.۵',
|
||||
dataIndex: 'wire15_rings',
|
||||
key: 'wire15_rings',
|
||||
type: 'Number',
|
||||
sortField: 'wire15_rings',
|
||||
filterField: 'wire15_rings'
|
||||
},
|
||||
{
|
||||
title: 'حلقه ۲.۵',
|
||||
dataIndex: 'wire25_rings',
|
||||
key: 'wire25_rings',
|
||||
type: 'Number',
|
||||
sortField: 'wire25_rings',
|
||||
filterField: 'wire25_rings'
|
||||
},
|
||||
{
|
||||
title: 'مقدار فروش',
|
||||
dataIndex: 'consumed_amount',
|
||||
key: 'consumed_amount',
|
||||
type: 'Number',
|
||||
sortField: 'consumed_amount',
|
||||
filterField: 'consumed_amount'
|
||||
},
|
||||
{
|
||||
title: 'مانده',
|
||||
dataIndex: 'leftover_amount',
|
||||
key: 'leftover_amount',
|
||||
type: 'Number',
|
||||
sortField: 'leftover_amount',
|
||||
filterField: 'leftover_amount'
|
||||
},
|
||||
{
|
||||
title: 'واحد',
|
||||
dataIndex: 'asset_unit',
|
||||
key: 'asset_unit',
|
||||
type: 'Text',
|
||||
sortField: 'asset_unit',
|
||||
filterField: 'asset_unit'
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'status_label',
|
||||
key: 'status',
|
||||
type: 'Text',
|
||||
sortField: 'status_label',
|
||||
filterField: 'status_label',
|
||||
slot: 'status'
|
||||
},
|
||||
{
|
||||
title: 'تاریخ',
|
||||
dataIndex: 'created_label',
|
||||
key: 'created_label',
|
||||
type: 'Text',
|
||||
sortField: 'created_at',
|
||||
filterField: 'created_label'
|
||||
},
|
||||
{
|
||||
title: 'عملیات',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
slot: 'action',
|
||||
filterable: false,
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
|
||||
const tblProps = ref({
|
||||
columns,
|
||||
api: fetchCopperConvertTable
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,170 @@
|
||||
import { ref } from 'vue'
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import type { Filter, TableInput, TableOutput } from '@core/type/baseTable'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
approveCopperConvertRequest,
|
||||
getCopperConvertRequests,
|
||||
rejectCopperConvertRequest,
|
||||
type CopperConvertRequestRow
|
||||
} from '@/api/copperConvert'
|
||||
|
||||
export type CopperConvertTableRow = CopperConvertRequestRow & {
|
||||
source_label: string
|
||||
status_label: string
|
||||
created_label: string
|
||||
}
|
||||
|
||||
const numericKeys = new Set(['id', 'wire15_rings', 'wire25_rings', 'consumed_amount', 'leftover_amount'])
|
||||
|
||||
export function sourceLabel(source: string) {
|
||||
if (source === 'katod') return 'کاتد'
|
||||
if (source === 'maftoul') return 'مفتول'
|
||||
if (source === 'shamsh') return 'شمش'
|
||||
return source
|
||||
}
|
||||
|
||||
export function statusLabel(status: string) {
|
||||
if (status === 'pending') return 'در انتظار'
|
||||
if (status === 'approved') return 'تأیید شده'
|
||||
if (status === 'rejected') return 'رد شده'
|
||||
return status
|
||||
}
|
||||
|
||||
export function statusColors(status: string) {
|
||||
if (status === 'approved') return { text: '#25855A', bg: '#E3F4E9' }
|
||||
if (status === 'rejected') return { text: '#C53030', bg: '#FECACA' }
|
||||
return { text: '#B45309', bg: '#FEF3C7' }
|
||||
}
|
||||
|
||||
function decorate(row: CopperConvertRequestRow): CopperConvertTableRow {
|
||||
return {
|
||||
...row,
|
||||
source_label: sourceLabel(row.source),
|
||||
status_label: statusLabel(row.status),
|
||||
created_label: row.created_at ? toJalali(row.created_at) : '-'
|
||||
}
|
||||
}
|
||||
|
||||
function asText(value: unknown) {
|
||||
return value == null ? '' : String(value).toLowerCase()
|
||||
}
|
||||
|
||||
function matchFilter(row: Record<string, unknown>, filter: Filter) {
|
||||
const raw = row[filter.field]
|
||||
const op = filter.op
|
||||
const value = filter.value
|
||||
if (op === 'null') return raw == null || raw === ''
|
||||
if (op === 'nn') return raw != null && raw !== ''
|
||||
if (value === '' || value == null) return true
|
||||
if (op === 'bet' && Array.isArray(value)) {
|
||||
const n = Number(raw)
|
||||
return n >= Number(value[0]) && n <= Number(value[1])
|
||||
}
|
||||
if (op === 'in' && Array.isArray(value)) {
|
||||
return value.map(String).includes(String(raw ?? ''))
|
||||
}
|
||||
const text = asText(raw)
|
||||
const needle = asText(value)
|
||||
if (op === 'eq') return text === needle
|
||||
if (op === 'not') return text !== needle
|
||||
if (op === 'sw') return text.startsWith(needle)
|
||||
if (op === 'ew') return text.endsWith(needle)
|
||||
if (op === 'has' || op == null) return text.includes(needle)
|
||||
const left = Number(raw)
|
||||
const right = Number(value)
|
||||
if (!Number.isFinite(left) || !Number.isFinite(right)) return false
|
||||
if (op === 'gt') return left > right
|
||||
if (op === 'lt') return left < right
|
||||
if (op === 'gte') return left >= right
|
||||
if (op === 'lte') return left <= right
|
||||
return true
|
||||
}
|
||||
|
||||
function queryRows(rows: CopperConvertTableRow[], params: TableInput): TableOutput<CopperConvertTableRow> {
|
||||
const search = (params.search ?? '').trim().toLowerCase()
|
||||
let list = rows.filter((row) => {
|
||||
if (!search) return true
|
||||
return [row.customer_name, row.customer_mobile, row.source_label, row.status_label, row.asset_unit, row.created_label]
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
.includes(search)
|
||||
})
|
||||
for (const filter of params.filters ?? []) {
|
||||
if (!filter.field) continue
|
||||
list = list.filter((row) => matchFilter(row as unknown as Record<string, unknown>, filter))
|
||||
}
|
||||
const sortKey = params.sort?.key
|
||||
if (sortKey) {
|
||||
const dir = params.sort?.order === 'desc' ? -1 : 1
|
||||
list = [...list].sort((a, b) => {
|
||||
const av = (a as Record<string, unknown>)[sortKey]
|
||||
const bv = (b as Record<string, unknown>)[sortKey]
|
||||
if (numericKeys.has(sortKey)) return (Number(av) - Number(bv)) * dir
|
||||
return String(av ?? '').localeCompare(String(bv ?? ''), 'fa') * dir
|
||||
})
|
||||
}
|
||||
const page = params.page || 1
|
||||
const limit = params.limit || 10
|
||||
return {
|
||||
rows: list.slice((page - 1) * limit, page * limit),
|
||||
query: {
|
||||
...params,
|
||||
page,
|
||||
limit,
|
||||
total: list.length,
|
||||
search: params.search ?? null,
|
||||
filters: params.filters ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchCopperConvertTable(params: TableInput) {
|
||||
const data = await getCopperConvertRequests()
|
||||
const rows = (Array.isArray(data) ? data : []).map(decorate)
|
||||
return queryRows(rows, params)
|
||||
}
|
||||
|
||||
export function useCopperConvertActions(reload: () => unknown) {
|
||||
const busyId = ref(0)
|
||||
|
||||
function approve(row: CopperConvertRequestRow) {
|
||||
Modal.confirm({
|
||||
title: 'تأیید تبدیل',
|
||||
content: 'دارایی مشتری فروخته و حلقههای سیم برای او خریداری شود؟',
|
||||
okText: 'تأیید',
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
busyId.value = row.id
|
||||
try {
|
||||
await approveCopperConvertRequest(row.id)
|
||||
message.success('تبدیل ثبت شد')
|
||||
await reload()
|
||||
} finally {
|
||||
busyId.value = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function reject(row: CopperConvertRequestRow) {
|
||||
Modal.confirm({
|
||||
title: 'رد درخواست',
|
||||
content: 'این درخواست تبدیل رد شود؟',
|
||||
okText: 'رد',
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
busyId.value = row.id
|
||||
try {
|
||||
await rejectCopperConvertRequest(row.id)
|
||||
message.success('درخواست رد شد')
|
||||
await reload()
|
||||
} finally {
|
||||
busyId.value = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { busyId, approve, reject }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<BasicMainCard>
|
||||
<div class="flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden">
|
||||
<tbl class="min-h-0 flex-1" />
|
||||
</div>
|
||||
</BasicMainCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import tbl from './components/table.vue'
|
||||
</script>
|
||||
@@ -4,12 +4,14 @@
|
||||
<div class="flex min-w-0 flex-1 items-center gap-2">
|
||||
<BaseIcon icon="vuesax-linear:user" size="20" color="#6b7280" />
|
||||
<button
|
||||
v-if="can('info')"
|
||||
type="button"
|
||||
class="truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900 cursor-pointer"
|
||||
@click.stop="$emit('info', item)"
|
||||
>
|
||||
{{ item.name || '-' }}
|
||||
</button>
|
||||
<span v-else class="truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="shrink-0 text-sm text-gray-600">{{ item.mobile || '-' }}</div>
|
||||
@@ -19,6 +21,7 @@
|
||||
{{ item.type_str || 'کاربر' }}
|
||||
</span>
|
||||
<MobileIconButton
|
||||
v-if="can('restore')"
|
||||
icon="vuesax-linear:archive-slash"
|
||||
color="#e3bf00"
|
||||
:size="20"
|
||||
@@ -34,6 +37,9 @@
|
||||
import type { Customer } from '@/model/customer'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
item: Customer
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<a-tooltip v-if="can('restore')" :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<template #title>
|
||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||
</template>
|
||||
@@ -20,7 +20,7 @@
|
||||
</a-popconfirm>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title><span>مشخصات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
@@ -52,6 +52,9 @@ import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { customersArchivePageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'charge'])
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="decisionVisible"
|
||||
:source-label="provider === 'zarin' ? 'زرین' : 'تهحساب'"
|
||||
:allow-push="provider === 'tahesab'"
|
||||
:app-gold="decision?.app_gold"
|
||||
:app-cash="decision?.app_cash"
|
||||
:tahesab-gold="decision?.tahesab_gold ?? decision?.zarin_gold"
|
||||
@@ -96,7 +97,9 @@ const visibleProxy = computed({
|
||||
function currentCodeOf(customer: Customer | null): string {
|
||||
if (!customer) return ''
|
||||
if (props.provider === 'pargar') return displayAccountingCode(customer.pargar_account_id)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin') return displayAccountingCode(customer.moshtari_code)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin' || props.provider === 'shayegan') {
|
||||
return displayAccountingCode(customer.moshtari_code)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -120,8 +123,12 @@ async function saveCode(customerId: number, body: Record<string, string>) {
|
||||
close()
|
||||
}
|
||||
|
||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||
if (props.provider === 'zarin') {
|
||||
if (mode === 'push') {
|
||||
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||
return { ok: false, message: 'پشتیبانی نمیشود' }
|
||||
}
|
||||
return syncCustomerWalletFromZarin(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
@@ -131,11 +138,12 @@ async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep
|
||||
return syncCustomerWalletFromTahesab(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
}
|
||||
|
||||
async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
const pending = pendingPayload.value
|
||||
decisionVisible.value = false
|
||||
if (!pending) return
|
||||
@@ -144,6 +152,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
await saveCode(pending.customerId, pending.body)
|
||||
const res = await applyWalletDecision(pending.customerId, mode)
|
||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||
else message.success(res.message || 'مانده حسابداری روی کیف اعمال شد')
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
@@ -156,7 +165,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
|
||||
async function submit() {
|
||||
if (!props.customer?.id) return
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin') {
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin' && props.provider !== 'shayegan') {
|
||||
message.error('حسابداری فعال نیست.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
</section>
|
||||
|
||||
<BaseButton
|
||||
v-if="can('charge')"
|
||||
class="customer-mobile-sheet__charge-btn"
|
||||
size="middle"
|
||||
type="primary"
|
||||
@@ -39,7 +40,7 @@
|
||||
|
||||
<div class="customer-mobile-sheet__actions">
|
||||
<BaseButton
|
||||
v-if="accountingCodeLabel"
|
||||
v-if="can('accountingCode') && accountingCodeLabel"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:card-edit"
|
||||
@@ -47,14 +48,14 @@
|
||||
>
|
||||
کد حسابداری
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
<BaseButton v-if="can('info')" size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
مشخصات
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
<BaseButton v-if="can('edit')" size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
ویرایش
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerLevelProfitEnabled"
|
||||
v-if="can('referral') && customerLevelProfitEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:hierarchy-2"
|
||||
@@ -62,11 +63,11 @@
|
||||
>
|
||||
سود چندسطحی
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
<BaseButton v-if="can('archive')" size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
بایگانی
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerDirectSmsEnabled"
|
||||
v-if="can('sms') && customerDirectSmsEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:sms"
|
||||
@@ -75,7 +76,7 @@
|
||||
پیامک
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="!row.is_legal"
|
||||
v-if="can('approve') && !row.is_legal"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:user-search"
|
||||
@@ -84,6 +85,7 @@
|
||||
تایید
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('active')"
|
||||
size="small"
|
||||
:type="row.active ? 'default' : 'primary'"
|
||||
:icon="row.active ? 'vuesax-linear:user-remove' : 'vuesax-linear:user-tick'"
|
||||
@@ -92,6 +94,7 @@
|
||||
{{ row.active ? 'غیرفعال' : 'فعال' }}
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('trade')"
|
||||
size="small"
|
||||
:type="row.trade_active === 1 ? 'default' : 'primary'"
|
||||
:icon="row.trade_active === 1 ? 'vuesax-linear:box-remove' : 'vuesax-linear:box-tick'"
|
||||
@@ -135,6 +138,9 @@ import {
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode } from '@/utils/accountingCode'
|
||||
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
<div class="min-w-0 flex-1 space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
v-if="can('info')"
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900"
|
||||
@click.stop="$emit('info', item)"
|
||||
>
|
||||
{{ item.name || '-' }}
|
||||
</button>
|
||||
<span v-else class="min-w-0 flex-1 truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||
<span
|
||||
class="inline-block h-2.5 w-2.5 shrink-0 rounded-full"
|
||||
:class="item.active ? 'bg-green-500' : 'bg-red-500'"
|
||||
@@ -41,6 +43,7 @@
|
||||
عملیات
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('edit')"
|
||||
type="default"
|
||||
size="small"
|
||||
class="min-w-[4.5rem]"
|
||||
@@ -57,6 +60,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { Customer } from '@/model/customer'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
item: Customer
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-model:visible="visibleProxy"
|
||||
:width="isMobile ? '92vw' : '36rem'"
|
||||
:width="isMobile ? '92vw' : '40rem'"
|
||||
title="تصمیم برای مانده حساب"
|
||||
:custom-footer="true"
|
||||
cancel-text="بعداً"
|
||||
@close="close"
|
||||
>
|
||||
<div class="flex flex-col gap-3 text-sm" style="color: var(--admin-text)">
|
||||
<p class="m-0" style="color: var(--admin-text-secondary)">
|
||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند؛ یکی را پس از بررسی سندها تأیید کنید.
|
||||
<p class="m-0 leading-6" style="color: var(--admin-text-secondary)">
|
||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند — یکی از سه مسیر زیر را انتخاب کنید.
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="appIsEmpty && allowPush"
|
||||
class="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900"
|
||||
>
|
||||
موجودی اپ صفر است. اگر «اعمال مانده اپ روی تهحساب» را بزنید، مانده تهحساب با سند تعدیل همتراز صفر اپ میشود.
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-base p-3 space-y-2" style="background: var(--admin-bg-muted)">
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">موجودی اپ (طلا)</span>
|
||||
@@ -84,12 +92,58 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<a-button type="primary" block :loading="loading === 'overwrite'" :disabled="!!loading" @click="choose('overwrite')">
|
||||
اعمال مانده {{ sourceLabel }} روی کیف
|
||||
</a-button>
|
||||
<a-button block :loading="loading === 'keep'" :disabled="!!loading" @click="choose('keep')">
|
||||
نگه داشتن موجودی فعلی اپ
|
||||
</a-button>
|
||||
<button
|
||||
type="button"
|
||||
class="mande-choice mande-choice--primary"
|
||||
:disabled="!!loading"
|
||||
@click="choose('overwrite')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'overwrite'" size="small" class="me-1" />
|
||||
اعمال مانده {{ sourceLabel }} روی کیف اپ
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
موجودی اپ مثل {{ sourceLabel }} میشود. سند تعدیل روی کیف اپ ثبت میشود.
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="allowPush"
|
||||
type="button"
|
||||
class="mande-choice"
|
||||
:class="appIsEmpty ? 'mande-choice--warn' : 'mande-choice--secondary'"
|
||||
:disabled="!!loading"
|
||||
@click="choose('push')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'push'" size="small" class="me-1" />
|
||||
اعمال مانده اپ روی {{ sourceLabel }}
|
||||
<span v-if="appIsEmpty" class="mande-choice__badge">اپ صفر</span>
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
{{
|
||||
appIsEmpty
|
||||
? `مانده ${sourceLabel} با سند تعدیل همتراز صفر اپ میشود. کیف اپ تغییر نمیکند.`
|
||||
: `مانده ${sourceLabel} مثل موجودی اپ میشود. کیف اپ تغییر نمیکند.`
|
||||
}}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="mande-choice"
|
||||
:disabled="!!loading"
|
||||
@click="choose('keep')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'keep'" size="small" class="me-1" />
|
||||
نگه داشتن وضعیت فعلی
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
نه کیف اپ عوض میشود نه {{ sourceLabel }}؛ اختلاف برای بعد میماند.
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<a-button type="link" block :disabled="!!loading" @click="close">بعداً</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,7 +157,10 @@ import BasicModal from '@/components/BasicModal.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { TahesabPreviewDoc } from '@/api/tahesab'
|
||||
|
||||
const props = defineProps<{
|
||||
export type MandeDecisionMode = 'overwrite' | 'keep' | 'push'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
appGold?: number | null
|
||||
appCash?: number | null
|
||||
@@ -114,16 +171,20 @@ const props = defineProps<{
|
||||
goldDelta?: number | null
|
||||
rialDelta?: number | null
|
||||
sourceLabel?: string
|
||||
/** فقط تهحساب: اجازهٔ نوشتن مانده اپ روی حسابداری */
|
||||
allowPush?: boolean
|
||||
walletDocs?: TahesabPreviewDoc[]
|
||||
tahesabDocs?: TahesabPreviewDoc[]
|
||||
}>()
|
||||
}>(),
|
||||
{ allowPush: false }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'decide', mode: 'overwrite' | 'keep'): void
|
||||
(e: 'decide', mode: MandeDecisionMode): void
|
||||
}>()
|
||||
|
||||
const loading = ref<'overwrite' | 'keep' | null>(null)
|
||||
const loading = ref<MandeDecisionMode | null>(null)
|
||||
const sourceLabel = computed(() => props.sourceLabel || 'تهحساب')
|
||||
const sourceGoldValue = computed(() => props.sourceGold ?? props.tahesabGold)
|
||||
const sourceCashValue = computed(() => props.sourceCash ?? props.tahesabCash)
|
||||
@@ -140,6 +201,11 @@ const sourceDocs = computed(() => props.tahesabDocs ?? [])
|
||||
const showDocs = computed(
|
||||
() => sourceLabel.value === 'تهحساب' || walletDocs.value.length > 0 || sourceDocs.value.length > 0
|
||||
)
|
||||
const appIsEmpty = computed(() => {
|
||||
const g = Math.abs(Number(props.appGold ?? 0))
|
||||
const c = Math.abs(Number(props.appCash ?? 0))
|
||||
return g < 0.0005 && c < 1
|
||||
})
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
@@ -186,8 +252,75 @@ function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
function choose(mode: 'overwrite' | 'keep') {
|
||||
function choose(mode: MandeDecisionMode) {
|
||||
loading.value = mode
|
||||
emit('decide', mode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mande-choice {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.25rem;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
border-radius: 0.75rem;
|
||||
border: 1px solid var(--admin-border, #e5e7eb);
|
||||
background: var(--admin-surface, #fff);
|
||||
padding: 0.75rem 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
|
||||
.mande-choice:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.mande-choice:not(:disabled):hover {
|
||||
border-color: var(--admin-primary, #10913a);
|
||||
}
|
||||
|
||||
.mande-choice--primary {
|
||||
border-color: var(--admin-primary, #10913a);
|
||||
background: color-mix(in srgb, var(--admin-primary, #10913a) 8%, white);
|
||||
}
|
||||
|
||||
.mande-choice--secondary:not(:disabled):hover {
|
||||
background: var(--admin-bg-muted, #f8fafc);
|
||||
}
|
||||
|
||||
.mande-choice--warn {
|
||||
border-color: #f59e0b;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.mande-choice__title {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text, #111827);
|
||||
}
|
||||
|
||||
.mande-choice__hint {
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
color: var(--admin-text-secondary, #6b7280);
|
||||
}
|
||||
|
||||
.mande-choice__badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 700;
|
||||
padding: 0.1rem 0.45rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
</template>
|
||||
<template #accountingCode="{ record }">
|
||||
<button
|
||||
v-if="can('accountingCode')"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-sm cursor-pointer"
|
||||
style="color: var(--admin-text)"
|
||||
@@ -29,10 +30,11 @@
|
||||
<span dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||
<Icon icon="vuesax-linear:edit-2" size="16" color="#4572E9" />
|
||||
</button>
|
||||
<span v-else dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="gap-2 hidden md:flex justify-center">
|
||||
<a-tooltip :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<a-tooltip v-if="can('archive')" :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<template #title>
|
||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||
</template>
|
||||
@@ -47,6 +49,7 @@
|
||||
</a-popconfirm>
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('active')"
|
||||
:key="record.active"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -60,12 +63,12 @@
|
||||
:color="record.active ? '#54AD06' : '#ad0627'"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('chargeWallet', record)">
|
||||
<a-tooltip v-if="can('charge')" placement="bottom" class="cursor-pointer" @click="emits('chargeWallet', record)">
|
||||
<template #title><span>شارژ کیف پول</span></template>
|
||||
<Icon icon="vuesax-linear:wallet-add" color="#9333ea" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
v-if="can('tahesab') && tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openTahesabRegister(record)"
|
||||
@@ -74,7 +77,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
v-if="can('zarin') && zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openZarinRegister(record)"
|
||||
@@ -83,7 +86,16 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#0284C7" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="pargarEnabled && !isValidAccountingCode(record.pargar_account_id)"
|
||||
v-if="shayeganEnabled && accountingProvider === 'shayegan' && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openShayeganRegister(record)"
|
||||
>
|
||||
<template #title><span>در شایگان ثبت نشده — کلیک برای ثبت</span></template>
|
||||
<Icon icon="vuesax-linear:profile-add" color="#0D9488" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('pargar') && pargarEnabled && !isValidAccountingCode(record.pargar_account_id)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openPargarRegister(record)"
|
||||
@@ -92,7 +104,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="accountingEnabled"
|
||||
v-if="can('accountingCode') && accountingEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openAccountingCodeEdit(record)"
|
||||
@@ -100,16 +112,16 @@
|
||||
<template #title><span>ویرایش کد حسابداری</span></template>
|
||||
<Icon icon="vuesax-linear:card-edit" color="#0d9488" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title><span>مشخصات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title><span>ویرایش</span></template>
|
||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="customerLevelProfitEnabled"
|
||||
v-if="can('referral') && customerLevelProfitEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openLevelProfit(record)"
|
||||
@@ -118,6 +130,7 @@
|
||||
<Icon icon="vuesax-linear:hierarchy-2" color="#ca8a04" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('trade')"
|
||||
:key="record.trade_active"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -132,7 +145,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="customerDirectSmsEnabled"
|
||||
v-if="can('sms') && customerDirectSmsEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openDirectSms(record)"
|
||||
@@ -141,7 +154,7 @@
|
||||
<Icon icon="vuesax-linear:sms" color="#0ea5e9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.is_legal"
|
||||
v-if="can('approve') && !record.is_legal"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openConfirmUser(record)"
|
||||
@@ -233,6 +246,13 @@
|
||||
:customer-name="pargarCustomer?.name"
|
||||
@success="fetch"
|
||||
/>
|
||||
<ShayeganCustomerRegisterModal
|
||||
v-if="shayeganEnabled && accountingProvider === 'shayegan'"
|
||||
v-model="shayeganRegisterVisible"
|
||||
:customer-id="shayeganCustomer?.id"
|
||||
:customer-name="shayeganCustomer?.name"
|
||||
@success="fetch"
|
||||
/>
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
@@ -262,10 +282,12 @@ import { isMobile } from '@core/utils/is'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import ZarinRetryModal from '@/components/ZarinRetryModal.vue'
|
||||
import PargarRetryModal from '@/components/PargarRetryModal.vue'
|
||||
import ShayeganCustomerRegisterModal from '@/components/ShayeganCustomerRegisterModal.vue'
|
||||
import {
|
||||
tahesabEnabledSetting,
|
||||
zarinEnabledSetting,
|
||||
pargarEnabledSetting,
|
||||
shayeganEnabledSetting,
|
||||
accountingProviderSetting,
|
||||
customerDirectSmsEnabledSetting,
|
||||
customerLevelProfitEnabledSetting,
|
||||
@@ -274,6 +296,9 @@ import {
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||
import { customersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'chargeWallet'])
|
||||
@@ -290,6 +315,10 @@ const zarinEnabled = zarinEnabledSetting
|
||||
const pargarRegisterVisible = ref(false)
|
||||
const pargarCustomer = ref<Customer>()
|
||||
const pargarEnabled = pargarEnabledSetting
|
||||
const shayeganRegisterVisible = ref(false)
|
||||
const shayeganCustomer = ref<Customer>()
|
||||
const shayeganEnabled = shayeganEnabledSetting
|
||||
const accountingProvider = accountingProviderSetting
|
||||
const customerDirectSmsEnabled = customerDirectSmsEnabledSetting
|
||||
const customerLevelProfitEnabled = customerLevelProfitEnabledSetting
|
||||
const levelProfitVisible = ref(false)
|
||||
@@ -298,13 +327,13 @@ const accountingCodeVisible = ref(false)
|
||||
const accountingCodeCustomer = ref<Customer | null>(null)
|
||||
const accountingEnabled = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||
})
|
||||
|
||||
function accountingCodeOf(record: Customer) {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(record.pargar_account_id)
|
||||
if (provider === 'tahesab' || provider === 'zarin') return displayAccountingCode(record.moshtari_code)
|
||||
if (provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') return displayAccountingCode(record.moshtari_code)
|
||||
return '-'
|
||||
}
|
||||
|
||||
@@ -397,6 +426,11 @@ function openPargarRegister(user: Customer) {
|
||||
pargarRegisterVisible.value = true
|
||||
}
|
||||
|
||||
function openShayeganRegister(user: Customer) {
|
||||
shayeganCustomer.value = user
|
||||
shayeganRegisterVisible.value = true
|
||||
}
|
||||
|
||||
function handleArchive(customer: Customer) {
|
||||
Modal.confirm({
|
||||
title: 'آیا مشتری را بایگانی می کنید؟',
|
||||
|
||||
@@ -14,7 +14,7 @@ export type CustomerColumnOptions = {
|
||||
}
|
||||
|
||||
function accountingCodeColumn(provider: AccountingProvider | undefined): BaseTableColumn | null {
|
||||
if (provider === 'pargar' || provider === 'tahesab' || provider === 'zarin') {
|
||||
if (provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') {
|
||||
const field = provider === 'pargar' ? 'pargar_account_id' : 'moshtari_code'
|
||||
return {
|
||||
title: 'کد حسابداری',
|
||||
|
||||
@@ -308,6 +308,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="tahesabDecisionVisible"
|
||||
:source-label="walletDecisionLabel"
|
||||
:allow-push="walletDecisionProvider === 'tahesab'"
|
||||
:app-gold="tahesabDecision?.app_gold"
|
||||
:app-cash="tahesabDecision?.app_cash"
|
||||
:tahesab-gold="tahesabDecision?.tahesab_gold ?? tahesabDecision?.zarin_gold"
|
||||
@@ -774,7 +775,7 @@ const userInfo = ref<Customer>()
|
||||
|
||||
const accountingCodeVisible = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||
})
|
||||
|
||||
const conditionalOrderEnabled = computed(() => conditionalOrderEnabledSetting.value)
|
||||
@@ -796,7 +797,7 @@ function onConditionalOrderUpdated(payload: {
|
||||
const accountingCodeValue = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(userInfo.value?.pargar_account_id)
|
||||
if (provider === 'tahesab' || provider === 'zarin') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
if (provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
return '-'
|
||||
})
|
||||
|
||||
@@ -855,7 +856,7 @@ function openTahesabDecision(result?: TahesabWalletSyncResult['result'], provide
|
||||
tahesabDecisionVisible.value = true
|
||||
}
|
||||
|
||||
async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' | 'push' = 'ask') {
|
||||
if (!userInfo.value?.id || !tahesabWalletCanSync.value || tahesabSyncLoading.value) return
|
||||
tahesabSyncLoading.value = true
|
||||
try {
|
||||
@@ -877,6 +878,7 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
ask_if_conflict: false,
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
})
|
||||
|
||||
if (res.needs_decision || res.result?.needs_decision) {
|
||||
@@ -885,7 +887,14 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
}
|
||||
|
||||
if (res.result?.applied || res.ok) {
|
||||
message.success(res.message || 'مانده از تهحساب روی کیف اعمال شد')
|
||||
message.success(
|
||||
res.message ||
|
||||
(mode === 'push'
|
||||
? 'مانده اپ روی تهحساب اعمال شد'
|
||||
: mode === 'keep'
|
||||
? 'موجودی اپ حفظ شد'
|
||||
: 'مانده از تهحساب روی کیف اعمال شد')
|
||||
)
|
||||
} else {
|
||||
message.info(res.message || 'تغییری برای اعمال نبود')
|
||||
}
|
||||
@@ -902,18 +911,24 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
refreshTable()
|
||||
|
||||
if (data?.result?.applied || data?.ok) {
|
||||
message.success(data?.message || 'مانده از تهحساب روی کیف اعمال شد')
|
||||
message.success(data?.message || 'مانده با تهحساب همتراز شد')
|
||||
} else if (status !== 422) {
|
||||
message.warning(data?.message || 'اعمال مانده از تهحساب ناموفق بود')
|
||||
message.warning(data?.message || 'اعمال مانده با تهحساب ناموفق بود')
|
||||
} else if (data?.message) {
|
||||
message.warning(data.message)
|
||||
}
|
||||
} finally {
|
||||
tahesabSyncLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
tahesabDecisionVisible.value = false
|
||||
if (walletDecisionProvider.value === 'zarin') {
|
||||
if (mode === 'push') {
|
||||
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||
return
|
||||
}
|
||||
await syncZarinWallet(mode)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<BasicShowContext title="خرید اقساطی" :help="digipayInstallmentPageIntro">
|
||||
<div class="flex flex-col gap-2 p-2.5">
|
||||
<div class="text-sm font-bold">ثبت اعتبار بعد از دیجیپی</div>
|
||||
<p class="text-xs opacity-70">
|
||||
کاربر اول با لینک تنظیمات به دیجیپی میرود. بعد از احراز، مانده اعتبارش را اینجا بنویسید تا در اپ بتواند مس بخرد.
|
||||
</p>
|
||||
<a-form layout="vertical" class="sm:grid sm:grid-cols-2 sm:gap-2" @finish="save">
|
||||
<a-form-item label="موبایل مشتری" name="mobile" :rules="[{ required: true, message: 'موبایل را وارد کنید' }]">
|
||||
<a-input v-model:value="form.mobile" placeholder="09..." />
|
||||
</a-form-item>
|
||||
<a-form-item label="مانده ۴ قسط (تومان)" name="plan4">
|
||||
<a-input-number v-model:value="form.plan4_toman" class="w-full" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="مانده ۱۲ قسط (تومان)" name="plan12">
|
||||
<a-input-number v-model:value="form.plan12_toman" class="w-full" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label=" " class="flex items-end">
|
||||
<a-button type="primary" html-type="submit" :loading="saving">ثبت اعتبار</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<div class="mt-2 text-sm font-bold">خریدهای اخیر</div>
|
||||
<a-table
|
||||
size="small"
|
||||
row-key="id"
|
||||
:loading="loading"
|
||||
:data-source="rows"
|
||||
:pagination="false"
|
||||
:columns="columns"
|
||||
/>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import { digipayInstallmentPageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const form = reactive({ mobile: '', plan4_toman: 0, plan12_toman: 0 })
|
||||
const saving = ref(false)
|
||||
const loading = ref(false)
|
||||
const rows = ref<Record<string, unknown>[]>([])
|
||||
|
||||
const columns = [
|
||||
{ title: 'مشتری', dataIndex: 'name' },
|
||||
{ title: 'موبایل', dataIndex: 'mobile' },
|
||||
{ title: 'طرح', dataIndex: 'plan' },
|
||||
{ title: 'مبلغ مس (تومان)', dataIndex: 'amount_toman' },
|
||||
{ title: 'کارمزد (تومان)', dataIndex: 'fee_toman' },
|
||||
{ title: 'مقدار', dataIndex: 'grams' }
|
||||
]
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await useAxios.post('/admin/digipay_installment/orders')
|
||||
rows.value = res?.data?.data || res?.data || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
try {
|
||||
await useAxios.post('/admin/digipay_installment/credit', {
|
||||
mobile: form.mobile,
|
||||
plan4_toman: form.plan4_toman || 0,
|
||||
plan12_toman: form.plan12_toman || 0
|
||||
})
|
||||
message.success('اعتبار ثبت شد')
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'ثبت اعتبار انجام نشد')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex gap-3 justify-center items-center">
|
||||
<a-tooltip placement="top">
|
||||
<a-tooltip v-if="can('detail')" placement="top">
|
||||
<template #title>جزئیات</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:eye"
|
||||
@@ -24,7 +24,7 @@
|
||||
@click.stop="openDetails(record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="record.status === 'active'" placement="top">
|
||||
<a-tooltip v-if="can('edit') && record.status === 'active'" placement="top">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -86,6 +86,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { getCustomersList } from '@/api/customer'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { Item } from '@/model/Item'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const modalVisible = ref(false)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<BaseTable v-bind="tblProps" @register="registerTable" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div v-if="record.status === 'pending'" class="flex gap-2 justify-center">
|
||||
<BaseButton type="primary" size="small" @click.stop="openApprove(record)">
|
||||
<BaseButton v-if="can('approve')" type="primary" size="small" @click.stop="openApprove(record)">
|
||||
تأیید
|
||||
</BaseButton>
|
||||
<BaseButton size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
||||
<BaseButton v-if="can('reject')" size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
||||
</div>
|
||||
<span v-else class="text-gray-400 text-xs">—</span>
|
||||
</template>
|
||||
@@ -46,6 +46,9 @@ import {
|
||||
} from '@/api/goldCredit'
|
||||
import GoldCreditModal from '@/pages/menuPages/customers/base/components/goldCreditModal.vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [registerTable, reload] = useBaseTable()
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -21,7 +21,7 @@ import { computed } from 'vue'
|
||||
import BasicMenu from '@/components/BasicMenu/index.vue'
|
||||
import { useRouterStore } from '@core/stores/router'
|
||||
import { get } from 'lodash'
|
||||
import { customerSpecialPricingEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
||||
import { customerSpecialPricingEnabledSetting, digipayInstallmentEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
||||
|
||||
initWalletSettingsFromApi()
|
||||
|
||||
@@ -36,6 +36,7 @@ const menu = computed(() => {
|
||||
.filter((child) => {
|
||||
if (child.name === 'customerMain_specialPrice') return customerSpecialPricingEnabledSetting.value
|
||||
if (child.name === 'customerMain_goldCredit') return goldCreditEnabledSetting.value
|
||||
if (child.name === 'customerMain_digipayInstallment') return digipayInstallmentEnabledSetting.value
|
||||
return true
|
||||
})
|
||||
.sort((a, b) => (a.meta?.order ?? 99) - (b.meta?.order ?? 99))
|
||||
|
||||
@@ -391,7 +391,21 @@ async function submitEdit() {
|
||||
await editFormRef.value?.validate()
|
||||
if (!editId.value) return
|
||||
actionLoading.value = true
|
||||
await updateCustomer(editId.value, editForm.value as Customer)
|
||||
const payload: Partial<Customer> = {
|
||||
fname: editForm.value.fname,
|
||||
lname: editForm.value.lname,
|
||||
mobile: editForm.value.mobile,
|
||||
birth_date: editForm.value.birth_date,
|
||||
phone_number: editForm.value.phone_number,
|
||||
province: editForm.value.province,
|
||||
city: editForm.value.city,
|
||||
n_code: editForm.value.n_code,
|
||||
}
|
||||
const password = String(editForm.value.password || '').trim()
|
||||
if (password !== '') {
|
||||
payload.password = password
|
||||
}
|
||||
await updateCustomer(editId.value, payload as Customer)
|
||||
message.success('ویرایش با موفقیت انجام شد')
|
||||
editVisible.value = false
|
||||
await load()
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title><span>ویرایش</span></template>
|
||||
<Icon icon="vuesax-linear:edit-2" color="#4572E9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('toggle', record)">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom" class="cursor-pointer" @click="emits('toggle', record)">
|
||||
<template #title>
|
||||
<span>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</span>
|
||||
</template>
|
||||
@@ -29,6 +29,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-popconfirm
|
||||
v-if="can('delete')"
|
||||
title="پکیج حذف شود؟"
|
||||
ok-text="تایید"
|
||||
cancel-text="انصراف"
|
||||
@@ -56,6 +57,9 @@ import { getSpecialPricePackageColumns } from '../hooks/specialPriceColumns'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { ref } from 'vue'
|
||||
import { specialPricePageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'add'): void
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title>
|
||||
<span>ویرایش</span>
|
||||
</template>
|
||||
@@ -30,6 +30,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { cols } from '../hooks/discountColumns'
|
||||
import { getDiscountTable } from '@/api/discount'
|
||||
import { discountPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -11,7 +11,39 @@
|
||||
@cancel="close"
|
||||
@close="close"
|
||||
>
|
||||
<div v-if="isMobile" class="mb-3 text-base font-700">لیست کدهای کارت هدیه</div>
|
||||
<div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="min-w-0 space-y-1">
|
||||
<p v-if="giftCardCustomer" class="m-0 text-13px font-600" style="color: var(--admin-text)">
|
||||
مشتری: {{ giftCardCustomer.name }} — <span dir="ltr">{{ giftCardCustomer.mobile }}</span>
|
||||
</p>
|
||||
<p v-else class="m-0 text-13px font-600" style="color: var(--admin-text)">
|
||||
کد عمومی — بدون مشتری مشخص
|
||||
</p>
|
||||
<p class="m-0 text-13px text-[var(--admin-text-secondary)]">
|
||||
{{ codes.length }} کد — دانلود به صورت اکسل یا PDF
|
||||
</p>
|
||||
</div>
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
placement="bottomLeft"
|
||||
:overlay-style="{ zIndex: SELECT_DROPDOWN_Z_INDEX }"
|
||||
>
|
||||
<BaseButton
|
||||
type="default"
|
||||
size="small"
|
||||
icon="vuesax-linear:document-download"
|
||||
:disabled="!codes.length"
|
||||
>
|
||||
دانلود
|
||||
</BaseButton>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleDownload">
|
||||
<a-menu-item key="excel">اکسل (CSV)</a-menu-item>
|
||||
<a-menu-item key="pdf">PDF</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
class="hidden md:block"
|
||||
@@ -22,6 +54,21 @@
|
||||
>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'index'">{{ index + 1 }}</template>
|
||||
<template v-else-if="column.key === 'code'">
|
||||
<div class="flex items-center justify-center gap-1" dir="ltr">
|
||||
<span class="font-mono text-xs">{{ record.code || '-' }}</span>
|
||||
<a-tooltip v-if="record.code" title="کپی کد">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex cursor-pointer items-center border-none bg-transparent p-0"
|
||||
aria-label="کپی کد"
|
||||
@click="copyCode(record.code)"
|
||||
>
|
||||
<Icon icon="vuesax-linear:copy" :size="16" color="#4572E9" />
|
||||
</button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'sts'">
|
||||
<CustomTag v-if="record.sts === 1" textColor="#ca8a04" bgColor="#fef3c7">فعال</CustomTag>
|
||||
<CustomTag v-else-if="record.sts === 2" textColor="#25855A" bgColor="#E3F4E9">استفاده شده</CustomTag>
|
||||
@@ -63,19 +110,31 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Giftcardcode } from '@/model/giftCard'
|
||||
import type { Giftcard, Giftcardcode } from '@/model/giftCard'
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import GiftCardCodeMobileDetailSheet from './GiftCardCodeMobileDetailSheet.vue'
|
||||
import GiftCardCodeMobileListItem from './GiftCardCodeMobileListItem.vue'
|
||||
import {
|
||||
downloadGiftCardCodesExcel,
|
||||
downloadGiftCardCodesPdf,
|
||||
type GiftCardCodesExportMeta
|
||||
} from '../utils/exportGiftCardCodes'
|
||||
import { resolveGiftCardCustomer } from '../utils/giftCardCustomer'
|
||||
import { SELECT_DROPDOWN_Z_INDEX } from '@/constants/overlayZIndex'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
|
||||
const { copy, isSupported } = useClipboard()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
codes: Giftcardcode[]
|
||||
giftCard?: Giftcard | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -97,11 +156,54 @@ const columns = [
|
||||
{ title: 'وضعیت', dataIndex: 'sts', key: 'sts' },
|
||||
{ title: 'تاریخ انقضا', dataIndex: 'expiry_date', key: 'expiry_date' },
|
||||
{ title: 'تاریخ استفاده', dataIndex: 'used_at', key: 'used_at' },
|
||||
{ title: 'نام کاربر اختصاص داده شده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
||||
{ title: 'شماره موبایل کاربر اختصاص داده شده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
||||
{ title: 'نام استفادهکننده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
||||
{ title: 'موبایل استفادهکننده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
||||
]
|
||||
|
||||
function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
async function copyCode(code?: string) {
|
||||
const value = String(code ?? '').trim()
|
||||
if (!value) return
|
||||
try {
|
||||
if (isSupported.value) await copy(value)
|
||||
else {
|
||||
const el = document.createElement('textarea')
|
||||
el.value = value
|
||||
el.style.position = 'fixed'
|
||||
el.style.opacity = '0'
|
||||
document.body.appendChild(el)
|
||||
el.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(el)
|
||||
}
|
||||
message.success('کد کپی شد')
|
||||
} catch {
|
||||
message.error('کپی انجام نشد')
|
||||
}
|
||||
}
|
||||
|
||||
const giftCardCustomer = computed(() => resolveGiftCardCustomer(props.giftCard))
|
||||
|
||||
const exportMeta = computed<GiftCardCodesExportMeta>(() => ({
|
||||
id: props.giftCard?.id,
|
||||
unit: props.giftCard?.unit,
|
||||
count: props.giftCard?.count,
|
||||
customerName: giftCardCustomer.value?.name,
|
||||
customerMobile: giftCardCustomer.value?.mobile,
|
||||
createdAt: props.giftCard?.created_at
|
||||
}))
|
||||
|
||||
function handleDownload({ key }: { key: string }) {
|
||||
if (!props.codes.length) return
|
||||
if (key === 'excel') {
|
||||
downloadGiftCardCodesExcel(props.codes, exportMeta.value)
|
||||
return
|
||||
}
|
||||
if (key === 'pdf') {
|
||||
downloadGiftCardCodesPdf(props.codes, exportMeta.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<BasicActionSheet
|
||||
v-model:visible="visibleProxy"
|
||||
title="گزارش استفاده کدهای هدیه"
|
||||
modal-width="92%"
|
||||
drawer-height="92vh"
|
||||
:show-button="true"
|
||||
:show-cancel="true"
|
||||
:show-ok="false"
|
||||
cancel-text="بستن"
|
||||
@cancel="close"
|
||||
@close="close"
|
||||
>
|
||||
<p class="m-0 mb-3 text-13px leading-6 text-[var(--admin-text-secondary)]">
|
||||
هر سطر یک کد است. ستون «تعداد استفاده» برای کدهای عمومی چندمصرف، تعداد مصرف کل پویش است.
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="summary"
|
||||
class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-5"
|
||||
>
|
||||
<div class="rounded-lg border border-solid border-[var(--admin-border)] p-2.5 text-center">
|
||||
<div class="text-xs text-[var(--admin-text-secondary)]">کل کدها</div>
|
||||
<div class="text-base font-700">{{ summary.total_codes }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-solid border-[var(--admin-border)] p-2.5 text-center">
|
||||
<div class="text-xs text-[var(--admin-text-secondary)]">استفادهشده</div>
|
||||
<div class="text-base font-700 text-emerald-700">{{ summary.used_codes }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-solid border-[var(--admin-border)] p-2.5 text-center">
|
||||
<div class="text-xs text-[var(--admin-text-secondary)]">بدون مصرف</div>
|
||||
<div class="text-base font-700">{{ summary.unused_codes }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-solid border-[var(--admin-border)] p-2.5 text-center">
|
||||
<div class="text-xs text-[var(--admin-text-secondary)]">فعال</div>
|
||||
<div class="text-base font-700">{{ summary.active_codes }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg border border-solid border-[var(--admin-border)] p-2.5 text-center col-span-2 sm:col-span-1">
|
||||
<div class="text-xs text-[var(--admin-text-secondary)]">منقضی</div>
|
||||
<div class="text-base font-700 text-red-600">{{ summary.expired_codes }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<BaseTable
|
||||
class="h-[min(58vh,520px)] min-h-0 min-w-0"
|
||||
v-bind="tblProps"
|
||||
@register="submit"
|
||||
/>
|
||||
</BasicActionSheet>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import useBaseTable from '@core/components/BaseTableOld/hooks/useBaseTable'
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import { getGiftCardCodesUsageReport } from '@/api/giftCard'
|
||||
import { getGiftCardUsageReportColumns } from '../hooks/usageReportColumns'
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: (value: boolean) => emit('update:visible', value),
|
||||
})
|
||||
|
||||
const summary = ref<{
|
||||
total_codes: number
|
||||
used_codes: number
|
||||
unused_codes: number
|
||||
active_codes: number
|
||||
expired_codes: number
|
||||
} | null>(null)
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
const tblProps = ref({
|
||||
columns: getGiftCardUsageReportColumns(),
|
||||
api: async (params: TableInput) => {
|
||||
const res = await getGiftCardCodesUsageReport(params)
|
||||
summary.value = res.summary ?? null
|
||||
return res
|
||||
},
|
||||
})
|
||||
|
||||
function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(open) => {
|
||||
if (open) {
|
||||
void reload()
|
||||
}
|
||||
},
|
||||
)
|
||||
</script>
|
||||
@@ -1,25 +1,48 @@
|
||||
<template>
|
||||
<a-form :model="form" ref="formRef" autocomplete="off">
|
||||
<a-form :model="props.form" ref="formRef" autocomplete="off">
|
||||
<div class="space-y-3">
|
||||
<a-form-item name="mobile" :rules="inputLenRules(11)">
|
||||
<a-form-item name="assignMode" :rules="inputRules()">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="شماره موبایل مشتری" :help="giftCardMobileHelp" />
|
||||
<AdminLabelWithHelp label="نوع ثبت" :help="giftCardAssignModeHelp" />
|
||||
</template>
|
||||
<BasicInput v-model:value="form.mobile" type="tel" placeholder="09123456789" />
|
||||
<a-radio-group v-model:value="props.form.assignMode" button-style="solid" @change="onAssignModeChange">
|
||||
<a-radio-button value="public">کد عمومی (بدون مشتری)</a-radio-button>
|
||||
<a-radio-button value="customer">اختصاص به مشتری</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="name" :rules="inputRules()">
|
||||
<a-form-item v-if="isPublicMode" name="show_in_app" :rules="inputRules()">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="نام مشتری" :help="giftCardNameHelp" />
|
||||
<AdminLabelWithHelp label="نمایش در اپ کاربر" :help="giftCardPublicVisibilityHelp" />
|
||||
</template>
|
||||
<BasicInput v-model:value="form.name" placeholder="نام و نام خانوادگی مشتری" />
|
||||
<a-radio-group v-model:value="props.form.show_in_app" button-style="solid" class="flex flex-col gap-2 sm:flex-row">
|
||||
<a-radio-button :value="1">نمایش برای همه</a-radio-button>
|
||||
<a-radio-button :value="0">مخفی — فقط با وارد کردن کد</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item v-if="isCustomerMode" name="customer_id" :rules="customerIdRules">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="مشتری" :help="giftCardCustomerSelectHelp" />
|
||||
</template>
|
||||
<a-select
|
||||
v-model:value="props.form.customer_id"
|
||||
show-search
|
||||
allow-clear
|
||||
placeholder="انتخاب مشتری"
|
||||
class="w-full"
|
||||
:options="customerOptions"
|
||||
:loading="customersLoading"
|
||||
:filter-option="filterCustomer"
|
||||
:dropdown-style="{ zIndex: SELECT_DROPDOWN_Z_INDEX }"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="unit" :rules="inputRules()">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="نوع کارت هدیه" :help="giftCardUnitHelp" />
|
||||
</template>
|
||||
<a-radio-group v-model:value="form.unit" button-style="solid">
|
||||
<a-radio-group v-model:value="props.form.unit" button-style="solid">
|
||||
<a-radio-button value="1">ریالی</a-radio-button>
|
||||
<a-radio-button value="2">{{ metalLabel.goldWalletShort() }}</a-radio-button>
|
||||
</a-radio-group>
|
||||
@@ -29,33 +52,33 @@
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="تعداد کدها" :help="giftCardCountHelp" />
|
||||
</template>
|
||||
<BasicInput v-model:value="form.count" type="tel" placeholder="تعداد کدهای کارت هدیه" />
|
||||
<BasicInput v-model:value="props.form.count" type="tel" placeholder="تعداد کدهای کارت هدیه" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="amount" :rules="inputRulesNumber()">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp
|
||||
:label="`مقدار ${form.unit === '2' ? '(گرم)' : '(ریال)'}`"
|
||||
:label="`مقدار ${props.form.unit === '2' ? '(گرم)' : '(ریال)'}`"
|
||||
:help="giftCardAmountHelp"
|
||||
/>
|
||||
</template>
|
||||
<BasicInput
|
||||
v-model:value="form.amount"
|
||||
:addon-before="form.unit === '2' ? 'گرم' : 'ریال'"
|
||||
v-model:value="props.form.amount"
|
||||
:addon-before="props.form.unit === '2' ? 'گرم' : 'ریال'"
|
||||
type="tel"
|
||||
placeholder="مقدار کارت هدیه"
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item name="expiry_date" :rules="inputRules()">
|
||||
<a-form-item name="expiry_date" :rules="expiryDateRules">
|
||||
<template #label>
|
||||
<AdminLabelWithHelp label="تاریخ انقضا" :help="giftCardExpiryHelp" />
|
||||
</template>
|
||||
<BaseDatePicker v-model:value="form.expiry_date" format="YYYY-MM-DD" />
|
||||
<BaseDatePicker v-model:value="props.form.expiry_date" format="YYYY-MM-DD" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="توضیحات" name="description" class="mb-0">
|
||||
<BasicTextArea v-model:value="form.description" place-holder="توضیحات اختیاری — فقط برای یادداشت شما در پنل" />
|
||||
<BasicTextArea v-model:value="props.form.description" place-holder="توضیحات اختیاری — فقط برای یادداشت شما در پنل" />
|
||||
</a-form-item>
|
||||
</div>
|
||||
</a-form>
|
||||
@@ -64,23 +87,108 @@
|
||||
<script setup lang="ts">
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import type { GiftcardInput } from '@/model/giftCard'
|
||||
import { getCustomersList } from '@/api/customer'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import AdminLabelWithHelp from '@/components/AdminLabelWithHelp.vue'
|
||||
import {
|
||||
giftCardAmountHelp,
|
||||
giftCardAssignModeHelp,
|
||||
giftCardCountHelp,
|
||||
giftCardCustomerSelectHelp,
|
||||
giftCardExpiryHelp,
|
||||
giftCardMobileHelp,
|
||||
giftCardNameHelp,
|
||||
giftCardPublicVisibilityHelp,
|
||||
giftCardUnitHelp,
|
||||
} from '@/utils/adminHelpCopy'
|
||||
import { inputLenRules, inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||
import { SELECT_DROPDOWN_Z_INDEX } from '@/constants/overlayZIndex'
|
||||
import { inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
form: GiftcardInput
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const customers = ref<Customer[]>([])
|
||||
const customersLoading = ref(false)
|
||||
|
||||
const isCustomerMode = computed(() => props.form.assignMode === 'customer')
|
||||
const isPublicMode = computed(() => props.form.assignMode === 'public')
|
||||
|
||||
const customerOptions = computed(() =>
|
||||
customers.value.map((customer) => ({
|
||||
value: customer.id,
|
||||
label: `${customer.name ?? '—'} — ${customer.mobile ?? ''}`.trim(),
|
||||
}))
|
||||
)
|
||||
|
||||
const customerIdRules = [
|
||||
{
|
||||
validator(_rule: unknown, value: unknown) {
|
||||
if (props.form.assignMode !== 'customer') {
|
||||
return Promise.resolve()
|
||||
}
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return Promise.reject('انتخاب مشتری الزامی است')
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
trigger: ['change', 'blur'],
|
||||
},
|
||||
]
|
||||
|
||||
const expiryDateRules = [
|
||||
...inputRules(),
|
||||
{
|
||||
validator(_rule: unknown, value: unknown) {
|
||||
if (value === undefined || value === null || value === '') {
|
||||
return Promise.reject('پر کردن مورد بالا الزامی است')
|
||||
}
|
||||
const day = dayjs(value as string | number | Date)
|
||||
if (!day.isValid()) {
|
||||
return Promise.reject('تاریخ انقضا نامعتبر است')
|
||||
}
|
||||
if (day.startOf('day').isBefore(dayjs().startOf('day'))) {
|
||||
return Promise.reject('تاریخ انقضا نمیتواند قبل از امروز باشد')
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
trigger: ['change', 'blur'],
|
||||
},
|
||||
]
|
||||
|
||||
function filterCustomer(input: string, option?: { label?: string }) {
|
||||
return String(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
|
||||
}
|
||||
|
||||
function onAssignModeChange() {
|
||||
if (props.form.assignMode === 'public') {
|
||||
props.form.customer_id = undefined
|
||||
if (props.form.show_in_app === undefined) {
|
||||
props.form.show_in_app = 0
|
||||
}
|
||||
formRef.value?.clearValidate?.(['customer_id'])
|
||||
return
|
||||
}
|
||||
|
||||
props.form.show_in_app = 0
|
||||
formRef.value?.clearValidate?.(['show_in_app'])
|
||||
}
|
||||
|
||||
async function loadCustomers() {
|
||||
customersLoading.value = true
|
||||
try {
|
||||
customers.value = (await getCustomersList()) ?? []
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
customersLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadCustomers()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
validateFields: () => formRef.value?.validateFields(),
|
||||
|
||||
@@ -16,8 +16,13 @@
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:hide-customer="!!customerId"
|
||||
:can-edit="canEdit"
|
||||
:can-delete="canDelete"
|
||||
:can-codes="canCodes"
|
||||
@open="openSheet"
|
||||
@gift-card-codes="$emit('giftCardCodes', $event)"
|
||||
@edit="$emit('edit', $event)"
|
||||
@delete="$emit('delete', $event)"
|
||||
/>
|
||||
</MobileCardList>
|
||||
|
||||
@@ -38,10 +43,15 @@ type GiftCardRow = Giftcard & { customer?: { name?: string; mobile?: string } }
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
canEdit?: boolean
|
||||
canDelete?: boolean
|
||||
canCodes?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'giftCardCodes', item: GiftCardRow): void
|
||||
(e: 'edit', item: GiftCardRow): void
|
||||
(e: 'delete', id: number): void
|
||||
}>()
|
||||
|
||||
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<GiftCardRow>()
|
||||
|
||||
@@ -18,11 +18,26 @@
|
||||
</div>
|
||||
|
||||
<MobileIconButton
|
||||
v-if="canCodes"
|
||||
icon="vuesax-linear:document-text"
|
||||
color="#1890ff"
|
||||
:size="20"
|
||||
@click="$emit('giftCardCodes', item)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canEdit"
|
||||
icon="vuesax-linear:edit"
|
||||
color="#4572E9"
|
||||
:size="20"
|
||||
@click="$emit('edit', item)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canDelete"
|
||||
icon="vuesax-linear:trash"
|
||||
color="#EB3535"
|
||||
:size="20"
|
||||
@click="item.id && $emit('delete', item.id)"
|
||||
/>
|
||||
</div>
|
||||
</MobileCard>
|
||||
</template>
|
||||
@@ -38,11 +53,16 @@ type GiftCardRow = Giftcard & { customer?: { name?: string; mobile?: string } }
|
||||
const props = defineProps<{
|
||||
item: GiftCardRow
|
||||
hideCustomer?: boolean
|
||||
canEdit?: boolean
|
||||
canDelete?: boolean
|
||||
canCodes?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'open', item: GiftCardRow): void
|
||||
(e: 'giftCardCodes', item: GiftCardRow): void
|
||||
(e: 'edit', item: GiftCardRow): void
|
||||
(e: 'delete', id: number): void
|
||||
}>()
|
||||
|
||||
const unitLabel = computed(() => (props.item.unit === 2 ? metalLabel.goldWalletShort() : 'ریالی'))
|
||||
|
||||
@@ -23,22 +23,43 @@
|
||||
>
|
||||
افزودن کد تخفیف
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="!customerId && (can('usageReport') || can('codes'))"
|
||||
type="default"
|
||||
size="small"
|
||||
icon="vuesax-linear:chart-2"
|
||||
@click="usageReportVisible = true"
|
||||
>
|
||||
گزارش استفاده کدها
|
||||
</BaseButton>
|
||||
</div>
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title>
|
||||
<span>مشخصات</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('giftcardcodes', record)">
|
||||
<a-tooltip v-if="can('codes')" placement="bottom" class="cursor-pointer" @click="emits('giftcardcodes', record)">
|
||||
<template #title>
|
||||
<span>کدهای {{ record.unit == 3 ? 'تخفیف' : 'کارت هدیه' }}</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:document-text" color="#1890ff" />
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title>
|
||||
<span>ویرایش</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="can('delete')" placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||
<template #title>
|
||||
<span>حذف</span>
|
||||
</template>
|
||||
<Icon icon="vuesax-linear:trash" color="#EB3535" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</BaseTable>
|
||||
@@ -49,9 +70,16 @@
|
||||
class="min-h-0 flex-1"
|
||||
:customer-id="customerId"
|
||||
@gift-card-codes="emits('giftcardcodes', $event)"
|
||||
:can-edit="can('edit')"
|
||||
:can-delete="can('delete')"
|
||||
:can-codes="can('codes')"
|
||||
@edit="emits('edit', $event)"
|
||||
@delete="emits('delete', $event)"
|
||||
/>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
|
||||
<GiftCardCodesUsageReportSheet v-model:visible="usageReportVisible" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -66,6 +94,8 @@ import GiftCardMobileCardList from './GiftCardMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { isStoreApp } from '@/utils/config'
|
||||
import { giftCardsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
import GiftCardCodesUsageReportSheet from './GiftCardCodesUsageReportSheet.vue'
|
||||
|
||||
interface Prop {
|
||||
customerId?: number
|
||||
@@ -73,6 +103,8 @@ interface Prop {
|
||||
|
||||
const props = defineProps<Prop>()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'giftcardcodes'])
|
||||
const { can } = usePageActionAccess()
|
||||
const usageReportVisible = ref(false)
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -3,6 +3,7 @@ import { toJalali } from '@core/utils/useDataTime'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { giftCardCustomerLabel, giftCardCustomerMobile } from '../utils/giftCardCustomer'
|
||||
/*import BudgetSelect from '@/components/BudgetSelect.vue'
|
||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
import type { FilterSelect } from '@/model/filterSelect'
|
||||
@@ -105,18 +106,14 @@ export function getGiftCardColumns(): BaseTableColumn[] {
|
||||
dataIndex: 'customer.name',
|
||||
key: 'customer.name',
|
||||
type: 'Text',
|
||||
customRender: ({ record }) => {
|
||||
return record.customer?.name ?? '-'
|
||||
}
|
||||
customRender: ({ record }) => giftCardCustomerLabel(record)
|
||||
},
|
||||
{
|
||||
title: 'شماره موبایل مشتری',
|
||||
dataIndex: 'customer.mobile',
|
||||
key: 'customer.mobile',
|
||||
type: 'Number',
|
||||
customRender: ({ record }) => {
|
||||
return record.customer?.mobile ?? '-'
|
||||
}
|
||||
customRender: ({ record }) => giftCardCustomerMobile(record)
|
||||
},
|
||||
{
|
||||
title: 'توضیحات',
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
import type { BaseTableColumn } from '@core/type/baseTable'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
|
||||
export function getGiftCardUsageReportColumns(): BaseTableColumn[] {
|
||||
return [
|
||||
{
|
||||
title: 'ردیف',
|
||||
dataIndex: 'id',
|
||||
key: 'row',
|
||||
filterable: false,
|
||||
sortable: false,
|
||||
customRender: (record: { index: number }) => record.index + 1,
|
||||
},
|
||||
{
|
||||
title: 'کد',
|
||||
dataIndex: 'code',
|
||||
key: 'code',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
title: 'نام پویش',
|
||||
dataIndex: 'campaign_name',
|
||||
key: 'campaign_name',
|
||||
type: 'text',
|
||||
},
|
||||
{
|
||||
title: 'تعداد استفاده',
|
||||
dataIndex: 'usage_count',
|
||||
key: 'usage_count',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
},
|
||||
{
|
||||
title: 'وضعیت کد',
|
||||
dataIndex: 'sts',
|
||||
key: 'sts',
|
||||
type: 'Number',
|
||||
customRender: ({ record }) => {
|
||||
const sts = Number(record.sts)
|
||||
if (sts === 1) {
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#ca8a04" bgColor="#fef3c7">
|
||||
فعال
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (sts === 2) {
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
|
||||
استفاده شده
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#C53030" bgColor="#FECACA">
|
||||
منقضی / غیرفعال
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'نوع',
|
||||
dataIndex: 'unit',
|
||||
key: 'unit',
|
||||
filterable: false,
|
||||
customRender: ({ record }) => {
|
||||
const unit = Number(record.unit)
|
||||
if (unit === 3) {
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#1d4ed8" bgColor="#dbeafe">
|
||||
تخفیف
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (unit === 2) {
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#C53030" bgColor="#FECACA">
|
||||
{metalLabel.goldWalletShort()}
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div class="flex justify-center">
|
||||
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
|
||||
ریالی
|
||||
</CustomTag>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
},
|
||||
{
|
||||
title: 'مصرفکننده',
|
||||
dataIndex: 'assigned_to',
|
||||
key: 'assigned_to_name',
|
||||
filterable: false,
|
||||
customRender: ({ record }) => record.assigned_to?.name ?? '-',
|
||||
},
|
||||
{
|
||||
title: 'موبایل مصرفکننده',
|
||||
dataIndex: 'assigned_to',
|
||||
key: 'assigned_to_mobile',
|
||||
filterable: false,
|
||||
customRender: ({ record }) => (
|
||||
<span dir="ltr" class="inline-block">
|
||||
{record.assigned_to?.mobile ?? '-'}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'تاریخ استفاده',
|
||||
dataIndex: 'used_at',
|
||||
key: 'used_at',
|
||||
filterable: false,
|
||||
customRender: ({ record }) => (record.used_at ? toJalali(record.used_at) : '-'),
|
||||
},
|
||||
{
|
||||
title: 'انقضا',
|
||||
dataIndex: 'expiry_date',
|
||||
key: 'expiry_date',
|
||||
filterable: false,
|
||||
customRender: ({ record }) => (record.expiry_date ? toJalali(record.expiry_date) : '-'),
|
||||
},
|
||||
{
|
||||
title: 'کل مجاز پویش',
|
||||
dataIndex: 'campaign_count',
|
||||
key: 'campaign_count',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
},
|
||||
{
|
||||
title: 'مصرفشده پویش',
|
||||
dataIndex: 'campaign_used_count',
|
||||
key: 'campaign_used_count',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -91,7 +91,11 @@
|
||||
:name="infoParams.name"
|
||||
:items="infoParams.items"
|
||||
/>
|
||||
<GiftCardCodesSheet v-model:visible="giftCardCodesVisible" :codes="selectedGiftCardCodes" />
|
||||
<GiftCardCodesSheet
|
||||
v-model:visible="giftCardCodesVisible"
|
||||
:codes="selectedGiftCardCodes"
|
||||
:gift-card="selectedGiftCard"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -112,10 +116,11 @@ import { confirmDeleteItem } from '@/utils/confirmModal'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import type { Item } from '@/model/Item'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import { createCustomer, deleteCustomer, getCustomersList, updateCustomer } from '@/api/customer'
|
||||
import { createGiftCard, deleteGiftCard, updateGiftCard } from '@/api/giftCard'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { allowsPageAction, notifyPageActionDenied, parsePageAccess } from '@/utils/adminPageAccess'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import type { Giftcard, Giftcardcode, GiftcardInput } from '@/model/giftCard'
|
||||
import { createGiftCard } from '@/api/giftCard'
|
||||
import dayjs from 'dayjs'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
@@ -131,6 +136,7 @@ import {
|
||||
discountPercentHelp,
|
||||
} from '@/utils/adminHelpCopy'
|
||||
import BaseDatePicker from '@core/components/BaseDatePicker'
|
||||
import { giftCardCustomerLabel, giftCardCustomerMobile } from './utils/giftCardCustomer'
|
||||
|
||||
//loading
|
||||
const loading = ref<boolean>(false)
|
||||
@@ -165,8 +171,9 @@ function closeGiftCardSheet() {
|
||||
|
||||
//form
|
||||
const form = ref<GiftcardInput>({
|
||||
mobile: '',
|
||||
name: '',
|
||||
assignMode: 'public',
|
||||
customer_id: undefined,
|
||||
show_in_app: 0,
|
||||
count: undefined,
|
||||
amount: undefined,
|
||||
unit: '1',
|
||||
@@ -178,12 +185,17 @@ const form = ref<GiftcardInput>({
|
||||
let infoParams = reactive<Info>({})
|
||||
const giftCardCodesVisible = ref<boolean>(false)
|
||||
const selectedGiftCardCodes = ref<Giftcardcode[]>([])
|
||||
const selectedGiftCard = ref<Giftcard | null>(null)
|
||||
|
||||
function info(val: Giftcard) {
|
||||
if (!giftPageAllows('info')) {
|
||||
notifyPageActionDenied('info')
|
||||
return
|
||||
}
|
||||
// نمایش اطلاعات اصلی در BasicInfoModal
|
||||
infoParams.title = 'اطلاعات کارت هدیه'
|
||||
infoParams.name = val.customer?.name ?? '-'
|
||||
infoParams.type = val.customer?.mobile ?? '-'
|
||||
infoParams.name = giftCardCustomerLabel(val)
|
||||
infoParams.type = giftCardCustomerMobile(val)
|
||||
infoParams.date = toJalaliNoTime(val.created_at)
|
||||
infoParams.time = toTime(val.created_at)
|
||||
infoParams.itemsTitle = 'اطلاعات کارت هدیه'
|
||||
@@ -192,6 +204,18 @@ function info(val: Giftcard) {
|
||||
key: 'کد',
|
||||
value: val.id ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'نوع ثبت',
|
||||
value: val.customer_id ? 'اختصاصی' : Number(val.show_in_app) === 1 ? 'عمومی — نمایش در اپ' : 'عمومی — مخفی (فقط با کد)'
|
||||
},
|
||||
{
|
||||
key: 'مشتری',
|
||||
value: giftCardCustomerLabel(val)
|
||||
},
|
||||
{
|
||||
key: 'موبایل مشتری',
|
||||
value: giftCardCustomerMobile(val)
|
||||
},
|
||||
{
|
||||
key: 'نوع کارت هدیه',
|
||||
value: val.unit === 3 ? 'تخفیف' : val.unit === 2 ? metalLabel.goldWalletShort() : 'ریالی'
|
||||
@@ -208,10 +232,6 @@ function info(val: Giftcard) {
|
||||
key: 'مبلغ کل (ریال)',
|
||||
value: usePrice(val.total ?? 0)
|
||||
},
|
||||
{
|
||||
key: 'کد یکتا',
|
||||
value: val.unique_code ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'تعداد استفاده شده',
|
||||
value: val.used_count ?? '-'
|
||||
@@ -237,8 +257,13 @@ function info(val: Giftcard) {
|
||||
}
|
||||
|
||||
function showGiftCardCodes(val: Giftcard) {
|
||||
if (!giftPageAllows('codes')) {
|
||||
notifyPageActionDenied('codes')
|
||||
return
|
||||
}
|
||||
// نمایش کدهای کارت هدیه در مودال جداگانه
|
||||
if (val.giftcardcodes && val.giftcardcodes.length > 0) {
|
||||
selectedGiftCard.value = val
|
||||
selectedGiftCardCodes.value = val.giftcardcodes
|
||||
giftCardCodesVisible.value = true
|
||||
} else {
|
||||
@@ -249,12 +274,29 @@ function showGiftCardCodes(val: Giftcard) {
|
||||
//edit
|
||||
let editId: number | undefined = undefined
|
||||
|
||||
const route = useRoute()
|
||||
const userStore = useUserStore()
|
||||
|
||||
function giftPageAllows(flag: string) {
|
||||
return allowsPageAction(
|
||||
parsePageAccess(userStore.userInfo?.page_access),
|
||||
userStore.hasFullPageAccess,
|
||||
route.matched.map((item) => item.name),
|
||||
flag
|
||||
)
|
||||
}
|
||||
|
||||
async function edit(record: Giftcard) {
|
||||
if (!giftPageAllows('edit')) {
|
||||
notifyPageActionDenied('edit')
|
||||
return
|
||||
}
|
||||
addGiftCardVisible.value = true
|
||||
editId = record.id
|
||||
form.value = {
|
||||
mobile: record.customer?.mobile ?? '',
|
||||
name: record.customer?.name ?? '',
|
||||
assignMode: record.customer_id ? 'customer' : 'public',
|
||||
customer_id: record.customer_id ?? undefined,
|
||||
show_in_app: record.customer_id ? 0 : Number(record.show_in_app) === 1 ? 1 : 0,
|
||||
count: record.count,
|
||||
amount: record.amount,
|
||||
unit: record.unit.toString(),
|
||||
@@ -322,8 +364,9 @@ async function addGiftOrDiscount(type: 'gift' | 'discount' = 'gift') {
|
||||
const resetData = () => {
|
||||
giftCardEditorRef.value?.resetFields?.()
|
||||
form.value = {
|
||||
mobile: '',
|
||||
name: '',
|
||||
assignMode: 'public',
|
||||
customer_id: undefined,
|
||||
show_in_app: 0,
|
||||
count: undefined,
|
||||
amount: undefined,
|
||||
unit: '1',
|
||||
@@ -333,7 +376,13 @@ const resetData = () => {
|
||||
}
|
||||
|
||||
//delete
|
||||
const deleteItem = (id: number) => confirmDeleteItem('کارت هدیه', id, deleteCustomer, refreshTable)
|
||||
const deleteItem = (id: number) => {
|
||||
if (!giftPageAllows('delete')) {
|
||||
notifyPageActionDenied('delete')
|
||||
return
|
||||
}
|
||||
confirmDeleteItem('کارت هدیه', id, deleteGiftCard, refreshTable)
|
||||
}
|
||||
|
||||
//add project modal
|
||||
const addGiftCardVisible = ref<boolean>(false)
|
||||
@@ -341,26 +390,42 @@ const userInfoVisible = ref<boolean>(false)
|
||||
|
||||
//submit gift card
|
||||
async function ok() {
|
||||
if (loading.value) return
|
||||
await giftCardEditorRef.value?.validateFields?.().then(async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// تنظیم تاریخ انقضا به آخر همان روز (23:59:59) و تبدیل به میلادی
|
||||
const formData = { ...form.value }
|
||||
const formData: Record<string, unknown> = {
|
||||
count: Number(form.value.count),
|
||||
amount: Number(form.value.amount),
|
||||
unit: form.value.unit,
|
||||
expiry_date: form.value.expiry_date,
|
||||
description: form.value.description,
|
||||
}
|
||||
if (form.value.assignMode === 'customer' && form.value.customer_id) {
|
||||
formData.customer_id = Number(form.value.customer_id)
|
||||
} else if (form.value.assignMode === 'public') {
|
||||
formData.show_in_app = Number(form.value.show_in_app) === 1 ? 1 : 0
|
||||
}
|
||||
if (formData.expiry_date) {
|
||||
// تبدیل به میلادی و تنظیم به آخر روز
|
||||
formData.expiry_date = dayjs(formData.expiry_date)
|
||||
formData.expiry_date = dayjs(formData.expiry_date as string)
|
||||
.calendar('gregory')
|
||||
.endOf('day')
|
||||
.format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
await createGiftCard(formData)
|
||||
if (editId) {
|
||||
await updateGiftCard(editId, formData as GiftcardInput)
|
||||
message.success('کارت هدیه با موفقیت ویرایش شد')
|
||||
} else {
|
||||
await createGiftCard(formData as GiftcardInput)
|
||||
message.success('کارت هدیه با موفقیت ثبت شد')
|
||||
}
|
||||
addGiftCardVisible.value = false
|
||||
resetData()
|
||||
refreshTable()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
message.error('خطا در ثبت کارت هدیه')
|
||||
message.error(e?.response?.data?.message || 'خطا در ثبت کارت هدیه')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
import type { Giftcardcode } from '@/model/giftCard'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
|
||||
export interface GiftCardCodesExportMeta {
|
||||
id?: number
|
||||
unit?: number
|
||||
count?: number
|
||||
customerName?: string
|
||||
customerMobile?: string
|
||||
createdAt?: string
|
||||
}
|
||||
|
||||
interface ExportRow {
|
||||
index: number
|
||||
code: string
|
||||
unit: string
|
||||
amount: string
|
||||
status: string
|
||||
expiryDate: string
|
||||
usedAt: string
|
||||
assignedName: string
|
||||
assignedMobile: string
|
||||
}
|
||||
|
||||
const CSV_HEADERS = [
|
||||
'ردیف',
|
||||
'کد',
|
||||
'نوع',
|
||||
'مقدار',
|
||||
'وضعیت',
|
||||
'تاریخ انقضا',
|
||||
'تاریخ استفاده',
|
||||
'نام کاربر',
|
||||
'موبایل کاربر'
|
||||
]
|
||||
|
||||
function statusLabel(sts: number): string {
|
||||
if (sts === 1) return 'فعال'
|
||||
if (sts === 2) return 'استفاده شده'
|
||||
return 'غیرفعال'
|
||||
}
|
||||
|
||||
function unitLabel(unit: number): string {
|
||||
if (unit === 2) return metalLabel.goldWalletShort()
|
||||
if (unit === 3) return 'تخفیف'
|
||||
return 'ریالی'
|
||||
}
|
||||
|
||||
function amountLabel(code: Giftcardcode): string {
|
||||
const suffix = code.unit === 2 ? 'گرم' : 'ریال'
|
||||
return `${code.amount ?? '-'} ${suffix}`
|
||||
}
|
||||
|
||||
function buildRows(codes: Giftcardcode[]): ExportRow[] {
|
||||
return codes.map((code, index) => ({
|
||||
index: index + 1,
|
||||
code: code.code,
|
||||
unit: unitLabel(code.unit),
|
||||
amount: amountLabel(code),
|
||||
status: statusLabel(code.sts),
|
||||
expiryDate: code.expiry_date ? toJalali(code.expiry_date) : '-',
|
||||
usedAt: code.used_at ? toJalali(code.used_at) : '-',
|
||||
assignedName: code.assigned_to?.name ?? '-',
|
||||
assignedMobile: code.assigned_to?.mobile ?? '-'
|
||||
}))
|
||||
}
|
||||
|
||||
function csvCell(value: unknown): string {
|
||||
const text = value == null || value === '' ? '-' : String(value)
|
||||
if (/[",\n\r]/.test(text)) {
|
||||
return `"${text.replace(/"/g, '""')}"`
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
function buildFilename(meta: GiftCardCodesExportMeta, extension: string): string {
|
||||
const idPart = meta.id ? `-${meta.id}` : ''
|
||||
const datePart = new Date().toISOString().slice(0, 10)
|
||||
return `giftcard-codes${idPart}-${datePart}.${extension}`
|
||||
}
|
||||
|
||||
function downloadBlob(content: string, filename: string, mime: string) {
|
||||
const blob = new Blob([content], { type: mime })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = filename
|
||||
link.click()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function buildSummary(meta: GiftCardCodesExportMeta): string[] {
|
||||
const lines: string[] = []
|
||||
if (meta.id) lines.push(`شناسه کارت هدیه: ${meta.id}`)
|
||||
if (meta.unit != null) lines.push(`نوع: ${unitLabel(meta.unit)}`)
|
||||
if (meta.count != null) lines.push(`تعداد کدها: ${meta.count}`)
|
||||
if (meta.customerName) lines.push(`مشتری: ${meta.customerName}`)
|
||||
if (meta.customerMobile) lines.push(`موبایل: ${meta.customerMobile}`)
|
||||
if (meta.createdAt) lines.push(`تاریخ ثبت: ${toJalali(meta.createdAt)}`)
|
||||
return lines
|
||||
}
|
||||
|
||||
export function downloadGiftCardCodesExcel(codes: Giftcardcode[], meta: GiftCardCodesExportMeta = {}) {
|
||||
const rows = buildRows(codes)
|
||||
const lines = [
|
||||
CSV_HEADERS.map(csvCell).join(','),
|
||||
...rows.map((row) =>
|
||||
[
|
||||
row.index,
|
||||
row.code,
|
||||
row.unit,
|
||||
row.amount,
|
||||
row.status,
|
||||
row.expiryDate,
|
||||
row.usedAt,
|
||||
row.assignedName,
|
||||
row.assignedMobile
|
||||
]
|
||||
.map(csvCell)
|
||||
.join(',')
|
||||
)
|
||||
]
|
||||
const content = `\uFEFF${lines.join('\r\n')}`
|
||||
downloadBlob(content, buildFilename(meta, 'csv'), 'text/csv;charset=utf-8')
|
||||
}
|
||||
|
||||
export function downloadGiftCardCodesPdf(codes: Giftcardcode[], meta: GiftCardCodesExportMeta = {}) {
|
||||
const rows = buildRows(codes)
|
||||
const summary = buildSummary(meta)
|
||||
const title = meta.id ? `لیست کدهای کارت هدیه #${meta.id}` : 'لیست کدهای کارت هدیه'
|
||||
|
||||
const tableRows = rows
|
||||
.map(
|
||||
(row) => `
|
||||
<tr>
|
||||
<td>${row.index}</td>
|
||||
<td dir="ltr">${row.code}</td>
|
||||
<td>${row.unit}</td>
|
||||
<td>${row.amount}</td>
|
||||
<td>${row.status}</td>
|
||||
<td>${row.expiryDate}</td>
|
||||
<td>${row.usedAt}</td>
|
||||
<td>${row.assignedName}</td>
|
||||
<td dir="ltr">${row.assignedMobile}</td>
|
||||
</tr>`
|
||||
)
|
||||
.join('')
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>${title}</title>
|
||||
<style>
|
||||
body { font-family: Tahoma, Arial, sans-serif; margin: 24px; color: #111; }
|
||||
h1 { font-size: 18px; margin: 0 0 8px; }
|
||||
.summary { font-size: 12px; color: #555; margin-bottom: 16px; line-height: 1.8; }
|
||||
table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
||||
th, td { border: 1px solid #ddd; padding: 8px; text-align: right; }
|
||||
th { background: #f5f5f5; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>${title}</h1>
|
||||
${summary.length ? `<div class="summary">${summary.map((line) => `<div>${line}</div>`).join('')}</div>` : ''}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
${CSV_HEADERS.map((header) => `<th>${header}</th>`).join('')}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>${tableRows}</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
const printWindow = window.open('', '_blank')
|
||||
if (!printWindow) return
|
||||
|
||||
printWindow.document.open()
|
||||
printWindow.document.write(html)
|
||||
printWindow.document.close()
|
||||
printWindow.focus()
|
||||
window.setTimeout(() => {
|
||||
printWindow.print()
|
||||
printWindow.close()
|
||||
}, 300)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import type { Giftcard } from '@/model/giftCard'
|
||||
|
||||
export function resolveGiftCardCustomer(giftCard?: Giftcard | null) {
|
||||
if (!giftCard) return null
|
||||
|
||||
const name = giftCard.customer?.name ?? giftCard.name
|
||||
const mobile = giftCard.customer?.mobile ?? giftCard.mobile
|
||||
|
||||
if (name || mobile) {
|
||||
return {
|
||||
name: name || '-',
|
||||
mobile: mobile || '-',
|
||||
}
|
||||
}
|
||||
|
||||
if (giftCard.customer_id) {
|
||||
return {
|
||||
name: `مشتری #${giftCard.customer_id}`,
|
||||
mobile: '-',
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export function giftCardCustomerLabel(giftCard?: Giftcard | null) {
|
||||
return resolveGiftCardCustomer(giftCard)?.name ?? '— (کد عمومی)'
|
||||
}
|
||||
|
||||
export function giftCardCustomerMobile(giftCard?: Giftcard | null) {
|
||||
return resolveGiftCardCustomer(giftCard)?.mobile ?? '-'
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title>
|
||||
<span>مشخصات</span>
|
||||
</template>
|
||||
@@ -50,6 +50,9 @@ import { getOrderTable } from '@/api/order'
|
||||
import OrderMobileCardList from './OrderMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { ordersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -182,7 +182,7 @@ export function orderFeeBaseTotal(order: Order): number {
|
||||
}
|
||||
}
|
||||
const stored = Math.round(Math.abs(Number(order.total_price_original ?? 0)))
|
||||
// اگر فقط مظنهٔ واحد ذخیره شده (نه جمع)، از حاصلضرب استفاده کن
|
||||
// اگر فقط قیمت واحد ذخیره شده (نه جمع)، از حاصلضرب استفاده کن
|
||||
if (stored > 0 && !looksLikeUnitPriceAsTotal(stored, perUnit, amount)) {
|
||||
return stored
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<a-tooltip v-if="canAdjust(record)">
|
||||
<a-tooltip v-if="can('amount') && canAdjust(record)">
|
||||
<template #title>ویرایش مقدار</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit-2"
|
||||
@@ -22,7 +22,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip v-if="canApprove(record)">
|
||||
<a-tooltip v-if="can('approve') && canApprove(record)">
|
||||
<template #title>{{ physicalWithdrawApproveHelp }}</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:tick-circle"
|
||||
@@ -33,7 +33,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
|
||||
<ADropdown v-if="canChangeStatus(record)" :trigger="['click']">
|
||||
<ADropdown v-if="can('status') && canChangeStatus(record)" :trigger="['click']">
|
||||
<a-tooltip>
|
||||
<template #title>{{ physicalWithdrawStatusHelp }}</template>
|
||||
<Icon icon="vuesax-linear:status-up" color="#CA8A04" class="cursor-pointer" />
|
||||
@@ -53,7 +53,7 @@
|
||||
</template>
|
||||
</ADropdown>
|
||||
|
||||
<a-tooltip v-if="record.sts >= 50 && record.sts <= 70">
|
||||
<a-tooltip v-if="can('factor') && record.sts >= 50 && record.sts <= 70">
|
||||
<template #title>دریافت فاکتور</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:document-download"
|
||||
@@ -92,6 +92,9 @@ import {
|
||||
physicalWithdrawPageIntro,
|
||||
physicalWithdrawStatusHelp
|
||||
} from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const emits = defineEmits(['add'])
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
:items="productItems"
|
||||
key-name="id"
|
||||
value-name="label"
|
||||
placeholder="آبشده، سکه، نقره و ..."
|
||||
placeholder="کاتد مس، مفتول مس و..."
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -20,7 +20,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||
@@ -29,7 +29,7 @@
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -52,6 +52,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { cols } from '../hooks/priceTriggersColumns'
|
||||
import { getPriceTriggersTable } from '@/api/priceTriggers'
|
||||
import { priceTriggersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('detail', record)">
|
||||
<a-tooltip v-if="can('details')" placement="bottom" class="cursor-pointer" @click="emits('detail', record)">
|
||||
<template #title>
|
||||
<span>جزئیات محصولات</span>
|
||||
</template>
|
||||
@@ -63,6 +63,9 @@ import PriceMobileCardList from './PriceMobileCardList.vue'
|
||||
import { pricingPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
defineProps<{ syncing?: boolean }>()
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<span class="truncate text-sm font-700 text-gray-900">{{ item.title || '-' }}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<MobileIconButton icon="vuesax-linear:archive-slash" color="#e3bf00" @click="$emit('unarchive', item)" />
|
||||
<MobileIconButton icon="vuesax-linear:stickynote" color="#10913A" @click="$emit('info', item)" />
|
||||
<MobileIconButton v-if="can('restore')" icon="vuesax-linear:archive-slash" color="#e3bf00" @click="$emit('unarchive', item)" />
|
||||
<MobileIconButton v-if="can('info')" icon="vuesax-linear:stickynote" color="#10913A" @click="$emit('info', item)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,6 +32,9 @@ import type { Product } from '@/model/product'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
defineProps<{
|
||||
item: Product
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer">
|
||||
<a-tooltip v-if="can('restore')" placement="bottom" class="cursor-pointer">
|
||||
<template #title>
|
||||
<span>بیرون بردن از بایگانی</span>
|
||||
</template>
|
||||
@@ -26,7 +26,7 @@
|
||||
</a-popconfirm>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title>
|
||||
<span>مشخصات</span>
|
||||
</template>
|
||||
@@ -56,6 +56,9 @@ import { getProductArchiveColumns } from '../hooks/archiveColumns'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
|
||||
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const productArchiveHelp: DashboardHelp = {
|
||||
description:
|
||||
|
||||
@@ -99,7 +99,7 @@ watch(
|
||||
const formulaWeight = computed(() => resolveFormulaWeight(props.productAmount))
|
||||
|
||||
const formulaHelp = computed((): DashboardHelp => ({
|
||||
description: 'قیمت از فرمول و مظنه مرجع محاسبه میشود.',
|
||||
description: 'قیمت از فرمول و قیمت مرجع محاسبه میشود.',
|
||||
}))
|
||||
|
||||
const computedProductPrice = computed(() =>
|
||||
|
||||
@@ -481,6 +481,16 @@
|
||||
</template>
|
||||
<BasicInput v-model:value="form.inventory" type="number" />
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
v-if="shayeganEnabled"
|
||||
name="shayegan_item_number"
|
||||
class="!mb-0 md:col-span-2"
|
||||
>
|
||||
<template #label>
|
||||
<DashboardLabelWithHelp label="کد کالای شایگان (ItemNumber)" :help="shayeganItemHelp" size="sm" />
|
||||
</template>
|
||||
<BasicInput v-model:value="form.shayegan_item_number" placeholder="مثلاً 200000010" />
|
||||
</a-form-item>
|
||||
<div
|
||||
v-if="weightOption === '1' && !isMeltedGroup && form.amount && form.amount < 1 && 0 < form.amount && tradeWeightUnit === 'گرم'"
|
||||
class="flex items-end pb-1 text-sm text-gray-500"
|
||||
@@ -496,11 +506,19 @@
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<div class="product-visibility-panel">
|
||||
<div class="product-visibility-row">
|
||||
<span class="text-sm">نمایش در لیست محصولات</span>
|
||||
<DashboardLabelWithHelp
|
||||
label="نمایش در لیست محصولات"
|
||||
:help="showInListHelp"
|
||||
size="sm"
|
||||
/>
|
||||
<a-switch v-model:checked="form.show_in_list" />
|
||||
</div>
|
||||
<div class="product-visibility-row">
|
||||
<span class="text-sm">نمایش در تابلو TV</span>
|
||||
<DashboardLabelWithHelp
|
||||
label="نمایش در تابلو TV"
|
||||
:help="showOnTvHelp"
|
||||
size="sm"
|
||||
/>
|
||||
<a-switch v-model:checked="form.show_on_tv" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -682,6 +700,7 @@ import { inputRules, inputRulesNumber, requiredPriceRules } from '@/utils/inputR
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import IndexImageUploader from '@/components/ProductUploader/IndexImageUploader.vue'
|
||||
import { getConfiguration } from '@/api/configuration'
|
||||
import { shayeganEnabledSetting } from '@/utils/config'
|
||||
import { isSwitchOn } from '@/pages/menuPages/configuration/settingTypes'
|
||||
import type { last } from '@/model/price'
|
||||
import type { MethodePrices } from '@/model/product'
|
||||
@@ -759,22 +778,29 @@ const inventoryHelp: DashboardHelp = {
|
||||
description: 'تعداد موجودی فروشگاه (فقط حالت فروشگاه).',
|
||||
}
|
||||
|
||||
const shayeganItemHelp: DashboardHelp = {
|
||||
description:
|
||||
'کد کالا (ItemNumber) در شایگان برای فاکتور همین محصول. خالی = fallback از تنظیم «کد کالای مس».',
|
||||
}
|
||||
|
||||
const cashFeeBuyHelp: DashboardHelp = {
|
||||
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
||||
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از قیمت.',
|
||||
formula: 'نقدی: +۱۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۵٪ از قیمت پایه',
|
||||
}
|
||||
|
||||
const cashFeeSellHelp: DashboardHelp = {
|
||||
description: 'مبلغ کسر از قیمت پایه برای فروش — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
||||
description: 'مبلغ کسر از قیمت پایه برای فروش — نقدی (ریال ثابت) یا درصدی از قیمت.',
|
||||
formula: 'نقدی: −۲۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۱۰٪ از قیمت پایه',
|
||||
}
|
||||
|
||||
const showOnTvHelp: DashboardHelp = {
|
||||
description: 'روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده میشود.',
|
||||
description:
|
||||
'مستقل از لیست محصولات است. روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده میشود؛ حتی اگر در لیست محصولات خاموش باشد.',
|
||||
}
|
||||
|
||||
const showInListHelp: DashboardHelp = {
|
||||
description: 'روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده میشود.',
|
||||
description:
|
||||
'مستقل از تابلو TV است. روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده میشود. همان آیکون تیک/ضربدر در ستون عملیات همین وضعیت را عوض میکند.',
|
||||
}
|
||||
|
||||
const autoOpenHelp: DashboardHelp = {
|
||||
@@ -858,6 +884,7 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
const isStore = ref(Boolean(props.isStore))
|
||||
const shayeganEnabled = shayeganEnabledSetting
|
||||
|
||||
const tradeWeightUnit = ref('گرم')
|
||||
/** دسته آبشده/کاتد — ساختار فرم ثابت است */
|
||||
@@ -945,6 +972,7 @@ watch(
|
||||
props.form.price_formula_enabled = false
|
||||
props.form.reading_method = null
|
||||
props.form.price_offset_percent = 0
|
||||
props.form.direct_price = 1
|
||||
} else if (option === '3') {
|
||||
// قیمت اپ: مرجع خارجی ندارد، متغیر (هر گرم × وزن)
|
||||
props.form.reading_method = null
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user