Compare commits
29
Commits
4d8d35c37d
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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']
|
PargarRetryModal: typeof import('./src/components/PargarRetryModal.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
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']
|
SmsCreditWidget: typeof import('./src/components/SmsCreditWidget.vue')['default']
|
||||||
SmsNegativeBalanceHost: typeof import('./src/components/SmsNegativeBalanceHost.vue')['default']
|
SmsNegativeBalanceHost: typeof import('./src/components/SmsNegativeBalanceHost.vue')['default']
|
||||||
SmsNegativeBalanceModal: typeof import('./src/components/SmsNegativeBalanceModal.vue')['default']
|
SmsNegativeBalanceModal: typeof import('./src/components/SmsNegativeBalanceModal.vue')['default']
|
||||||
SubscriptionExpiryHost: typeof import('./src/components/SubscriptionExpiryHost.vue')['default']
|
SubscriptionExpiryHost: typeof import('./src/components/SubscriptionExpiryHost.vue')['default']
|
||||||
SubscriptionExpiryModal: typeof import('./src/components/SubscriptionExpiryModal.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']
|
TahesabRetryModal: typeof import('./src/components/TahesabRetryModal.vue')['default']
|
||||||
ThemeMenuSection: typeof import('./src/core/components/ThemeMenuSection.vue')['default']
|
ThemeMenuSection: typeof import('./src/core/components/ThemeMenuSection.vue')['default']
|
||||||
ThemeToggle: typeof import('./src/core/components/ThemeToggle.vue')['default']
|
ThemeToggle: typeof import('./src/core/components/ThemeToggle.vue')['default']
|
||||||
|
|||||||
+13
@@ -2,7 +2,9 @@
|
|||||||
<AConfigProvider direction="rtl">
|
<AConfigProvider direction="rtl">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
<CustomerImportProgress />
|
<CustomerImportProgress />
|
||||||
|
<TahesabDocSyncProgress />
|
||||||
<GroupSmsSendProgress />
|
<GroupSmsSendProgress />
|
||||||
|
<ShayeganChargeAlertHost />
|
||||||
</AConfigProvider>
|
</AConfigProvider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -12,8 +14,11 @@ import { message } from 'ant-design-vue'
|
|||||||
import { useConfigStore } from '@/store/configStore'
|
import { useConfigStore } from '@/store/configStore'
|
||||||
import { initDarkmode } from '@core/stores/darkmode'
|
import { initDarkmode } from '@core/stores/darkmode'
|
||||||
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
||||||
|
import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue'
|
||||||
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
||||||
|
import ShayeganChargeAlertHost from '@/components/ShayeganChargeAlertHost.vue'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||||
|
|
||||||
@@ -64,7 +69,15 @@ watch(latestIncomingNotification, (payload) => {
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await config.getConfigData()
|
await config.getConfigData()
|
||||||
|
void useTahesabDocSyncStore().hydrate()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => userStore.userInfo?.id,
|
||||||
|
(id) => {
|
||||||
|
if (id) void useTahesabDocSyncStore().hydrate()
|
||||||
|
},
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less"></style>
|
<style lang="less"></style>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ export type CategoryListParams = {
|
|||||||
export const getCategories = async (params?: CategoryListParams) =>
|
export const getCategories = async (params?: CategoryListParams) =>
|
||||||
await useAxios.get<Category[]>('/admin/categories', { params })
|
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>) =>
|
export const updateCategory = async (id: number, payload: Partial<CategoryInput>) =>
|
||||||
await useAxios.put<Category>(`/admin/categories/${id}`, payload)
|
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) =>
|
export const getGiftCardTable = async (params: TableInput) =>
|
||||||
await useAxios.post<Array<Giftcard>>('/admin/giftcard/table', params)
|
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) =>
|
export const createGiftCard = async (obj: GiftcardInput) =>
|
||||||
await useAxios.post<Giftcard>(`/admin/giftcard/generate`, obj)
|
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) => {
|
export const changeActiveProduct = async (id: number) => {
|
||||||
return await useAxios.get(`/admin/product/active/${id}`)
|
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) => {
|
export const changeVisibilityProduct = async (id: number) => {
|
||||||
return await useAxios.get(`/admin/product/hide/${id}`)
|
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) =>
|
export const retryTahesabSanad = async (id: number) =>
|
||||||
await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`)
|
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 {
|
export interface TahesabPendingSummary {
|
||||||
failed_rows: number
|
failed_rows: number
|
||||||
missing_withdraws: number
|
missing_withdraws: number
|
||||||
missing_orders: number
|
missing_orders: number
|
||||||
total: number
|
total: number
|
||||||
|
doc_sync?: TahesabDocSyncState
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TahesabSyncAllResult {
|
export interface TahesabSyncAllResult {
|
||||||
@@ -71,6 +91,34 @@ export const syncAllTahesabPending = async (limit = 80, customerId?: number) =>
|
|||||||
...(customerId ? { customer_id: customerId } : {})
|
...(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) =>
|
export const registerCustomerInTahesab = async (customerId: number) =>
|
||||||
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
|
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
|
||||||
`/admin/customer/${customerId}/tahesab/register`
|
`/admin/customer/${customerId}/tahesab/register`
|
||||||
@@ -129,6 +177,7 @@ export interface CustomerSyncStatus {
|
|||||||
last_page: number
|
last_page: number
|
||||||
total: number
|
total: number
|
||||||
}
|
}
|
||||||
|
doc_sync?: TahesabDocSyncState
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCustomerSyncStatus = async (params?: {
|
export const getCustomerSyncStatus = async (params?: {
|
||||||
@@ -205,13 +254,20 @@ export interface TahesabWalletSyncResult {
|
|||||||
/** همگامسازی مانده یک مشتری با تهحساب */
|
/** همگامسازی مانده یک مشتری با تهحساب */
|
||||||
export const syncCustomerWalletFromTahesab = async (
|
export const syncCustomerWalletFromTahesab = async (
|
||||||
customerId: number,
|
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>(
|
await useAxios.post<TahesabWalletSyncResult>(
|
||||||
`/admin/customer/${customerId}/tahesab/sync-wallet`,
|
`/admin/customer/${customerId}/tahesab/sync-wallet`,
|
||||||
{
|
{
|
||||||
overwrite: opts?.overwrite ?? false,
|
overwrite: opts?.overwrite ?? false,
|
||||||
keep: opts?.keep ?? false,
|
keep: opts?.keep ?? false,
|
||||||
|
push_to_tahesab: opts?.push_to_tahesab ?? false,
|
||||||
ask_if_conflict: opts?.ask_if_conflict ?? true,
|
ask_if_conflict: opts?.ask_if_conflict ?? true,
|
||||||
always_ask: opts?.always_ask ?? false,
|
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) =>
|
export const completeWithdraw = async (params: Withdraw) =>
|
||||||
await useAxios.post<boolean>('/admin/wallet/withdraw/complete', params)
|
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) => {
|
export const updateSts = async (id: number, sts: Object) => {
|
||||||
return await useAxios.put(`/admin/wallet/withdraw/${id}`, sts)
|
return await useAxios.put(`/admin/wallet/withdraw/${id}`, sts)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
import { defineProps } from 'vue'
|
import { defineProps } from 'vue'
|
||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
menu: RouteRecordRaw[]
|
menu: RouteRecordRaw[]
|
||||||
@@ -30,7 +31,7 @@ interface Prop {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
function handleClickMenu(item: RouteRecordRaw) {
|
function handleClickMenu(item: RouteRecordRaw) {
|
||||||
//debugger
|
if (!confirmMenuAccess(item.name)) return
|
||||||
router.push({ name: item.name })
|
router.push({ name: item.name })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<AMenu
|
<AMenu
|
||||||
v-model:selectedKeys="selectedKeys"
|
:selectedKeys="selectedKeys"
|
||||||
:style="{ width: props.width }"
|
:style="{ width: props.width }"
|
||||||
:mode="props.mode"
|
:mode="props.mode"
|
||||||
:theme="resolvedTheme"
|
:theme="resolvedTheme"
|
||||||
@@ -49,10 +49,13 @@ const props = withDefaults(defineProps<Prop>(), {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const resolvedTheme = computed(() => props.theme ?? menuTheme.value)
|
const resolvedTheme = computed(() => props.theme ?? menuTheme.value)
|
||||||
onMounted(() => {
|
watch(
|
||||||
selectedKeys.value = [router.currentRoute.value.name as string]
|
() => router.currentRoute.value.name,
|
||||||
//emits('onChange', '1')
|
(name) => {
|
||||||
})
|
selectedKeys.value = name ? [String(name)] : []
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import BasicMobileOverflowMenu from '@/components/BasicMobileOverflowMenu.vue'
|
|||||||
import { sortBy } from 'lodash'
|
import { sortBy } from 'lodash'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
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']
|
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') {
|
if (item.name === 'support' || item.meta?.permissionsKey === 'support') {
|
||||||
return supportChatMenuEnabledSetting.value
|
return supportChatMenuEnabledSetting.value
|
||||||
}
|
}
|
||||||
|
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||||
return true
|
return true
|
||||||
}),
|
}),
|
||||||
(item) => item.meta?.order
|
(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">
|
<div class="customer-wallet-balance__detail-group-title">
|
||||||
<span class="customer-wallet-balance__group-dot" aria-hidden="true" />
|
<span class="customer-wallet-balance__group-dot" aria-hidden="true" />
|
||||||
<span>{{ metal.label }}</span>
|
<span>{{ minimalMetalLabel(metal) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="line in linesForMetal(metal.metal_id)"
|
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() {
|
function inventoryCards() {
|
||||||
if (!summary.value) return [] as WalletInventoryCard[]
|
return uniqueInventoryCards()
|
||||||
return [...(summary.value.inventory_cards ?? []), ...(summary.value.count_products ?? [])]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCountChargeTarget(target: ChargeTarget) {
|
function isCountChargeTarget(target: ChargeTarget) {
|
||||||
@@ -310,22 +322,33 @@ function formatCard(card: WalletInventoryCard) {
|
|||||||
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'گرم'}`
|
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'گرم'}`
|
||||||
}
|
}
|
||||||
|
|
||||||
function linesForMetal(metalId: number) {
|
function formatMetalGroupTotal(metalId: number, metalCards: WalletInventoryCard[], metal?: WalletMetalTotal) {
|
||||||
const cards = summary.value?.inventory_cards ?? []
|
const allCount = metalCards.length > 0 && metalCards.every((card) => card.display_type === 'count')
|
||||||
const countCards = summary.value?.count_products ?? []
|
if (allCount) {
|
||||||
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
|
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]
|
function linesForMetal(metalId: number) {
|
||||||
.filter((card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0)
|
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
|
||||||
.map((card) => ({
|
const metalCards = uniqueInventoryCards().filter(
|
||||||
key: `card-${card.product_id}`,
|
(card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0
|
||||||
label: card.title,
|
)
|
||||||
value: formatCard(card)
|
|
||||||
}))
|
const productLines = metalCards.map((card) => ({
|
||||||
|
key: `card-${card.product_id}`,
|
||||||
|
label: card.title,
|
||||||
|
value: formatCard(card)
|
||||||
|
}))
|
||||||
|
|
||||||
const lines: Array<{ key: string; label: string; value: string }> = [...productLines]
|
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({
|
lines.push({
|
||||||
key: 'melted',
|
key: 'melted',
|
||||||
label: 'موجودی آبشده / کیف اصلی',
|
label: 'موجودی آبشده / کیف اصلی',
|
||||||
@@ -333,11 +356,11 @@ function linesForMetal(metalId: number) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metal && lines.length > 1) {
|
if (lines.length > 0) {
|
||||||
lines.push({
|
lines.push({
|
||||||
key: 'total',
|
key: 'total',
|
||||||
label: 'مجموع',
|
label: `مجموع ${minimalMetalLabel(metal ?? { metal_id: metalId } as WalletMetalTotal)}`,
|
||||||
value: formatMetalTotal(metal)
|
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">
|
<script setup lang="ts">
|
||||||
import { menuIconSize } from '@root/config'
|
import { menuIconSize } from '@root/config'
|
||||||
import type { RouteRecordRaw } from 'vue-router'
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
|
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -25,6 +26,7 @@ interface Props {
|
|||||||
const props = withDefaults(defineProps<Props>(), {})
|
const props = withDefaults(defineProps<Props>(), {})
|
||||||
|
|
||||||
async function handleClickMenuItem(item: RouteRecordRaw) {
|
async function handleClickMenuItem(item: RouteRecordRaw) {
|
||||||
|
if (!confirmMenuAccess(item.name)) return
|
||||||
router.push({ name: item.name })
|
router.push({ name: item.name })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<AMenu
|
<AMenu
|
||||||
:mode="layoutStore.sideMenu.mode"
|
:mode="layoutStore.sideMenu.mode"
|
||||||
:theme="menuTheme"
|
:theme="menuTheme"
|
||||||
v-model:selectedKeys="selectedKeys"
|
:selectedKeys="selectedKeys"
|
||||||
>
|
>
|
||||||
<template v-for="item in menu">
|
<template v-for="item in menu">
|
||||||
<BasicSubMenu
|
<BasicSubMenu
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
import type { ComputedRef } from 'vue'
|
import type { ComputedRef } from 'vue'
|
||||||
import { sortBy } from 'lodash'
|
import { sortBy } from 'lodash'
|
||||||
import { usePrefix } from '@core/composable/usePrefix'
|
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 type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import { useAdminTheme } from '@core/composable/useAdminTheme'
|
import { useAdminTheme } from '@core/composable/useAdminTheme'
|
||||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
import { hasLandingSetting, supportChatMenuEnabledSetting } from '@/utils/config'
|
||||||
|
|
||||||
const { prefixCls } = usePrefix('basic-menu')
|
const { prefixCls } = usePrefix('basic-menu')
|
||||||
const layoutStore = useLayoutStore()
|
const layoutStore = useLayoutStore()
|
||||||
@@ -45,29 +45,28 @@ const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
|||||||
const routerStore = useRouterStore()
|
const routerStore = useRouterStore()
|
||||||
const { menuTheme } = useAdminTheme()
|
const { menuTheme } = useAdminTheme()
|
||||||
|
|
||||||
const path: (RouteRecordName | undefined)[] = []
|
function syncSelectedKeys() {
|
||||||
|
const path: (RouteRecordName | undefined)[] = []
|
||||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
function walkInRoutes(routes: RouteRecordRaw[]): boolean {
|
||||||
for (const route of routes) {
|
for (const route of routes) {
|
||||||
if (route.name == currentRoute.name) {
|
if (route.name == currentRoute.name) {
|
||||||
path.push(route.name)
|
path.push(route.name)
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (route.children && route.children.length > 0) {
|
|
||||||
path.push(route.name)
|
|
||||||
const res = walkInRoutes(route.children)
|
|
||||||
if (!res) {
|
|
||||||
path.pop()
|
|
||||||
} else {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if (route.children && route.children.length > 0) {
|
||||||
|
path.push(route.name)
|
||||||
|
const res = walkInRoutes(route.children)
|
||||||
|
if (!res) path.pop()
|
||||||
|
else return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return false
|
walkInRoutes(routerStore.routes)
|
||||||
|
selectedKeys.value = path
|
||||||
}
|
}
|
||||||
|
|
||||||
walkInRoutes(routerStore.routes)
|
watch(() => currentRoute.name, syncSelectedKeys, { immediate: true })
|
||||||
selectedKeys.value = path
|
|
||||||
|
|
||||||
function isSupportMenuRoute(item: RouteRecordRaw): boolean {
|
function isSupportMenuRoute(item: RouteRecordRaw): boolean {
|
||||||
return item.name === 'support' || item.meta?.permissionsKey === 'support'
|
return item.name === 'support' || item.meta?.permissionsKey === 'support'
|
||||||
@@ -79,6 +78,7 @@ const menu: ComputedRef<RouteRecordRaw[]> = computed(() => {
|
|||||||
}).filter((item) => {
|
}).filter((item) => {
|
||||||
if (item.meta?.hideMenu) return false
|
if (item.meta?.hideMenu) return false
|
||||||
if (isSupportMenuRoute(item)) return supportChatMenuEnabledSetting.value
|
if (isSupportMenuRoute(item)) return supportChatMenuEnabledSetting.value
|
||||||
|
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
showServerUnavailableOverlay,
|
showServerUnavailableOverlay,
|
||||||
} from '@/utils/serverUnavailable'
|
} from '@/utils/serverUnavailable'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
|
import { mutationBlockMessage } from '@/utils/adminPageAccess'
|
||||||
|
import { readAdminAccessState } from '@/utils/adminAccessState'
|
||||||
//import { isToken } from '@/utils/is'
|
//import { isToken } from '@/utils/is'
|
||||||
//import router from '@/router'
|
//import router from '@/router'
|
||||||
//import { getToken, removeToken } from '@/utils/useUtility'
|
//import { getToken, removeToken } from '@/utils/useUtility'
|
||||||
@@ -58,6 +60,18 @@ _axios.interceptors.request.use(
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
config.headers['Authorization'] = 'Bearer ' + token
|
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
|
return config
|
||||||
},
|
},
|
||||||
@@ -77,6 +91,15 @@ _axios.interceptors.response.use(
|
|||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
async function (error) {
|
async function (error) {
|
||||||
|
const deniedText = String(error?.message || '')
|
||||||
|
if (
|
||||||
|
error?.pageAccessDenied ||
|
||||||
|
deniedText === 'شما به این صفحه دسترسی ندارید' ||
|
||||||
|
deniedText === 'شما مجوز ویرایش در این صفحه را ندارید' ||
|
||||||
|
deniedText === 'شما مجوز حذف در این صفحه را ندارید'
|
||||||
|
) {
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
//console.log('this is axios error', error)
|
//console.log('this is axios error', error)
|
||||||
/* if (error.response.data && error.response.data.code) {
|
/* if (error.response.data && error.response.data.code) {
|
||||||
@@ -109,7 +132,12 @@ _axios.interceptors.response.use(
|
|||||||
await router.push({ name: 'login' })
|
await router.push({ name: 'login' })
|
||||||
} else if (error.response && error.response.status == 403) {
|
} else if (error.response && error.response.status == 403) {
|
||||||
if (!error.config?.meta?.silent) {
|
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) {
|
} else if (error.response && error.response.status == 422) {
|
||||||
if (!error.config?.meta?.silent) {
|
if (!error.config?.meta?.silent) {
|
||||||
|
|||||||
+30
-2
@@ -14,6 +14,14 @@ import { setupRoutes } from '@/router'
|
|||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { setupPinia } from '@core/plugins/pinia'
|
import { setupPinia } from '@core/plugins/pinia'
|
||||||
import { initStoreModeFromSettings } from '@/utils/config'
|
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 init = async () => {
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
@@ -57,9 +65,29 @@ const init = async () => {
|
|||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (token) {
|
if (token) {
|
||||||
if (to.name == 'login') {
|
if (to.name == 'login') {
|
||||||
return next({ name: 'dashboard' })
|
return next({ name: firstAllowedRouteName() || 'dashboardMain' })
|
||||||
}
|
}
|
||||||
return next()
|
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 {
|
} else {
|
||||||
if (['login', '404'].includes(to.name as string)) {
|
if (['login', '404'].includes(to.name as string)) {
|
||||||
return next()
|
return next()
|
||||||
|
|||||||
+17
-2
@@ -1,6 +1,16 @@
|
|||||||
|
export interface GiftcardCustomer {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
mobile: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface Giftcard {
|
export interface Giftcard {
|
||||||
id: number
|
id: number
|
||||||
customer_id: any
|
customer_id: any
|
||||||
|
name?: string
|
||||||
|
mobile?: string
|
||||||
|
customer?: GiftcardCustomer
|
||||||
|
show_in_app?: number | boolean
|
||||||
count: number
|
count: number
|
||||||
amount: number
|
amount: number
|
||||||
total: number
|
total: number
|
||||||
@@ -35,9 +45,14 @@ export interface AssignedTo {
|
|||||||
mobile: string
|
mobile: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type GiftCardAssignMode = 'customer' | 'public'
|
||||||
|
|
||||||
export interface GiftcardInput {
|
export interface GiftcardInput {
|
||||||
mobile: string
|
assignMode: GiftCardAssignMode
|
||||||
name: string
|
customer_id?: number
|
||||||
|
show_in_app?: number
|
||||||
|
mobile?: string
|
||||||
|
name?: string
|
||||||
count: number
|
count: number
|
||||||
amount: number
|
amount: number
|
||||||
unit: string
|
unit: string
|
||||||
|
|||||||
+5
-1
@@ -1,4 +1,5 @@
|
|||||||
import type { Const } from '@/model/const'
|
import type { Const } from '@/model/const'
|
||||||
|
import type { PageAccessMap } from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
active?: boolean
|
active?: boolean
|
||||||
@@ -12,13 +13,16 @@ export interface User {
|
|||||||
lname?: string
|
lname?: string
|
||||||
mobile?: number
|
mobile?: number
|
||||||
name?: string
|
name?: string
|
||||||
|
n_code?: string
|
||||||
sts?: number
|
sts?: number
|
||||||
token_sms?: string
|
token_sms?: string
|
||||||
user_type?: string
|
user_type?: string
|
||||||
send_sms?:boolean
|
send_sms?: boolean
|
||||||
settings?: Const[]
|
settings?: Const[]
|
||||||
sms_billing_enabled?: boolean
|
sms_billing_enabled?: boolean
|
||||||
sms_panel_access?: boolean
|
sms_panel_access?: boolean
|
||||||
|
/** null = دسترسی کامل */
|
||||||
|
page_access?: PageAccessMap | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddId {
|
export interface AddId {
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ export interface Withdraw {
|
|||||||
date_at?: string
|
date_at?: string
|
||||||
sts?: number
|
sts?: number
|
||||||
type?: number
|
type?: number
|
||||||
|
receipt?: string | null
|
||||||
|
receipt_url?: string | null
|
||||||
|
deposit_identifier?: string | null
|
||||||
|
reject_reason?: string | null
|
||||||
bank_account_id?: number | null
|
bank_account_id?: number | null
|
||||||
created_at?: string
|
created_at?: string
|
||||||
updated_at?: string
|
updated_at?: string
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ import OtpInput from 'vue3-otp-input'
|
|||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
import { setupRoutes } from '@/router'
|
import { setupRoutes } from '@/router'
|
||||||
import { getConfigApp, initStoreModeFromSettings } from '@/utils/config'
|
import { getConfigApp, initStoreModeFromSettings } from '@/utils/config'
|
||||||
|
import { firstAllowedRouteName } from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
//define emit
|
//define emit
|
||||||
const emits = defineEmits(['enter'])
|
const emits = defineEmits(['enter'])
|
||||||
@@ -175,7 +176,12 @@ const onUserPassFormFinish = async () => {
|
|||||||
}*/
|
}*/
|
||||||
//router.removeRoute('usersMain')
|
//router.removeRoute('usersMain')
|
||||||
//router.removeRoute('users')
|
//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) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
/* if (e?.response.status === 422) {
|
/* if (e?.response.status === 422) {
|
||||||
|
|||||||
@@ -31,13 +31,11 @@ function enterTest() {
|
|||||||
.login-page__toggle {
|
.login-page__toggle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 16px;
|
top: 16px;
|
||||||
left: 16px;
|
inset-inline-start: 16px;
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
padding: 4px 10px 4px 6px;
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
background: var(--admin-bg-elevated);
|
background: var(--admin-bg-elevated);
|
||||||
border: 1px solid var(--admin-border);
|
border: 1px solid var(--admin-border);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="!row.pargar_ref && !row.customer?.pargar_account_id"
|
v-if="can('register') && !row.pargar_ref && !row.customer?.pargar_account_id"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:profile-add"
|
icon="vuesax-linear:profile-add"
|
||||||
color="#7C3AED"
|
color="#7C3AED"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
@click="$emit('register-customer', row)"
|
@click="$emit('register-customer', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="canRetry(row)"
|
v-if="can('send') && canRetry(row)"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:refresh-circle"
|
icon="vuesax-linear:refresh-circle"
|
||||||
color="#CA8A04"
|
color="#CA8A04"
|
||||||
@@ -88,6 +88,9 @@ import {
|
|||||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<TahesabDocSyncBox />
|
||||||
|
|
||||||
<!-- ─── تبها ─── -->
|
<!-- ─── تبها ─── -->
|
||||||
<div class="cs-tabs">
|
<div class="cs-tabs">
|
||||||
<button
|
<button
|
||||||
@@ -103,8 +105,8 @@
|
|||||||
<a-button
|
<a-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="syncingPanel"
|
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_out')"
|
||||||
:disabled="!status?.panel_only"
|
:disabled="!status?.panel_only && !docSyncStore.active"
|
||||||
@click="syncAllPanel"
|
@click="syncAllPanel"
|
||||||
>
|
>
|
||||||
<template #icon><Icon icon="vuesax-linear:send-2" :size="13" /></template>
|
<template #icon><Icon icon="vuesax-linear:send-2" :size="13" /></template>
|
||||||
@@ -241,11 +243,15 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
<a-button
|
<a-button
|
||||||
size="small"
|
size="small"
|
||||||
:loading="importStore.active"
|
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_in')"
|
||||||
:disabled="!importableCount"
|
:disabled="!importableCount && !docSyncStore.active"
|
||||||
@click="importAll"
|
@click="importAll"
|
||||||
>
|
>
|
||||||
{{ importStore.active ? 'در حال…' : `وارد کردن همه (${importableCount})` }}
|
{{
|
||||||
|
docSyncStore.active && docSyncStore.stage === 'customers_in'
|
||||||
|
? 'در حال…'
|
||||||
|
: `وارد کردن همه (${importableCount})`
|
||||||
|
}}
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -362,7 +368,6 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
|||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import {
|
import {
|
||||||
getCustomerSyncStatus,
|
getCustomerSyncStatus,
|
||||||
syncPanelToTahesab,
|
|
||||||
importFromTahesab,
|
importFromTahesab,
|
||||||
registerCustomerInTahesab,
|
registerCustomerInTahesab,
|
||||||
linkTahesabMatchingPhones,
|
linkTahesabMatchingPhones,
|
||||||
@@ -372,12 +377,13 @@ import {
|
|||||||
type TahesabOnlyCustomer,
|
type TahesabOnlyCustomer,
|
||||||
type SyncPanelResult,
|
type SyncPanelResult,
|
||||||
} from '@/api/tahesab'
|
} from '@/api/tahesab'
|
||||||
import { useCustomerImportStore } from '@/store/customerImportStore'
|
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||||
import ColleagueAccountingAccounts from '@/pages/menuPages/colleagueOrders/components/ColleagueAccountingAccounts.vue'
|
import ColleagueAccountingAccounts from '@/pages/menuPages/colleagueOrders/components/ColleagueAccountingAccounts.vue'
|
||||||
|
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||||
import { accountingTahesabCustomerSyncIntro } from '@/utils/adminHelpCopy'
|
import { accountingTahesabCustomerSyncIntro } from '@/utils/adminHelpCopy'
|
||||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||||
|
|
||||||
const importStore = useCustomerImportStore()
|
const docSyncStore = useTahesabDocSyncStore()
|
||||||
|
|
||||||
// ─── state ───
|
// ─── state ───
|
||||||
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
|
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
|
||||||
@@ -505,6 +511,7 @@ async function load(panelPage = 1) {
|
|||||||
} else {
|
} else {
|
||||||
status.value = res
|
status.value = res
|
||||||
}
|
}
|
||||||
|
docSyncStore.apply(res.doc_sync)
|
||||||
panelList.value = res.panel_only_list.data
|
panelList.value = res.panel_only_list.data
|
||||||
panelPagination.value = {
|
panelPagination.value = {
|
||||||
page: res.panel_only_list.current_page,
|
page: res.panel_only_list.current_page,
|
||||||
@@ -534,6 +541,7 @@ async function loadTahesab() {
|
|||||||
} else {
|
} else {
|
||||||
status.value = res
|
status.value = res
|
||||||
}
|
}
|
||||||
|
docSyncStore.apply(res.doc_sync)
|
||||||
tahesabOnlyList.value = res.tahesab_only_list?.data ?? []
|
tahesabOnlyList.value = res.tahesab_only_list?.data ?? []
|
||||||
mandeFetched.clear()
|
mandeFetched.clear()
|
||||||
tahesabFetched.value = true
|
tahesabFetched.value = true
|
||||||
@@ -556,6 +564,7 @@ async function loadPanel(page = 1) {
|
|||||||
status.value.panel_registered = res.panel_registered
|
status.value.panel_registered = res.panel_registered
|
||||||
status.value.panel_only = res.panel_only
|
status.value.panel_only = res.panel_only
|
||||||
}
|
}
|
||||||
|
docSyncStore.apply(res.doc_sync)
|
||||||
panelList.value = res.panel_only_list.data
|
panelList.value = res.panel_only_list.data
|
||||||
panelPagination.value = {
|
panelPagination.value = {
|
||||||
page: res.panel_only_list.current_page,
|
page: res.panel_only_list.current_page,
|
||||||
@@ -592,18 +601,15 @@ async function registerOnePanel(customer: PanelOnlyCustomer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function syncAllPanel() {
|
async function syncAllPanel() {
|
||||||
syncingPanel.value = true
|
if (docSyncStore.active) {
|
||||||
panelSyncResult.value = null
|
docSyncStore.expand()
|
||||||
showPanelErrors.value = false
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await syncPanelToTahesab()
|
await docSyncStore.startOutbound()
|
||||||
panelSyncResult.value = res
|
} catch (e: any) {
|
||||||
if (res.success) message.success(`${res.success} مشتری ثبت شد`)
|
message.error(e?.response?.data?.message || e?.message || 'شروع ثبت ناموفق بود')
|
||||||
if (res.failed) message.warning(`${res.failed} مشتری ثبت نشد`)
|
}
|
||||||
await load(1)
|
|
||||||
panelDone.clear()
|
|
||||||
} catch { message.error('خطا در ارتباط با سرور') }
|
|
||||||
finally { syncingPanel.value = false }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── تب ۲: عملیات ───
|
// ─── تب ۲: عملیات ───
|
||||||
@@ -695,11 +701,15 @@ async function importSelected() {
|
|||||||
async function importAll() {
|
async function importAll() {
|
||||||
const pending = importableList.value
|
const pending = importableList.value
|
||||||
if (!pending.length) return
|
if (!pending.length) return
|
||||||
if (importStore.active) {
|
if (docSyncStore.active) {
|
||||||
importStore.expand()
|
docSyncStore.expand()
|
||||||
return
|
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() {
|
async function confirmLinkPhones() {
|
||||||
@@ -763,26 +773,21 @@ async function enrichPageMande() {
|
|||||||
|
|
||||||
watch([tahesabPage, tahesabSearch], () => { void enrichPageMande() })
|
watch([tahesabPage, tahesabSearch], () => { void enrichPageMande() })
|
||||||
|
|
||||||
// با پیشرفت عملیات سراسری، ردیفهای وارد شده را همینجا هم تیک بزن
|
watch(
|
||||||
watch(() => importStore.doneCodes.length, () => {
|
() => docSyncStore.finished,
|
||||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
async (done, wasDone) => {
|
||||||
})
|
if (!done || wasDone) return
|
||||||
|
await load(1)
|
||||||
// پس از پایان کامل، آمار و لیست را تازه کن
|
panelDone.clear()
|
||||||
watch(() => importStore.status, async (s, prev) => {
|
if (docSyncStore.stage === 'customers_in') {
|
||||||
if (prev === 'running' && (s === 'done' || s === 'canceled')) {
|
tahesabFetched.value = false
|
||||||
selectedTahesab.clear()
|
if (activeTab.value === 'tahesab') await loadTahesab()
|
||||||
if (status.value?.tahesab_only_count != null) {
|
|
||||||
status.value.tahesab_only_count = Math.max(0, status.value.tahesab_only_count - importStore.success)
|
|
||||||
}
|
}
|
||||||
await loadPanel(panelPagination.value.page)
|
},
|
||||||
}
|
)
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
load(1)
|
load(1)
|
||||||
// اگر عملیات سراسری در حال اجراست، ردیفهای انجامشده را همگام کن
|
|
||||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
|
||||||
})
|
})
|
||||||
</script>
|
</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">
|
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="!row.tahesab_id && !row.customer?.moshtari_code"
|
v-if="can('register') && !row.tahesab_id && !row.customer?.moshtari_code"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:profile-add"
|
icon="vuesax-linear:profile-add"
|
||||||
color="#7C3AED"
|
color="#7C3AED"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
@click="$emit('register-customer', row)"
|
@click="$emit('register-customer', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="canRetry(row)"
|
v-if="can('send') && canRetry(row)"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:refresh-circle"
|
icon="vuesax-linear:refresh-circle"
|
||||||
color="#CA8A04"
|
color="#CA8A04"
|
||||||
@@ -60,6 +60,9 @@ import {
|
|||||||
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<AdminFieldHelp :text="accountingTahesabBalanceSyncIntro" size="sm" />
|
<AdminFieldHelp :text="accountingTahesabBalanceSyncIntro" size="sm" />
|
||||||
</div>
|
</div>
|
||||||
<p class="tw-bulk__hint">
|
<p class="tw-bulk__hint">
|
||||||
همگام تکی: اول سندها و اختلاف را میبینید، بعد تأیید میکنید. دو مانده جمع نمیشوند.
|
همگام تکی: اول سندها و اختلاف را میبینید، بعد یکی از سه مسیر را تأیید میکنید (تهحساب→اپ، اپ→تهحساب حتی اگر اپ صفر باشد، یا نگه داشتن). دو مانده جمع نمیشوند.
|
||||||
همگام همه فقط کیف خالی را مینشاند؛ تداخل برای تصمیم دستی میماند.
|
همگام همه فقط کیف خالی را مینشاند؛ تداخل برای تصمیم دستی میماند.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,6 +154,7 @@
|
|||||||
<TahesabMandeDecisionModal
|
<TahesabMandeDecisionModal
|
||||||
v-model:visible="decisionVisible"
|
v-model:visible="decisionVisible"
|
||||||
source-label="تهحساب"
|
source-label="تهحساب"
|
||||||
|
:allow-push="true"
|
||||||
:app-gold="decisionResult?.app_gold"
|
:app-gold="decisionResult?.app_gold"
|
||||||
:app-cash="decisionResult?.app_cash"
|
:app-cash="decisionResult?.app_cash"
|
||||||
:tahesab-gold="decisionResult?.tahesab_gold"
|
:tahesab-gold="decisionResult?.tahesab_gold"
|
||||||
@@ -200,7 +201,7 @@ const failed = ref(0)
|
|||||||
const errors = ref<TahesabBulkWalletSyncChunk['errors']>([])
|
const errors = ref<TahesabBulkWalletSyncChunk['errors']>([])
|
||||||
const decisions = ref<TahesabBulkWalletSyncChunk['decisions']>([])
|
const decisions = ref<TahesabBulkWalletSyncChunk['decisions']>([])
|
||||||
const decidingId = ref<number | null>(null)
|
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 search = ref('')
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
@@ -209,7 +210,7 @@ const listTotal = ref(0)
|
|||||||
const listLoading = ref(false)
|
const listLoading = ref(false)
|
||||||
const rows = ref<TahesabWalletLinkedRow[]>([])
|
const rows = ref<TahesabWalletLinkedRow[]>([])
|
||||||
const syncingId = ref<number | null>(null)
|
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 decisionVisible = ref(false)
|
||||||
const decisionCustomerId = ref<number | null>(null)
|
const decisionCustomerId = ref<number | null>(null)
|
||||||
const decisionResult = ref<TahesabWalletSyncResult['result'] | 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
|
const customerId = decisionCustomerId.value
|
||||||
decisionVisible.value = false
|
decisionVisible.value = false
|
||||||
if (!customerId) return
|
if (!customerId) return
|
||||||
@@ -337,22 +338,25 @@ function dismissResult() {
|
|||||||
showDetails.value = false
|
showDetails.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||||
decidingId.value = customerId
|
decidingId.value = customerId
|
||||||
decidingMode.value = mode
|
decidingMode.value = mode
|
||||||
try {
|
try {
|
||||||
const res = await syncCustomerWalletFromTahesab(customerId, {
|
const res = await syncCustomerWalletFromTahesab(customerId, {
|
||||||
overwrite: mode === 'overwrite',
|
overwrite: mode === 'overwrite',
|
||||||
keep: mode === 'keep',
|
keep: mode === 'keep',
|
||||||
|
push_to_tahesab: mode === 'push',
|
||||||
ask_if_conflict: false,
|
ask_if_conflict: false,
|
||||||
})
|
})
|
||||||
decisions.value = decisions.value.filter(d => d.id !== customerId)
|
decisions.value = decisions.value.filter(d => d.id !== customerId)
|
||||||
needsDecision.value = Math.max(0, decisions.value.length)
|
needsDecision.value = Math.max(0, decisions.value.length)
|
||||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||||
|
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||||
else message.success(res.message || 'مانده تهحساب اعمال شد')
|
else message.success(res.message || 'مانده تهحساب اعمال شد')
|
||||||
await loadList()
|
await loadList()
|
||||||
} catch {
|
} catch (e: unknown) {
|
||||||
message.error('اعمال تصمیم ناموفق بود')
|
const data = (e as { response?: { data?: { message?: string } } })?.response?.data
|
||||||
|
message.error(data?.message || 'اعمال تصمیم ناموفق بود')
|
||||||
} finally {
|
} finally {
|
||||||
decidingId.value = null
|
decidingId.value = null
|
||||||
decidingMode.value = null
|
decidingMode.value = null
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="!row.zarin_id && !row.customer?.moshtari_code"
|
v-if="can('register') && !row.zarin_id && !row.customer?.moshtari_code"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:profile-add"
|
icon="vuesax-linear:profile-add"
|
||||||
color="#7C3AED"
|
color="#7C3AED"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
@click="$emit('register-customer', row)"
|
@click="$emit('register-customer', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="canRetry(row)"
|
v-if="can('send') && canRetry(row)"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:refresh-circle"
|
icon="vuesax-linear:refresh-circle"
|
||||||
color="#CA8A04"
|
color="#CA8A04"
|
||||||
@@ -60,6 +60,9 @@ import {
|
|||||||
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
|||||||
@@ -7,14 +7,14 @@
|
|||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title><span>اطلاعات سند</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<!-- دکمه ۲: ثبت مشتری در پرگار (فقط اگر سند هنوز ثبت نشده و مشتری کد ندارد) -->
|
<!-- دکمه ۲: ثبت مشتری در پرگار (فقط اگر سند هنوز ثبت نشده و مشتری کد ندارد) -->
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openRegister(record)"
|
@click="openRegister(record)"
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
<!-- دکمه ۳: ارسال به پرگار (فقط اگر هنوز در پرگار ثبت نشده) -->
|
<!-- دکمه ۳: ارسال به پرگار (فقط اگر هنوز در پرگار ثبت نشده) -->
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="canRetryPargar(record)"
|
v-if="can('send') && canRetryPargar(record)"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openSend(record)"
|
@click="openSend(record)"
|
||||||
@@ -138,6 +138,9 @@ import {
|
|||||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import { accountingPargarDocsIntro } from '@/utils/adminHelpCopy'
|
import { accountingPargarDocsIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
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>
|
<template #extra>
|
||||||
<a-button
|
<a-button
|
||||||
v-if="(pending?.total ?? 0) > 0"
|
v-if="customerId && (pending?.total ?? 0) > 0"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="syncing"
|
:loading="syncing"
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<TahesabDocSyncBox v-if="!customerId" @refreshed="onDocSyncRefreshed" />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="(pending?.total ?? 0) > 0"
|
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"
|
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>
|
||||||
<template v-else-if="column.key === 'action'">
|
<template v-else-if="column.key === 'action'">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title><span>جزئیات</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openRegister(record)"
|
@click="openRegister(record)"
|
||||||
@@ -91,6 +93,7 @@
|
|||||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-button
|
<a-button
|
||||||
|
v-if="can('send')"
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="syncingRowKey === failedRowKey(record)"
|
:loading="syncingRowKey === failedRowKey(record)"
|
||||||
@@ -109,13 +112,13 @@
|
|||||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title><span>اطلاعات سند</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openRegister(record)"
|
@click="openRegister(record)"
|
||||||
@@ -125,7 +128,7 @@
|
|||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="!record.tahesab_id"
|
v-if="can('send') && !record.tahesab_id"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openSend(record)"
|
@click="openSend(record)"
|
||||||
@@ -207,6 +210,7 @@ import { isMobile } from '@core/utils/is'
|
|||||||
import BasicModal from '@/components/BasicModal.vue'
|
import BasicModal from '@/components/BasicModal.vue'
|
||||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||||
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
|
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
|
||||||
|
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||||
import {
|
import {
|
||||||
tahesabIssueKindLabel,
|
tahesabIssueKindLabel,
|
||||||
tahesabStatusLabel
|
tahesabStatusLabel
|
||||||
@@ -217,6 +221,12 @@ import {
|
|||||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
|
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
|
const docSyncStore = useTahesabDocSyncStore()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
customerId?: number
|
customerId?: number
|
||||||
@@ -386,17 +396,24 @@ function openRegister(record: TahesabRecord) {
|
|||||||
async function loadPending() {
|
async function loadPending() {
|
||||||
try {
|
try {
|
||||||
pending.value = await getTahesabPendingSummary(props.customerId)
|
pending.value = await getTahesabPendingSummary(props.customerId)
|
||||||
|
docSyncStore.apply(pending.value?.doc_sync)
|
||||||
} catch {
|
} catch {
|
||||||
pending.value = null
|
pending.value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onDocSyncRefreshed() {
|
||||||
|
await loadPending()
|
||||||
|
if (docsView.value === 'failed') await loadFailedDocs()
|
||||||
|
}
|
||||||
|
|
||||||
async function loadFailedDocs() {
|
async function loadFailedDocs() {
|
||||||
failedLoading.value = true
|
failedLoading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await getTahesabPendingDocs(props.customerId, 200)
|
const res = await getTahesabPendingDocs(props.customerId, 200)
|
||||||
failedRows.value = res.rows || []
|
failedRows.value = res.rows || []
|
||||||
pending.value = res.summary
|
pending.value = res.summary
|
||||||
|
docSyncStore.apply(res.summary?.doc_sync)
|
||||||
} catch {
|
} catch {
|
||||||
failedRows.value = []
|
failedRows.value = []
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -76,12 +76,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-else-if="column.key === 'action'">
|
<template v-else-if="column.key === 'action'">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title><span>جزئیات</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openRegister(record)"
|
@click="openRegister(record)"
|
||||||
@@ -90,6 +90,7 @@
|
|||||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-button
|
<a-button
|
||||||
|
v-if="can('send')"
|
||||||
type="link"
|
type="link"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="syncingRowKey === failedRowKey(record)"
|
:loading="syncingRowKey === failedRowKey(record)"
|
||||||
@@ -108,13 +109,13 @@
|
|||||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title><span>اطلاعات سند</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openRegister(record)"
|
@click="openRegister(record)"
|
||||||
@@ -124,7 +125,7 @@
|
|||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="!record.zarin_id"
|
v-if="can('send') && !record.zarin_id"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openSend(record)"
|
@click="openSend(record)"
|
||||||
@@ -216,6 +217,9 @@ import {
|
|||||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import { accountingZarinDocsIntro } from '@/utils/adminHelpCopy'
|
import { accountingZarinDocsIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
customerId?: number
|
customerId?: number
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
<ATabPane v-if="pargarEnabled" key="pargar" tab="اسناد پرگار" />
|
<ATabPane v-if="pargarEnabled" key="pargar" tab="اسناد پرگار" />
|
||||||
<ATabPane v-if="pargarEnabled" key="pargar-customer-sync" tab="همگام سازی مشتریان در پرگار" />
|
<ATabPane v-if="pargarEnabled" key="pargar-customer-sync" tab="همگام سازی مشتریان در پرگار" />
|
||||||
<ATabPane v-if="pargarEnabled" key="pargar-wallet-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>
|
</ATabs>
|
||||||
<tbl v-if="activeTab === 'reports'" ref="table" class="min-h-0 flex-1" />
|
<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" />
|
<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" />
|
<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" />
|
<pargarCustomerSync v-else-if="pargarEnabled && activeTab === 'pargar-customer-sync'" class="shrink-0" />
|
||||||
<pargarWalletSync v-else-if="pargarEnabled && activeTab === 'pargar-wallet-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>
|
</div>
|
||||||
</BasicMainCard>
|
</BasicMainCard>
|
||||||
<BasicModal
|
<BasicModal
|
||||||
@@ -154,7 +158,8 @@
|
|||||||
// import BasicInfoModal from '@/components/BasicInfoModal'
|
// import BasicInfoModal from '@/components/BasicInfoModal'
|
||||||
import { inputLenRules, inputRules, inputRulesNumber } from '@/utils/inputRules'
|
import { inputLenRules, inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
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 tbl from './components/table.vue'
|
||||||
import tahesabTbl from './components/tahesabTable.vue'
|
import tahesabTbl from './components/tahesabTable.vue'
|
||||||
import customerSync from './components/TahesabCustomerSync.vue'
|
import customerSync from './components/TahesabCustomerSync.vue'
|
||||||
@@ -162,6 +167,8 @@ import tahesabWalletSync from './components/TahesabWalletBulkSync.vue'
|
|||||||
import zarinTbl from './components/zarinTable.vue'
|
import zarinTbl from './components/zarinTable.vue'
|
||||||
import zarinCustomerSync from './components/ZarinCustomerSync.vue'
|
import zarinCustomerSync from './components/ZarinCustomerSync.vue'
|
||||||
import zarinWalletSync from './components/ZarinWalletBulkSync.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 pargarTbl from './components/pargarTable.vue'
|
||||||
import pargarCustomerSync from './components/PargarCustomerSync.vue'
|
import pargarCustomerSync from './components/PargarCustomerSync.vue'
|
||||||
import pargarWalletSync from './components/PargarWalletBulkSync.vue'
|
import pargarWalletSync from './components/PargarWalletBulkSync.vue'
|
||||||
@@ -183,15 +190,26 @@ import type { last } from '@/model/price'
|
|||||||
import { createOrder } from '@/api/order'
|
import { createOrder } from '@/api/order'
|
||||||
import { getCashBalance, getGoldBalance } from '@/components/mobile/utils/wallet'
|
import { getCashBalance, getGoldBalance } from '@/components/mobile/utils/wallet'
|
||||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||||
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting } from '@/utils/config'
|
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting, shayeganEnabledSetting } from '@/utils/config'
|
||||||
|
|
||||||
//loading
|
//loading
|
||||||
|
const route = useRoute()
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
const submitError = ref('')
|
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 tahesabEnabled = tahesabEnabledSetting
|
||||||
const zarinEnabled = zarinEnabledSetting
|
const zarinEnabled = zarinEnabledSetting
|
||||||
const pargarEnabled = pargarEnabledSetting
|
const pargarEnabled = pargarEnabledSetting
|
||||||
|
const shayeganEnabled = shayeganEnabledSetting
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.query.tab,
|
||||||
|
(tab) => {
|
||||||
|
if (tab && typeof tab === 'string') {
|
||||||
|
activeTab.value = tab as any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
//define store
|
//define store
|
||||||
const store = useStaticApiListsStore()
|
const store = useStaticApiListsStore()
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<div class="flex justify-center gap-2">
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('recipients')" placement="bottom">
|
||||||
<template #title>گیرندگان</template>
|
<template #title>گیرندگان</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:profile-2user"
|
icon="vuesax-linear:profile-2user"
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
@click="emits('recipients', record)"
|
@click="emits('recipients', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('readers')" placement="bottom">
|
||||||
<template #title>بازدیدکنندگان</template>
|
<template #title>بازدیدکنندگان</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:people"
|
icon="vuesax-linear:people"
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
@click="emits('readers', record)"
|
@click="emits('readers', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip v-if="!isSystemRecord(record)" placement="bottom">
|
<a-tooltip v-if="can('edit') && !isSystemRecord(record)" placement="bottom">
|
||||||
<template #title>ویرایش</template>
|
<template #title>ویرایش</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
@click="emits('edit', record)"
|
@click="emits('edit', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||||
<Icon
|
<Icon
|
||||||
:icon="record.is_active ? 'vuesax-linear:close-circle' : 'vuesax-linear:tick-circle'"
|
:icon="record.is_active ? 'vuesax-linear:close-circle' : 'vuesax-linear:tick-circle'"
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
@click="emits('toggle', record)"
|
@click="emits('toggle', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||||
<template #title>حذف</template>
|
<template #title>حذف</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
@@ -91,6 +91,9 @@ import {
|
|||||||
APP_NOTIFICATION_SOURCE_TABS,
|
APP_NOTIFICATION_SOURCE_TABS,
|
||||||
type AppNotificationSourceFilter,
|
type AppNotificationSourceFilter,
|
||||||
} from '@/model/appNotifications'
|
} from '@/model/appNotifications'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
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="truncate font-bold text-slate-800 dark:text-slate-100">{{ item.name }}</div>
|
||||||
<div class="text-xs text-gray-500">{{ item.code }}</div>
|
<div class="text-xs text-gray-500">{{ item.code }}</div>
|
||||||
</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>
|
||||||
<div class="line-clamp-2 text-sm text-slate-600 dark:text-slate-300">{{ item.body }}</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">
|
<div class="flex items-center justify-between text-xs text-gray-500">
|
||||||
<span>ارسال {{ Number(item.sent_count ?? 0) }} · ناموفق {{ Number(item.failed_count ?? 0) }}</span>
|
<span>ارسال {{ Number(item.sent_count ?? 0) }} · ناموفق {{ Number(item.failed_count ?? 0) }}</span>
|
||||||
<div class="flex gap-3">
|
<div class="flex gap-3">
|
||||||
<Icon
|
<Icon
|
||||||
|
v-if="can('edit')"
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
color="#4572E9"
|
color="#4572E9"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="emits('edit', item)"
|
@click="emits('edit', item)"
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
|
v-if="can('delete')"
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
color="#C53030"
|
color="#C53030"
|
||||||
class="cursor-pointer"
|
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">
|
<BaseTable v-else class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #is_active="{ record }">
|
<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>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<div class="flex justify-center gap-2">
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('preview')" placement="bottom">
|
||||||
<template #title>اجرای آزمایشی</template>
|
<template #title>اجرای آزمایشی</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:play"
|
icon="vuesax-linear:play"
|
||||||
@@ -59,7 +61,7 @@
|
|||||||
@click="emits('runNow', record)"
|
@click="emits('runNow', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('log')" placement="bottom">
|
||||||
<template #title>لاگ ارسال</template>
|
<template #title>لاگ ارسال</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:document-text"
|
icon="vuesax-linear:document-text"
|
||||||
@@ -68,7 +70,7 @@
|
|||||||
@click="emits('sends', record)"
|
@click="emits('sends', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||||
<template #title>ویرایش</template>
|
<template #title>ویرایش</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
@@ -77,7 +79,7 @@
|
|||||||
@click="emits('edit', record)"
|
@click="emits('edit', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||||
<template #title>حذف</template>
|
<template #title>حذف</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
@@ -104,6 +106,9 @@ import { getAutomationsTable } from '@/api/automations'
|
|||||||
import type { Automation } from '@/model/automations'
|
import type { Automation } from '@/model/automations'
|
||||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||||
import { automationsPageIntro } from '@/utils/adminHelpCopy'
|
import { automationsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="banner-image-upload">
|
<div class="banner-image-upload fix-capture" @pointerdown="ensureGalleryCapture" @click="ensureGalleryCapture">
|
||||||
<a-upload
|
<a-upload
|
||||||
v-if="!displayUrl"
|
v-if="!displayUrl"
|
||||||
class="banner-image-upload__zone"
|
class="banner-image-upload__zone fix-capture"
|
||||||
name="file"
|
name="file"
|
||||||
accept="image/*"
|
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||||
:show-upload-list="false"
|
:show-upload-list="false"
|
||||||
:action="uploadURL"
|
:action="uploadURL"
|
||||||
:headers="fileHeader"
|
:headers="fileHeader"
|
||||||
@@ -37,8 +37,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="banner-image-upload__bar">
|
<div class="banner-image-upload__bar">
|
||||||
<a-upload
|
<a-upload
|
||||||
|
class="fix-capture"
|
||||||
name="file"
|
name="file"
|
||||||
accept="image/*"
|
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||||
:show-upload-list="false"
|
:show-upload-list="false"
|
||||||
:action="uploadURL"
|
:action="uploadURL"
|
||||||
:headers="fileHeader"
|
:headers="fileHeader"
|
||||||
@@ -63,11 +64,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watch, onMounted, nextTick } from 'vue'
|
||||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { uploadURL } from '@root/config'
|
import { uploadURL } from '@root/config'
|
||||||
import { getToken } from '@/utils'
|
import { getToken } from '@/utils'
|
||||||
import { fileUrlCandidates, normalizeUploadFileResponse, toAbsoluteFileUrl } from '@/utils/file'
|
import { fileUrlCandidates, normalizeUploadFileResponse, toAbsoluteFileUrl } from '@/utils/file'
|
||||||
|
import { fixFileCapture } from '@/utils/fixFileCapture'
|
||||||
import {
|
import {
|
||||||
createImageBeforeUpload,
|
createImageBeforeUpload,
|
||||||
createImageCustomRequest
|
createImageCustomRequest
|
||||||
@@ -89,11 +92,22 @@ const candidateIndex = ref(0)
|
|||||||
const candidates = computed(() => fileUrlCandidates(props.imageUrl))
|
const candidates = computed(() => fileUrlCandidates(props.imageUrl))
|
||||||
const displayUrl = computed(() => candidates.value[candidateIndex.value] ?? '')
|
const displayUrl = computed(() => candidates.value[candidateIndex.value] ?? '')
|
||||||
|
|
||||||
|
function ensureGalleryCapture() {
|
||||||
|
fixFileCapture()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
fixFileCapture()
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.imageUrl,
|
() => props.imageUrl,
|
||||||
() => {
|
() => {
|
||||||
previewFailed.value = false
|
previewFailed.value = false
|
||||||
candidateIndex.value = 0
|
candidateIndex.value = 0
|
||||||
|
nextTick(() => {
|
||||||
|
fixFileCapture()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('toggle')"
|
||||||
:icon="item.sts === 2 ? 'vuesax-linear:card-tick' : 'vuesax-linear:card-remove'"
|
:icon="item.sts === 2 ? 'vuesax-linear:card-tick' : 'vuesax-linear:card-remove'"
|
||||||
:color="item.sts === 2 ? '#16A34A' : '#DC2626'"
|
:color="item.sts === 2 ? '#16A34A' : '#DC2626'"
|
||||||
:size="20"
|
:size="20"
|
||||||
@click="$emit('toggleSts', item)"
|
@click="$emit('toggleSts', item)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('delete')"
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
color="#DC2626"
|
color="#DC2626"
|
||||||
:size="20"
|
:size="20"
|
||||||
@@ -34,6 +36,9 @@
|
|||||||
import type { Card } from '@/model/card'
|
import type { Card } from '@/model/card'
|
||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
import MobileIconButton from '@/components/mobile/MobileIconButton.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 }
|
type AccountRow = Card & { sts_str?: string; created_at?: string; customer_id?: number }
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<template #action="{ column, record }">
|
<template #action="{ column, record }">
|
||||||
<div class="gap-2 flex justify-center items-center">
|
<div class="gap-2 flex justify-center items-center">
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
|
v-if="can('toggle')"
|
||||||
:key="record.sts"
|
:key="record.sts"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
:color="record.sts !== 2 ? 'red' : 'green'"
|
:color="record.sts !== 2 ? 'red' : 'green'"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</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>
|
<template #title>
|
||||||
<span>حذف کارت</span>
|
<span>حذف کارت</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -63,6 +64,9 @@ import type { Card } from '@/model/card'
|
|||||||
import AccountMobileCardList from './AccountMobileCardList.vue'
|
import AccountMobileCardList from './AccountMobileCardList.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { cardsPageIntro } from '@/utils/adminHelpCopy'
|
import { cardsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<div class="flex justify-center gap-2">
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||||
<template #title>ویرایش</template>
|
<template #title>ویرایش</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
@click="emits('edit', record)"
|
@click="emits('edit', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||||
<Icon
|
<Icon
|
||||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
@click="emits('toggle', record)"
|
@click="emits('toggle', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||||
<template #title>حذف</template>
|
<template #title>حذف</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
@@ -54,6 +54,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
|||||||
import { cols } from '../hooks/conditionalOrdersColumns'
|
import { cols } from '../hooks/conditionalOrdersColumns'
|
||||||
import { getConditionalOrdersTable } from '@/api/conditionalOrders'
|
import { getConditionalOrdersTable } from '@/api/conditionalOrders'
|
||||||
import { conditionalOrdersPageIntro } from '@/utils/adminHelpCopy'
|
import { conditionalOrdersPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
:value="priceValue"
|
:value="priceValue"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
|
:addon-after="unitLabel || undefined"
|
||||||
:formatter="(v: string) => `${v}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
:formatter="(v: string) => `${v}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
||||||
:parser="(v: string) => sanitizeNumericString(v, { allowDecimal: false })"
|
:parser="(v: string) => sanitizeNumericString(v, { allowDecimal: false })"
|
||||||
@update:value="onPriceChange"
|
@update:value="onPriceChange"
|
||||||
@@ -109,6 +110,7 @@
|
|||||||
inputmode="numeric"
|
inputmode="numeric"
|
||||||
allow-clear
|
allow-clear
|
||||||
class="w-full"
|
class="w-full"
|
||||||
|
:addon-after="unitLabel || undefined"
|
||||||
@update:value="onPlainNumberChange"
|
@update:value="onPlainNumberChange"
|
||||||
@blur="emit('blur')"
|
@blur="emit('blur')"
|
||||||
/>
|
/>
|
||||||
@@ -144,6 +146,7 @@ import TemplateTextField from './TemplateTextField.vue'
|
|||||||
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
|
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
|
||||||
import { hasTemplateField } from './templateFields'
|
import { hasTemplateField } from './templateFields'
|
||||||
import {
|
import {
|
||||||
|
getSettingUnitLabel,
|
||||||
normalizeTimeValue,
|
normalizeTimeValue,
|
||||||
parseSelectOptions,
|
parseSelectOptions,
|
||||||
resolveSettingFieldType,
|
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 isZaarboxPriceKey = computed(() => props.settingKey === 'zaarbox_price_key')
|
||||||
const isMontzarProductId = computed(() => props.settingKey === 'montzar_product_id')
|
const isMontzarProductId = computed(() => props.settingKey === 'montzar_product_id')
|
||||||
const isMainWalletProducts = computed(() => props.settingKey === 'main_wallet_products')
|
const isMainWalletProducts = computed(() => props.settingKey === 'main_wallet_products')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="h-full min-h-0">
|
<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">
|
<div class="settings-toolbar">
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="search"
|
v-model:value="search"
|
||||||
@@ -207,10 +207,10 @@ import { loading } from '@/utils'
|
|||||||
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
|
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
|
||||||
import SettingValueField from './SettingValueField.vue'
|
import SettingValueField from './SettingValueField.vue'
|
||||||
import SettingCard from './SettingCard.vue'
|
import SettingCard from './SettingCard.vue'
|
||||||
import { configurationPageIntro } from '@/utils/adminHelpCopy'
|
import { configurationPageIntro, websiteSettingsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
import { refreshAppModeMenu } from '@/router'
|
import { refreshAppModeMenu } from '@/router'
|
||||||
import { useUserStore } from '@/store/userStore'
|
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 {
|
import {
|
||||||
EDITABLE_SETTING_GROUPS,
|
EDITABLE_SETTING_GROUPS,
|
||||||
SYSTEM_SETTING_GROUPS,
|
SYSTEM_SETTING_GROUPS,
|
||||||
@@ -218,6 +218,12 @@ import {
|
|||||||
OTHER_PAGE_SETTING_MENUS,
|
OTHER_PAGE_SETTING_MENUS,
|
||||||
type SettingGroupDef
|
type SettingGroupDef
|
||||||
} from './settingGroups'
|
} from './settingGroups'
|
||||||
|
import {
|
||||||
|
LANDING_SETTING_GROUPS,
|
||||||
|
isLandingContentKey,
|
||||||
|
landingSectionByPrefix,
|
||||||
|
matchesLandingPrefix
|
||||||
|
} from './landingSettings'
|
||||||
import {
|
import {
|
||||||
SETTING_TYPE_OPTIONS,
|
SETTING_TYPE_OPTIONS,
|
||||||
formatValueForSave,
|
formatValueForSave,
|
||||||
@@ -233,8 +239,9 @@ import {
|
|||||||
} from './settingTypes'
|
} from './settingTypes'
|
||||||
import { TRADING_HOURS_SETTING_KEY_SET } from './tradingHoursKeys'
|
import { TRADING_HOURS_SETTING_KEY_SET } from './tradingHoursKeys'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' }>(), {
|
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' | 'landing'; landingPrefix?: string }>(), {
|
||||||
mode: 'editable'
|
mode: 'editable',
|
||||||
|
landingPrefix: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
@@ -243,11 +250,24 @@ function refreshMenuAfterStoreChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isSystemMode = computed(() => props.mode === 'system')
|
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 refreshingSuperAdmin = ref(false)
|
||||||
const settingGroups = computed(() =>
|
const settingGroups = computed(() => {
|
||||||
isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
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
|
const settingTypeOptions = SETTING_TYPE_OPTIONS
|
||||||
|
|
||||||
@@ -327,6 +347,13 @@ const filteredRows = computed(() =>
|
|||||||
(baseData.value || []).filter((row) => {
|
(baseData.value || []).filter((row) => {
|
||||||
if (row.id == null || !matchesFilter(row)) return false
|
if (row.id == null || !matchesFilter(row)) return false
|
||||||
if (!isSettingVisible(row.key)) 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()
|
const menu = String(row.menu ?? '').trim()
|
||||||
if (OTHER_PAGE_SETTING_MENUS.has(menu)) return false
|
if (OTHER_PAGE_SETTING_MENUS.has(menu)) return false
|
||||||
if (!menu && !isSystemMode.value && TRADING_HOURS_SETTING_KEY_SET.has(row.key || '')) {
|
if (!menu && !isSystemMode.value && TRADING_HOURS_SETTING_KEY_SET.has(row.key || '')) {
|
||||||
@@ -486,7 +513,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.mode,
|
() => [props.mode, props.landingPrefix],
|
||||||
() => {
|
() => {
|
||||||
search.value = ''
|
search.value = ''
|
||||||
filterType.value = undefined
|
filterType.value = undefined
|
||||||
@@ -608,6 +635,7 @@ async function initConfig() {
|
|||||||
applyPriceProviderFromRows(baseData.value)
|
applyPriceProviderFromRows(baseData.value)
|
||||||
applyPriceChannelAccessFromRows(baseData.value)
|
applyPriceChannelAccessFromRows(baseData.value)
|
||||||
applySupportChatMenuEnabledFromRows(baseData.value)
|
applySupportChatMenuEnabledFromRows(baseData.value)
|
||||||
|
applyHasLandingFromRows(baseData.value)
|
||||||
applyGroupSmsFromRows(baseData.value)
|
applyGroupSmsFromRows(baseData.value)
|
||||||
applyCustomerSpecialPricingFromRows(baseData.value)
|
applyCustomerSpecialPricingFromRows(baseData.value)
|
||||||
applyGoldCreditEnabledFromRows(baseData.value)
|
applyGoldCreditEnabledFromRows(baseData.value)
|
||||||
@@ -616,6 +644,7 @@ async function initConfig() {
|
|||||||
!isSystemMode.value ||
|
!isSystemMode.value ||
|
||||||
!baseData.value.some((row) => row.key === 'price_provider') ||
|
!baseData.value.some((row) => row.key === 'price_provider') ||
|
||||||
!baseData.value.some((row) => row.key === 'show_to_users_chat') ||
|
!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 === 'price_channel_access') ||
|
||||||
!baseData.value.some((row) => row.key === 'group_sms') ||
|
!baseData.value.some((row) => row.key === 'group_sms') ||
|
||||||
!baseData.value.some((row) => row.key === 'customer_special_pricing') ||
|
!baseData.value.some((row) => row.key === 'customer_special_pricing') ||
|
||||||
@@ -627,6 +656,7 @@ async function initConfig() {
|
|||||||
const rows = Array.isArray(all) ? all : []
|
const rows = Array.isArray(all) ? all : []
|
||||||
applyPriceProviderFromRows(rows)
|
applyPriceProviderFromRows(rows)
|
||||||
applySupportChatMenuEnabledFromRows(rows)
|
applySupportChatMenuEnabledFromRows(rows)
|
||||||
|
applyHasLandingFromRows(rows)
|
||||||
applyPriceChannelAccessFromRows(rows)
|
applyPriceChannelAccessFromRows(rows)
|
||||||
applyGroupSmsFromRows(rows)
|
applyGroupSmsFromRows(rows)
|
||||||
applyCustomerSpecialPricingFromRows(rows)
|
applyCustomerSpecialPricingFromRows(rows)
|
||||||
@@ -688,6 +718,11 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
|||||||
setPriceTriggerEnabledFromSettings(isSwitchOn(value))
|
setPriceTriggerEnabledFromSettings(isSwitchOn(value))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (key === 'has_page_gift_card') {
|
||||||
|
setGiftCardEnabledFromSettings(isSwitchOn(value))
|
||||||
|
refreshMenuAfterStoreChange()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (key === 'has_page_notification') {
|
if (key === 'has_page_notification') {
|
||||||
setAppNotificationEnabledFromSettings(isSwitchOn(value))
|
setAppNotificationEnabledFromSettings(isSwitchOn(value))
|
||||||
return
|
return
|
||||||
@@ -701,6 +736,14 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
|||||||
if (row) row.value = value
|
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') {
|
if (key === 'price_channel_access') {
|
||||||
setPriceChannelAccessFromSettings(isSwitchOn(value))
|
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) */
|
/** گروههای صفحه تنظیمات عادی (فقط can_edit=1) */
|
||||||
export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
|
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',
|
id: 'general',
|
||||||
title: 'عمومی و برند',
|
title: 'عمومی و برند',
|
||||||
@@ -158,7 +164,7 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
|||||||
icon: 'vuesax-linear:people',
|
icon: 'vuesax-linear:people',
|
||||||
// فقط فلگهای مالک سوپرادمین — banner/tracking/نمایش محصول در «تنظیمات» عادیاند
|
// فقط فلگهای مالک سوپرادمین — banner/tracking/نمایش محصول در «تنظیمات» عادیاند
|
||||||
match: (k) =>
|
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
|
k
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -265,6 +271,12 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
|||||||
icon: 'vuesax-linear:document-text',
|
icon: 'vuesax-linear:document-text',
|
||||||
match: (k) => k.startsWith('pargar_') || k === 'send_to_pargar'
|
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',
|
id: 'price_channel',
|
||||||
title: 'ارسال قیمت به کانال',
|
title: 'ارسال قیمت به کانال',
|
||||||
@@ -304,13 +316,23 @@ export function resolveSettingMenu(
|
|||||||
row: { key?: string; menu?: string | null },
|
row: { key?: string; menu?: string | null },
|
||||||
groups: SettingGroupDef[]
|
groups: SettingGroupDef[]
|
||||||
): string {
|
): string {
|
||||||
|
const key = row.key || ''
|
||||||
|
const fromKey = getSettingGroupId(key, groups)
|
||||||
const menu = String(row.menu ?? '').trim()
|
const menu = String(row.menu ?? '').trim()
|
||||||
if (menu && groups.some((g) => g.id === menu)) return menu
|
if (menu && groups.some((g) => g.id === menu)) {
|
||||||
return getSettingGroupId(row.key || '', groups)
|
// 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(
|
export function getSettingSubsectionId(
|
||||||
key: string,
|
key: string,
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
|
|||||||
'jibit_enabled',
|
'jibit_enabled',
|
||||||
'permision__enabled',
|
'permision__enabled',
|
||||||
'show_to_users_chat',
|
'show_to_users_chat',
|
||||||
|
'has_landing',
|
||||||
])
|
])
|
||||||
|
|
||||||
export function isSuperAdminOwnedSettingKey(key?: string | null): boolean {
|
export function isSuperAdminOwnedSettingKey(key?: string | null): boolean {
|
||||||
@@ -324,7 +325,7 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
|||||||
minimum_sell: 'price',
|
minimum_sell: 'price',
|
||||||
gift_for_referrer: 'number',
|
gift_for_referrer: 'number',
|
||||||
gift_for_referral: 'number',
|
gift_for_referral: 'number',
|
||||||
referral_bonus_amount: 'text',
|
referral_bonus_amount: 'price',
|
||||||
montzar_product_id: 'number',
|
montzar_product_id: 'number',
|
||||||
montzar_account_zarin: 'text',
|
montzar_account_zarin: 'text',
|
||||||
montzar_account_tahesab: 'text',
|
montzar_account_tahesab: 'text',
|
||||||
@@ -429,7 +430,19 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
|||||||
pargar_item_id_gold: 'number',
|
pargar_item_id_gold: 'number',
|
||||||
support_messengers: 'longtext',
|
support_messengers: 'longtext',
|
||||||
show_to_users_chat: 'switch',
|
show_to_users_chat: 'switch',
|
||||||
|
has_landing: 'switch',
|
||||||
has_chat: '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: 'text',
|
||||||
chat_api_key: 'text',
|
chat_api_key: 'text',
|
||||||
chat_upload_url: 'text',
|
chat_upload_url: 'text',
|
||||||
@@ -623,6 +636,45 @@ export function formatValueForSave(
|
|||||||
return value ?? ''
|
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 } {
|
export function switchLabels(key: string | undefined): { on: string; off: string } {
|
||||||
if (key === REFERRAL_REQUIRED_KEY) {
|
if (key === REFERRAL_REQUIRED_KEY) {
|
||||||
return { on: 'اجباری', off: 'اختیاری' }
|
return { on: 'اجباری', off: 'اختیاری' }
|
||||||
@@ -800,7 +852,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
|||||||
referral_limit:
|
referral_limit:
|
||||||
'حداکثر تعداد دعوت مجاز برای هر کاربر. خالی = بدون محدودیت.',
|
'حداکثر تعداد دعوت مجاز برای هر کاربر. خالی = بدون محدودیت.',
|
||||||
referral_bonus_amount:
|
referral_bonus_amount:
|
||||||
'مبلغ یا مقدار پاداش معرف برای نمایش در پیامکها و متنهای دعوت.',
|
'مبلغ پاداش معرف (ریال) برای نمایش در پیامکها و متنهای دعوت. واحد روی خود فیلد مشخص است.',
|
||||||
jibit_verification:
|
jibit_verification:
|
||||||
'روشن: هنگام ثبت یا ویرایش کارت بانکی، تطبیق با سرویس احراز هویت جیبیت انجام میشود. خاموش: کارت بدون تطبیق جیبیت ثبت میشود.',
|
'روشن: هنگام ثبت یا ویرایش کارت بانکی، تطبیق با سرویس احراز هویت جیبیت انجام میشود. خاموش: کارت بدون تطبیق جیبیت ثبت میشود.',
|
||||||
register_jibit_verify:
|
register_jibit_verify:
|
||||||
@@ -832,7 +884,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
|||||||
montzar_open_sell:
|
montzar_open_sell:
|
||||||
'وضعیت واقعی از سرویس خارجی خوانده میشود. روشن: ثبت سفارش فروش از طریق قیمت همکار مجاز است. خاموش: ثبت سفارش فروش از طریق قیمت همکار غیرفعال است.',
|
'وضعیت واقعی از سرویس خارجی خوانده میشود. روشن: ثبت سفارش فروش از طریق قیمت همکار مجاز است. خاموش: ثبت سفارش فروش از طریق قیمت همکار غیرفعال است.',
|
||||||
montzar_order_wait_callback:
|
montzar_order_wait_callback:
|
||||||
'روشن (پیشفرض): بعد از ارسال سفارش به همکار، تا کالبک وضعیت (تأیید=۲ / رد=۴ یا ۶) یا استعلام مسیر وضعیت صبر میشود و کیف ثبت نمیشود. خاموش: مثل قبل با همان پاسخ HTTP همکار سفارش قطعی میشود.',
|
'با منبع قیمت همکار، سفارش همیشه تا کالبک یا استعلام وضعیت در انتظار میماند و کیف بعد از تأیید ثبت میشود. خاموش بودن این سوییچ دیگر مسیر قطعی بلافاصله را باز نمیکند. در رد همکار، SMS به ادمینهای دارای ارسال پیامک میرود.',
|
||||||
montzar_order_status_path:
|
montzar_order_status_path:
|
||||||
'مسیر GET روی دامنه همکار (montzar_base_url) برای استعلام وضعیت اگر کالبک نرسید. پیشفرض /server/customer/order — با شماره سفارش همکار میشود /server/customer/order/40000.',
|
'مسیر GET روی دامنه همکار (montzar_base_url) برای استعلام وضعیت اگر کالبک نرسید. پیشفرض /server/customer/order — با شماره سفارش همکار میشود /server/customer/order/40000.',
|
||||||
montzar_closed:
|
montzar_closed:
|
||||||
@@ -863,6 +915,19 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
|||||||
'فقط مواردی که در این لیست ثبت شوند در منوی شناور پشتیبانی اپ مشتری نمایش داده میشوند. برای تماس تلفنی یا پیامک، نوع «تماس تلفنی» / «پیامک» را با شماره اضافه کنید. لیست میتواند خالی باشد؛ اگر چت فعال باشد، پشتیبانی مستقیم به صفحه چت میرود.',
|
'فقط مواردی که در این لیست ثبت شوند در منوی شناور پشتیبانی اپ مشتری نمایش داده میشوند. برای تماس تلفنی یا پیامک، نوع «تماس تلفنی» / «پیامک» را با شماره اضافه کنید. لیست میتواند خالی باشد؛ اگر چت فعال باشد، پشتیبانی مستقیم به صفحه چت میرود.',
|
||||||
show_to_users_chat:
|
show_to_users_chat:
|
||||||
'روشن: قابلیت چت پشتیبانی برای این دیپلوی فعال است (منوی ادمین و پیشنیاز نمایش به کاربر). خاموش: چت در ادمین و اپ کاربر مخفی است و سوییچ «چت پشتیبانی» (has_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:
|
has_chat:
|
||||||
'روشن: چت پشتیبانی در اپ مشتری نمایش داده میشود (فقط وقتی show_to_users_chat هم روشن باشد). خاموش: دکمه و صفحه چت برای کاربر مخفی است.',
|
'روشن: چت پشتیبانی در اپ مشتری نمایش داده میشود (فقط وقتی show_to_users_chat هم روشن باشد). خاموش: دکمه و صفحه چت برای کاربر مخفی است.',
|
||||||
chat_api:
|
chat_api:
|
||||||
@@ -1119,6 +1184,8 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
|||||||
minimum_sell: 'حداقل مبلغ فروش (ریال)',
|
minimum_sell: 'حداقل مبلغ فروش (ریال)',
|
||||||
referral_id: 'کد معرف اجباری',
|
referral_id: 'کد معرف اجباری',
|
||||||
referral_bonus_amount: 'مقدار پاداش معرف',
|
referral_bonus_amount: 'مقدار پاداش معرف',
|
||||||
|
gift_for_referrer: 'پاداش معرف',
|
||||||
|
gift_for_referral: 'پاداش معرفشونده',
|
||||||
referral_gift_on_first_order: 'پاداش معرف پس از اولین سفارش',
|
referral_gift_on_first_order: 'پاداش معرف پس از اولین سفارش',
|
||||||
referral_gift_buy_from_montzar: 'خرید پاداش معرفی از همکار',
|
referral_gift_buy_from_montzar: 'خرید پاداش معرفی از همکار',
|
||||||
open_register: 'ثبتنام باز',
|
open_register: 'ثبتنام باز',
|
||||||
@@ -1187,7 +1254,19 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
|||||||
zarin_idbank: 'کد حساب بانک زرین',
|
zarin_idbank: 'کد حساب بانک زرین',
|
||||||
support_messengers: 'پیامرسانهای پشتیبانی',
|
support_messengers: 'پیامرسانهای پشتیبانی',
|
||||||
show_to_users_chat: 'نمایش چت به کاربران',
|
show_to_users_chat: 'نمایش چت به کاربران',
|
||||||
|
has_landing: 'لندینگ وبسایت',
|
||||||
has_chat: 'چت پشتیبانی',
|
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: 'API چت',
|
||||||
chat_api_key: 'کلید API چت',
|
chat_api_key: 'کلید API چت',
|
||||||
chat_upload_url: 'آدرس آپلود فایل چت',
|
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',
|
'price_channel_bale_to', 'price_channel_telegram_to', 'price_channel_rubika_to',
|
||||||
'unit',
|
'unit',
|
||||||
'wss_enabled',
|
'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 */
|
/** قابل ویرایش در پنل عادی — همتراز deploy_settings_const.sql */
|
||||||
@@ -1326,6 +1405,8 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
|||||||
'support_messengers', 'support_messenger_text',
|
'support_messengers', 'support_messenger_text',
|
||||||
'do_send_liman',
|
'do_send_liman',
|
||||||
'has_chat',
|
'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',
|
'text_about', 'text_rule', 'about_software', 'enamad_url', 'enamad_logo',
|
||||||
'login_hero_eyebrow', 'login_hero_title',
|
'login_hero_eyebrow', 'login_hero_title',
|
||||||
'login_hero_feature_1', 'login_hero_feature_2', 'login_hero_feature_3', 'login_hero_feature_4',
|
'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 دیتابیس اولویت دارد */
|
/** عنوان فارسی — کاتالوگ پنل بر 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()
|
const key = (row.key ?? '').trim()
|
||||||
if (key && KEY_LABEL_FALLBACK[key]) return KEY_LABEL_FALLBACK[key]
|
const base = (key && KEY_LABEL_FALLBACK[key]) ? KEY_LABEL_FALLBACK[key] : (row.title_fa?.trim() || key || '—')
|
||||||
return 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 دیتابیس اولویت دارد */
|
/** توضیح — کاتالوگ پنل بر 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">
|
<div class="flex min-w-0 flex-1 items-center gap-2">
|
||||||
<BaseIcon icon="vuesax-linear:user" size="20" color="#6b7280" />
|
<BaseIcon icon="vuesax-linear:user" size="20" color="#6b7280" />
|
||||||
<button
|
<button
|
||||||
|
v-if="can('info')"
|
||||||
type="button"
|
type="button"
|
||||||
class="truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900 cursor-pointer"
|
class="truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900 cursor-pointer"
|
||||||
@click.stop="$emit('info', item)"
|
@click.stop="$emit('info', item)"
|
||||||
>
|
>
|
||||||
{{ item.name || '-' }}
|
{{ item.name || '-' }}
|
||||||
</button>
|
</button>
|
||||||
|
<span v-else class="truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="shrink-0 text-sm text-gray-600">{{ item.mobile || '-' }}</div>
|
<div class="shrink-0 text-sm text-gray-600">{{ item.mobile || '-' }}</div>
|
||||||
@@ -19,6 +21,7 @@
|
|||||||
{{ item.type_str || 'کاربر' }}
|
{{ item.type_str || 'کاربر' }}
|
||||||
</span>
|
</span>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('restore')"
|
||||||
icon="vuesax-linear:archive-slash"
|
icon="vuesax-linear:archive-slash"
|
||||||
color="#e3bf00"
|
color="#e3bf00"
|
||||||
:size="20"
|
:size="20"
|
||||||
@@ -34,6 +37,9 @@
|
|||||||
import type { Customer } from '@/model/customer'
|
import type { Customer } from '@/model/customer'
|
||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: Customer
|
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">
|
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title>
|
||||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
</a-tooltip>
|
</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>
|
<template #title><span>مشخصات</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
@@ -52,6 +52,9 @@ import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
|||||||
import type { TableInput } from '@core/type/baseTable'
|
import type { TableInput } from '@core/type/baseTable'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { customersArchivePageIntro } from '@/utils/adminHelpCopy'
|
import { customersArchivePageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'charge'])
|
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'charge'])
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<TahesabMandeDecisionModal
|
<TahesabMandeDecisionModal
|
||||||
v-model:visible="decisionVisible"
|
v-model:visible="decisionVisible"
|
||||||
:source-label="provider === 'zarin' ? 'زرین' : 'تهحساب'"
|
:source-label="provider === 'zarin' ? 'زرین' : 'تهحساب'"
|
||||||
|
:allow-push="provider === 'tahesab'"
|
||||||
:app-gold="decision?.app_gold"
|
:app-gold="decision?.app_gold"
|
||||||
:app-cash="decision?.app_cash"
|
:app-cash="decision?.app_cash"
|
||||||
:tahesab-gold="decision?.tahesab_gold ?? decision?.zarin_gold"
|
:tahesab-gold="decision?.tahesab_gold ?? decision?.zarin_gold"
|
||||||
@@ -96,7 +97,9 @@ const visibleProxy = computed({
|
|||||||
function currentCodeOf(customer: Customer | null): string {
|
function currentCodeOf(customer: Customer | null): string {
|
||||||
if (!customer) return ''
|
if (!customer) return ''
|
||||||
if (props.provider === 'pargar') return displayAccountingCode(customer.pargar_account_id)
|
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 ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +123,12 @@ async function saveCode(customerId: number, body: Record<string, string>) {
|
|||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||||
if (props.provider === 'zarin') {
|
if (props.provider === 'zarin') {
|
||||||
|
if (mode === 'push') {
|
||||||
|
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||||
|
return { ok: false, message: 'پشتیبانی نمیشود' }
|
||||||
|
}
|
||||||
return syncCustomerWalletFromZarin(customerId, {
|
return syncCustomerWalletFromZarin(customerId, {
|
||||||
overwrite: mode === 'overwrite',
|
overwrite: mode === 'overwrite',
|
||||||
keep: mode === 'keep',
|
keep: mode === 'keep',
|
||||||
@@ -131,11 +138,12 @@ async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep
|
|||||||
return syncCustomerWalletFromTahesab(customerId, {
|
return syncCustomerWalletFromTahesab(customerId, {
|
||||||
overwrite: mode === 'overwrite',
|
overwrite: mode === 'overwrite',
|
||||||
keep: mode === 'keep',
|
keep: mode === 'keep',
|
||||||
|
push_to_tahesab: mode === 'push',
|
||||||
ask_if_conflict: false,
|
ask_if_conflict: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onDecide(mode: 'overwrite' | 'keep') {
|
async function onDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||||
const pending = pendingPayload.value
|
const pending = pendingPayload.value
|
||||||
decisionVisible.value = false
|
decisionVisible.value = false
|
||||||
if (!pending) return
|
if (!pending) return
|
||||||
@@ -144,6 +152,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
|||||||
await saveCode(pending.customerId, pending.body)
|
await saveCode(pending.customerId, pending.body)
|
||||||
const res = await applyWalletDecision(pending.customerId, mode)
|
const res = await applyWalletDecision(pending.customerId, mode)
|
||||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||||
|
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||||
else message.success(res.message || 'مانده حسابداری روی کیف اعمال شد')
|
else message.success(res.message || 'مانده حسابداری روی کیف اعمال شد')
|
||||||
emit('success')
|
emit('success')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -156,7 +165,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
|||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!props.customer?.id) return
|
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('حسابداری فعال نیست.')
|
message.error('حسابداری فعال نیست.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
v-if="can('charge')"
|
||||||
class="customer-mobile-sheet__charge-btn"
|
class="customer-mobile-sheet__charge-btn"
|
||||||
size="middle"
|
size="middle"
|
||||||
type="primary"
|
type="primary"
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
|
|
||||||
<div class="customer-mobile-sheet__actions">
|
<div class="customer-mobile-sheet__actions">
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="accountingCodeLabel"
|
v-if="can('accountingCode') && accountingCodeLabel"
|
||||||
size="small"
|
size="small"
|
||||||
type="default"
|
type="default"
|
||||||
icon="vuesax-linear:card-edit"
|
icon="vuesax-linear:card-edit"
|
||||||
@@ -47,14 +48,14 @@
|
|||||||
>
|
>
|
||||||
کد حسابداری
|
کد حسابداری
|
||||||
</BaseButton>
|
</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>
|
||||||
<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>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="customerLevelProfitEnabled"
|
v-if="can('referral') && customerLevelProfitEnabled"
|
||||||
size="small"
|
size="small"
|
||||||
type="default"
|
type="default"
|
||||||
icon="vuesax-linear:hierarchy-2"
|
icon="vuesax-linear:hierarchy-2"
|
||||||
@@ -62,11 +63,11 @@
|
|||||||
>
|
>
|
||||||
سود چندسطحی
|
سود چندسطحی
|
||||||
</BaseButton>
|
</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>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="customerDirectSmsEnabled"
|
v-if="can('sms') && customerDirectSmsEnabled"
|
||||||
size="small"
|
size="small"
|
||||||
type="default"
|
type="default"
|
||||||
icon="vuesax-linear:sms"
|
icon="vuesax-linear:sms"
|
||||||
@@ -75,7 +76,7 @@
|
|||||||
پیامک
|
پیامک
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
v-if="!row.is_legal"
|
v-if="can('approve') && !row.is_legal"
|
||||||
size="small"
|
size="small"
|
||||||
type="default"
|
type="default"
|
||||||
icon="vuesax-linear:user-search"
|
icon="vuesax-linear:user-search"
|
||||||
@@ -84,6 +85,7 @@
|
|||||||
تایید
|
تایید
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
v-if="can('active')"
|
||||||
size="small"
|
size="small"
|
||||||
:type="row.active ? 'default' : 'primary'"
|
:type="row.active ? 'default' : 'primary'"
|
||||||
:icon="row.active ? 'vuesax-linear:user-remove' : 'vuesax-linear:user-tick'"
|
:icon="row.active ? 'vuesax-linear:user-remove' : 'vuesax-linear:user-tick'"
|
||||||
@@ -92,6 +94,7 @@
|
|||||||
{{ row.active ? 'غیرفعال' : 'فعال' }}
|
{{ row.active ? 'غیرفعال' : 'فعال' }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
v-if="can('trade')"
|
||||||
size="small"
|
size="small"
|
||||||
:type="row.trade_active === 1 ? 'default' : 'primary'"
|
:type="row.trade_active === 1 ? 'default' : 'primary'"
|
||||||
:icon="row.trade_active === 1 ? 'vuesax-linear:box-remove' : 'vuesax-linear:box-tick'"
|
:icon="row.trade_active === 1 ? 'vuesax-linear:box-remove' : 'vuesax-linear:box-tick'"
|
||||||
@@ -135,6 +138,9 @@ import {
|
|||||||
} from '@/utils/config'
|
} from '@/utils/config'
|
||||||
import { displayAccountingCode } from '@/utils/accountingCode'
|
import { displayAccountingCode } from '@/utils/accountingCode'
|
||||||
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
|||||||
@@ -10,12 +10,14 @@
|
|||||||
<div class="min-w-0 flex-1 space-y-1.5">
|
<div class="min-w-0 flex-1 space-y-1.5">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
|
v-if="can('info')"
|
||||||
type="button"
|
type="button"
|
||||||
class="min-w-0 flex-1 truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900"
|
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)"
|
@click.stop="$emit('info', item)"
|
||||||
>
|
>
|
||||||
{{ item.name || '-' }}
|
{{ item.name || '-' }}
|
||||||
</button>
|
</button>
|
||||||
|
<span v-else class="min-w-0 flex-1 truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||||
<span
|
<span
|
||||||
class="inline-block h-2.5 w-2.5 shrink-0 rounded-full"
|
class="inline-block h-2.5 w-2.5 shrink-0 rounded-full"
|
||||||
:class="item.active ? 'bg-green-500' : 'bg-red-500'"
|
:class="item.active ? 'bg-green-500' : 'bg-red-500'"
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
عملیات
|
عملیات
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
v-if="can('edit')"
|
||||||
type="default"
|
type="default"
|
||||||
size="small"
|
size="small"
|
||||||
class="min-w-[4.5rem]"
|
class="min-w-[4.5rem]"
|
||||||
@@ -57,6 +60,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Customer } from '@/model/customer'
|
import type { Customer } from '@/model/customer'
|
||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: Customer
|
item: Customer
|
||||||
|
|||||||
@@ -1,16 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal
|
<BasicModal
|
||||||
v-model:visible="visibleProxy"
|
v-model:visible="visibleProxy"
|
||||||
:width="isMobile ? '92vw' : '36rem'"
|
:width="isMobile ? '92vw' : '40rem'"
|
||||||
title="تصمیم برای مانده حساب"
|
title="تصمیم برای مانده حساب"
|
||||||
:custom-footer="true"
|
:custom-footer="true"
|
||||||
cancel-text="بعداً"
|
cancel-text="بعداً"
|
||||||
@close="close"
|
@close="close"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col gap-3 text-sm" style="color: var(--admin-text)">
|
<div class="flex flex-col gap-3 text-sm" style="color: var(--admin-text)">
|
||||||
<p class="m-0" style="color: var(--admin-text-secondary)">
|
<p class="m-0 leading-6" style="color: var(--admin-text-secondary)">
|
||||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند؛ یکی را پس از بررسی سندها تأیید کنید.
|
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند — یکی از سه مسیر زیر را انتخاب کنید.
|
||||||
</p>
|
</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="rounded-lg border border-base p-3 space-y-2" style="background: var(--admin-bg-muted)">
|
||||||
<div class="flex justify-between gap-2">
|
<div class="flex justify-between gap-2">
|
||||||
<span style="color: var(--admin-text-secondary)">موجودی اپ (طلا)</span>
|
<span style="color: var(--admin-text-secondary)">موجودی اپ (طلا)</span>
|
||||||
@@ -84,12 +92,58 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<a-button type="primary" block :loading="loading === 'overwrite'" :disabled="!!loading" @click="choose('overwrite')">
|
<button
|
||||||
اعمال مانده {{ sourceLabel }} روی کیف
|
type="button"
|
||||||
</a-button>
|
class="mande-choice mande-choice--primary"
|
||||||
<a-button block :loading="loading === 'keep'" :disabled="!!loading" @click="choose('keep')">
|
:disabled="!!loading"
|
||||||
نگه داشتن موجودی فعلی اپ
|
@click="choose('overwrite')"
|
||||||
</a-button>
|
>
|
||||||
|
<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>
|
<a-button type="link" block :disabled="!!loading" @click="close">بعداً</a-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -103,27 +157,34 @@ import BasicModal from '@/components/BasicModal.vue'
|
|||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import type { TahesabPreviewDoc } from '@/api/tahesab'
|
import type { TahesabPreviewDoc } from '@/api/tahesab'
|
||||||
|
|
||||||
const props = defineProps<{
|
export type MandeDecisionMode = 'overwrite' | 'keep' | 'push'
|
||||||
visible: boolean
|
|
||||||
appGold?: number | null
|
const props = withDefaults(
|
||||||
appCash?: number | null
|
defineProps<{
|
||||||
tahesabGold?: number | null
|
visible: boolean
|
||||||
tahesabCash?: number | null
|
appGold?: number | null
|
||||||
sourceGold?: number | null
|
appCash?: number | null
|
||||||
sourceCash?: number | null
|
tahesabGold?: number | null
|
||||||
goldDelta?: number | null
|
tahesabCash?: number | null
|
||||||
rialDelta?: number | null
|
sourceGold?: number | null
|
||||||
sourceLabel?: string
|
sourceCash?: number | null
|
||||||
walletDocs?: TahesabPreviewDoc[]
|
goldDelta?: number | null
|
||||||
tahesabDocs?: TahesabPreviewDoc[]
|
rialDelta?: number | null
|
||||||
}>()
|
sourceLabel?: string
|
||||||
|
/** فقط تهحساب: اجازهٔ نوشتن مانده اپ روی حسابداری */
|
||||||
|
allowPush?: boolean
|
||||||
|
walletDocs?: TahesabPreviewDoc[]
|
||||||
|
tahesabDocs?: TahesabPreviewDoc[]
|
||||||
|
}>(),
|
||||||
|
{ allowPush: false }
|
||||||
|
)
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:visible', value: boolean): void
|
(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 sourceLabel = computed(() => props.sourceLabel || 'تهحساب')
|
||||||
const sourceGoldValue = computed(() => props.sourceGold ?? props.tahesabGold)
|
const sourceGoldValue = computed(() => props.sourceGold ?? props.tahesabGold)
|
||||||
const sourceCashValue = computed(() => props.sourceCash ?? props.tahesabCash)
|
const sourceCashValue = computed(() => props.sourceCash ?? props.tahesabCash)
|
||||||
@@ -140,6 +201,11 @@ const sourceDocs = computed(() => props.tahesabDocs ?? [])
|
|||||||
const showDocs = computed(
|
const showDocs = computed(
|
||||||
() => sourceLabel.value === 'تهحساب' || walletDocs.value.length > 0 || sourceDocs.value.length > 0
|
() => 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({
|
const visibleProxy = computed({
|
||||||
get: () => props.visible,
|
get: () => props.visible,
|
||||||
@@ -186,8 +252,75 @@ function close() {
|
|||||||
visibleProxy.value = false
|
visibleProxy.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function choose(mode: 'overwrite' | 'keep') {
|
function choose(mode: MandeDecisionMode) {
|
||||||
loading.value = mode
|
loading.value = mode
|
||||||
emit('decide', mode)
|
emit('decide', mode)
|
||||||
}
|
}
|
||||||
</script>
|
</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>
|
||||||
<template #accountingCode="{ record }">
|
<template #accountingCode="{ record }">
|
||||||
<button
|
<button
|
||||||
|
v-if="can('accountingCode')"
|
||||||
type="button"
|
type="button"
|
||||||
class="inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-sm cursor-pointer"
|
class="inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-sm cursor-pointer"
|
||||||
style="color: var(--admin-text)"
|
style="color: var(--admin-text)"
|
||||||
@@ -29,10 +30,11 @@
|
|||||||
<span dir="ltr">{{ accountingCodeOf(record) }}</span>
|
<span dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||||
<Icon icon="vuesax-linear:edit-2" size="16" color="#4572E9" />
|
<Icon icon="vuesax-linear:edit-2" size="16" color="#4572E9" />
|
||||||
</button>
|
</button>
|
||||||
|
<span v-else dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="gap-2 hidden md:flex justify-center">
|
<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>
|
<template #title>
|
||||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -47,6 +49,7 @@
|
|||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
|
v-if="can('active')"
|
||||||
:key="record.active"
|
:key="record.active"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -60,12 +63,12 @@
|
|||||||
:color="record.active ? '#54AD06' : '#ad0627'"
|
:color="record.active ? '#54AD06' : '#ad0627'"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</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>
|
<template #title><span>شارژ کیف پول</span></template>
|
||||||
<Icon icon="vuesax-linear:wallet-add" color="#9333ea" />
|
<Icon icon="vuesax-linear:wallet-add" color="#9333ea" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
v-if="can('tahesab') && tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openTahesabRegister(record)"
|
@click="openTahesabRegister(record)"
|
||||||
@@ -74,7 +77,7 @@
|
|||||||
<Icon icon="vuesax-linear:profile-add" color="#CA8A04" />
|
<Icon icon="vuesax-linear:profile-add" color="#CA8A04" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
v-if="can('zarin') && zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openZarinRegister(record)"
|
@click="openZarinRegister(record)"
|
||||||
@@ -83,7 +86,16 @@
|
|||||||
<Icon icon="vuesax-linear:profile-add" color="#0284C7" />
|
<Icon icon="vuesax-linear:profile-add" color="#0284C7" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<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"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openPargarRegister(record)"
|
@click="openPargarRegister(record)"
|
||||||
@@ -92,7 +104,7 @@
|
|||||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="accountingEnabled"
|
v-if="can('accountingCode') && accountingEnabled"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openAccountingCodeEdit(record)"
|
@click="openAccountingCodeEdit(record)"
|
||||||
@@ -100,16 +112,16 @@
|
|||||||
<template #title><span>ویرایش کد حسابداری</span></template>
|
<template #title><span>ویرایش کد حسابداری</span></template>
|
||||||
<Icon icon="vuesax-linear:card-edit" color="#0d9488" />
|
<Icon icon="vuesax-linear:card-edit" color="#0d9488" />
|
||||||
</a-tooltip>
|
</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>
|
<template #title><span>مشخصات</span></template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</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>
|
<template #title><span>ویرایش</span></template>
|
||||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="customerLevelProfitEnabled"
|
v-if="can('referral') && customerLevelProfitEnabled"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openLevelProfit(record)"
|
@click="openLevelProfit(record)"
|
||||||
@@ -118,6 +130,7 @@
|
|||||||
<Icon icon="vuesax-linear:hierarchy-2" color="#ca8a04" />
|
<Icon icon="vuesax-linear:hierarchy-2" color="#ca8a04" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
|
v-if="can('trade')"
|
||||||
:key="record.trade_active"
|
:key="record.trade_active"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -132,7 +145,7 @@
|
|||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="customerDirectSmsEnabled"
|
v-if="can('sms') && customerDirectSmsEnabled"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openDirectSms(record)"
|
@click="openDirectSms(record)"
|
||||||
@@ -141,7 +154,7 @@
|
|||||||
<Icon icon="vuesax-linear:sms" color="#0ea5e9" />
|
<Icon icon="vuesax-linear:sms" color="#0ea5e9" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="!record.is_legal"
|
v-if="can('approve') && !record.is_legal"
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openConfirmUser(record)"
|
@click="openConfirmUser(record)"
|
||||||
@@ -233,6 +246,13 @@
|
|||||||
:customer-name="pargarCustomer?.name"
|
:customer-name="pargarCustomer?.name"
|
||||||
@success="fetch"
|
@success="fetch"
|
||||||
/>
|
/>
|
||||||
|
<ShayeganCustomerRegisterModal
|
||||||
|
v-if="shayeganEnabled && accountingProvider === 'shayegan'"
|
||||||
|
v-model="shayeganRegisterVisible"
|
||||||
|
:customer-id="shayeganCustomer?.id"
|
||||||
|
:customer-name="shayeganCustomer?.name"
|
||||||
|
@success="fetch"
|
||||||
|
/>
|
||||||
</BasicShowContext>
|
</BasicShowContext>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -262,10 +282,12 @@ import { isMobile } from '@core/utils/is'
|
|||||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||||
import ZarinRetryModal from '@/components/ZarinRetryModal.vue'
|
import ZarinRetryModal from '@/components/ZarinRetryModal.vue'
|
||||||
import PargarRetryModal from '@/components/PargarRetryModal.vue'
|
import PargarRetryModal from '@/components/PargarRetryModal.vue'
|
||||||
|
import ShayeganCustomerRegisterModal from '@/components/ShayeganCustomerRegisterModal.vue'
|
||||||
import {
|
import {
|
||||||
tahesabEnabledSetting,
|
tahesabEnabledSetting,
|
||||||
zarinEnabledSetting,
|
zarinEnabledSetting,
|
||||||
pargarEnabledSetting,
|
pargarEnabledSetting,
|
||||||
|
shayeganEnabledSetting,
|
||||||
accountingProviderSetting,
|
accountingProviderSetting,
|
||||||
customerDirectSmsEnabledSetting,
|
customerDirectSmsEnabledSetting,
|
||||||
customerLevelProfitEnabledSetting,
|
customerLevelProfitEnabledSetting,
|
||||||
@@ -274,6 +296,9 @@ import {
|
|||||||
} from '@/utils/config'
|
} from '@/utils/config'
|
||||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||||
import { customersPageIntro } from '@/utils/adminHelpCopy'
|
import { customersPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'chargeWallet'])
|
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'chargeWallet'])
|
||||||
@@ -290,6 +315,10 @@ const zarinEnabled = zarinEnabledSetting
|
|||||||
const pargarRegisterVisible = ref(false)
|
const pargarRegisterVisible = ref(false)
|
||||||
const pargarCustomer = ref<Customer>()
|
const pargarCustomer = ref<Customer>()
|
||||||
const pargarEnabled = pargarEnabledSetting
|
const pargarEnabled = pargarEnabledSetting
|
||||||
|
const shayeganRegisterVisible = ref(false)
|
||||||
|
const shayeganCustomer = ref<Customer>()
|
||||||
|
const shayeganEnabled = shayeganEnabledSetting
|
||||||
|
const accountingProvider = accountingProviderSetting
|
||||||
const customerDirectSmsEnabled = customerDirectSmsEnabledSetting
|
const customerDirectSmsEnabled = customerDirectSmsEnabledSetting
|
||||||
const customerLevelProfitEnabled = customerLevelProfitEnabledSetting
|
const customerLevelProfitEnabled = customerLevelProfitEnabledSetting
|
||||||
const levelProfitVisible = ref(false)
|
const levelProfitVisible = ref(false)
|
||||||
@@ -298,13 +327,13 @@ const accountingCodeVisible = ref(false)
|
|||||||
const accountingCodeCustomer = ref<Customer | null>(null)
|
const accountingCodeCustomer = ref<Customer | null>(null)
|
||||||
const accountingEnabled = computed(() => {
|
const accountingEnabled = computed(() => {
|
||||||
const provider = accountingProviderSetting.value
|
const provider = accountingProviderSetting.value
|
||||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||||
})
|
})
|
||||||
|
|
||||||
function accountingCodeOf(record: Customer) {
|
function accountingCodeOf(record: Customer) {
|
||||||
const provider = accountingProviderSetting.value
|
const provider = accountingProviderSetting.value
|
||||||
if (provider === 'pargar') return displayAccountingCode(record.pargar_account_id)
|
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 '-'
|
return '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +426,11 @@ function openPargarRegister(user: Customer) {
|
|||||||
pargarRegisterVisible.value = true
|
pargarRegisterVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openShayeganRegister(user: Customer) {
|
||||||
|
shayeganCustomer.value = user
|
||||||
|
shayeganRegisterVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
function handleArchive(customer: Customer) {
|
function handleArchive(customer: Customer) {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: 'آیا مشتری را بایگانی می کنید؟',
|
title: 'آیا مشتری را بایگانی می کنید؟',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export type CustomerColumnOptions = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function accountingCodeColumn(provider: AccountingProvider | undefined): BaseTableColumn | null {
|
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'
|
const field = provider === 'pargar' ? 'pargar_account_id' : 'moshtari_code'
|
||||||
return {
|
return {
|
||||||
title: 'کد حسابداری',
|
title: 'کد حسابداری',
|
||||||
|
|||||||
@@ -308,6 +308,7 @@
|
|||||||
<TahesabMandeDecisionModal
|
<TahesabMandeDecisionModal
|
||||||
v-model:visible="tahesabDecisionVisible"
|
v-model:visible="tahesabDecisionVisible"
|
||||||
:source-label="walletDecisionLabel"
|
:source-label="walletDecisionLabel"
|
||||||
|
:allow-push="walletDecisionProvider === 'tahesab'"
|
||||||
:app-gold="tahesabDecision?.app_gold"
|
:app-gold="tahesabDecision?.app_gold"
|
||||||
:app-cash="tahesabDecision?.app_cash"
|
:app-cash="tahesabDecision?.app_cash"
|
||||||
:tahesab-gold="tahesabDecision?.tahesab_gold ?? tahesabDecision?.zarin_gold"
|
:tahesab-gold="tahesabDecision?.tahesab_gold ?? tahesabDecision?.zarin_gold"
|
||||||
@@ -774,7 +775,7 @@ const userInfo = ref<Customer>()
|
|||||||
|
|
||||||
const accountingCodeVisible = computed(() => {
|
const accountingCodeVisible = computed(() => {
|
||||||
const provider = accountingProviderSetting.value
|
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)
|
const conditionalOrderEnabled = computed(() => conditionalOrderEnabledSetting.value)
|
||||||
@@ -796,7 +797,7 @@ function onConditionalOrderUpdated(payload: {
|
|||||||
const accountingCodeValue = computed(() => {
|
const accountingCodeValue = computed(() => {
|
||||||
const provider = accountingProviderSetting.value
|
const provider = accountingProviderSetting.value
|
||||||
if (provider === 'pargar') return displayAccountingCode(userInfo.value?.pargar_account_id)
|
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 '-'
|
return '-'
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -855,7 +856,7 @@ function openTahesabDecision(result?: TahesabWalletSyncResult['result'], provide
|
|||||||
tahesabDecisionVisible.value = true
|
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
|
if (!userInfo.value?.id || !tahesabWalletCanSync.value || tahesabSyncLoading.value) return
|
||||||
tahesabSyncLoading.value = true
|
tahesabSyncLoading.value = true
|
||||||
try {
|
try {
|
||||||
@@ -877,6 +878,7 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
|||||||
ask_if_conflict: false,
|
ask_if_conflict: false,
|
||||||
overwrite: mode === 'overwrite',
|
overwrite: mode === 'overwrite',
|
||||||
keep: mode === 'keep',
|
keep: mode === 'keep',
|
||||||
|
push_to_tahesab: mode === 'push',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res.needs_decision || res.result?.needs_decision) {
|
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) {
|
if (res.result?.applied || res.ok) {
|
||||||
message.success(res.message || 'مانده از تهحساب روی کیف اعمال شد')
|
message.success(
|
||||||
|
res.message ||
|
||||||
|
(mode === 'push'
|
||||||
|
? 'مانده اپ روی تهحساب اعمال شد'
|
||||||
|
: mode === 'keep'
|
||||||
|
? 'موجودی اپ حفظ شد'
|
||||||
|
: 'مانده از تهحساب روی کیف اعمال شد')
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
message.info(res.message || 'تغییری برای اعمال نبود')
|
message.info(res.message || 'تغییری برای اعمال نبود')
|
||||||
}
|
}
|
||||||
@@ -902,18 +911,24 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
|||||||
refreshTable()
|
refreshTable()
|
||||||
|
|
||||||
if (data?.result?.applied || data?.ok) {
|
if (data?.result?.applied || data?.ok) {
|
||||||
message.success(data?.message || 'مانده از تهحساب روی کیف اعمال شد')
|
message.success(data?.message || 'مانده با تهحساب همتراز شد')
|
||||||
} else if (status !== 422) {
|
} else if (status !== 422) {
|
||||||
message.warning(data?.message || 'اعمال مانده از تهحساب ناموفق بود')
|
message.warning(data?.message || 'اعمال مانده با تهحساب ناموفق بود')
|
||||||
|
} else if (data?.message) {
|
||||||
|
message.warning(data.message)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
tahesabSyncLoading.value = false
|
tahesabSyncLoading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep') {
|
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||||
tahesabDecisionVisible.value = false
|
tahesabDecisionVisible.value = false
|
||||||
if (walletDecisionProvider.value === 'zarin') {
|
if (walletDecisionProvider.value === 'zarin') {
|
||||||
|
if (mode === 'push') {
|
||||||
|
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||||
|
return
|
||||||
|
}
|
||||||
await syncZarinWallet(mode)
|
await syncZarinWallet(mode)
|
||||||
return
|
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>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex gap-3 justify-center items-center">
|
<div class="flex gap-3 justify-center items-center">
|
||||||
<a-tooltip placement="top">
|
<a-tooltip v-if="can('detail')" placement="top">
|
||||||
<template #title>جزئیات</template>
|
<template #title>جزئیات</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:eye"
|
icon="vuesax-linear:eye"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
@click.stop="openDetails(record)"
|
@click.stop="openDetails(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</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>
|
<template #title>ویرایش</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
@@ -86,6 +86,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
|||||||
import { getCustomersList } from '@/api/customer'
|
import { getCustomersList } from '@/api/customer'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import type { Item } from '@/model/Item'
|
import type { Item } from '@/model/Item'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const modalVisible = ref(false)
|
const modalVisible = ref(false)
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<BaseTable v-bind="tblProps" @register="registerTable" ref="tbl">
|
<BaseTable v-bind="tblProps" @register="registerTable" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div v-if="record.status === 'pending'" class="flex gap-2 justify-center">
|
<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>
|
||||||
<BaseButton size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
<BaseButton v-if="can('reject')" size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
<span v-else class="text-gray-400 text-xs">—</span>
|
<span v-else class="text-gray-400 text-xs">—</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -46,6 +46,9 @@ import {
|
|||||||
} from '@/api/goldCredit'
|
} from '@/api/goldCredit'
|
||||||
import GoldCreditModal from '@/pages/menuPages/customers/base/components/goldCreditModal.vue'
|
import GoldCreditModal from '@/pages/menuPages/customers/base/components/goldCreditModal.vue'
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [registerTable, reload] = useBaseTable()
|
const [registerTable, reload] = useBaseTable()
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { computed } from 'vue'
|
|||||||
import BasicMenu from '@/components/BasicMenu/index.vue'
|
import BasicMenu from '@/components/BasicMenu/index.vue'
|
||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import { get } from 'lodash'
|
import { get } from 'lodash'
|
||||||
import { customerSpecialPricingEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
import { customerSpecialPricingEnabledSetting, digipayInstallmentEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
||||||
|
|
||||||
initWalletSettingsFromApi()
|
initWalletSettingsFromApi()
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ const menu = computed(() => {
|
|||||||
.filter((child) => {
|
.filter((child) => {
|
||||||
if (child.name === 'customerMain_specialPrice') return customerSpecialPricingEnabledSetting.value
|
if (child.name === 'customerMain_specialPrice') return customerSpecialPricingEnabledSetting.value
|
||||||
if (child.name === 'customerMain_goldCredit') return goldCreditEnabledSetting.value
|
if (child.name === 'customerMain_goldCredit') return goldCreditEnabledSetting.value
|
||||||
|
if (child.name === 'customerMain_digipayInstallment') return digipayInstallmentEnabledSetting.value
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
.sort((a, b) => (a.meta?.order ?? 99) - (b.meta?.order ?? 99))
|
.sort((a, b) => (a.meta?.order ?? 99) - (b.meta?.order ?? 99))
|
||||||
|
|||||||
@@ -391,7 +391,21 @@ async function submitEdit() {
|
|||||||
await editFormRef.value?.validate()
|
await editFormRef.value?.validate()
|
||||||
if (!editId.value) return
|
if (!editId.value) return
|
||||||
actionLoading.value = true
|
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('ویرایش با موفقیت انجام شد')
|
message.success('ویرایش با موفقیت انجام شد')
|
||||||
editVisible.value = false
|
editVisible.value = false
|
||||||
await load()
|
await load()
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex items-center justify-center gap-2">
|
<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>
|
<template #title><span>ویرایش</span></template>
|
||||||
<Icon icon="vuesax-linear:edit-2" color="#4572E9" />
|
<Icon icon="vuesax-linear:edit-2" color="#4572E9" />
|
||||||
</a-tooltip>
|
</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>
|
<template #title>
|
||||||
<span>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</span>
|
<span>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
|
v-if="can('delete')"
|
||||||
title="پکیج حذف شود؟"
|
title="پکیج حذف شود؟"
|
||||||
ok-text="تایید"
|
ok-text="تایید"
|
||||||
cancel-text="انصراف"
|
cancel-text="انصراف"
|
||||||
@@ -56,6 +57,9 @@ import { getSpecialPricePackageColumns } from '../hooks/specialPriceColumns'
|
|||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { specialPricePageIntro } from '@/utils/adminHelpCopy'
|
import { specialPricePageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const emits = defineEmits<{
|
const emits = defineEmits<{
|
||||||
(e: 'add'): void
|
(e: 'add'): void
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ column, record }">
|
<template #action="{ column, record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<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>
|
<template #title>
|
||||||
<span>ویرایش</span>
|
<span>ویرایش</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -30,6 +30,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
|||||||
import { cols } from '../hooks/discountColumns'
|
import { cols } from '../hooks/discountColumns'
|
||||||
import { getDiscountTable } from '@/api/discount'
|
import { getDiscountTable } from '@/api/discount'
|
||||||
import { discountPageIntro } from '@/utils/adminHelpCopy'
|
import { discountPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,39 @@
|
|||||||
@cancel="close"
|
@cancel="close"
|
||||||
@close="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
|
<a-table
|
||||||
class="hidden md:block"
|
class="hidden md:block"
|
||||||
@@ -22,6 +54,21 @@
|
|||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record, index }">
|
<template #bodyCell="{ column, record, index }">
|
||||||
<template v-if="column.key === 'index'">{{ index + 1 }}</template>
|
<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'">
|
<template v-else-if="column.key === 'sts'">
|
||||||
<CustomTag v-if="record.sts === 1" textColor="#ca8a04" bgColor="#fef3c7">فعال</CustomTag>
|
<CustomTag v-if="record.sts === 1" textColor="#ca8a04" bgColor="#fef3c7">فعال</CustomTag>
|
||||||
<CustomTag v-else-if="record.sts === 2" textColor="#25855A" bgColor="#E3F4E9">استفاده شده</CustomTag>
|
<CustomTag v-else-if="record.sts === 2" textColor="#25855A" bgColor="#E3F4E9">استفاده شده</CustomTag>
|
||||||
@@ -63,19 +110,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Giftcardcode } from '@/model/giftCard'
|
import type { Giftcard, Giftcardcode } from '@/model/giftCard'
|
||||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||||
import CustomTag from '@/components/CustomTag.vue'
|
import CustomTag from '@/components/CustomTag.vue'
|
||||||
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
||||||
import { isMobile } from '@core/utils/is'
|
|
||||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import GiftCardCodeMobileDetailSheet from './GiftCardCodeMobileDetailSheet.vue'
|
import GiftCardCodeMobileDetailSheet from './GiftCardCodeMobileDetailSheet.vue'
|
||||||
import GiftCardCodeMobileListItem from './GiftCardCodeMobileListItem.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<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
codes: Giftcardcode[]
|
codes: Giftcardcode[]
|
||||||
|
giftCard?: Giftcard | null
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -97,11 +156,54 @@ const columns = [
|
|||||||
{ title: 'وضعیت', dataIndex: 'sts', key: 'sts' },
|
{ title: 'وضعیت', dataIndex: 'sts', key: 'sts' },
|
||||||
{ title: 'تاریخ انقضا', dataIndex: 'expiry_date', key: 'expiry_date' },
|
{ title: 'تاریخ انقضا', dataIndex: 'expiry_date', key: 'expiry_date' },
|
||||||
{ title: 'تاریخ استفاده', dataIndex: 'used_at', key: 'used_at' },
|
{ title: 'تاریخ استفاده', dataIndex: 'used_at', key: 'used_at' },
|
||||||
{ title: 'نام کاربر اختصاص داده شده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
{ title: 'نام استفادهکننده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
||||||
{ title: 'شماره موبایل کاربر اختصاص داده شده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
{ title: 'موبایل استفادهکننده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
||||||
]
|
]
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
visibleProxy.value = false
|
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>
|
</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>
|
<template>
|
||||||
<a-form :model="form" ref="formRef" autocomplete="off">
|
<a-form :model="props.form" ref="formRef" autocomplete="off">
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<a-form-item name="mobile" :rules="inputLenRules(11)">
|
<a-form-item name="assignMode" :rules="inputRules()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp label="شماره موبایل مشتری" :help="giftCardMobileHelp" />
|
<AdminLabelWithHelp label="نوع ثبت" :help="giftCardAssignModeHelp" />
|
||||||
</template>
|
</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>
|
||||||
|
|
||||||
<a-form-item name="name" :rules="inputRules()">
|
<a-form-item v-if="isPublicMode" name="show_in_app" :rules="inputRules()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp label="نام مشتری" :help="giftCardNameHelp" />
|
<AdminLabelWithHelp label="نمایش در اپ کاربر" :help="giftCardPublicVisibilityHelp" />
|
||||||
</template>
|
</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>
|
||||||
|
|
||||||
<a-form-item name="unit" :rules="inputRules()">
|
<a-form-item name="unit" :rules="inputRules()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp label="نوع کارت هدیه" :help="giftCardUnitHelp" />
|
<AdminLabelWithHelp label="نوع کارت هدیه" :help="giftCardUnitHelp" />
|
||||||
</template>
|
</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="1">ریالی</a-radio-button>
|
||||||
<a-radio-button value="2">{{ metalLabel.goldWalletShort() }}</a-radio-button>
|
<a-radio-button value="2">{{ metalLabel.goldWalletShort() }}</a-radio-button>
|
||||||
</a-radio-group>
|
</a-radio-group>
|
||||||
@@ -29,33 +52,33 @@
|
|||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp label="تعداد کدها" :help="giftCardCountHelp" />
|
<AdminLabelWithHelp label="تعداد کدها" :help="giftCardCountHelp" />
|
||||||
</template>
|
</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>
|
||||||
|
|
||||||
<a-form-item name="amount" :rules="inputRulesNumber()">
|
<a-form-item name="amount" :rules="inputRulesNumber()">
|
||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp
|
<AdminLabelWithHelp
|
||||||
:label="`مقدار ${form.unit === '2' ? '(گرم)' : '(ریال)'}`"
|
:label="`مقدار ${props.form.unit === '2' ? '(گرم)' : '(ریال)'}`"
|
||||||
:help="giftCardAmountHelp"
|
:help="giftCardAmountHelp"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<BasicInput
|
<BasicInput
|
||||||
v-model:value="form.amount"
|
v-model:value="props.form.amount"
|
||||||
:addon-before="form.unit === '2' ? 'گرم' : 'ریال'"
|
:addon-before="props.form.unit === '2' ? 'گرم' : 'ریال'"
|
||||||
type="tel"
|
type="tel"
|
||||||
placeholder="مقدار کارت هدیه"
|
placeholder="مقدار کارت هدیه"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item name="expiry_date" :rules="inputRules()">
|
<a-form-item name="expiry_date" :rules="expiryDateRules">
|
||||||
<template #label>
|
<template #label>
|
||||||
<AdminLabelWithHelp label="تاریخ انقضا" :help="giftCardExpiryHelp" />
|
<AdminLabelWithHelp label="تاریخ انقضا" :help="giftCardExpiryHelp" />
|
||||||
</template>
|
</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>
|
||||||
|
|
||||||
<a-form-item label="توضیحات" name="description" class="mb-0">
|
<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>
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
</a-form>
|
</a-form>
|
||||||
@@ -64,23 +87,108 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { FormInstance } from 'ant-design-vue'
|
import type { FormInstance } from 'ant-design-vue'
|
||||||
import type { GiftcardInput } from '@/model/giftCard'
|
import type { GiftcardInput } from '@/model/giftCard'
|
||||||
|
import { getCustomersList } from '@/api/customer'
|
||||||
|
import type { Customer } from '@/model/customer'
|
||||||
import AdminLabelWithHelp from '@/components/AdminLabelWithHelp.vue'
|
import AdminLabelWithHelp from '@/components/AdminLabelWithHelp.vue'
|
||||||
import {
|
import {
|
||||||
giftCardAmountHelp,
|
giftCardAmountHelp,
|
||||||
|
giftCardAssignModeHelp,
|
||||||
giftCardCountHelp,
|
giftCardCountHelp,
|
||||||
|
giftCardCustomerSelectHelp,
|
||||||
giftCardExpiryHelp,
|
giftCardExpiryHelp,
|
||||||
giftCardMobileHelp,
|
giftCardPublicVisibilityHelp,
|
||||||
giftCardNameHelp,
|
|
||||||
giftCardUnitHelp,
|
giftCardUnitHelp,
|
||||||
} from '@/utils/adminHelpCopy'
|
} 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 { metalLabel } from '@/utils/adminMetalLabels'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
form: GiftcardInput
|
form: GiftcardInput
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const formRef = ref<FormInstance>()
|
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({
|
defineExpose({
|
||||||
validateFields: () => formRef.value?.validateFields(),
|
validateFields: () => formRef.value?.validateFields(),
|
||||||
|
|||||||
@@ -16,8 +16,13 @@
|
|||||||
:key="item.id"
|
:key="item.id"
|
||||||
:item="item"
|
:item="item"
|
||||||
:hide-customer="!!customerId"
|
:hide-customer="!!customerId"
|
||||||
|
:can-edit="canEdit"
|
||||||
|
:can-delete="canDelete"
|
||||||
|
:can-codes="canCodes"
|
||||||
@open="openSheet"
|
@open="openSheet"
|
||||||
@gift-card-codes="$emit('giftCardCodes', $event)"
|
@gift-card-codes="$emit('giftCardCodes', $event)"
|
||||||
|
@edit="$emit('edit', $event)"
|
||||||
|
@delete="$emit('delete', $event)"
|
||||||
/>
|
/>
|
||||||
</MobileCardList>
|
</MobileCardList>
|
||||||
|
|
||||||
@@ -38,10 +43,15 @@ type GiftCardRow = Giftcard & { customer?: { name?: string; mobile?: string } }
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
customerId?: number
|
customerId?: number
|
||||||
|
canEdit?: boolean
|
||||||
|
canDelete?: boolean
|
||||||
|
canCodes?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(e: 'giftCardCodes', item: GiftCardRow): void
|
(e: 'giftCardCodes', item: GiftCardRow): void
|
||||||
|
(e: 'edit', item: GiftCardRow): void
|
||||||
|
(e: 'delete', id: number): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<GiftCardRow>()
|
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<GiftCardRow>()
|
||||||
|
|||||||
@@ -18,11 +18,26 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="canCodes"
|
||||||
icon="vuesax-linear:document-text"
|
icon="vuesax-linear:document-text"
|
||||||
color="#1890ff"
|
color="#1890ff"
|
||||||
:size="20"
|
:size="20"
|
||||||
@click="$emit('giftCardCodes', item)"
|
@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>
|
</div>
|
||||||
</MobileCard>
|
</MobileCard>
|
||||||
</template>
|
</template>
|
||||||
@@ -38,11 +53,16 @@ type GiftCardRow = Giftcard & { customer?: { name?: string; mobile?: string } }
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: GiftCardRow
|
item: GiftCardRow
|
||||||
hideCustomer?: boolean
|
hideCustomer?: boolean
|
||||||
|
canEdit?: boolean
|
||||||
|
canDelete?: boolean
|
||||||
|
canCodes?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(e: 'open', item: GiftCardRow): void
|
(e: 'open', item: GiftCardRow): void
|
||||||
(e: 'giftCardCodes', 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() : 'ریالی'))
|
const unitLabel = computed(() => (props.item.unit === 2 ? metalLabel.goldWalletShort() : 'ریالی'))
|
||||||
|
|||||||
@@ -23,22 +23,43 @@
|
|||||||
>
|
>
|
||||||
افزودن کد تخفیف
|
افزودن کد تخفیف
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
|
<BaseButton
|
||||||
|
v-if="!customerId && (can('usageReport') || can('codes'))"
|
||||||
|
type="default"
|
||||||
|
size="small"
|
||||||
|
icon="vuesax-linear:chart-2"
|
||||||
|
@click="usageReportVisible = true"
|
||||||
|
>
|
||||||
|
گزارش استفاده کدها
|
||||||
|
</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ column, record }">
|
<template #action="{ column, record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<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>
|
<template #title>
|
||||||
<span>مشخصات</span>
|
<span>مشخصات</span>
|
||||||
</template>
|
</template>
|
||||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||||
</a-tooltip>
|
</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>
|
<template #title>
|
||||||
<span>کدهای {{ record.unit == 3 ? 'تخفیف' : 'کارت هدیه' }}</span>
|
<span>کدهای {{ record.unit == 3 ? 'تخفیف' : 'کارت هدیه' }}</span>
|
||||||
</template>
|
</template>
|
||||||
<Icon icon="vuesax-linear:document-text" color="#1890ff" />
|
<Icon icon="vuesax-linear:document-text" color="#1890ff" />
|
||||||
</a-tooltip>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</BaseTable>
|
</BaseTable>
|
||||||
@@ -49,9 +70,16 @@
|
|||||||
class="min-h-0 flex-1"
|
class="min-h-0 flex-1"
|
||||||
:customer-id="customerId"
|
:customer-id="customerId"
|
||||||
@gift-card-codes="emits('giftcardcodes', $event)"
|
@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>
|
</div>
|
||||||
</BasicShowContext>
|
</BasicShowContext>
|
||||||
|
|
||||||
|
<GiftCardCodesUsageReportSheet v-model:visible="usageReportVisible" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -66,6 +94,8 @@ import GiftCardMobileCardList from './GiftCardMobileCardList.vue'
|
|||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { isStoreApp } from '@/utils/config'
|
import { isStoreApp } from '@/utils/config'
|
||||||
import { giftCardsPageIntro } from '@/utils/adminHelpCopy'
|
import { giftCardsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
import GiftCardCodesUsageReportSheet from './GiftCardCodesUsageReportSheet.vue'
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
customerId?: number
|
customerId?: number
|
||||||
@@ -73,6 +103,8 @@ interface Prop {
|
|||||||
|
|
||||||
const props = defineProps<Prop>()
|
const props = defineProps<Prop>()
|
||||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'giftcardcodes'])
|
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'giftcardcodes'])
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
const usageReportVisible = ref(false)
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
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 CustomTag from '@/components/CustomTag.vue'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||||
|
import { giftCardCustomerLabel, giftCardCustomerMobile } from '../utils/giftCardCustomer'
|
||||||
/*import BudgetSelect from '@/components/BudgetSelect.vue'
|
/*import BudgetSelect from '@/components/BudgetSelect.vue'
|
||||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||||
import type { FilterSelect } from '@/model/filterSelect'
|
import type { FilterSelect } from '@/model/filterSelect'
|
||||||
@@ -105,18 +106,14 @@ export function getGiftCardColumns(): BaseTableColumn[] {
|
|||||||
dataIndex: 'customer.name',
|
dataIndex: 'customer.name',
|
||||||
key: 'customer.name',
|
key: 'customer.name',
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
customRender: ({ record }) => {
|
customRender: ({ record }) => giftCardCustomerLabel(record)
|
||||||
return record.customer?.name ?? '-'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'شماره موبایل مشتری',
|
title: 'شماره موبایل مشتری',
|
||||||
dataIndex: 'customer.mobile',
|
dataIndex: 'customer.mobile',
|
||||||
key: 'customer.mobile',
|
key: 'customer.mobile',
|
||||||
type: 'Number',
|
type: 'Number',
|
||||||
customRender: ({ record }) => {
|
customRender: ({ record }) => giftCardCustomerMobile(record)
|
||||||
return record.customer?.mobile ?? '-'
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'توضیحات',
|
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"
|
:name="infoParams.name"
|
||||||
:items="infoParams.items"
|
:items="infoParams.items"
|
||||||
/>
|
/>
|
||||||
<GiftCardCodesSheet v-model:visible="giftCardCodesVisible" :codes="selectedGiftCardCodes" />
|
<GiftCardCodesSheet
|
||||||
|
v-model:visible="giftCardCodesVisible"
|
||||||
|
:codes="selectedGiftCardCodes"
|
||||||
|
:gift-card="selectedGiftCard"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -112,10 +116,11 @@ import { confirmDeleteItem } from '@/utils/confirmModal'
|
|||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
import type { Item } from '@/model/Item'
|
import type { Item } from '@/model/Item'
|
||||||
import type { Customer } from '@/model/customer'
|
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 { usePrice } from '@core/utils/usePrice'
|
||||||
import type { Giftcard, Giftcardcode, GiftcardInput } from '@/model/giftCard'
|
import type { Giftcard, Giftcardcode, GiftcardInput } from '@/model/giftCard'
|
||||||
import { createGiftCard } from '@/api/giftCard'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||||
@@ -131,6 +136,7 @@ import {
|
|||||||
discountPercentHelp,
|
discountPercentHelp,
|
||||||
} from '@/utils/adminHelpCopy'
|
} from '@/utils/adminHelpCopy'
|
||||||
import BaseDatePicker from '@core/components/BaseDatePicker'
|
import BaseDatePicker from '@core/components/BaseDatePicker'
|
||||||
|
import { giftCardCustomerLabel, giftCardCustomerMobile } from './utils/giftCardCustomer'
|
||||||
|
|
||||||
//loading
|
//loading
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
@@ -165,8 +171,9 @@ function closeGiftCardSheet() {
|
|||||||
|
|
||||||
//form
|
//form
|
||||||
const form = ref<GiftcardInput>({
|
const form = ref<GiftcardInput>({
|
||||||
mobile: '',
|
assignMode: 'public',
|
||||||
name: '',
|
customer_id: undefined,
|
||||||
|
show_in_app: 0,
|
||||||
count: undefined,
|
count: undefined,
|
||||||
amount: undefined,
|
amount: undefined,
|
||||||
unit: '1',
|
unit: '1',
|
||||||
@@ -178,12 +185,17 @@ const form = ref<GiftcardInput>({
|
|||||||
let infoParams = reactive<Info>({})
|
let infoParams = reactive<Info>({})
|
||||||
const giftCardCodesVisible = ref<boolean>(false)
|
const giftCardCodesVisible = ref<boolean>(false)
|
||||||
const selectedGiftCardCodes = ref<Giftcardcode[]>([])
|
const selectedGiftCardCodes = ref<Giftcardcode[]>([])
|
||||||
|
const selectedGiftCard = ref<Giftcard | null>(null)
|
||||||
|
|
||||||
function info(val: Giftcard) {
|
function info(val: Giftcard) {
|
||||||
|
if (!giftPageAllows('info')) {
|
||||||
|
notifyPageActionDenied('info')
|
||||||
|
return
|
||||||
|
}
|
||||||
// نمایش اطلاعات اصلی در BasicInfoModal
|
// نمایش اطلاعات اصلی در BasicInfoModal
|
||||||
infoParams.title = 'اطلاعات کارت هدیه'
|
infoParams.title = 'اطلاعات کارت هدیه'
|
||||||
infoParams.name = val.customer?.name ?? '-'
|
infoParams.name = giftCardCustomerLabel(val)
|
||||||
infoParams.type = val.customer?.mobile ?? '-'
|
infoParams.type = giftCardCustomerMobile(val)
|
||||||
infoParams.date = toJalaliNoTime(val.created_at)
|
infoParams.date = toJalaliNoTime(val.created_at)
|
||||||
infoParams.time = toTime(val.created_at)
|
infoParams.time = toTime(val.created_at)
|
||||||
infoParams.itemsTitle = 'اطلاعات کارت هدیه'
|
infoParams.itemsTitle = 'اطلاعات کارت هدیه'
|
||||||
@@ -192,6 +204,18 @@ function info(val: Giftcard) {
|
|||||||
key: 'کد',
|
key: 'کد',
|
||||||
value: val.id ?? '-'
|
value: val.id ?? '-'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'نوع ثبت',
|
||||||
|
value: val.customer_id ? 'اختصاصی' : Number(val.show_in_app) === 1 ? 'عمومی — نمایش در اپ' : 'عمومی — مخفی (فقط با کد)'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'مشتری',
|
||||||
|
value: giftCardCustomerLabel(val)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'موبایل مشتری',
|
||||||
|
value: giftCardCustomerMobile(val)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'نوع کارت هدیه',
|
key: 'نوع کارت هدیه',
|
||||||
value: val.unit === 3 ? 'تخفیف' : val.unit === 2 ? metalLabel.goldWalletShort() : 'ریالی'
|
value: val.unit === 3 ? 'تخفیف' : val.unit === 2 ? metalLabel.goldWalletShort() : 'ریالی'
|
||||||
@@ -208,10 +232,6 @@ function info(val: Giftcard) {
|
|||||||
key: 'مبلغ کل (ریال)',
|
key: 'مبلغ کل (ریال)',
|
||||||
value: usePrice(val.total ?? 0)
|
value: usePrice(val.total ?? 0)
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'کد یکتا',
|
|
||||||
value: val.unique_code ?? '-'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'تعداد استفاده شده',
|
key: 'تعداد استفاده شده',
|
||||||
value: val.used_count ?? '-'
|
value: val.used_count ?? '-'
|
||||||
@@ -237,8 +257,13 @@ function info(val: Giftcard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showGiftCardCodes(val: Giftcard) {
|
function showGiftCardCodes(val: Giftcard) {
|
||||||
|
if (!giftPageAllows('codes')) {
|
||||||
|
notifyPageActionDenied('codes')
|
||||||
|
return
|
||||||
|
}
|
||||||
// نمایش کدهای کارت هدیه در مودال جداگانه
|
// نمایش کدهای کارت هدیه در مودال جداگانه
|
||||||
if (val.giftcardcodes && val.giftcardcodes.length > 0) {
|
if (val.giftcardcodes && val.giftcardcodes.length > 0) {
|
||||||
|
selectedGiftCard.value = val
|
||||||
selectedGiftCardCodes.value = val.giftcardcodes
|
selectedGiftCardCodes.value = val.giftcardcodes
|
||||||
giftCardCodesVisible.value = true
|
giftCardCodesVisible.value = true
|
||||||
} else {
|
} else {
|
||||||
@@ -249,12 +274,29 @@ function showGiftCardCodes(val: Giftcard) {
|
|||||||
//edit
|
//edit
|
||||||
let editId: number | undefined = undefined
|
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) {
|
async function edit(record: Giftcard) {
|
||||||
|
if (!giftPageAllows('edit')) {
|
||||||
|
notifyPageActionDenied('edit')
|
||||||
|
return
|
||||||
|
}
|
||||||
addGiftCardVisible.value = true
|
addGiftCardVisible.value = true
|
||||||
editId = record.id
|
editId = record.id
|
||||||
form.value = {
|
form.value = {
|
||||||
mobile: record.customer?.mobile ?? '',
|
assignMode: record.customer_id ? 'customer' : 'public',
|
||||||
name: record.customer?.name ?? '',
|
customer_id: record.customer_id ?? undefined,
|
||||||
|
show_in_app: record.customer_id ? 0 : Number(record.show_in_app) === 1 ? 1 : 0,
|
||||||
count: record.count,
|
count: record.count,
|
||||||
amount: record.amount,
|
amount: record.amount,
|
||||||
unit: record.unit.toString(),
|
unit: record.unit.toString(),
|
||||||
@@ -322,8 +364,9 @@ async function addGiftOrDiscount(type: 'gift' | 'discount' = 'gift') {
|
|||||||
const resetData = () => {
|
const resetData = () => {
|
||||||
giftCardEditorRef.value?.resetFields?.()
|
giftCardEditorRef.value?.resetFields?.()
|
||||||
form.value = {
|
form.value = {
|
||||||
mobile: '',
|
assignMode: 'public',
|
||||||
name: '',
|
customer_id: undefined,
|
||||||
|
show_in_app: 0,
|
||||||
count: undefined,
|
count: undefined,
|
||||||
amount: undefined,
|
amount: undefined,
|
||||||
unit: '1',
|
unit: '1',
|
||||||
@@ -333,7 +376,13 @@ const resetData = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete
|
//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
|
//add project modal
|
||||||
const addGiftCardVisible = ref<boolean>(false)
|
const addGiftCardVisible = ref<boolean>(false)
|
||||||
@@ -341,26 +390,42 @@ const userInfoVisible = ref<boolean>(false)
|
|||||||
|
|
||||||
//submit gift card
|
//submit gift card
|
||||||
async function ok() {
|
async function ok() {
|
||||||
|
if (loading.value) return
|
||||||
await giftCardEditorRef.value?.validateFields?.().then(async () => {
|
await giftCardEditorRef.value?.validateFields?.().then(async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
// تنظیم تاریخ انقضا به آخر همان روز (23:59:59) و تبدیل به میلادی
|
const formData: Record<string, unknown> = {
|
||||||
const formData = { ...form.value }
|
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) {
|
if (formData.expiry_date) {
|
||||||
// تبدیل به میلادی و تنظیم به آخر روز
|
// تبدیل به میلادی و تنظیم به آخر روز
|
||||||
formData.expiry_date = dayjs(formData.expiry_date)
|
formData.expiry_date = dayjs(formData.expiry_date as string)
|
||||||
.calendar('gregory')
|
.calendar('gregory')
|
||||||
.endOf('day')
|
.endOf('day')
|
||||||
.format('YYYY-MM-DD HH:mm:ss')
|
.format('YYYY-MM-DD HH:mm:ss')
|
||||||
}
|
}
|
||||||
await createGiftCard(formData)
|
if (editId) {
|
||||||
message.success('کارت هدیه با موفقیت ثبت شد')
|
await updateGiftCard(editId, formData as GiftcardInput)
|
||||||
|
message.success('کارت هدیه با موفقیت ویرایش شد')
|
||||||
|
} else {
|
||||||
|
await createGiftCard(formData as GiftcardInput)
|
||||||
|
message.success('کارت هدیه با موفقیت ثبت شد')
|
||||||
|
}
|
||||||
addGiftCardVisible.value = false
|
addGiftCardVisible.value = false
|
||||||
resetData()
|
resetData()
|
||||||
refreshTable()
|
refreshTable()
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
message.error('خطا در ثبت کارت هدیه')
|
message.error(e?.response?.data?.message || 'خطا در ثبت کارت هدیه')
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
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>
|
||||||
<template #action="{ column, record }">
|
<template #action="{ column, record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<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>
|
<template #title>
|
||||||
<span>مشخصات</span>
|
<span>مشخصات</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -50,6 +50,9 @@ import { getOrderTable } from '@/api/order'
|
|||||||
import OrderMobileCardList from './OrderMobileCardList.vue'
|
import OrderMobileCardList from './OrderMobileCardList.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { ordersPageIntro } from '@/utils/adminHelpCopy'
|
import { ordersPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex items-center justify-center gap-2">
|
<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>
|
<template #title>ویرایش مقدار</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit-2"
|
icon="vuesax-linear:edit-2"
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<a-tooltip v-if="canApprove(record)">
|
<a-tooltip v-if="can('approve') && canApprove(record)">
|
||||||
<template #title>{{ physicalWithdrawApproveHelp }}</template>
|
<template #title>{{ physicalWithdrawApproveHelp }}</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:tick-circle"
|
icon="vuesax-linear:tick-circle"
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
|
|
||||||
<ADropdown v-if="canChangeStatus(record)" :trigger="['click']">
|
<ADropdown v-if="can('status') && canChangeStatus(record)" :trigger="['click']">
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
<template #title>{{ physicalWithdrawStatusHelp }}</template>
|
<template #title>{{ physicalWithdrawStatusHelp }}</template>
|
||||||
<Icon icon="vuesax-linear:status-up" color="#CA8A04" class="cursor-pointer" />
|
<Icon icon="vuesax-linear:status-up" color="#CA8A04" class="cursor-pointer" />
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</ADropdown>
|
</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>
|
<template #title>دریافت فاکتور</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:document-download"
|
icon="vuesax-linear:document-download"
|
||||||
@@ -92,6 +92,9 @@ import {
|
|||||||
physicalWithdrawPageIntro,
|
physicalWithdrawPageIntro,
|
||||||
physicalWithdrawStatusHelp
|
physicalWithdrawStatusHelp
|
||||||
} from '@/utils/adminHelpCopy'
|
} from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const emits = defineEmits(['add'])
|
const emits = defineEmits(['add'])
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
:items="productItems"
|
:items="productItems"
|
||||||
key-name="id"
|
key-name="id"
|
||||||
value-name="label"
|
value-name="label"
|
||||||
placeholder="آبشده، سکه، نقره و ..."
|
placeholder="کاتد مس، مفتول مس و..."
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<div class="flex justify-center gap-2">
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||||
<template #title>ویرایش</template>
|
<template #title>ویرایش</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
@click="emits('edit', record)"
|
@click="emits('edit', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||||
<Icon
|
<Icon
|
||||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
@click="emits('toggle', record)"
|
@click="emits('toggle', record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom">
|
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||||
<template #title>حذف</template>
|
<template #title>حذف</template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:trash"
|
icon="vuesax-linear:trash"
|
||||||
@@ -52,6 +52,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
|||||||
import { cols } from '../hooks/priceTriggersColumns'
|
import { cols } from '../hooks/priceTriggersColumns'
|
||||||
import { getPriceTriggersTable } from '@/api/priceTriggers'
|
import { getPriceTriggersTable } from '@/api/priceTriggers'
|
||||||
import { priceTriggersPageIntro } from '@/utils/adminHelpCopy'
|
import { priceTriggersPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const [submit, reload] = useBaseTable()
|
const [submit, reload] = useBaseTable()
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="flex justify-center gap-2">
|
<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>
|
<template #title>
|
||||||
<span>جزئیات محصولات</span>
|
<span>جزئیات محصولات</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -63,6 +63,9 @@ import PriceMobileCardList from './PriceMobileCardList.vue'
|
|||||||
import { pricingPageIntro } from '@/utils/adminHelpCopy'
|
import { pricingPageIntro } from '@/utils/adminHelpCopy'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
import type { PriceSyncLog } from '@/model/priceSyncLog'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
defineProps<{ syncing?: boolean }>()
|
defineProps<{ syncing?: boolean }>()
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<span class="truncate text-sm font-700 text-gray-900">{{ item.title || '-' }}</span>
|
<span class="truncate text-sm font-700 text-gray-900">{{ item.title || '-' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<MobileIconButton icon="vuesax-linear:archive-slash" color="#e3bf00" @click="$emit('unarchive', item)" />
|
<MobileIconButton v-if="can('restore')" 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('info')" icon="vuesax-linear:stickynote" color="#10913A" @click="$emit('info', item)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -32,6 +32,9 @@ import type { Product } from '@/model/product'
|
|||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
item: Product
|
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">
|
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<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>
|
<template #title>
|
||||||
<span>بیرون بردن از بایگانی</span>
|
<span>بیرون بردن از بایگانی</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
</a-tooltip>
|
</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>
|
<template #title>
|
||||||
<span>مشخصات</span>
|
<span>مشخصات</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -56,6 +56,9 @@ import { getProductArchiveColumns } from '../hooks/archiveColumns'
|
|||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
|
import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
|
||||||
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
|
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const productArchiveHelp: DashboardHelp = {
|
const productArchiveHelp: DashboardHelp = {
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -481,6 +481,16 @@
|
|||||||
</template>
|
</template>
|
||||||
<BasicInput v-model:value="form.inventory" type="number" />
|
<BasicInput v-model:value="form.inventory" type="number" />
|
||||||
</a-form-item>
|
</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
|
<div
|
||||||
v-if="weightOption === '1' && !isMeltedGroup && form.amount && form.amount < 1 && 0 < form.amount && tradeWeightUnit === 'گرم'"
|
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"
|
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="grid gap-4 md:grid-cols-2">
|
||||||
<div class="product-visibility-panel">
|
<div class="product-visibility-panel">
|
||||||
<div class="product-visibility-row">
|
<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" />
|
<a-switch v-model:checked="form.show_in_list" />
|
||||||
</div>
|
</div>
|
||||||
<div class="product-visibility-row">
|
<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" />
|
<a-switch v-model:checked="form.show_on_tv" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -682,6 +700,7 @@ import { inputRules, inputRulesNumber, requiredPriceRules } from '@/utils/inputR
|
|||||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||||
import IndexImageUploader from '@/components/ProductUploader/IndexImageUploader.vue'
|
import IndexImageUploader from '@/components/ProductUploader/IndexImageUploader.vue'
|
||||||
import { getConfiguration } from '@/api/configuration'
|
import { getConfiguration } from '@/api/configuration'
|
||||||
|
import { shayeganEnabledSetting } from '@/utils/config'
|
||||||
import { isSwitchOn } from '@/pages/menuPages/configuration/settingTypes'
|
import { isSwitchOn } from '@/pages/menuPages/configuration/settingTypes'
|
||||||
import type { last } from '@/model/price'
|
import type { last } from '@/model/price'
|
||||||
import type { MethodePrices } from '@/model/product'
|
import type { MethodePrices } from '@/model/product'
|
||||||
@@ -759,6 +778,11 @@ const inventoryHelp: DashboardHelp = {
|
|||||||
description: 'تعداد موجودی فروشگاه (فقط حالت فروشگاه).',
|
description: 'تعداد موجودی فروشگاه (فقط حالت فروشگاه).',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shayeganItemHelp: DashboardHelp = {
|
||||||
|
description:
|
||||||
|
'کد کالا (ItemNumber) در شایگان برای فاکتور همین محصول. خالی = fallback از تنظیم «کد کالای مس».',
|
||||||
|
}
|
||||||
|
|
||||||
const cashFeeBuyHelp: DashboardHelp = {
|
const cashFeeBuyHelp: DashboardHelp = {
|
||||||
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
||||||
formula: 'نقدی: +۱۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۵٪ از قیمت پایه',
|
formula: 'نقدی: +۱۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۵٪ از قیمت پایه',
|
||||||
@@ -770,11 +794,13 @@ const cashFeeSellHelp: DashboardHelp = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const showOnTvHelp: DashboardHelp = {
|
const showOnTvHelp: DashboardHelp = {
|
||||||
description: 'روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده میشود.',
|
description:
|
||||||
|
'مستقل از لیست محصولات است. روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده میشود؛ حتی اگر در لیست محصولات خاموش باشد.',
|
||||||
}
|
}
|
||||||
|
|
||||||
const showInListHelp: DashboardHelp = {
|
const showInListHelp: DashboardHelp = {
|
||||||
description: 'روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده میشود.',
|
description:
|
||||||
|
'مستقل از تابلو TV است. روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده میشود. همان آیکون تیک/ضربدر در ستون عملیات همین وضعیت را عوض میکند.',
|
||||||
}
|
}
|
||||||
|
|
||||||
const autoOpenHelp: DashboardHelp = {
|
const autoOpenHelp: DashboardHelp = {
|
||||||
@@ -858,6 +884,7 @@ const props = defineProps<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const isStore = ref(Boolean(props.isStore))
|
const isStore = ref(Boolean(props.isStore))
|
||||||
|
const shayeganEnabled = shayeganEnabledSetting
|
||||||
|
|
||||||
const tradeWeightUnit = ref('گرم')
|
const tradeWeightUnit = ref('گرم')
|
||||||
/** دسته آبشده/کاتد — ساختار فرم ثابت است */
|
/** دسته آبشده/کاتد — ساختار فرم ثابت است */
|
||||||
@@ -945,6 +972,7 @@ watch(
|
|||||||
props.form.price_formula_enabled = false
|
props.form.price_formula_enabled = false
|
||||||
props.form.reading_method = null
|
props.form.reading_method = null
|
||||||
props.form.price_offset_percent = 0
|
props.form.price_offset_percent = 0
|
||||||
|
props.form.direct_price = 1
|
||||||
} else if (option === '3') {
|
} else if (option === '3') {
|
||||||
// قیمت اپ: مرجع خارجی ندارد، متغیر (هر گرم × وزن)
|
// قیمت اپ: مرجع خارجی ندارد، متغیر (هر گرم × وزن)
|
||||||
props.form.reading_method = null
|
props.form.reading_method = null
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
@toggleBuy="$emit('toggleBuy', $event)"
|
@toggleBuy="$emit('toggleBuy', $event)"
|
||||||
@toggleSell="$emit('toggleSell', $event)"
|
@toggleSell="$emit('toggleSell', $event)"
|
||||||
@toggleActive="$emit('toggleActive', $event)"
|
@toggleActive="$emit('toggleActive', $event)"
|
||||||
|
@toggleShowOnTv="$emit('toggleShowOnTv', $event)"
|
||||||
@edit="$emit('edit', $event)"
|
@edit="$emit('edit', $event)"
|
||||||
@archive="$emit('archive', $event)"
|
@archive="$emit('archive', $event)"
|
||||||
/>
|
/>
|
||||||
@@ -43,6 +44,7 @@ defineEmits<{
|
|||||||
(e: 'toggleBuy', item: Product): void
|
(e: 'toggleBuy', item: Product): void
|
||||||
(e: 'toggleSell', item: Product): void
|
(e: 'toggleSell', item: Product): void
|
||||||
(e: 'toggleActive', item: Product): void
|
(e: 'toggleActive', item: Product): void
|
||||||
|
(e: 'toggleShowOnTv', item: Product): void
|
||||||
(e: 'archive', item: Product): void
|
(e: 'archive', item: Product): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<span class="min-w-0 truncate">{{ row.title || '-' }}</span>
|
<span class="min-w-0 truncate">{{ row.title || '-' }}</span>
|
||||||
<div class="flex shrink-0 items-center gap-2">
|
<div class="flex shrink-0 items-center gap-2">
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('buy')"
|
||||||
plain
|
plain
|
||||||
:key="`buy-${row.id}-${row.open_buy}`"
|
:key="`buy-${row.id}-${row.open_buy}`"
|
||||||
icon="vuesax-linear:money-receive"
|
icon="vuesax-linear:money-receive"
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
@click="$emit('toggleBuy', row)"
|
@click="$emit('toggleBuy', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('sell')"
|
||||||
plain
|
plain
|
||||||
:key="`sell-${row.id}-${row.open_sell}`"
|
:key="`sell-${row.id}-${row.open_sell}`"
|
||||||
icon="vuesax-linear:money-send"
|
icon="vuesax-linear:money-send"
|
||||||
@@ -23,13 +25,23 @@
|
|||||||
@click="$emit('toggleSell', row)"
|
@click="$emit('toggleSell', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('list')"
|
||||||
plain
|
plain
|
||||||
:key="`active-${row.id}-${row.active}`"
|
:key="`list-${row.id}-${row.show_in_list ?? row.active}`"
|
||||||
:icon="row.active ? 'vuesax-linear:tick-circle' : 'vuesax-linear:close-circle'"
|
:icon="(row.show_in_list ?? row.active) ? 'vuesax-linear:tick-circle' : 'vuesax-linear:close-circle'"
|
||||||
:color="row.active ? '#16A34A' : '#DC2626'"
|
:color="(row.show_in_list ?? row.active) ? '#16A34A' : '#DC2626'"
|
||||||
:size="22"
|
:size="22"
|
||||||
@click="$emit('toggleActive', row)"
|
@click="$emit('toggleActive', row)"
|
||||||
/>
|
/>
|
||||||
|
<MobileIconButton
|
||||||
|
v-if="can('tv')"
|
||||||
|
plain
|
||||||
|
:key="`tv-${row.id}-${row.show_on_tv}`"
|
||||||
|
icon="vuesax-linear:monitor"
|
||||||
|
:color="row.show_on_tv ? '#16A34A' : '#DC2626'"
|
||||||
|
:size="22"
|
||||||
|
@click="$emit('toggleShowOnTv', row)"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -68,6 +80,7 @@
|
|||||||
</MobileInfoGrid>
|
</MobileInfoGrid>
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
v-if="can('archive')"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
size="middle"
|
size="middle"
|
||||||
type="default"
|
type="default"
|
||||||
@@ -92,6 +105,9 @@ import { resolveProductTradeTypeLabel } from '@/utils/productCategories'
|
|||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { toJalali } from '@core/utils/useDataTime'
|
import { toJalali } from '@core/utils/useDataTime'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
@@ -103,6 +119,7 @@ const emit = defineEmits<{
|
|||||||
(e: 'toggleBuy', item: Product): void
|
(e: 'toggleBuy', item: Product): void
|
||||||
(e: 'toggleSell', item: Product): void
|
(e: 'toggleSell', item: Product): void
|
||||||
(e: 'toggleActive', item: Product): void
|
(e: 'toggleActive', item: Product): void
|
||||||
|
(e: 'toggleShowOnTv', item: Product): void
|
||||||
(e: 'edit', item: Product): void
|
(e: 'edit', item: Product): void
|
||||||
(e: 'archive', item: Product): void
|
(e: 'archive', item: Product): void
|
||||||
}>()
|
}>()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
{{ item.title || '-' }}
|
{{ item.title || '-' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<MobileIconButton icon="vuesax-linear:edit" color="#2563eb" :size="20" @click="$emit('edit', item)" />
|
<MobileIconButton v-if="can('edit')" icon="vuesax-linear:edit" color="#2563eb" :size="20" @click="$emit('edit', item)" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3 flex items-center justify-between gap-2">
|
<div class="mt-3 flex items-center justify-between gap-2">
|
||||||
@@ -26,6 +26,9 @@ import type { Product } from '@/model/product'
|
|||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||||
import { usePrice } from '@core/utils/usePrice'
|
import { usePrice } from '@core/utils/usePrice'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: Product
|
item: Product
|
||||||
@@ -36,7 +39,9 @@ defineEmits<{
|
|||||||
(e: 'edit', item: Product): void
|
(e: 'edit', item: Product): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const statusDotClass = computed(() => (props.item.active ? 'bg-green-500' : 'bg-red-400'))
|
const statusDotClass = computed(() =>
|
||||||
|
(props.item.show_in_list ?? props.item.active) ? 'bg-green-500' : 'bg-red-400',
|
||||||
|
)
|
||||||
const priceLabel = computed(() => (props.item.price ? usePrice(props.item.price) : '-'))
|
const priceLabel = computed(() => (props.item.price ? usePrice(props.item.price) : '-'))
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<div class="gap-2 flex justify-center">
|
||||||
<a-tooltip class="cursor-pointer" :key="`buy-${record.id}-${record.open_buy}`">
|
<a-tooltip v-if="can('buy')" class="cursor-pointer" :key="`buy-${record.id}-${record.open_buy}`">
|
||||||
<template v-if="!record.open_buy" #title><span>فعال کردن خرید</span></template>
|
<template v-if="!record.open_buy" #title><span>فعال کردن خرید</span></template>
|
||||||
<template v-else #title><span>غیر فعال کردن خرید</span></template>
|
<template v-else #title><span>غیر فعال کردن خرید</span></template>
|
||||||
<BaseIcon
|
<BaseIcon
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
@click="activeBuy(record)"
|
@click="activeBuy(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip class="cursor-pointer" :key="`sell-${record.id}-${record.open_sell}`">
|
<a-tooltip v-if="can('sell')" class="cursor-pointer" :key="`sell-${record.id}-${record.open_sell}`">
|
||||||
<template v-if="!record.open_sell" #title><span>فعال کردن فروش</span></template>
|
<template v-if="!record.open_sell" #title><span>فعال کردن فروش</span></template>
|
||||||
<template v-else #title><span>غیر فعال کردن فروش</span></template>
|
<template v-else #title><span>غیر فعال کردن فروش</span></template>
|
||||||
<BaseIcon
|
<BaseIcon
|
||||||
@@ -75,27 +75,44 @@
|
|||||||
@click="activeSell(record)"
|
@click="activeSell(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip class="cursor-pointer" :key="`active-${record.id}-${record.active}`">
|
<a-tooltip v-if="can('list')" class="cursor-pointer" :key="`list-${record.id}-${record.show_in_list ?? record.active}`">
|
||||||
<template v-if="!record.active" #title><span>فعال کردن محصول</span></template>
|
<template v-if="!(record.show_in_list ?? record.active)" #title>
|
||||||
<template v-else #title><span>غیر فعال کردن محصول</span></template>
|
<span>فعال کردن نمایش در لیست محصولات</span>
|
||||||
|
</template>
|
||||||
|
<template v-else #title>
|
||||||
|
<span>غیرفعال کردن نمایش در لیست محصولات</span>
|
||||||
|
</template>
|
||||||
<BaseIcon
|
<BaseIcon
|
||||||
v-if="!record.active"
|
v-if="!(record.show_in_list ?? record.active)"
|
||||||
icon="vuesax-linear:close-circle"
|
icon="vuesax-linear:close-circle"
|
||||||
color="#DC2626"
|
color="#DC2626"
|
||||||
@click="activeProduct(record)"
|
@click="toggleShowInList(record)"
|
||||||
/>
|
/>
|
||||||
<BaseIcon
|
<BaseIcon
|
||||||
v-else
|
v-else
|
||||||
icon="vuesax-linear:tick-circle"
|
icon="vuesax-linear:tick-circle"
|
||||||
color="#16A34A"
|
color="#16A34A"
|
||||||
@click="activeProduct(record)"
|
@click="toggleShowInList(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
<a-tooltip v-if="can('tv')" class="cursor-pointer" :key="`tv-${record.id}-${record.show_on_tv}`">
|
||||||
|
<template v-if="!record.show_on_tv" #title>
|
||||||
|
<span>فعال کردن نمایش در تابلو TV</span>
|
||||||
|
</template>
|
||||||
|
<template v-else #title>
|
||||||
|
<span>غیرفعال کردن نمایش در تابلو TV</span>
|
||||||
|
</template>
|
||||||
|
<BaseIcon
|
||||||
|
icon="vuesax-linear:monitor"
|
||||||
|
:color="record.show_on_tv ? '#16A34A' : '#DC2626'"
|
||||||
|
@click="toggleShowOnTv(record)"
|
||||||
|
/>
|
||||||
|
</a-tooltip>
|
||||||
|
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||||
<template #title><span>ویرایش</span></template>
|
<template #title><span>ویرایش</span></template>
|
||||||
<BaseIcon icon="vuesax-linear:edit" color="#4572E9" />
|
<BaseIcon icon="vuesax-linear:edit" color="#4572E9" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip placement="bottom" class="cursor-pointer">
|
<a-tooltip v-if="can('archive')" placement="bottom" class="cursor-pointer">
|
||||||
<template #title><span>بایگانی کردن</span></template>
|
<template #title><span>بایگانی کردن</span></template>
|
||||||
<a-popconfirm
|
<a-popconfirm
|
||||||
title="آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال میشود."
|
title="آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال میشود."
|
||||||
@@ -118,7 +135,8 @@
|
|||||||
@edit="emits('edit', $event)"
|
@edit="emits('edit', $event)"
|
||||||
@toggleBuy="activeBuy"
|
@toggleBuy="activeBuy"
|
||||||
@toggleSell="activeSell"
|
@toggleSell="activeSell"
|
||||||
@toggleActive="activeProduct"
|
@toggleActive="toggleShowInList"
|
||||||
|
@toggleShowOnTv="toggleShowOnTv"
|
||||||
@archive="handleArchive"
|
@archive="handleArchive"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -137,6 +155,7 @@ import {
|
|||||||
changeActiveProduct,
|
changeActiveProduct,
|
||||||
changeBuyActiveProduct,
|
changeBuyActiveProduct,
|
||||||
changeSellActiveProduct,
|
changeSellActiveProduct,
|
||||||
|
changeShowOnTvProduct,
|
||||||
getCustomerTable,
|
getCustomerTable,
|
||||||
setActiveTime
|
setActiveTime
|
||||||
} from '@/api/product'
|
} from '@/api/product'
|
||||||
@@ -149,6 +168,9 @@ import type { TableInput } from '@core/type/baseTable'
|
|||||||
import type { Product } from '@/model/product'
|
import type { Product } from '@/model/product'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { productsPageIntro } from '@/utils/adminHelpCopy'
|
import { productsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
@@ -232,12 +254,18 @@ const activeBuy = (product: Product) =>
|
|||||||
await fetch()
|
await fetch()
|
||||||
})
|
})
|
||||||
|
|
||||||
const activeProduct = (product: Product) =>
|
const toggleShowInList = (product: Product) =>
|
||||||
confirmToggle('آیا مطمئن به انجام این عملیات هستید؟', async () => {
|
confirmToggle('نمایش این محصول در لیست محصولات تغییر میکند. آیا مطمئن هستید؟', async () => {
|
||||||
await changeActiveProduct(product.id)
|
await changeActiveProduct(product.id)
|
||||||
await fetch()
|
await fetch()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const toggleShowOnTv = (product: Product) =>
|
||||||
|
confirmToggle('نمایش این محصول در تابلو TV تغییر میکند. آیا مطمئن هستید؟', async () => {
|
||||||
|
await changeShowOnTvProduct(product.id)
|
||||||
|
await fetch()
|
||||||
|
})
|
||||||
|
|
||||||
function handleArchive(product: Product) {
|
function handleArchive(product: Product) {
|
||||||
confirmToggle(
|
confirmToggle(
|
||||||
'آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال میشود.',
|
'آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال میشود.',
|
||||||
|
|||||||
@@ -104,21 +104,44 @@ export function getProductColumns(): BaseTableColumn[] {
|
|||||||
},
|
},
|
||||||
...(isStoreApp() ? [inventoryColumn] : []),
|
...(isStoreApp() ? [inventoryColumn] : []),
|
||||||
{
|
{
|
||||||
title: 'وضعیت محصول',
|
title: 'وضعیت لیست',
|
||||||
dataIndex: 'active',
|
dataIndex: 'show_in_list',
|
||||||
key: 'active',
|
key: 'show_in_list',
|
||||||
type: 'Boolean',
|
type: 'Boolean',
|
||||||
customRender: (record) => (
|
customRender: (record) => {
|
||||||
<div class="flex justify-center">
|
const on = record?.record.show_in_list ?? record?.record.active
|
||||||
<CustomTag
|
return (
|
||||||
class="px-3 font-bold py-1"
|
<div class="flex justify-center">
|
||||||
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
|
<CustomTag
|
||||||
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
|
class="px-3 font-bold py-1"
|
||||||
>
|
textColor={on ? '#65a30d' : '#dc2626'}
|
||||||
{record?.record.active ? 'باز' : 'بسته'}
|
bgColor={on ? '#ecfccb' : '#fee2e2'}
|
||||||
</CustomTag>
|
>
|
||||||
</div>
|
{on ? 'باز' : 'بسته'}
|
||||||
)
|
</CustomTag>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'تابلو TV',
|
||||||
|
dataIndex: 'show_on_tv',
|
||||||
|
key: 'show_on_tv',
|
||||||
|
type: 'Boolean',
|
||||||
|
customRender: (record) => {
|
||||||
|
const on = !!record?.record.show_on_tv
|
||||||
|
return (
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<CustomTag
|
||||||
|
class="px-3 font-bold py-1"
|
||||||
|
textColor={on ? '#65a30d' : '#dc2626'}
|
||||||
|
bgColor={on ? '#ecfccb' : '#fee2e2'}
|
||||||
|
>
|
||||||
|
{on ? 'روشن' : 'خاموش'}
|
||||||
|
</CustomTag>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'عملیات',
|
title: 'عملیات',
|
||||||
|
|||||||
@@ -456,6 +456,7 @@ function resetData() {
|
|||||||
has_physical_delivery: false,
|
has_physical_delivery: false,
|
||||||
min_physical_delivery_quantity: undefined,
|
min_physical_delivery_quantity: undefined,
|
||||||
inventory: 0,
|
inventory: 0,
|
||||||
|
shayegan_item_number: '',
|
||||||
description: '',
|
description: '',
|
||||||
karat: '',
|
karat: '',
|
||||||
min_order_cash: undefined,
|
min_order_cash: undefined,
|
||||||
@@ -490,6 +491,7 @@ const DETAILS_FIELDS = new Set([
|
|||||||
'unit',
|
'unit',
|
||||||
'direct_price',
|
'direct_price',
|
||||||
'inventory',
|
'inventory',
|
||||||
|
'shayegan_item_number',
|
||||||
'trade_by_quantity',
|
'trade_by_quantity',
|
||||||
'show_in_assets',
|
'show_in_assets',
|
||||||
'show_on_tv',
|
'show_on_tv',
|
||||||
@@ -602,9 +604,11 @@ async function saveProduct() {
|
|||||||
payload.price_formula = String(payload.price_formula ?? '').trim() || '((P)/MG)*W+100000'
|
payload.price_formula = String(payload.price_formula ?? '').trim() || '((P)/MG)*W+100000'
|
||||||
delete payload.price
|
delete payload.price
|
||||||
} else if (methodOption.value === '1') {
|
} else if (methodOption.value === '1') {
|
||||||
|
// دستی: direct_price=1 تا enrich وزنمحور مظنهٔ زنده را روی price ذخیرهشده ننویسد
|
||||||
payload.reading_method = null
|
payload.reading_method = null
|
||||||
payload.price_offset_percent = 0
|
payload.price_offset_percent = 0
|
||||||
payload.app_price = false
|
payload.app_price = false
|
||||||
|
payload.direct_price = 1
|
||||||
payload.price_formula_enabled = false
|
payload.price_formula_enabled = false
|
||||||
} else if (methodOption.value === '3') {
|
} else if (methodOption.value === '3') {
|
||||||
// قیمت اپ: بدون مرجع خارجی، متغیر (هر گرم × وزن)، قیمت دستی نگه نمیدارد
|
// قیمت اپ: بدون مرجع خارجی، متغیر (هر گرم × وزن)، قیمت دستی نگه نمیدارد
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
دستهبندی محصولات
|
دستهبندی محصولات
|
||||||
<AdminFieldHelp :text="productsCategoriesPageIntro" size="sm" />
|
<AdminFieldHelp :text="productsCategoriesPageIntro" size="sm" />
|
||||||
</span>
|
</span>
|
||||||
|
<BaseButton type="primary" size="small" icon="vuesax-linear:add" @click="openAddModal">
|
||||||
|
افزودن دستهبندی جدید
|
||||||
|
</BaseButton>
|
||||||
<BaseButton :loading="syncing" @click="handleSync">
|
<BaseButton :loading="syncing" @click="handleSync">
|
||||||
همگامسازی از محصولات
|
همگامسازی از محصولات
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
@@ -58,6 +61,37 @@
|
|||||||
</a-table>
|
</a-table>
|
||||||
</a-spin>
|
</a-spin>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<BasicActionSheet
|
||||||
|
v-model:visible="addVisible"
|
||||||
|
title="افزودن دستهبندی جدید"
|
||||||
|
modal-width="28rem"
|
||||||
|
drawer-height="auto"
|
||||||
|
:loading="adding"
|
||||||
|
:showButton="true"
|
||||||
|
:showCancel="true"
|
||||||
|
:showOk="true"
|
||||||
|
ok-text="ثبت"
|
||||||
|
cancel-text="انصراف"
|
||||||
|
@ok="submitAdd"
|
||||||
|
@cancel="closeAddModal"
|
||||||
|
@close="closeAddModal"
|
||||||
|
>
|
||||||
|
<p class="m-0 mb-3 text-13px text-[var(--admin-text-secondary)]">
|
||||||
|
نام دسته را وارد کنید؛ بعد از ثبت در لیست پایین و سلکت افزودن محصول قابل استفاده است.
|
||||||
|
</p>
|
||||||
|
<a-form ref="addFormRef" :model="addForm" layout="vertical" autocomplete="off">
|
||||||
|
<a-form-item label="نام دسته" name="name" :rules="inputRules()">
|
||||||
|
<BasicInput v-model:value="addForm.name" placeholder="مثلاً سکه، شمش، آبشده" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="نمایش محصولات در اپ" name="active">
|
||||||
|
<a-switch v-model:checked="addForm.active" checked-children="فعال" un-checked-children="مخفی" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="سلکت افزودن محصول" name="show_in_select" class="mb-0">
|
||||||
|
<a-switch v-model:checked="addForm.show_in_select" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</BasicActionSheet>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -66,14 +100,26 @@ import { message } from 'ant-design-vue'
|
|||||||
import type { TableColumnType } from 'ant-design-vue'
|
import type { TableColumnType } from 'ant-design-vue'
|
||||||
import { useResizeObserver } from '@vueuse/core'
|
import { useResizeObserver } from '@vueuse/core'
|
||||||
import { debounce } from 'lodash'
|
import { debounce } from 'lodash'
|
||||||
|
import type { FormInstance } from 'ant-design-vue'
|
||||||
import { onMounted, onUnmounted, ref } from 'vue'
|
import { onMounted, onUnmounted, ref } from 'vue'
|
||||||
import { getCategories, syncCategoriesFromProducts, updateCategory } from '@/api/category'
|
import { createCategory, getCategories, syncCategoriesFromProducts, updateCategory } from '@/api/category'
|
||||||
import type { Category } from '@/model/category'
|
import type { Category } from '@/model/category'
|
||||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||||
|
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||||
|
import BasicInput from '@/components/BasicInput.vue'
|
||||||
import { productsCategoriesPageIntro } from '@/utils/adminHelpCopy'
|
import { productsCategoriesPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { inputRules } from '@/utils/inputRules'
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const syncing = ref(false)
|
const syncing = ref(false)
|
||||||
|
const adding = ref(false)
|
||||||
|
const addVisible = ref(false)
|
||||||
|
const addFormRef = ref<FormInstance>()
|
||||||
|
const addForm = ref({
|
||||||
|
name: '',
|
||||||
|
active: true,
|
||||||
|
show_in_select: true,
|
||||||
|
})
|
||||||
const savingOrder = ref(false)
|
const savingOrder = ref(false)
|
||||||
const items = ref<Category[]>([])
|
const items = ref<Category[]>([])
|
||||||
const tableWrapRef = ref<HTMLElement | null>(null)
|
const tableWrapRef = ref<HTMLElement | null>(null)
|
||||||
@@ -400,6 +446,52 @@ async function handleSync() {
|
|||||||
await syncList(true)
|
await syncList(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetAddForm() {
|
||||||
|
addForm.value = {
|
||||||
|
name: '',
|
||||||
|
active: true,
|
||||||
|
show_in_select: true,
|
||||||
|
}
|
||||||
|
addFormRef.value?.clearValidate?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
function openAddModal() {
|
||||||
|
resetAddForm()
|
||||||
|
addVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAddModal() {
|
||||||
|
addVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitAdd() {
|
||||||
|
try {
|
||||||
|
await addFormRef.value?.validateFields?.()
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
adding.value = true
|
||||||
|
try {
|
||||||
|
const created = await createCategory({
|
||||||
|
name: addForm.value.name.trim(),
|
||||||
|
active: addForm.value.active ? 1 : 0,
|
||||||
|
show_in_select: addForm.value.show_in_select ? 1 : 0,
|
||||||
|
})
|
||||||
|
items.value = [...items.value, created].sort(
|
||||||
|
(a, b) => (a.sort_order ?? 0) - (b.sort_order ?? 0) || a.id - b.id
|
||||||
|
)
|
||||||
|
message.success('دستهبندی با موفقیت ثبت شد')
|
||||||
|
closeAddModal()
|
||||||
|
updateTableScrollY()
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(e)
|
||||||
|
message.error(e?.response?.data?.message || 'خطا در ثبت دستهبندی')
|
||||||
|
} finally {
|
||||||
|
adding.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void fetchList()
|
void fetchList()
|
||||||
updateTableScrollY()
|
updateTableScrollY()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
:color="record.active ? '#54AD06' : '#ad0627'"
|
:color="record.active ? '#54AD06' : '#ad0627'"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>-->
|
</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>
|
<template #title>
|
||||||
<span>مشخصات</span>
|
<span>مشخصات</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -76,6 +76,9 @@ import { getTransactionTable } from '@/api/transaction'
|
|||||||
import TransactionMobileCardList from './TransactionMobileCardList.vue'
|
import TransactionMobileCardList from './TransactionMobileCardList.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { transactionsPageIntro } from '@/utils/adminHelpCopy'
|
import { transactionsPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
interface Prop {
|
interface Prop {
|
||||||
customerId?: number
|
customerId?: number
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<div class="flex w-full items-center justify-between gap-3">
|
<div class="flex w-full items-center justify-between gap-3">
|
||||||
<span class="min-w-0 truncate">{{ sheetTitle }}</span>
|
<span class="min-w-0 truncate">{{ sheetTitle }}</span>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('delete')"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:user-remove"
|
icon="vuesax-linear:user-remove"
|
||||||
color="#EB3535"
|
color="#EB3535"
|
||||||
@@ -35,6 +36,9 @@ import MobileInfoGrid from '@/components/mobile/MobileInfoGrid.vue'
|
|||||||
import MobileSheetHeader from '@/components/mobile/MobileSheetHeader.vue'
|
import MobileSheetHeader from '@/components/mobile/MobileSheetHeader.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { toJalaliNoTime } from '@core/utils/useDataTime'
|
import { toJalaliNoTime } from '@core/utils/useDataTime'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean
|
visible: boolean
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('edit')"
|
||||||
icon="vuesax-linear:edit"
|
icon="vuesax-linear:edit"
|
||||||
color="#4572E9"
|
color="#4572E9"
|
||||||
:size="20"
|
:size="20"
|
||||||
@@ -24,6 +25,9 @@
|
|||||||
import type { User } from '@/model/user'
|
import type { User } from '@/model/user'
|
||||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
item: User
|
item: User
|
||||||
|
|||||||
@@ -0,0 +1,325 @@
|
|||||||
|
<template>
|
||||||
|
<div :class="scroll ? 'access-scroll' : ''">
|
||||||
|
<a-collapse
|
||||||
|
v-model:activeKey="openKey"
|
||||||
|
accordion
|
||||||
|
:bordered="false"
|
||||||
|
expand-icon-position="start"
|
||||||
|
class="access-collapse"
|
||||||
|
:class="{ 'access-collapse--nested': !scroll }"
|
||||||
|
>
|
||||||
|
<a-collapse-panel v-for="item in list" :key="item.key">
|
||||||
|
<template #header>
|
||||||
|
<div class="flex min-w-0 items-center gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">{{ item.title }}</span>
|
||||||
|
<span class="access-chip shrink-0" :data-state="chipState(item)">{{ summary(item) }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||||
|
<span class="text-xs leading-5 opacity-70">
|
||||||
|
{{ item.route ? 'ورود به این صفحه' : 'برای همهٔ صفحههای این بخش' }}
|
||||||
|
</span>
|
||||||
|
<div class="flex shrink-0 items-center gap-3">
|
||||||
|
<a-checkbox
|
||||||
|
class="access-check"
|
||||||
|
:checked="viewState(item).checked"
|
||||||
|
:indeterminate="viewState(item).indeterminate"
|
||||||
|
@change="toggleView(item, $event)"
|
||||||
|
>
|
||||||
|
مشاهده
|
||||||
|
</a-checkbox>
|
||||||
|
<a-checkbox
|
||||||
|
v-if="!item.route && actionPairs(item).length"
|
||||||
|
class="access-check"
|
||||||
|
:checked="opsState(item).checked"
|
||||||
|
:indeterminate="opsState(item).indeterminate"
|
||||||
|
@change="toggleAllActions(item, $event)"
|
||||||
|
>
|
||||||
|
همه عملیات
|
||||||
|
</a-checkbox>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="item.route && pageActions(item.route).length"
|
||||||
|
class="grid grid-cols-1 gap-1.5 sm:grid-cols-2"
|
||||||
|
>
|
||||||
|
<a-checkbox
|
||||||
|
v-for="action in pageActions(item.route)"
|
||||||
|
:key="action.key"
|
||||||
|
class="access-op"
|
||||||
|
:checked="actionEnabled(modelValue?.[item.route], action.key)"
|
||||||
|
@change="toggleAction(item.route, action.key, $event)"
|
||||||
|
>
|
||||||
|
<span class="text-xs">{{ action.label }}</span>
|
||||||
|
</a-checkbox>
|
||||||
|
</div>
|
||||||
|
<p v-else-if="item.route" class="m-0 text-xs leading-5 opacity-60">
|
||||||
|
این صفحه عملیات جدولی ندارد.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ManagerPageAccessTree
|
||||||
|
v-if="shownChildren(item).length"
|
||||||
|
:nodes="shownChildren(item)"
|
||||||
|
:scroll="false"
|
||||||
|
:model-value="modelValue"
|
||||||
|
@update:model-value="emit('update:modelValue', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-collapse-panel>
|
||||||
|
</a-collapse>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default { name: 'ManagerPageAccessTree' }
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ADMIN_PAGE_TREE,
|
||||||
|
PAGE_TABLE_ACTIONS,
|
||||||
|
actionEnabled,
|
||||||
|
type AccessNode,
|
||||||
|
type PageAccessFlags,
|
||||||
|
type PageAccessMap
|
||||||
|
} from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
nodes?: AccessNode[]
|
||||||
|
scroll?: boolean
|
||||||
|
modelValue?: PageAccessMap | null
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
scroll: true,
|
||||||
|
modelValue: () => ({})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: PageAccessMap): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const openKey = ref<string>()
|
||||||
|
|
||||||
|
function isShown(node: AccessNode): boolean {
|
||||||
|
if (node.enabled && !node.enabled()) return false
|
||||||
|
if (node.children?.length) return (node.children ?? []).some((child) => isShown(child))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function shownChildren(node: AccessNode): AccessNode[] {
|
||||||
|
return (node.children ?? []).filter((child) => isShown(child))
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = computed(() => (props.nodes ?? ADMIN_PAGE_TREE).filter((item) => isShown(item)))
|
||||||
|
|
||||||
|
function leavesOf(node: AccessNode): string[] {
|
||||||
|
if (!isShown(node)) return []
|
||||||
|
if (node.route) return [node.route]
|
||||||
|
return shownChildren(node).flatMap(leavesOf)
|
||||||
|
}
|
||||||
|
|
||||||
|
function pageActions(route?: string) {
|
||||||
|
return route ? PAGE_TABLE_ACTIONS[route] ?? [] : []
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionPairs(node: AccessNode): { route: string; key: string }[] {
|
||||||
|
if (!isShown(node)) return []
|
||||||
|
if (node.route) {
|
||||||
|
return pageActions(node.route).map((item) => ({ route: node.route as string, key: item.key }))
|
||||||
|
}
|
||||||
|
return shownChildren(node).flatMap(actionPairs)
|
||||||
|
}
|
||||||
|
|
||||||
|
function blankRow(): PageAccessFlags {
|
||||||
|
return { view: false, edit: false, delete: false, actions: {} }
|
||||||
|
}
|
||||||
|
|
||||||
|
function withActions(route: string, row: PageAccessFlags): PageAccessFlags {
|
||||||
|
const actions: Record<string, boolean> = {}
|
||||||
|
const hasMap = !!row.actions
|
||||||
|
for (const item of pageActions(route)) {
|
||||||
|
if (hasMap) {
|
||||||
|
actions[item.key] = Object.prototype.hasOwnProperty.call(row.actions, item.key)
|
||||||
|
? Boolean(row.actions?.[item.key])
|
||||||
|
: false
|
||||||
|
} else {
|
||||||
|
actions[item.key] = actionEnabled({ ...row, view: true }, item.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...row,
|
||||||
|
actions,
|
||||||
|
edit: Boolean(actions.edit),
|
||||||
|
delete: Boolean(actions.delete)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function viewState(node: AccessNode) {
|
||||||
|
const leaves = leavesOf(node)
|
||||||
|
const on = leaves.filter((key) => props.modelValue?.[key]?.view).length
|
||||||
|
return {
|
||||||
|
checked: leaves.length > 0 && on === leaves.length,
|
||||||
|
indeterminate: on > 0 && on < leaves.length,
|
||||||
|
on,
|
||||||
|
total: leaves.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function opsState(node: AccessNode) {
|
||||||
|
const pairs = actionPairs(node)
|
||||||
|
const on = pairs.filter((pair) => actionEnabled(props.modelValue?.[pair.route], pair.key)).length
|
||||||
|
return {
|
||||||
|
checked: pairs.length > 0 && on === pairs.length,
|
||||||
|
indeterminate: on > 0 && on < pairs.length,
|
||||||
|
on,
|
||||||
|
total: pairs.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function chipState(node: AccessNode) {
|
||||||
|
const view = viewState(node)
|
||||||
|
if (!view.on) return 'none'
|
||||||
|
const ops = opsState(node)
|
||||||
|
if (view.checked && (!ops.total || ops.checked)) return 'full'
|
||||||
|
return 'part'
|
||||||
|
}
|
||||||
|
|
||||||
|
function summary(node: AccessNode) {
|
||||||
|
const view = viewState(node)
|
||||||
|
const ops = opsState(node)
|
||||||
|
if (!view.on) return 'بدون دسترسی'
|
||||||
|
if (!view.checked) return `${view.on} از ${view.total} صفحه`
|
||||||
|
if (!ops.total || !ops.on) return 'فقط مشاهده'
|
||||||
|
if (ops.checked) return 'دسترسی کامل'
|
||||||
|
return `${ops.on} از ${ops.total} عملیات`
|
||||||
|
}
|
||||||
|
|
||||||
|
function commit(next: PageAccessMap) {
|
||||||
|
emit('update:modelValue', next)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleView(node: AccessNode, event: { target?: { checked?: boolean } }) {
|
||||||
|
const checked = Boolean(event?.target?.checked)
|
||||||
|
const next: PageAccessMap = { ...(props.modelValue ?? {}) }
|
||||||
|
for (const route of leavesOf(node)) {
|
||||||
|
if (!checked) {
|
||||||
|
delete next[route]
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!next[route]) {
|
||||||
|
next[route] = {
|
||||||
|
view: true,
|
||||||
|
edit: false,
|
||||||
|
delete: false,
|
||||||
|
actions: Object.fromEntries(pageActions(route).map((item) => [item.key, false]))
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
next[route] = withActions(route, { ...next[route], view: true })
|
||||||
|
}
|
||||||
|
commit(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleAction(route: string, actionKey: string, event: { target?: { checked?: boolean } }) {
|
||||||
|
const checked = Boolean(event?.target?.checked)
|
||||||
|
const next: PageAccessMap = { ...(props.modelValue ?? {}) }
|
||||||
|
const row = withActions(route, { ...(next[route] ?? blankRow()), view: true })
|
||||||
|
row.actions = { ...(row.actions ?? {}), [actionKey]: checked }
|
||||||
|
row.view = true
|
||||||
|
row.edit = Boolean(row.actions.edit)
|
||||||
|
row.delete = Boolean(row.actions.delete)
|
||||||
|
next[route] = row
|
||||||
|
commit(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleAllActions(node: AccessNode, event: { target?: { checked?: boolean } }) {
|
||||||
|
const checked = Boolean(event?.target?.checked)
|
||||||
|
const next: PageAccessMap = { ...(props.modelValue ?? {}) }
|
||||||
|
for (const pair of actionPairs(node)) {
|
||||||
|
const row = withActions(pair.route, {
|
||||||
|
...(next[pair.route] ?? blankRow()),
|
||||||
|
view: next[pair.route]?.view ?? checked
|
||||||
|
})
|
||||||
|
if (checked) row.view = true
|
||||||
|
row.actions = { ...(row.actions ?? {}), [pair.key]: checked }
|
||||||
|
row.edit = Boolean(row.actions.edit)
|
||||||
|
row.delete = Boolean(row.actions.delete)
|
||||||
|
next[pair.route] = row
|
||||||
|
}
|
||||||
|
commit(next)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.access-scroll {
|
||||||
|
max-height: 28rem;
|
||||||
|
overflow: auto;
|
||||||
|
padding-inline-end: 2px;
|
||||||
|
}
|
||||||
|
.access-collapse {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.access-collapse :deep(.ant-collapse-item) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--admin-border, rgba(255, 255, 255, 0.08));
|
||||||
|
border-radius: 10px;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
.access-collapse :deep(.ant-collapse-item:last-child) {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
.access-collapse :deep(.ant-collapse-header) {
|
||||||
|
align-items: center !important;
|
||||||
|
padding: 8px 10px !important;
|
||||||
|
}
|
||||||
|
.access-collapse :deep(.ant-collapse-content) {
|
||||||
|
background: transparent;
|
||||||
|
border-top: 1px solid var(--admin-border, rgba(255, 255, 255, 0.08));
|
||||||
|
}
|
||||||
|
.access-collapse :deep(.ant-collapse-content-box) {
|
||||||
|
padding: 8px 10px 10px !important;
|
||||||
|
}
|
||||||
|
.access-collapse--nested :deep(.ant-collapse-item) {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.access-chip {
|
||||||
|
border: 1px solid var(--admin-border, rgba(255, 255, 255, 0.08));
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 20px;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
.access-chip[data-state='part'] {
|
||||||
|
color: #d4af37;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.access-chip[data-state='full'] {
|
||||||
|
color: #6fbf8b;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.access-check {
|
||||||
|
margin-inline-start: 0 !important;
|
||||||
|
}
|
||||||
|
.access-op {
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 6px 8px;
|
||||||
|
border: 1px solid var(--admin-border, rgba(255, 255, 255, 0.08));
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
.access-check :deep(.ant-checkbox + span),
|
||||||
|
.access-op :deep(.ant-checkbox + span) {
|
||||||
|
padding-inline-start: 6px;
|
||||||
|
padding-inline-end: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user