Compare commits
19
Commits
0f60c1e1a5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87c35c3101 | ||
|
|
a778aad7bc | ||
|
|
e0e2b6daa5 | ||
|
|
379995e0ab | ||
|
|
c9b7876734 | ||
|
|
29904adf02 | ||
|
|
ec92e288ad | ||
|
|
3df3164e0b | ||
|
|
dfc6f8dc64 | ||
|
|
88271dba2a | ||
|
|
e5b3d0c931 | ||
|
|
2927d64c64 | ||
|
|
d067551d37 | ||
|
|
8a4f95da7d | ||
|
|
7e869902d6 | ||
|
|
8004dd52b3 | ||
|
|
7ff90b05d0 | ||
|
|
3c56672a27 | ||
|
|
2d5e8da2cb |
Vendored
+2
@@ -92,6 +92,8 @@ 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']
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<CustomerImportProgress />
|
<CustomerImportProgress />
|
||||||
<TahesabDocSyncProgress />
|
<TahesabDocSyncProgress />
|
||||||
<GroupSmsSendProgress />
|
<GroupSmsSendProgress />
|
||||||
|
<ShayeganChargeAlertHost />
|
||||||
</AConfigProvider>
|
</AConfigProvider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@ 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 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 { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||||
|
|||||||
@@ -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}`)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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'
|
||||||
|
)
|
||||||
|
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -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,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'
|
||||||
@@ -45,9 +45,9 @@ const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
|||||||
const routerStore = useRouterStore()
|
const routerStore = useRouterStore()
|
||||||
const { menuTheme } = useAdminTheme()
|
const { menuTheme } = useAdminTheme()
|
||||||
|
|
||||||
|
function syncSelectedKeys() {
|
||||||
const path: (RouteRecordName | undefined)[] = []
|
const path: (RouteRecordName | undefined)[] = []
|
||||||
|
function walkInRoutes(routes: RouteRecordRaw[]): boolean {
|
||||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
|
||||||
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)
|
||||||
@@ -56,18 +56,17 @@ function walkInRoutes(routes: RouteRecordRaw[]) {
|
|||||||
if (route.children && route.children.length > 0) {
|
if (route.children && route.children.length > 0) {
|
||||||
path.push(route.name)
|
path.push(route.name)
|
||||||
const res = walkInRoutes(route.children)
|
const res = walkInRoutes(route.children)
|
||||||
if (!res) {
|
if (!res) path.pop()
|
||||||
path.pop()
|
else return true
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
walkInRoutes(routerStore.routes)
|
walkInRoutes(routerStore.routes)
|
||||||
selectedKeys.value = path
|
selectedKeys.value = path
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => currentRoute.name, syncSelectedKeys, { immediate: true })
|
||||||
|
|
||||||
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'
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
+29
-1
@@ -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' })
|
||||||
}
|
}
|
||||||
|
if (canOpenRoute(to.name)) {
|
||||||
|
setCurrentAdminRoute(String(to.name || ''))
|
||||||
return next()
|
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
|
||||||
|
|||||||
@@ -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,6 +13,7 @@ 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
|
||||||
@@ -19,6 +21,8 @@ export interface User {
|
|||||||
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>
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -79,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)"
|
||||||
@@ -93,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)"
|
||||||
@@ -111,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)"
|
||||||
@@ -127,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)"
|
||||||
@@ -221,6 +222,9 @@ import {
|
|||||||
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 { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
|
|
||||||
const docSyncStore = useTahesabDocSyncStore()
|
const docSyncStore = useTahesabDocSyncStore()
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ import SettingCard from './SettingCard.vue'
|
|||||||
import { configurationPageIntro, websiteSettingsPageIntro } 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, applyHasLandingFromRows, setHasLandingFromSettings } 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,
|
||||||
@@ -718,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
|
||||||
|
|||||||
@@ -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: 'عمومی و برند',
|
||||||
@@ -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,9 +316,19 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمیآیند */
|
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمیآیند */
|
||||||
|
|||||||
@@ -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'])
|
||||||
|
|||||||
@@ -97,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 ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +165,7 @@ async function onDecide(mode: 'overwrite' | 'keep' | 'push') {
|
|||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -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: 'کد حسابداری',
|
||||||
|
|||||||
@@ -775,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)
|
||||||
@@ -797,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 '-'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
await updateGiftCard(editId, formData as GiftcardInput)
|
||||||
|
message.success('کارت هدیه با موفقیت ویرایش شد')
|
||||||
|
} else {
|
||||||
|
await createGiftCard(formData as GiftcardInput)
|
||||||
message.success('کارت هدیه با موفقیت ثبت شد')
|
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"
|
||||||
@@ -690,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'
|
||||||
@@ -767,6 +778,11 @@ const inventoryHelp: DashboardHelp = {
|
|||||||
description: 'تعداد موجودی فروشگاه (فقط حالت فروشگاه).',
|
description: 'تعداد موجودی فروشگاه (فقط حالت فروشگاه).',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const shayeganItemHelp: DashboardHelp = {
|
||||||
|
description:
|
||||||
|
'کد کالا (ItemNumber) در شایگان برای فاکتور همین محصول. خالی = fallback از تنظیم «کد کالای مس».',
|
||||||
|
}
|
||||||
|
|
||||||
const cashFeeBuyHelp: DashboardHelp = {
|
const cashFeeBuyHelp: DashboardHelp = {
|
||||||
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
description: 'مبلغ اضافه روی قیمت پایه برای خرید — نقدی (ریال ثابت) یا درصدی از مظنه.',
|
||||||
formula: 'نقدی: +۱۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۵٪ از قیمت پایه',
|
formula: 'نقدی: +۱۰۰٬۰۰۰ ریال | درصدی: ۰.۵٪ یا ۵٪ از قیمت پایه',
|
||||||
@@ -868,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('گرم')
|
||||||
/** دسته آبشده/کاتد — ساختار فرم ثابت است */
|
/** دسته آبشده/کاتد — ساختار فرم ثابت است */
|
||||||
|
|||||||
@@ -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,6 +25,7 @@
|
|||||||
@click="$emit('toggleSell', row)"
|
@click="$emit('toggleSell', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('list')"
|
||||||
plain
|
plain
|
||||||
:key="`list-${row.id}-${row.show_in_list ?? row.active}`"
|
:key="`list-${row.id}-${row.show_in_list ?? row.active}`"
|
||||||
:icon="(row.show_in_list ?? 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'"
|
||||||
@@ -31,6 +34,7 @@
|
|||||||
@click="$emit('toggleActive', row)"
|
@click="$emit('toggleActive', row)"
|
||||||
/>
|
/>
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
|
v-if="can('tv')"
|
||||||
plain
|
plain
|
||||||
:key="`tv-${row.id}-${row.show_on_tv}`"
|
:key="`tv-${row.id}-${row.show_on_tv}`"
|
||||||
icon="vuesax-linear:monitor"
|
icon="vuesax-linear:monitor"
|
||||||
@@ -76,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"
|
||||||
@@ -100,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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,7 +75,7 @@
|
|||||||
@click="activeSell(record)"
|
@click="activeSell(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip class="cursor-pointer" :key="`list-${record.id}-${record.show_in_list ?? 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.show_in_list ?? record.active)" #title>
|
<template v-if="!(record.show_in_list ?? record.active)" #title>
|
||||||
<span>فعال کردن نمایش در لیست محصولات</span>
|
<span>فعال کردن نمایش در لیست محصولات</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
@click="toggleShowInList(record)"
|
@click="toggleShowInList(record)"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip class="cursor-pointer" :key="`tv-${record.id}-${record.show_on_tv}`">
|
<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>
|
<template v-if="!record.show_on_tv" #title>
|
||||||
<span>فعال کردن نمایش در تابلو TV</span>
|
<span>فعال کردن نمایش در تابلو TV</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -108,11 +108,11 @@
|
|||||||
@click="toggleShowOnTv(record)"
|
@click="toggleShowOnTv(record)"
|
||||||
/>
|
/>
|
||||||
</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>
|
||||||
<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="آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال میشود."
|
||||||
@@ -168,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)
|
||||||
|
|
||||||
|
|||||||
@@ -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',
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -22,19 +22,19 @@
|
|||||||
</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('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>
|
||||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||||
</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>
|
||||||
@@ -66,6 +66,9 @@ import { cols } from '../hooks/usersColumns'
|
|||||||
import ManagerMobileCardList from './ManagerMobileCardList.vue'
|
import ManagerMobileCardList from './ManagerMobileCardList.vue'
|
||||||
import { isMobile } from '@core/utils/is'
|
import { isMobile } from '@core/utils/is'
|
||||||
import { usersPageIntro } from '@/utils/adminHelpCopy'
|
import { usersPageIntro } 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)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<!-- </BasicMainCard>-->
|
<!-- </BasicMainCard>-->
|
||||||
<BasicModal
|
<BasicModal
|
||||||
v-model:visible="addUserVisible"
|
v-model:visible="addUserVisible"
|
||||||
width="40rem"
|
width="min(52rem, 96vw)"
|
||||||
:title="`${editId ? 'ویرایش' : 'افزودن'} کاربر`"
|
:title="`${editId ? 'ویرایش' : 'افزودن'} کاربر`"
|
||||||
@ok="ok"
|
@ok="ok"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
@@ -48,6 +48,19 @@
|
|||||||
</a-switch>
|
</a-switch>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="canAssignAccess" class="mt-1 flex flex-col gap-2">
|
||||||
|
<div>
|
||||||
|
<div class="text-sm font-medium">دسترسی صفحات</div>
|
||||||
|
<p class="mt-0.5 text-xs leading-5 opacity-70">
|
||||||
|
هر صفحه را باز کنید و مشاهده و عملیات جدول همان صفحه را مشخص کنید. بسته میماند تا وقتی لازم است.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<span class="text-sm">دسترسی کامل به همهٔ صفحات</span>
|
||||||
|
<a-switch v-model:checked="fullAccess" />
|
||||||
|
</div>
|
||||||
|
<ManagerPageAccessTree v-if="!fullAccess" v-model="form.page_access" />
|
||||||
|
</div>
|
||||||
</a-form>
|
</a-form>
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
<!-- <BasicInfoModal
|
<!-- <BasicInfoModal
|
||||||
@@ -81,12 +94,18 @@ import { toJalaliNoTime, toTime } from '@core/utils/useDataTime'
|
|||||||
import { confirmDeleteItem } from '@/utils/confirmModal'
|
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 ManagerPageAccessTree from './components/ManagerPageAccessTree.vue'
|
||||||
|
import { allGrantedMap, hasAnyView, parsePageAccess } from '@/utils/adminPageAccess'
|
||||||
|
import { useUserStore } from '@/store/userStore'
|
||||||
|
|
||||||
//loading
|
//loading
|
||||||
const loading = ref<boolean>(false)
|
const loading = ref<boolean>(false)
|
||||||
|
|
||||||
//define store
|
//define store
|
||||||
const store = useStaticApiListsStore()
|
const store = useStaticApiListsStore()
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const canAssignAccess = computed(() => userStore.hasFullPageAccess)
|
||||||
|
const fullAccess = ref(true)
|
||||||
|
|
||||||
//define tbl
|
//define tbl
|
||||||
const table = ref(null)
|
const table = ref(null)
|
||||||
@@ -112,6 +131,11 @@ const form = ref<User>({
|
|||||||
})
|
})
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
|
|
||||||
|
watch(fullAccess, (on) => {
|
||||||
|
if (on) return
|
||||||
|
if (form.value.page_access == null) form.value.page_access = allGrantedMap()
|
||||||
|
})
|
||||||
|
|
||||||
//info
|
//info
|
||||||
let infoParams = reactive<Info>({})
|
let infoParams = reactive<Info>({})
|
||||||
|
|
||||||
@@ -141,6 +165,8 @@ async function edit(record: User) {
|
|||||||
addUserVisible.value = true
|
addUserVisible.value = true
|
||||||
editId = record.id
|
editId = record.id
|
||||||
form.value = cloneDeep(record)
|
form.value = cloneDeep(record)
|
||||||
|
form.value.page_access = parsePageAccess(record.page_access)
|
||||||
|
fullAccess.value = form.value.page_access == null
|
||||||
}
|
}
|
||||||
|
|
||||||
//add
|
//add
|
||||||
@@ -164,8 +190,10 @@ const resetData = () => {
|
|||||||
avatar_id: undefined,
|
avatar_id: undefined,
|
||||||
sts: undefined,
|
sts: undefined,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
mobile: undefined
|
mobile: undefined,
|
||||||
|
page_access: null
|
||||||
}
|
}
|
||||||
|
fullAccess.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete — DELETE /admin/user/:id
|
//delete — DELETE /admin/user/:id
|
||||||
@@ -226,21 +254,33 @@ async function ok() {
|
|||||||
formRef.value?.validateFields().then(async () => {
|
formRef.value?.validateFields().then(async () => {
|
||||||
// console.log('salam', form.value)
|
// console.log('salam', form.value)
|
||||||
// return
|
// return
|
||||||
|
const payload = cloneDeep(form.value)
|
||||||
|
delete payload.repassword
|
||||||
|
if (canAssignAccess.value) {
|
||||||
|
payload.page_access = fullAccess.value ? null : payload.page_access ?? allGrantedMap()
|
||||||
|
if (!fullAccess.value && !hasAnyView(payload.page_access)) {
|
||||||
|
message.error('حداقل مشاهدهٔ یک صفحه را انتخاب کنید')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete payload.page_access
|
||||||
|
}
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
if (editId) {
|
if (editId) {
|
||||||
if (form.value.password) {
|
if (form.value.password) {
|
||||||
if (form.value.password === form.value.repassword) {
|
if (form.value.password === form.value.repassword) {
|
||||||
await updateUser(editId, form.value)
|
await updateUser(editId, payload)
|
||||||
} else {
|
} else {
|
||||||
message.error('پسورد وارد شده با تکرار پسورد وارد شده یکسان نیست')
|
message.error('پسورد وارد شده با تکرار پسورد وارد شده یکسان نیست')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await updateUser(editId, form.value)
|
delete payload.password
|
||||||
|
await updateUser(editId, payload)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await createUser(form.value)
|
await createUser(payload)
|
||||||
}
|
}
|
||||||
addUserVisible.value = false
|
addUserVisible.value = false
|
||||||
refreshTable()
|
refreshTable()
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
<BaseTable v-if="!isMobile" class="min-h-0 min-w-0 flex-1" v-bind="tblProps" @register="submit" ref="tbl">
|
<BaseTable v-if="!isMobile" class="min-h-0 min-w-0 flex-1" 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="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>
|
||||||
@@ -82,6 +82,9 @@ import { totalMetalWalletTitle } from '@/utils/adminMetalLabels'
|
|||||||
import type { WalletTableSums } from '@/model/wallet'
|
import type { WalletTableSums } from '@/model/wallet'
|
||||||
import { formatMetalDisplayValue, metalDisplayUnit } from '@/utils/metalWeight'
|
import { formatMetalDisplayValue, metalDisplayUnit } from '@/utils/metalWeight'
|
||||||
import { walletPageIntro } from '@/utils/adminHelpCopy'
|
import { walletPageIntro } 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)
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
:item="selectedItem"
|
:item="selectedItem"
|
||||||
@withdraw="(row) => emit('withdraw', row)"
|
@withdraw="(row) => emit('withdraw', row)"
|
||||||
@weight="(row) => emit('weight', row)"
|
@weight="(row) => emit('weight', row)"
|
||||||
|
@approve-deposit="(row) => emit('approveDeposit', row)"
|
||||||
|
@reject-deposit="(row) => emit('rejectDeposit', row)"
|
||||||
@change-status="changeStatusHandler"
|
@change-status="changeStatusHandler"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -53,6 +55,8 @@ const props = withDefaults(
|
|||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'withdraw', item: Withdraw): void
|
(e: 'withdraw', item: Withdraw): void
|
||||||
(e: 'weight', item: Withdraw): void
|
(e: 'weight', item: Withdraw): void
|
||||||
|
(e: 'approveDeposit', item: Withdraw): void
|
||||||
|
(e: 'rejectDeposit', item: Withdraw): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<Withdraw>()
|
const { sheetVisible, selectedItem, openSheet, syncSelectedItem } = useMobileDetailSheet<Withdraw>()
|
||||||
|
|||||||
@@ -6,8 +6,24 @@
|
|||||||
<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>
|
||||||
<div class="flex shrink-0 items-center gap-2">
|
<div class="flex shrink-0 items-center gap-2">
|
||||||
|
<template v-if="isPendingDepositRequest(row) && !isMobile">
|
||||||
<MobileIconButton
|
<MobileIconButton
|
||||||
v-if="needsTrackingConfirmation(row)"
|
plain
|
||||||
|
icon="vuesax-linear:tick-circle"
|
||||||
|
color="#16A34A"
|
||||||
|
:size="22"
|
||||||
|
@click="$emit('approveDeposit', row)"
|
||||||
|
/>
|
||||||
|
<MobileIconButton
|
||||||
|
plain
|
||||||
|
icon="vuesax-linear:close-circle"
|
||||||
|
color="#DC2626"
|
||||||
|
:size="22"
|
||||||
|
@click="$emit('rejectDeposit', row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<MobileIconButton
|
||||||
|
v-else-if="needsTrackingConfirmation(row)"
|
||||||
plain
|
plain
|
||||||
icon="vuesax-linear:tick-circle"
|
icon="vuesax-linear:tick-circle"
|
||||||
color="#16A34A"
|
color="#16A34A"
|
||||||
@@ -103,8 +119,53 @@
|
|||||||
<MobileDetailRow label="نام و نام خانوادگی" full-width :value="row.customer?.name || '-'" />
|
<MobileDetailRow label="نام و نام خانوادگی" full-width :value="row.customer?.name || '-'" />
|
||||||
<MobileDetailRow label="شماره کارت" full-width :value="row.bank_account?.cart_number || '-'" />
|
<MobileDetailRow label="شماره کارت" full-width :value="row.bank_account?.cart_number || '-'" />
|
||||||
<MobileDetailRow label="شماره شبا" full-width :value="row.bank_account?.shaba_number || '-'" />
|
<MobileDetailRow label="شماره شبا" full-width :value="row.bank_account?.shaba_number || '-'" />
|
||||||
|
<MobileDetailRow
|
||||||
|
label="شناسه واریز"
|
||||||
|
full-width
|
||||||
|
:value="row.deposit_identifier || row.customer?.n_code || '-'"
|
||||||
|
/>
|
||||||
<MobileDetailRow label="تاریخ ثبت" full-width :value="dateLabel(row)" />
|
<MobileDetailRow label="تاریخ ثبت" full-width :value="dateLabel(row)" />
|
||||||
|
<MobileDetailRow
|
||||||
|
v-if="row.reject_reason"
|
||||||
|
label="علت رد درخواست"
|
||||||
|
full-width
|
||||||
|
:value="row.reject_reason"
|
||||||
|
/>
|
||||||
|
<div v-if="row.receipt_url" class="col-span-2 py-1 min-w-0">
|
||||||
|
<div class="text-xs text-gray-500 mb-1.5">فیش واریزی (برای بزرگنمایی لمس کنید)</div>
|
||||||
|
<div class="withdraw-mobile-receipt">
|
||||||
|
<a-image
|
||||||
|
:src="row.receipt_url"
|
||||||
|
class="withdraw-mobile-receipt__img"
|
||||||
|
alt="فیش واریزی"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</MobileInfoGrid>
|
</MobileInfoGrid>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="isPendingDepositRequest(row)"
|
||||||
|
class="withdraw-mobile-actions"
|
||||||
|
>
|
||||||
|
<div class="withdraw-mobile-actions__grid">
|
||||||
|
<BaseButton
|
||||||
|
type="primary"
|
||||||
|
class="!bg-emerald-600 hover:!bg-emerald-700 !border-emerald-600 text-white"
|
||||||
|
@click="$emit('approveDeposit', row)"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<BaseIcon icon="vuesax-linear:tick-circle" size="16" />
|
||||||
|
</template>
|
||||||
|
تایید واریز
|
||||||
|
</BaseButton>
|
||||||
|
<BaseButton danger @click="$emit('rejectDeposit', row)">
|
||||||
|
<template #icon>
|
||||||
|
<BaseIcon icon="vuesax-linear:close-circle" size="16" />
|
||||||
|
</template>
|
||||||
|
رد واریز
|
||||||
|
</BaseButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MobileDetailSheet>
|
</MobileDetailSheet>
|
||||||
</template>
|
</template>
|
||||||
@@ -121,6 +182,7 @@ import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
|||||||
import {
|
import {
|
||||||
formatWithdrawAmountDisplay,
|
formatWithdrawAmountDisplay,
|
||||||
isMoneyWithdraw,
|
isMoneyWithdraw,
|
||||||
|
isPendingDepositRequest,
|
||||||
needsTrackingConfirmation,
|
needsTrackingConfirmation,
|
||||||
needsWeightAssignment,
|
needsWeightAssignment,
|
||||||
withdrawAmountValue,
|
withdrawAmountValue,
|
||||||
@@ -140,6 +202,8 @@ const emit = defineEmits<{
|
|||||||
(e: 'update:visible', value: boolean): void
|
(e: 'update:visible', value: boolean): void
|
||||||
(e: 'withdraw', item: Withdraw): void
|
(e: 'withdraw', item: Withdraw): void
|
||||||
(e: 'weight', item: Withdraw): void
|
(e: 'weight', item: Withdraw): void
|
||||||
|
(e: 'approveDeposit', item: Withdraw): void
|
||||||
|
(e: 'rejectDeposit', item: Withdraw): void
|
||||||
(e: 'changeStatus', item: Withdraw, statusEntry: [string, (typeof status)[keyof typeof status]]): void
|
(e: 'changeStatus', item: Withdraw, statusEntry: [string, (typeof status)[keyof typeof status]]): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
@@ -208,3 +272,58 @@ function amountIconColor(row: Withdraw) {
|
|||||||
return '#b45309'
|
return '#b45309'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.withdraw-mobile-receipt {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
border: 1px solid var(--admin-border, #e5e7eb);
|
||||||
|
background: var(--admin-bg-muted, #f9fafb);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-mobile-receipt :deep(.ant-image) {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-mobile-receipt :deep(.ant-image-img) {
|
||||||
|
width: auto !important;
|
||||||
|
max-width: 100% !important;
|
||||||
|
max-height: 9rem !important;
|
||||||
|
height: auto !important;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-mobile-actions {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 2;
|
||||||
|
margin-top: 0.75rem;
|
||||||
|
padding-top: 0.75rem;
|
||||||
|
padding-bottom: calc(0.25rem + env(safe-area-inset-bottom));
|
||||||
|
background: var(--admin-bg-elevated, #fff);
|
||||||
|
border-top: 1px solid var(--admin-border, #e5e7eb);
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-mobile-actions__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-mobile-actions__grid :deep(.ant-btn) {
|
||||||
|
min-height: 2.5rem;
|
||||||
|
width: 100%;
|
||||||
|
padding-inline: 0.5rem;
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
line-height: 1.25rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -11,15 +11,35 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #tracked="{ column, record }">
|
<template #tracked="{ column, record }">
|
||||||
<div v-if="record.tracked_number">{{ record.tracked_number }}</div>
|
<div v-if="record.tracked_number">{{ record.tracked_number }}</div>
|
||||||
<div v-else-if="needsTrackingConfirmation(record)">
|
<div v-else-if="!isPendingDepositRequest(record) && needsTrackingConfirmation(record)">
|
||||||
<BaseButton @click="emits('withdraw', record)">
|
<BaseButton v-if="can('confirm')" @click="emits('withdraw', record)">
|
||||||
{{ confirmLabelForRecord(record, props.flowType) }}
|
{{ confirmLabelForRecord(record, props.flowType) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>-</div>
|
<div v-else>-</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template #receipt="{ column, record }">
|
||||||
|
<div v-if="record.receipt_url" class="flex justify-center items-center">
|
||||||
|
<a-image
|
||||||
|
:src="record.receipt_url"
|
||||||
|
:width="36"
|
||||||
|
:height="36"
|
||||||
|
class="rounded object-cover border border-gray-200 cursor-pointer shadow-sm hover:opacity-80 transition"
|
||||||
|
alt="فیش واریز"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<span v-else class="text-gray-400">-</span>
|
||||||
|
</template>
|
||||||
<template #action="{ column, record }">
|
<template #action="{ column, record }">
|
||||||
<div class="gap-2 flex justify-center">
|
<div class="gap-2 flex justify-center items-center">
|
||||||
|
<a-tooltip v-if="record.reject_reason" class="cursor-pointer">
|
||||||
|
<template #title>
|
||||||
|
<span class="whitespace-pre-wrap">علت رد: {{ record.reject_reason }}</span>
|
||||||
|
</template>
|
||||||
|
<a-badge dot color="#dc2626">
|
||||||
|
<Icon icon="vuesax-linear:info-circle" color="#dc2626" />
|
||||||
|
</a-badge>
|
||||||
|
</a-tooltip>
|
||||||
<a-tooltip v-if="record.extra_note" class="cursor-pointer">
|
<a-tooltip v-if="record.extra_note" class="cursor-pointer">
|
||||||
<template #title>
|
<template #title>
|
||||||
<span class="whitespace-pre-wrap">{{ record.extra_note }}</span>
|
<span class="whitespace-pre-wrap">{{ record.extra_note }}</span>
|
||||||
@@ -28,14 +48,41 @@
|
|||||||
<Icon icon="vuesax-linear:message-text" color="#64748b" />
|
<Icon icon="vuesax-linear:message-text" color="#64748b" />
|
||||||
</a-badge>
|
</a-badge>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip v-if="needsTrackingConfirmation(record)" class="cursor-pointer">
|
<template v-if="isPendingDepositRequest(record) && can('confirm')">
|
||||||
|
<a-tooltip title="تایید واریز و شارژ کیف پول">
|
||||||
|
<BaseButton
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
class="!bg-emerald-600 hover:!bg-emerald-700 !border-emerald-600 text-white"
|
||||||
|
@click="emits('approveDeposit', record)"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<Icon icon="vuesax-linear:tick-circle" size="14" />
|
||||||
|
</template>
|
||||||
|
تایید
|
||||||
|
</BaseButton>
|
||||||
|
</a-tooltip>
|
||||||
|
<a-tooltip title="رد واریز">
|
||||||
|
<BaseButton
|
||||||
|
size="small"
|
||||||
|
danger
|
||||||
|
@click="emits('rejectDeposit', record)"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<Icon icon="vuesax-linear:close-circle" size="14" />
|
||||||
|
</template>
|
||||||
|
رد
|
||||||
|
</BaseButton>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<a-tooltip v-else-if="can('confirm') && needsTrackingConfirmation(record)" class="cursor-pointer">
|
||||||
<template #title><span>{{ confirmLabelForRecord(record, props.flowType) }}</span></template>
|
<template #title><span>{{ confirmLabelForRecord(record, props.flowType) }}</span></template>
|
||||||
<BaseButton size="small" type="primary" @click="emits('withdraw', record)">
|
<BaseButton size="small" type="primary" @click="emits('withdraw', record)">
|
||||||
{{ confirmLabelForRecord(record, props.flowType) }}
|
{{ confirmLabelForRecord(record, props.flowType) }}
|
||||||
</BaseButton>
|
</BaseButton>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<div class="flex gap-2" v-if="record.sts <= 70 && record.sts >= 50">
|
<div class="flex gap-2" v-if="record.sts <= 70 && record.sts >= 50">
|
||||||
<a-tooltip class="cursor-pointer">
|
<a-tooltip v-if="can('factor')" class="cursor-pointer">
|
||||||
<template #title><span>دریافت فاکتور</span></template>
|
<template #title><span>دریافت فاکتور</span></template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:document-download"
|
icon="vuesax-linear:document-download"
|
||||||
@@ -43,7 +90,7 @@
|
|||||||
@click="$router.push({ name: 'factor', params: { id: record.id } })"
|
@click="$router.push({ name: 'factor', params: { id: record.id } })"
|
||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip class="cursor-pointer">
|
<a-tooltip v-if="can('status')" class="cursor-pointer">
|
||||||
<template #title><span>وضعیت</span></template>
|
<template #title><span>وضعیت</span></template>
|
||||||
<ADropdown :trigger="['click']">
|
<ADropdown :trigger="['click']">
|
||||||
<Icon icon="vuesax-linear:status-up" color="#CA8A04" @click="test(record)" />
|
<Icon icon="vuesax-linear:status-up" color="#CA8A04" @click="test(record)" />
|
||||||
@@ -66,7 +113,7 @@
|
|||||||
</ADropdown>
|
</ADropdown>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</div>
|
</div>
|
||||||
<a-tooltip v-if="needsWeightAssignment(record)" class="cursor-pointer">
|
<a-tooltip v-if="can('weight') && needsWeightAssignment(record)" class="cursor-pointer">
|
||||||
<template #title><span>تعیین وزن</span></template>
|
<template #title><span>تعیین وزن</span></template>
|
||||||
<Icon
|
<Icon
|
||||||
icon="vuesax-linear:3d-cube-scan"
|
icon="vuesax-linear:3d-cube-scan"
|
||||||
@@ -75,7 +122,7 @@
|
|||||||
/>
|
/>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="tahesabEnabled && record.tahesab_failed_id"
|
v-if="can('tahesab') && tahesabEnabled && record.tahesab_failed_id"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openTahesabRetry(record)"
|
@click="openTahesabRetry(record)"
|
||||||
>
|
>
|
||||||
@@ -83,7 +130,7 @@
|
|||||||
<Icon icon="vuesax-linear:refresh-circle" color="#CA8A04" />
|
<Icon icon="vuesax-linear:refresh-circle" color="#CA8A04" />
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-tooltip
|
<a-tooltip
|
||||||
v-if="zarinEnabled && record.zarin_failed_id"
|
v-if="can('zarin') && zarinEnabled && record.zarin_failed_id"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="openZarinRetry(record)"
|
@click="openZarinRetry(record)"
|
||||||
>
|
>
|
||||||
@@ -101,6 +148,8 @@
|
|||||||
:flow-type="props.flowType"
|
:flow-type="props.flowType"
|
||||||
@withdraw="(row) => emits('withdraw', row)"
|
@withdraw="(row) => emits('withdraw', row)"
|
||||||
@weight="(row) => emits('weight', row)"
|
@weight="(row) => emits('weight', row)"
|
||||||
|
@approve-deposit="(row) => emits('approveDeposit', row)"
|
||||||
|
@reject-deposit="(row) => emits('rejectDeposit', row)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -138,6 +187,7 @@ import { isMobile } from '@core/utils/is'
|
|||||||
import type { WithdrawFlowType } from '../types'
|
import type { WithdrawFlowType } from '../types'
|
||||||
import {
|
import {
|
||||||
confirmLabelForRecord,
|
confirmLabelForRecord,
|
||||||
|
isPendingDepositRequest,
|
||||||
needsTrackingConfirmation,
|
needsTrackingConfirmation,
|
||||||
needsWeightAssignment
|
needsWeightAssignment
|
||||||
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
||||||
@@ -166,7 +216,7 @@ const zarinEnabled = zarinEnabledSetting
|
|||||||
val.sts === 1 ? return ['1'] : ['2']
|
val.sts === 1 ? return ['1'] : ['2']
|
||||||
}*/
|
}*/
|
||||||
//emits
|
//emits
|
||||||
const emits = defineEmits(['delete', 'edit', 'add', 'withdraw', 'weight'])
|
const emits = defineEmits(['delete', 'edit', 'add', 'withdraw', 'weight', 'approveDeposit', 'rejectDeposit'])
|
||||||
|
|
||||||
const { prefixCls } = usePrefix('pophoverstatus')
|
const { prefixCls } = usePrefix('pophoverstatus')
|
||||||
|
|
||||||
@@ -242,6 +292,9 @@ onMounted(() => {
|
|||||||
import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
import { status } from '@/pages/menuPages/withdraw/information/hooks/status'
|
||||||
import {toNumber} from "lodash";
|
import {toNumber} from "lodash";
|
||||||
import { withdrawPageIntro } from '@/utils/adminHelpCopy'
|
import { withdrawPageIntro } from '@/utils/adminHelpCopy'
|
||||||
|
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||||
|
|
||||||
|
const { can } = usePageActionAccess()
|
||||||
const withdrawId = ref(null)
|
const withdrawId = ref(null)
|
||||||
const sts = ref()
|
const sts = ref()
|
||||||
const statusList = computed(() => {
|
const statusList = computed(() => {
|
||||||
|
|||||||
@@ -74,6 +74,24 @@ export function getWithdrawColumns(): BaseTableColumn[] {
|
|||||||
key: 'customer.name',
|
key: 'customer.name',
|
||||||
type: 'Text'
|
type: 'Text'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'شناسه واریز',
|
||||||
|
dataIndex: 'deposit_identifier',
|
||||||
|
key: 'deposit_identifier',
|
||||||
|
type: 'Text',
|
||||||
|
customRender: ({ record }: any) => {
|
||||||
|
const val = record?.deposit_identifier || record?.customer?.n_code
|
||||||
|
return val ? <span dir="ltr" class="font-mono text-xs">{val}</span> : '-'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'فیش واریزی',
|
||||||
|
dataIndex: 'receipt_url',
|
||||||
|
key: 'receipt_url',
|
||||||
|
slot: 'receipt',
|
||||||
|
filterable: false,
|
||||||
|
sortable: false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: 'نوع',
|
title: 'نوع',
|
||||||
dataIndex: 'asset_type',
|
dataIndex: 'asset_type',
|
||||||
@@ -172,9 +190,18 @@ export function getWithdrawColumns(): BaseTableColumn[] {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
customRender: ({ record }) => {
|
customRender: ({ record }: any) => {
|
||||||
|
let textColor = '#ca8a04'
|
||||||
|
let bgColor = '#fef3c7'
|
||||||
|
if (record?.sts === 2 || record?.sts === 4) {
|
||||||
|
textColor = '#25855A'
|
||||||
|
bgColor = '#E3F4E9'
|
||||||
|
} else if (record?.sts === 3) {
|
||||||
|
textColor = '#C53030'
|
||||||
|
bgColor = '#FECACA'
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<CustomTag textColor='#ca8a04' bgColor='#fef3c7'>{record?.sts_str}</CustomTag>
|
<CustomTag textColor={textColor} bgColor={bgColor}>{record?.sts_str || '-'}</CustomTag>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
@delete="deleteItem"
|
@delete="deleteItem"
|
||||||
@withdraw="openWithdraw"
|
@withdraw="openWithdraw"
|
||||||
@weight="openWeight"
|
@weight="openWeight"
|
||||||
|
@approve-deposit="openApproveDeposit"
|
||||||
|
@reject-deposit="openRejectDeposit"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
|
||||||
@@ -92,6 +94,94 @@
|
|||||||
اطلاعات تراکنش یافت نشد
|
اطلاعات تراکنش یافت نشد
|
||||||
</div>
|
</div>
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
|
|
||||||
|
<!-- مدال تایید واریز وجه -->
|
||||||
|
<BasicModal
|
||||||
|
v-model:visible="approveDepositModalVisible"
|
||||||
|
width="28rem"
|
||||||
|
title="تایید واریز وجه به کیف پول"
|
||||||
|
wrap-class-name="withdraw-stack-modal withdraw-deposit-modal"
|
||||||
|
:loading="depositActionLoading"
|
||||||
|
@ok="handleApproveDeposit"
|
||||||
|
@close="approveDepositModalVisible = false"
|
||||||
|
>
|
||||||
|
<div v-if="selectedDepositRecord" class="space-y-3 py-2 text-sm">
|
||||||
|
<div class="rounded-lg bg-emerald-50 p-3 text-emerald-900 border border-emerald-200">
|
||||||
|
<div class="font-bold flex justify-between items-center">
|
||||||
|
<span>مشتری: {{ selectedDepositRecord.customer?.name || '-' }}</span>
|
||||||
|
<span class="text-xs text-emerald-700">موبایل: {{ selectedDepositRecord.customer?.mobile || '-' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 text-xs flex justify-between">
|
||||||
|
<span>شناسه واریز: <strong dir="ltr">{{ selectedDepositRecord.deposit_identifier || selectedDepositRecord.customer?.n_code || '-' }}</strong></span>
|
||||||
|
<span>مبلغ: <strong class="text-emerald-800 text-sm">{{ formatWithdrawAmountDisplay(selectedDepositRecord) }}</strong></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="selectedDepositRecord.receipt_url" class="withdraw-receipt-preview rounded border p-2 text-center bg-gray-50">
|
||||||
|
<div class="text-xs text-gray-500 mb-2">تصویر فیش واریزی (جهت بزرگنمایی روی عکس کلیک کنید):</div>
|
||||||
|
<a-image
|
||||||
|
:src="selectedDepositRecord.receipt_url"
|
||||||
|
class="withdraw-receipt-preview__img"
|
||||||
|
alt="فیش واریز"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="selectedDepositRecord.extra_note" class="rounded bg-gray-100 p-2 text-xs text-gray-700">
|
||||||
|
<span class="font-bold">توضیحات مشتری: </span>
|
||||||
|
<span>{{ selectedDepositRecord.extra_note }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-medium text-gray-700 mb-1">شماره پیگیری تراکنش:</label>
|
||||||
|
<BasicInput
|
||||||
|
v-model:value="approveTrackedNumber"
|
||||||
|
placeholder="شماره پیگیری فیش بانکی"
|
||||||
|
dir="ltr"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
با تایید، مبلغ به کیف پول نقدی مشتری واریز شده و پیامک تایید ارسال میگردد.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
|
|
||||||
|
<!-- مدال رد واریز وجه -->
|
||||||
|
<BasicModal
|
||||||
|
v-model:visible="rejectDepositModalVisible"
|
||||||
|
width="26rem"
|
||||||
|
title="رد درخواست واریز"
|
||||||
|
wrap-class-name="withdraw-stack-modal withdraw-deposit-modal"
|
||||||
|
:loading="depositActionLoading"
|
||||||
|
@ok="handleRejectDeposit"
|
||||||
|
@close="rejectDepositModalVisible = false"
|
||||||
|
>
|
||||||
|
<div v-if="selectedDepositRecord" class="space-y-3 py-2 text-sm">
|
||||||
|
<div class="rounded-lg bg-red-50 p-3 text-red-900 border border-red-200">
|
||||||
|
<div class="font-bold flex justify-between items-center">
|
||||||
|
<span>مشتری: {{ selectedDepositRecord.customer?.name || '-' }}</span>
|
||||||
|
<span class="text-xs text-red-700">موبایل: {{ selectedDepositRecord.customer?.mobile || '-' }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 text-xs flex justify-between">
|
||||||
|
<span>مبلغ: <strong>{{ formatWithdrawAmountDisplay(selectedDepositRecord) }}</strong></span>
|
||||||
|
<span>شناسه: <strong dir="ltr">{{ selectedDepositRecord.deposit_identifier || selectedDepositRecord.customer?.n_code || '-' }}</strong></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-medium text-gray-700 mb-1">علت رد درخواست (در پیامک برای مشتری ارسال میشود):</label>
|
||||||
|
<a-textarea
|
||||||
|
v-model:value="rejectReason"
|
||||||
|
:rows="3"
|
||||||
|
placeholder="مثال: عدم تطابق فیش واریزی با گردش حساب بانکی..."
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-xs text-gray-500">
|
||||||
|
با رد واریز، پیامک اطلاعرسانی حاوی علت رد برای مشتری ارسال میشود.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasicModal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -114,10 +204,21 @@ import type { Customer } from '@/model/customer'
|
|||||||
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
||||||
import type { Order } from '@/model/order'
|
import type { Order } from '@/model/order'
|
||||||
import type { Wallet, Withdraw } from '@/model/wallet'
|
import type { Wallet, Withdraw } from '@/model/wallet'
|
||||||
import {completeWithdraw, exportWithdrawReport, getWithdrawById, sendWeights} from '@/api/wallet'
|
import {
|
||||||
|
approveDeposit,
|
||||||
|
completeWithdraw,
|
||||||
|
exportWithdrawReport,
|
||||||
|
getWithdrawById,
|
||||||
|
rejectDeposit,
|
||||||
|
sendWeights
|
||||||
|
} from '@/api/wallet'
|
||||||
import Button from "@core/components/BaseButton";
|
import Button from "@core/components/BaseButton";
|
||||||
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
import type { WithdrawFlowType } from '@/pages/menuPages/withdraw/types'
|
||||||
import { confirmLabelForRecord, needsWeightAssignment } from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
import {
|
||||||
|
confirmLabelForRecord,
|
||||||
|
formatWithdrawAmountDisplay,
|
||||||
|
needsWeightAssignment
|
||||||
|
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
|
||||||
import { openHtmlPrintWindow } from '@/pages/menuPages/withdraw/utils/openHtmlPrintWindow'
|
import { openHtmlPrintWindow } from '@/pages/menuPages/withdraw/utils/openHtmlPrintWindow'
|
||||||
//import DatePicker from '@core/components/_sample/components/datePicker.vue'
|
//import DatePicker from '@core/components/_sample/components/datePicker.vue'
|
||||||
|
|
||||||
@@ -360,6 +461,65 @@ function ok(i) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deposit approval / rejection logic
|
||||||
|
const approveDepositModalVisible = ref(false)
|
||||||
|
const rejectDepositModalVisible = ref(false)
|
||||||
|
const selectedDepositRecord = ref<Withdraw | null>(null)
|
||||||
|
const approveTrackedNumber = ref('')
|
||||||
|
const rejectReason = ref('')
|
||||||
|
const depositActionLoading = ref(false)
|
||||||
|
|
||||||
|
function openApproveDeposit(record: Withdraw) {
|
||||||
|
selectedDepositRecord.value = record
|
||||||
|
approveTrackedNumber.value = record.tracked_number || ''
|
||||||
|
approveDepositModalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function openRejectDeposit(record: Withdraw) {
|
||||||
|
selectedDepositRecord.value = record
|
||||||
|
rejectReason.value = ''
|
||||||
|
rejectDepositModalVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleApproveDeposit() {
|
||||||
|
if (!selectedDepositRecord.value?.id) return
|
||||||
|
try {
|
||||||
|
depositActionLoading.value = true
|
||||||
|
await approveDeposit({
|
||||||
|
id: selectedDepositRecord.value.id,
|
||||||
|
tracked_number: approveTrackedNumber.value || undefined
|
||||||
|
})
|
||||||
|
message.success('واریز با موفقیت تایید و به کیف پول مشتری افزوده شد')
|
||||||
|
approveDepositModalVisible.value = false
|
||||||
|
selectedDepositRecord.value = null
|
||||||
|
refreshTable()
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(e)
|
||||||
|
message.error(e?.response?.data?.message || 'خطا در تایید واریز')
|
||||||
|
} finally {
|
||||||
|
depositActionLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleRejectDeposit() {
|
||||||
|
if (!selectedDepositRecord.value?.id) return
|
||||||
|
try {
|
||||||
|
depositActionLoading.value = true
|
||||||
|
await rejectDeposit({
|
||||||
|
id: selectedDepositRecord.value.id,
|
||||||
|
reject_reason: rejectReason.value || undefined
|
||||||
|
})
|
||||||
|
message.success('درخواست واریز رد شد و پیامک اطلاعرسانی ارسال گردید')
|
||||||
|
rejectDepositModalVisible.value = false
|
||||||
|
selectedDepositRecord.value = null
|
||||||
|
refreshTable()
|
||||||
|
} catch (e: any) {
|
||||||
|
console.error(e)
|
||||||
|
message.error(e?.response?.data?.message || 'خطا در رد واریز')
|
||||||
|
} finally {
|
||||||
|
depositActionLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
@@ -368,4 +528,43 @@ function ok(i) {
|
|||||||
.withdraw-stack-modal {
|
.withdraw-stack-modal {
|
||||||
z-index: 1100 !important;
|
z-index: 1100 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.withdraw-receipt-preview :deep(.ant-image) {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-receipt-preview :deep(.ant-image-img) {
|
||||||
|
width: auto !important;
|
||||||
|
max-width: 100% !important;
|
||||||
|
max-height: 9.5rem !important;
|
||||||
|
height: auto !important;
|
||||||
|
object-fit: contain;
|
||||||
|
margin-inline: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767.98px) {
|
||||||
|
.withdraw-deposit-modal .ant-modal {
|
||||||
|
max-width: calc(100vw - 1rem) !important;
|
||||||
|
margin: 0.5rem auto !important;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-deposit-modal .ant-modal-body #body {
|
||||||
|
max-height: min(70vh, 520px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-deposit-modal .ant-modal-footer {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
.withdraw-deposit-modal .ant-modal-footer .ant-btn {
|
||||||
|
margin: 0 !important;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ export function confirmLabelForRecord(
|
|||||||
return flowType === 'deposit' ? 'تایید واریز' : 'تایید برداشت'
|
return flowType === 'deposit' ? 'تایید واریز' : 'تایید برداشت'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** بررسی درخواست واریز معلق که نیاز به تایید یا رد ادمین دارد */
|
||||||
|
export function isPendingDepositRequest(
|
||||||
|
record: Pick<Withdraw, 'sts' | 'receipt' | 'receipt_url' | 'deposit_identifier' | 'note' | 'cash' | 'gold' | 'bank_account_id' | 'type'>
|
||||||
|
): boolean {
|
||||||
|
if (Number(record.sts ?? 0) !== 1) return false
|
||||||
|
if (record.receipt_url || record.receipt || record.deposit_identifier) return true
|
||||||
|
return resolveRecordFlowType(record as any) === 'deposit'
|
||||||
|
}
|
||||||
|
|
||||||
/** فقط تراکنشهای در انتظار پیگیری — نه واریز/کسر ادمین (sts=4) */
|
/** فقط تراکنشهای در انتظار پیگیری — نه واریز/کسر ادمین (sts=4) */
|
||||||
export function needsTrackingConfirmation(record: Pick<Withdraw, 'sts' | 'tracked_number'>): boolean {
|
export function needsTrackingConfirmation(record: Pick<Withdraw, 'sts' | 'tracked_number'>): boolean {
|
||||||
if (record.tracked_number) return false
|
if (record.tracked_number) return false
|
||||||
|
|||||||
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
//import router from '@/core/router/index'
|
//import router from '@/core/router/index'
|
||||||
import { useRouterStore } from '@core/stores/router'
|
import { useRouterStore } from '@core/stores/router'
|
||||||
import type { Router, RouteRecordRaw } from 'vue-router'
|
import type { Router, RouteRecordRaw } from 'vue-router'
|
||||||
import { getConfigApp, isStoreApp } from '@/utils/config'
|
import { getConfigApp, giftCardEnabledSetting, isStoreApp } from '@/utils/config'
|
||||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||||
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
||||||
import { useUserStore } from '@/store/userStore'
|
import { useUserStore } from '@/store/userStore'
|
||||||
@@ -42,7 +42,7 @@ function applyAppModeMeta(route: RouteRecordRaw, appName: string | null) {
|
|||||||
for (const child of route.children) {
|
for (const child of route.children) {
|
||||||
if (child.name === 'giftCardMain' && child.meta) {
|
if (child.name === 'giftCardMain' && child.meta) {
|
||||||
child.meta.title = store ? 'کارت هدیه و تخفیف' : 'کارت هدیه'
|
child.meta.title = store ? 'کارت هدیه و تخفیف' : 'کارت هدیه'
|
||||||
child.meta.hideMenu = !store && appName !== 'garoosi'
|
child.meta.hideMenu = !giftCardEnabledSetting.value
|
||||||
}
|
}
|
||||||
if (child.name === 'discounts' && child.meta) {
|
if (child.name === 'discounts' && child.meta) {
|
||||||
child.meta.hideMenu = store || appName !== 'goldsun'
|
child.meta.hideMenu = store || appName !== 'goldsun'
|
||||||
@@ -60,7 +60,7 @@ function filterRoutesByApp(routes: RouteRecordRaw, appName: string | null) {
|
|||||||
routes.children = routes.children.filter((item) => {
|
routes.children = routes.children.filter((item) => {
|
||||||
if (item.name === 'discounts' && (isStoreApp() || appName !== 'goldsun')) return false
|
if (item.name === 'discounts' && (isStoreApp() || appName !== 'goldsun')) return false
|
||||||
if (item.name === 'authentication' && appName !== 'garoosi') return false
|
if (item.name === 'authentication' && appName !== 'garoosi') return false
|
||||||
if (item.name === 'giftCardMain' && !isStoreApp() && appName !== 'garoosi') return false
|
if (item.name === 'giftCardMain' && !giftCardEnabledSetting.value) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ const Customers: RouteRecordRaw = {
|
|||||||
order: 4
|
order: 4
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'customerMain_digipayInstallment',
|
||||||
|
path: 'digipay-installment',
|
||||||
|
component: () => import('@/pages/menuPages/customers/digipayInstallment/index.vue'),
|
||||||
|
meta: {
|
||||||
|
icon: 'vuesax-linear:calendar',
|
||||||
|
title: 'خرید اقساطی',
|
||||||
|
order: 6
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'customerMain_goldCredit',
|
name: 'customerMain_goldCredit',
|
||||||
path: 'gold-credit',
|
path: 'gold-credit',
|
||||||
|
|||||||
@@ -130,6 +130,17 @@ const HesabKetab: RouteRecordRaw = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'copperConvertMain',
|
||||||
|
path: 'copper-convert',
|
||||||
|
component: () => import('@/pages/menuPages/copperConvert/index.vue'),
|
||||||
|
meta: {
|
||||||
|
permissionsKey: 'copperConvertMain',
|
||||||
|
icon: 'vuesax-linear:empty-wallet-time',
|
||||||
|
title: 'درخواست تبدیل',
|
||||||
|
order: 6.9
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'accountingMain',
|
name: 'accountingMain',
|
||||||
path: 'accounting',
|
path: 'accounting',
|
||||||
|
|||||||
@@ -4,12 +4,30 @@ import { getMyInformation } from '@/api/user'
|
|||||||
import { get } from 'lodash'
|
import { get } from 'lodash'
|
||||||
import { isDeployAdmin } from '@/utils/deployAdmin'
|
import { isDeployAdmin } from '@/utils/deployAdmin'
|
||||||
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
import { hasSmsPanelAccess, isSmsBillingEnabled } from '@/utils/smsPanelAccess'
|
||||||
|
import { setAdminAccessState } from '@/utils/adminAccessState'
|
||||||
|
import { parsePageAccess } from '@/utils/adminPageAccess'
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
const userInfo = ref<User | undefined>(undefined)
|
const userInfo = ref<User | undefined>(undefined)
|
||||||
|
|
||||||
|
function syncPageAccess() {
|
||||||
|
const info = userInfo.value
|
||||||
|
const deployAdmin = isDeployAdmin(info?.mobile)
|
||||||
|
const pageAccess = parsePageAccess(info?.page_access)
|
||||||
|
const unrestricted = deployAdmin || pageAccess == null
|
||||||
|
setAdminAccessState({
|
||||||
|
ready: true,
|
||||||
|
unrestricted,
|
||||||
|
pageAccess: unrestricted ? null : pageAccess ?? null,
|
||||||
|
deployAdmin,
|
||||||
|
smsPanel: hasSmsPanelAccess(info) && isSmsBillingEnabled(info)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function getMyInfo() {
|
async function getMyInfo() {
|
||||||
try {
|
try {
|
||||||
userInfo.value = await getMyInformation()
|
userInfo.value = await getMyInformation()
|
||||||
|
syncPageAccess()
|
||||||
return userInfo.value
|
return userInfo.value
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -37,6 +55,11 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
|
|
||||||
const isDeployAdminUser = computed(() => isDeployAdmin(userInfo.value?.mobile))
|
const isDeployAdminUser = computed(() => isDeployAdmin(userInfo.value?.mobile))
|
||||||
|
|
||||||
|
const hasFullPageAccess = computed(() => {
|
||||||
|
if (isDeployAdminUser.value) return true
|
||||||
|
return parsePageAccess(userInfo.value?.page_access) == null
|
||||||
|
})
|
||||||
|
|
||||||
const smsPanelAccess = computed(() => hasSmsPanelAccess(userInfo.value))
|
const smsPanelAccess = computed(() => hasSmsPanelAccess(userInfo.value))
|
||||||
const smsBillingEnabled = computed(() => isSmsBillingEnabled(userInfo.value))
|
const smsBillingEnabled = computed(() => isSmsBillingEnabled(userInfo.value))
|
||||||
|
|
||||||
@@ -48,6 +71,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
canAccess,
|
canAccess,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
isDeployAdminUser,
|
isDeployAdminUser,
|
||||||
|
hasFullPageAccess,
|
||||||
smsPanelAccess,
|
smsPanelAccess,
|
||||||
smsBillingEnabled
|
smsBillingEnabled
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
export type PageAccessFlags = {
|
||||||
|
view: boolean
|
||||||
|
edit?: boolean
|
||||||
|
delete?: boolean
|
||||||
|
/** کلیدهای ستون عملیات همان صفحه */
|
||||||
|
actions?: Record<string, boolean>
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PageAccessMap = Record<string, PageAccessFlags>
|
||||||
|
|
||||||
|
export type AdminAccessState = {
|
||||||
|
/** null یعنی هنوز بارگذاری نشده؛ تا آمدن /admin/me محدود نکن */
|
||||||
|
ready: boolean
|
||||||
|
unrestricted: boolean
|
||||||
|
pageAccess: PageAccessMap | null
|
||||||
|
deployAdmin: boolean
|
||||||
|
smsPanel: boolean
|
||||||
|
routeName: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const state: AdminAccessState = {
|
||||||
|
ready: false,
|
||||||
|
unrestricted: true,
|
||||||
|
pageAccess: null,
|
||||||
|
deployAdmin: false,
|
||||||
|
smsPanel: false,
|
||||||
|
routeName: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readAdminAccessState(): AdminAccessState {
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setAdminAccessState(next: Partial<AdminAccessState>) {
|
||||||
|
Object.assign(state, next)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setCurrentAdminRoute(name: string) {
|
||||||
|
state.routeName = name
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user