Compare commits
21
Commits
0f60c1e1a5
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d68e8f40f9 | ||
|
|
fa61e570d0 | ||
|
|
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']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
ShayeganChargeAlertHost: typeof import('./src/components/ShayeganChargeAlertHost.vue')['default']
|
||||
ShayeganCustomerRegisterModal: typeof import('./src/components/ShayeganCustomerRegisterModal.vue')['default']
|
||||
SmsCreditWidget: typeof import('./src/components/SmsCreditWidget.vue')['default']
|
||||
SmsNegativeBalanceHost: typeof import('./src/components/SmsNegativeBalanceHost.vue')['default']
|
||||
SmsNegativeBalanceModal: typeof import('./src/components/SmsNegativeBalanceModal.vue')['default']
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<CustomerImportProgress />
|
||||
<TahesabDocSyncProgress />
|
||||
<GroupSmsSendProgress />
|
||||
<ShayeganChargeAlertHost />
|
||||
</AConfigProvider>
|
||||
</template>
|
||||
|
||||
@@ -15,6 +16,7 @@ import { initDarkmode } from '@core/stores/darkmode'
|
||||
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
||||
import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue'
|
||||
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
||||
import ShayeganChargeAlertHost from '@/components/ShayeganChargeAlertHost.vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||
|
||||
+55
-2
@@ -49,6 +49,8 @@ function parseLegacySlider(value: string | null | undefined): IBenefits[] {
|
||||
}
|
||||
}
|
||||
|
||||
export const ASSETS_BANNER_CONST_KEY = 'assets_banner'
|
||||
|
||||
export type AppBannersConstState = {
|
||||
/** فقط وقتی رکورد واقعاً با key=app_banners است؛ وگرنه null تا create شود */
|
||||
id: number | null
|
||||
@@ -71,6 +73,20 @@ async function loadLegacySliderInto(merged: AppBannersValue): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAssetsBannerInto(merged: AppBannersValue): Promise<void> {
|
||||
try {
|
||||
const res = await useAxios.get<Const | Const[]>(
|
||||
`/api/const/key/${ASSETS_BANNER_CONST_KEY}`
|
||||
)
|
||||
const row = pickConstRow(res)
|
||||
if (!row) return
|
||||
const items = parseLegacySlider(row.value)
|
||||
if (items.length) merged.assetsBanner = items
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
async function loadLegacyThemeBanners(): Promise<AppBannersValue> {
|
||||
try {
|
||||
const themeRes = await useAxios.get<Const | Const[]>(
|
||||
@@ -102,7 +118,7 @@ export async function loadAppBannersConst(): Promise<AppBannersConstState> {
|
||||
let healedFromLegacy = false
|
||||
|
||||
// رکورد پوچ app_banners روی URLهای واقعی legacy سایه نیندازد
|
||||
if (isThemeBannersEmpty(data) || !data.slider.length) {
|
||||
if (isThemeBannersEmpty(data) || !data.slider.length || !(data.assetsBanner ?? []).length) {
|
||||
const before = serializeAppBanners(data)
|
||||
if (isThemeBannersEmpty(data)) {
|
||||
const legacyTheme = await loadLegacyThemeBanners()
|
||||
@@ -111,6 +127,9 @@ export async function loadAppBannersConst(): Promise<AppBannersConstState> {
|
||||
if (!data.slider.length) {
|
||||
await loadLegacySliderInto(data)
|
||||
}
|
||||
if (!(data.assetsBanner ?? []).length) {
|
||||
await loadAssetsBannerInto(data)
|
||||
}
|
||||
healedFromLegacy = serializeAppBanners(data) !== before
|
||||
}
|
||||
|
||||
@@ -125,8 +144,9 @@ export async function loadAppBannersConst(): Promise<AppBannersConstState> {
|
||||
const legacyTheme = await loadLegacyThemeBanners()
|
||||
Object.assign(merged, mergeAppBannersFromLegacy(merged, legacyTheme))
|
||||
await loadLegacySliderInto(merged)
|
||||
await loadAssetsBannerInto(merged)
|
||||
|
||||
const hasLegacy = !isThemeBannersEmpty(merged) || merged.slider.length > 0
|
||||
const hasLegacy = !isThemeBannersEmpty(merged) || merged.slider.length > 0 || (merged.assetsBanner ?? []).length > 0
|
||||
return { id: null, data: merged, healedFromLegacy: hasLegacy }
|
||||
}
|
||||
|
||||
@@ -192,5 +212,38 @@ export async function saveAppBannersConst(
|
||||
console.error('همگامسازی header_banner ناموفق بود:', error)
|
||||
}
|
||||
|
||||
try {
|
||||
await syncAssetsBannerConst(data.assetsBanner ?? [])
|
||||
} catch (error) {
|
||||
console.error('همگامسازی assets_banner ناموفق بود:', error)
|
||||
}
|
||||
|
||||
return nextId
|
||||
}
|
||||
|
||||
export async function syncAssetsBannerConst(items: IBenefits[]): Promise<void> {
|
||||
const value = JSON.stringify(items ?? [])
|
||||
const payload = {
|
||||
key: ASSETS_BANNER_CONST_KEY,
|
||||
value,
|
||||
title_fa: 'بنر صفحه داراییها',
|
||||
is_active: true,
|
||||
description: 'بنر صفحهٔ داراییهای اپ مشتری (زیر نمودار)',
|
||||
}
|
||||
|
||||
try {
|
||||
const existingRes = await useAxios.get<Const | Const[]>(
|
||||
`/api/const/key/${ASSETS_BANNER_CONST_KEY}`
|
||||
)
|
||||
const existing = pickConstRow(existingRes)
|
||||
const existingId = existing?.id ?? existing?.const_id ?? null
|
||||
if (existingId) {
|
||||
await useAxios.put<Const>(`/admin/const/${existingId}`, { id: existingId, ...payload })
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
// create below
|
||||
}
|
||||
|
||||
await useAxios.post<Const>(`/admin/const`, { id: 0, ...payload })
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ export type CategoryListParams = {
|
||||
export const getCategories = async (params?: CategoryListParams) =>
|
||||
await useAxios.get<Category[]>('/admin/categories', { params })
|
||||
|
||||
export const createCategory = async (payload: CategoryInput) =>
|
||||
await useAxios.post<Category>('/admin/categories', payload)
|
||||
|
||||
export const updateCategory = async (id: number, payload: Partial<CategoryInput>) =>
|
||||
await useAxios.put<Category>(`/admin/categories/${id}`, payload)
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
|
||||
export interface CopperConvertRequestRow {
|
||||
id: number
|
||||
status: 'pending' | 'approved' | 'rejected' | string
|
||||
source: string
|
||||
customer_name: string
|
||||
customer_mobile: string
|
||||
asset_unit: string
|
||||
consumed_amount: number
|
||||
leftover_amount: number
|
||||
source_unit_price: number
|
||||
wire15_rings: number
|
||||
wire15_unit_price: number
|
||||
wire25_rings: number
|
||||
wire25_unit_price: number
|
||||
created_at?: string
|
||||
}
|
||||
|
||||
export const getCopperConvertRequests = () =>
|
||||
useAxios.get<CopperConvertRequestRow[]>('/admin/copper-convert-request')
|
||||
|
||||
export const approveCopperConvertRequest = (id: number) =>
|
||||
useAxios.post(`/admin/copper-convert-request/${id}/approve`)
|
||||
|
||||
export const rejectCopperConvertRequest = (id: number) =>
|
||||
useAxios.post(`/admin/copper-convert-request/${id}/reject`)
|
||||
@@ -7,8 +7,33 @@ import type {Giftcard, GiftcardInput} from "@/model/giftCard";
|
||||
export const getGiftCardTable = async (params: TableInput) =>
|
||||
await useAxios.post<Array<Giftcard>>('/admin/giftcard/table', params)
|
||||
|
||||
export interface GiftCardCodesUsageSummary {
|
||||
total_codes: number
|
||||
used_codes: number
|
||||
unused_codes: number
|
||||
active_codes: number
|
||||
expired_codes: number
|
||||
}
|
||||
|
||||
export type GiftCardCodesUsageReportResponse = {
|
||||
rows: Record<string, unknown>[]
|
||||
summary?: GiftCardCodesUsageSummary
|
||||
query?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export const getGiftCardCodesUsageReport = async (params: TableInput) =>
|
||||
await useAxios.post<GiftCardCodesUsageReportResponse>(
|
||||
'/admin/giftcard/codes-usage-report',
|
||||
params,
|
||||
)
|
||||
|
||||
export const createGiftCard = async (obj: GiftcardInput) =>
|
||||
await useAxios.post<Giftcard>(`/admin/giftcard/generate`, obj)
|
||||
|
||||
export const updateGiftCard = async (id: number, obj: GiftcardInput) =>
|
||||
await useAxios.put<Giftcard>(`/admin/giftcard/${id}`, obj)
|
||||
|
||||
export const deleteGiftCard = async (id: number) => await useAxios.delete(`/admin/giftcard/${id}`)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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) =>
|
||||
await useAxios.post<boolean>('/admin/wallet/withdraw/complete', params)
|
||||
|
||||
export const approveDeposit = async (params: { id: number; tracked_number?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/approve', params)
|
||||
|
||||
export const rejectDeposit = async (params: { id: number; reject_reason?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/reject', params)
|
||||
|
||||
export const updateSts = async (id: number, sts: Object) => {
|
||||
return await useAxios.put(`/admin/wallet/withdraw/${id}`, sts)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import { defineProps } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
interface Prop {
|
||||
menu: RouteRecordRaw[]
|
||||
@@ -30,7 +31,7 @@ interface Prop {
|
||||
const router = useRouter()
|
||||
|
||||
function handleClickMenu(item: RouteRecordRaw) {
|
||||
//debugger
|
||||
if (!confirmMenuAccess(item.name)) return
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<AMenu
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:selectedKeys="selectedKeys"
|
||||
:style="{ width: props.width }"
|
||||
:mode="props.mode"
|
||||
:theme="resolvedTheme"
|
||||
@@ -49,10 +49,13 @@ const props = withDefaults(defineProps<Prop>(), {
|
||||
})
|
||||
|
||||
const resolvedTheme = computed(() => props.theme ?? menuTheme.value)
|
||||
onMounted(() => {
|
||||
selectedKeys.value = [router.currentRoute.value.name as string]
|
||||
//emits('onChange', '1')
|
||||
})
|
||||
watch(
|
||||
() => router.currentRoute.value.name,
|
||||
(name) => {
|
||||
selectedKeys.value = name ? [String(name)] : []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -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>
|
||||
@@ -319,7 +319,7 @@ function formatCard(card: WalletInventoryCard) {
|
||||
if (card.display_type === 'count') {
|
||||
return `${qty.toLocaleString('fa-IR')} ${card.unit || 'عدد'}`
|
||||
}
|
||||
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'گرم'}`
|
||||
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'کیلوگرم'}`
|
||||
}
|
||||
|
||||
function formatMetalGroupTotal(metalId: number, metalCards: WalletInventoryCard[], metal?: WalletMetalTotal) {
|
||||
|
||||
@@ -35,6 +35,10 @@ function applyLoadedData(data: AppBannersValue) {
|
||||
...slide,
|
||||
icon: toAbsoluteFileUrl(slide.icon) ?? slide.icon,
|
||||
}))
|
||||
next.assetsBanner = (next.assetsBanner ?? []).map((banner) => ({
|
||||
...banner,
|
||||
icon: toAbsoluteFileUrl(banner.icon) ?? banner.icon,
|
||||
}))
|
||||
Object.assign(state, next)
|
||||
}
|
||||
|
||||
@@ -57,6 +61,7 @@ function httpsSlider(slides: IBenefits[]): IBenefits[] {
|
||||
function snapshotForSave(): AppBannersValue {
|
||||
return {
|
||||
slider: httpsSlider([...state.slider]),
|
||||
assetsBanner: httpsSlider([...(state.assetsBanner ?? [])]),
|
||||
homeAsset: httpsPair(state.homeAsset),
|
||||
piggyCreate: httpsPair(state.piggyCreate),
|
||||
productsHero: (state.productsHero ?? []).map(httpsPair),
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
</template>
|
||||
</AInput>
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-1">
|
||||
<a-tooltip title="تازهسازی">
|
||||
<BaseButton
|
||||
type="text"
|
||||
class="text-gray-500"
|
||||
@@ -34,6 +35,7 @@
|
||||
@click="reload"
|
||||
>
|
||||
</BaseButton>
|
||||
</a-tooltip>
|
||||
<ABadge :count="activeFilterCount" class="bg-primary">
|
||||
<BaseButton
|
||||
type="text"
|
||||
@@ -47,33 +49,34 @@
|
||||
فیلتر
|
||||
</BaseButton>
|
||||
</ABadge>
|
||||
<a-tooltip title="خروجی اکسل">
|
||||
<BaseButton
|
||||
v-if="showExportExcel"
|
||||
type="text"
|
||||
class="text-gray-500"
|
||||
class="text-gray-500 hover:text-emerald-600"
|
||||
suffixIcon
|
||||
size="small"
|
||||
icon="vuesax-linear:setting-2"
|
||||
icon="vuesax-linear:document-download"
|
||||
iconSize="17"
|
||||
:loading="exportExcelLoading"
|
||||
@click="handleExportExcel"
|
||||
>
|
||||
</BaseButton>
|
||||
</a-tooltip>
|
||||
<a-tooltip title="خروجی PDF / چاپ">
|
||||
<BaseButton
|
||||
v-if="showExportPdf"
|
||||
type="text"
|
||||
class="text-gray-500"
|
||||
class="text-gray-500 hover:text-red-500"
|
||||
suffixIcon
|
||||
size="small"
|
||||
icon="vuesax-linear:printer"
|
||||
iconSize="17"
|
||||
:loading="exportPdfLoading"
|
||||
@click="handleExportPdf"
|
||||
>
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
type="text"
|
||||
class="text-gray-500"
|
||||
suffixIcon
|
||||
size="small"
|
||||
icon="vuesax-linear:direct-inbox"
|
||||
iconSize="17"
|
||||
>
|
||||
</BaseButton>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="$slots.extraHeader" class="w-full min-w-0 shrink-0 xl:w-auto xl:max-w-[55%]">
|
||||
@@ -278,8 +281,10 @@ import type {
|
||||
TableInput,
|
||||
TableOutput
|
||||
} from '@core/type/baseTable'
|
||||
import { Input, Select } from 'ant-design-vue'
|
||||
import { Input, Select, message } from 'ant-design-vue'
|
||||
import BaseDatePicker from '@core/components/BaseDatePicker'
|
||||
import { toJalali, toJalaliNoTime } from '@core/utils/useDataTime'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { cloneDeep, get, isArray, omit } from 'lodash'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
//import { filterOperatorList } from '../hooks/filterOperator'
|
||||
@@ -295,6 +300,7 @@ import {
|
||||
const DEFAULT_ACTION_WIDTH = 280
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
bordered?: boolean
|
||||
driver?: 'laravel-sql' | 'mongodb'
|
||||
mode?: 'simple' | 'pro'
|
||||
@@ -305,11 +311,14 @@ interface Props {
|
||||
pageSize?: number[]
|
||||
showPaginate?: boolean
|
||||
showOptionHeader?: boolean
|
||||
showExportExcel?: boolean
|
||||
showExportPdf?: boolean
|
||||
rowSelection?: any
|
||||
selectionKey?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
title: '',
|
||||
bordered: false,
|
||||
driver: 'laravel-sql',
|
||||
mode: 'pro',
|
||||
@@ -319,6 +328,8 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
defaultPageLimit: 10,
|
||||
showPaginate: true,
|
||||
showOptionHeader: true,
|
||||
showExportExcel: true,
|
||||
showExportPdf: true,
|
||||
selectionKey: 'id'
|
||||
})
|
||||
|
||||
@@ -335,7 +346,7 @@ const loading = ref<boolean>(false)
|
||||
const tableReady = ref(false)
|
||||
let callApiPromise: Promise<void> | null = null
|
||||
const _props = computed(() => {
|
||||
return omit(props, ['columns', 'pagination', 'dataSource', 'scroll'])
|
||||
return omit(props, ['columns', 'pagination', 'dataSource', 'scroll', 'title', 'showExportExcel', 'showExportPdf'])
|
||||
})
|
||||
|
||||
const tableScroll = computed(() => ({
|
||||
@@ -357,6 +368,8 @@ function isActionColumn(column: BaseTableColumn) {
|
||||
}
|
||||
const emit = defineEmits<{
|
||||
(e: 'register', data: BaseTableEmit): void
|
||||
(e: 'exportExcel', data: { rows: any[]; columns: BaseTableColumn[]; tableInput: TableInput }): void
|
||||
(e: 'exportPdf', data: { rows: any[]; columns: BaseTableColumn[]; tableInput: TableInput }): void
|
||||
}>()
|
||||
|
||||
const mapComponent = {
|
||||
@@ -377,8 +390,9 @@ const indicator = h(LoadingOutlined, {
|
||||
})
|
||||
|
||||
function getComponentProps(columnDataIndex: string) {
|
||||
const column = _columns.value.find((column) => {
|
||||
return column.dataIndex == columnDataIndex || column.filterField == columnDataIndex
|
||||
const column = findColumn(columnDataIndex) || _columns.value.find((c) => {
|
||||
const raw = Array.isArray(c.dataIndex) ? c.dataIndex.join('.') : String(c.dataIndex ?? '')
|
||||
return raw === columnDataIndex || c.filterField === columnDataIndex
|
||||
})
|
||||
if (column && column.filterComponentProps) return column.filterComponentProps
|
||||
return {}
|
||||
@@ -396,7 +410,9 @@ function toggleOrder() {
|
||||
function findColumn(columnDataIndex: string): BaseTableColumn | undefined {
|
||||
const cols = get(props, 'columns', [])
|
||||
return cols.find((column) => {
|
||||
return column.dataIndex == columnDataIndex || column.filterField == columnDataIndex
|
||||
const raw = column.filterField ?? column.dataIndex
|
||||
const rawStr = Array.isArray(raw) ? raw.join('.') : String(raw ?? '')
|
||||
return rawStr === columnDataIndex || column.dataIndex === columnDataIndex || column.filterField === columnDataIndex
|
||||
})
|
||||
}
|
||||
|
||||
@@ -420,25 +436,19 @@ function getComponentFilter(columnDataIndex: string) {
|
||||
//column: Partial<BaseTableColumn>, filter: Filter
|
||||
function handleChangeFilterColumn(columnDataIndex: string, index: number) {
|
||||
// console.log(filters.value[index])
|
||||
filters.value[index].value = ''
|
||||
const column = findColumn(columnDataIndex)
|
||||
//console.log('col', column)
|
||||
filters.value[index].value = column?.type === 'Select' ? undefined : ''
|
||||
if (column) {
|
||||
//console.log()
|
||||
filters.value[index].type = mapColumnTypeFilterToFilterType[column?.type ?? 'Text']
|
||||
filters.value[index].op = get(availableFilterType[column?.type ?? 'Text'], '[0]', null)
|
||||
//filter.type = mapColumnTypeFilterToFilterType[column?.type ?? 'Text']
|
||||
}
|
||||
//console.log('aaa', a, b, c)
|
||||
//return
|
||||
//filter.type = mapColumnTypeFilterToFilterType[column?.type ?? 'Text']
|
||||
//console.log('ffff', filter.type, column)
|
||||
//console.log(a, b, c, d)
|
||||
}
|
||||
|
||||
async function applyFilter() {
|
||||
filters.value = filters.value.filter((item) => {
|
||||
return item.field != ''
|
||||
if (!item.field) return false
|
||||
if (item.op === 'null' || item.op === 'nn') return true
|
||||
return item.value !== '' && item.value !== undefined && item.value !== null
|
||||
})
|
||||
tableInput.value.filters = cloneDeep(filters.value)
|
||||
pageReset()
|
||||
@@ -668,16 +678,424 @@ async function callApi() {
|
||||
return callApiPromise
|
||||
}
|
||||
|
||||
const exportExcelLoading = ref(false)
|
||||
const exportPdfLoading = ref(false)
|
||||
const route = useRoute()
|
||||
|
||||
const exportTitle = computed(() => {
|
||||
return (
|
||||
props.title ||
|
||||
(route?.meta?.title as string) ||
|
||||
document.title ||
|
||||
'گزارش جدول'
|
||||
)
|
||||
})
|
||||
|
||||
const exportColumns = computed(() => {
|
||||
return _columns.value.filter((column) => {
|
||||
if (isActionColumn(column)) return false
|
||||
const key = String(column.key ?? '')
|
||||
const dataIndex = Array.isArray(column.dataIndex)
|
||||
? column.dataIndex.join('.')
|
||||
: String(column.dataIndex ?? '')
|
||||
if (key === 'action' || key === 'row_action' || dataIndex === 'action') return false
|
||||
if (key === 'receipt_url' || dataIndex === 'receipt_url' || column.slot === 'receipt') return false
|
||||
if (!column.title || String(column.title).trim() === '') return false
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
function extractTextFromVNode(node: any): string {
|
||||
if (node == null || node === false) return ''
|
||||
if (typeof node === 'string' || typeof node === 'number') {
|
||||
return String(node).trim()
|
||||
}
|
||||
if (Array.isArray(node)) {
|
||||
return node
|
||||
.map(extractTextFromVNode)
|
||||
.filter((s) => s.length > 0)
|
||||
.join(' ')
|
||||
.trim()
|
||||
}
|
||||
if (typeof node === 'object') {
|
||||
if ('children' in node && !('__v_isVNode' in node)) {
|
||||
return extractTextFromVNode(node.children)
|
||||
}
|
||||
if (node.children) {
|
||||
if (typeof node.children === 'string' || typeof node.children === 'number') {
|
||||
return String(node.children).trim()
|
||||
}
|
||||
if (Array.isArray(node.children)) {
|
||||
return node.children
|
||||
.map(extractTextFromVNode)
|
||||
.filter((s) => s.length > 0)
|
||||
.join(' ')
|
||||
.trim()
|
||||
}
|
||||
if (typeof node.children === 'object' && typeof node.children.default === 'function') {
|
||||
try {
|
||||
return extractTextFromVNode(node.children.default())
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node.props) {
|
||||
if (typeof node.props.label === 'string') return node.props.label.trim()
|
||||
if (typeof node.props.title === 'string') return node.props.title.trim()
|
||||
if (typeof node.props.value === 'string' || typeof node.props.value === 'number') {
|
||||
return String(node.props.value).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function getRawRecordValue(record: any, dataIndex: any): any {
|
||||
if (!record || dataIndex == null) return ''
|
||||
let val: any
|
||||
if (Array.isArray(dataIndex)) {
|
||||
val = get(record, dataIndex.join('.'))
|
||||
if (val === undefined) {
|
||||
val = get(record, dataIndex)
|
||||
}
|
||||
} else if (typeof dataIndex === 'string') {
|
||||
val = get(record, dataIndex)
|
||||
}
|
||||
if (val == null) return ''
|
||||
if (typeof val === 'boolean') return val ? 'بله' : 'خیر'
|
||||
if (typeof val === 'object') {
|
||||
return val.name || val.title || val.label || ''
|
||||
}
|
||||
return String(val)
|
||||
}
|
||||
|
||||
function extractCellValue(record: any, column: BaseTableColumn, rowIndex: number): string {
|
||||
const rawVal = getRawRecordValue(record, column.dataIndex)
|
||||
|
||||
if (typeof column.customRender === 'function') {
|
||||
try {
|
||||
const renderRes = column.customRender({
|
||||
text: rawVal,
|
||||
value: rawVal,
|
||||
record,
|
||||
index: rowIndex,
|
||||
renderIndex: rowIndex,
|
||||
column
|
||||
} as any)
|
||||
|
||||
if (renderRes != null && renderRes !== false) {
|
||||
if (typeof renderRes === 'string' || typeof renderRes === 'number') {
|
||||
const s = String(renderRes).trim()
|
||||
if (s) return s
|
||||
}
|
||||
const extracted = extractTextFromVNode(renderRes)
|
||||
if (extracted) return extracted
|
||||
}
|
||||
} catch {
|
||||
// fallback
|
||||
}
|
||||
}
|
||||
|
||||
const colKey = String(column.key ?? '')
|
||||
const colTitle = String(column.title ?? '')
|
||||
if (colKey === 'id' && colTitle === 'ردیف') {
|
||||
return String(rowIndex + 1)
|
||||
}
|
||||
if (colKey === 'sts' && record?.sts_str) {
|
||||
return String(record.sts_str)
|
||||
}
|
||||
if (colKey === 'created_at' && record?.created_at) {
|
||||
try {
|
||||
return toJalali(record.created_at)
|
||||
} catch {
|
||||
return String(record.created_at)
|
||||
}
|
||||
}
|
||||
|
||||
return rawVal !== '' ? String(rawVal).trim() : '-'
|
||||
}
|
||||
|
||||
async function getAllExportRows(): Promise<any[]> {
|
||||
const api = get(_props.value, 'api', null)
|
||||
const total = totalRecord.value
|
||||
if (typeof api === 'function' && total > data.value.length) {
|
||||
try {
|
||||
const exportInput: TableInput = cloneDeep(tableInput.value)
|
||||
exportInput.page = 1
|
||||
exportInput.limit = Math.min(total, 50000)
|
||||
const res = await api(exportInput)
|
||||
if (res && Array.isArray(res.rows) && res.rows.length > 0) {
|
||||
return res.rows
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Could not fetch all records for export, fallback to loaded data', err)
|
||||
}
|
||||
}
|
||||
return data.value
|
||||
}
|
||||
|
||||
function csvCell(value: unknown): string {
|
||||
if (value == null) return '""'
|
||||
const s = String(value).replace(/"/g, '""')
|
||||
return `"${s}"`
|
||||
}
|
||||
|
||||
function downloadBlob(content: string, filename: string, mime: string) {
|
||||
const blob = new Blob([content], { type: mime })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = filename
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
function buildExportFileName(): string {
|
||||
const title = (exportTitle.value || 'گزارش-جدول').replace(/[\s\/\\:?*"<>|]+/g, '_')
|
||||
let date = ''
|
||||
try {
|
||||
date = toJalaliNoTime(new Date().toISOString(), 'jYYYY-jMM-jDD')
|
||||
} catch {
|
||||
date = new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
return `${title}_${date}`
|
||||
}
|
||||
|
||||
function escapeHtml(text: unknown): string {
|
||||
if (text == null) return ''
|
||||
return String(text)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
function exportToPdf(title: string, cols: BaseTableColumn[], rows: any[]) {
|
||||
const tableHeaders = cols.map((c) => `<th>${escapeHtml(c.title || '')}</th>`).join('')
|
||||
const tableRows = rows
|
||||
.map((row, rIdx) => {
|
||||
const cells = cols
|
||||
.map((col) => `<td>${escapeHtml(extractCellValue(row, col, rIdx))}</td>`)
|
||||
.join('')
|
||||
return `<tr>${cells}</tr>`
|
||||
})
|
||||
.join('')
|
||||
|
||||
let dateStr = ''
|
||||
try {
|
||||
dateStr = toJalali(new Date().toISOString(), 'jYYYY/jMM/jDD HH:mm')
|
||||
} catch {
|
||||
dateStr = new Date().toLocaleString('fa-IR')
|
||||
}
|
||||
const countStr = rows.length.toLocaleString('fa-IR')
|
||||
|
||||
const searchInfo = searchText.value
|
||||
? `<div class="filter-tag">جستجو: ${escapeHtml(searchText.value)}</div>`
|
||||
: ''
|
||||
|
||||
const html = `<!DOCTYPE html>
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>${escapeHtml(title)}</title>
|
||||
<style>
|
||||
@media print {
|
||||
@page {
|
||||
size: A4 landscape;
|
||||
margin: 10mm 8mm;
|
||||
}
|
||||
body {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
}
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
font-family: IRANSansWeb, Tahoma, 'B Nazanin', Arial, sans-serif;
|
||||
direction: rtl;
|
||||
margin: 16px;
|
||||
color: #111827;
|
||||
background: #ffffff;
|
||||
font-size: 11px;
|
||||
}
|
||||
.report-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-bottom: 2px solid #374151;
|
||||
padding-bottom: 10px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.report-title {
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #111827;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
.report-meta {
|
||||
font-size: 11px;
|
||||
color: #4b5563;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.filter-tag {
|
||||
display: inline-block;
|
||||
background: #f3f4f6;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 4px;
|
||||
padding: 2px 8px;
|
||||
font-size: 10px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: auto;
|
||||
margin-top: 8px;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #d1d5db;
|
||||
padding: 6px 8px;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
word-break: break-word;
|
||||
}
|
||||
th {
|
||||
background-color: #f3f4f6;
|
||||
font-weight: 700;
|
||||
color: #1f2937;
|
||||
font-size: 11px;
|
||||
}
|
||||
tbody tr:nth-child(even) {
|
||||
background-color: #f9fafb;
|
||||
}
|
||||
tbody tr:hover {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="report-header">
|
||||
<div>
|
||||
<h1 class="report-title">${escapeHtml(title)}</h1>
|
||||
<div class="report-meta">تعداد کل رکوردها: ${countStr} مورد</div>
|
||||
${searchInfo}
|
||||
</div>
|
||||
<div class="report-meta" style="text-align: left;">
|
||||
<div>تاریخ چاپ: ${dateStr}</div>
|
||||
<div>سیستم جامع مدیریت</div>
|
||||
</div>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>${tableHeaders}</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${tableRows}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
const printWindow = window.open('', '_blank')
|
||||
if (!printWindow) {
|
||||
message.warning('پاپآپ توسط مرورگر مسدود شد. لطفاً به مرورگر اجازه باز کردن پنجره را بدهید.')
|
||||
return
|
||||
}
|
||||
printWindow.document.open()
|
||||
printWindow.document.write(html)
|
||||
printWindow.document.close()
|
||||
printWindow.focus()
|
||||
setTimeout(() => {
|
||||
printWindow.print()
|
||||
}, 400)
|
||||
}
|
||||
|
||||
async function handleExportExcel() {
|
||||
try {
|
||||
exportExcelLoading.value = true
|
||||
const cols = exportColumns.value
|
||||
if (cols.length === 0) {
|
||||
message.warning('ستونی برای خروجی یافت نشد')
|
||||
return
|
||||
}
|
||||
|
||||
const rows = await getAllExportRows()
|
||||
if (!rows || rows.length === 0) {
|
||||
message.warning('رکوردی برای خروجی وجود ندارد')
|
||||
return
|
||||
}
|
||||
|
||||
emit('exportExcel', { rows, columns: cols, tableInput: cloneDeep(tableInput.value) })
|
||||
|
||||
const headers = cols.map((c) => csvCell(c.title || ''))
|
||||
const lines = [
|
||||
headers.join(','),
|
||||
...rows.map((row, rIdx) => {
|
||||
return cols.map((col) => csvCell(extractCellValue(row, col, rIdx))).join(',')
|
||||
})
|
||||
]
|
||||
const content = `\uFEFF${lines.join('\r\n')}`
|
||||
const fileName = `${buildExportFileName()}.csv`
|
||||
downloadBlob(content, fileName, 'text/csv;charset=utf-8')
|
||||
message.success('خروجی اکسل با موفقیت ایجاد شد')
|
||||
} catch (err) {
|
||||
console.error('Error exporting table to excel:', err)
|
||||
message.error('خطا در تهیه خروجی اکسل')
|
||||
} finally {
|
||||
exportExcelLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExportPdf() {
|
||||
try {
|
||||
exportPdfLoading.value = true
|
||||
const cols = exportColumns.value
|
||||
if (cols.length === 0) {
|
||||
message.warning('ستونی برای چاپ یافت نشد')
|
||||
return
|
||||
}
|
||||
|
||||
const rows = await getAllExportRows()
|
||||
if (!rows || rows.length === 0) {
|
||||
message.warning('رکوردی برای چاپ وجود ندارد')
|
||||
return
|
||||
}
|
||||
|
||||
emit('exportPdf', { rows, columns: cols, tableInput: cloneDeep(tableInput.value) })
|
||||
|
||||
exportToPdf(exportTitle.value, cols, rows)
|
||||
} catch (err) {
|
||||
console.error('Error exporting table to pdf:', err)
|
||||
message.error('خطا در تهیه خروجی PDF')
|
||||
} finally {
|
||||
exportPdfLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
tableReady.value = false
|
||||
await callApi()
|
||||
emit('register', { reload })
|
||||
emit('register', {
|
||||
reload,
|
||||
exportExcel: handleExportExcel,
|
||||
exportPdf: handleExportPdf
|
||||
})
|
||||
await nextTick()
|
||||
tableReady.value = true
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
loading
|
||||
loading,
|
||||
reload,
|
||||
exportExcel: handleExportExcel,
|
||||
exportPdf: handleExportPdf,
|
||||
getAllExportRows
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<script setup lang="ts">
|
||||
import { menuIconSize } from '@root/config'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
const router = useRouter()
|
||||
interface Props {
|
||||
@@ -25,6 +26,7 @@ interface Props {
|
||||
const props = withDefaults(defineProps<Props>(), {})
|
||||
|
||||
async function handleClickMenuItem(item: RouteRecordRaw) {
|
||||
if (!confirmMenuAccess(item.name)) return
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<AMenu
|
||||
:mode="layoutStore.sideMenu.mode"
|
||||
:theme="menuTheme"
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:selectedKeys="selectedKeys"
|
||||
>
|
||||
<template v-for="item in menu">
|
||||
<BasicSubMenu
|
||||
@@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { ComputedRef } from 'vue'
|
||||
import { sortBy } from 'lodash'
|
||||
import { usePrefix } from '@core/composable/usePrefix'
|
||||
@@ -45,9 +45,9 @@ const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
||||
const routerStore = useRouterStore()
|
||||
const { menuTheme } = useAdminTheme()
|
||||
|
||||
function syncSelectedKeys() {
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
function walkInRoutes(routes: RouteRecordRaw[]): boolean {
|
||||
for (const route of routes) {
|
||||
if (route.name == currentRoute.name) {
|
||||
path.push(route.name)
|
||||
@@ -56,18 +56,17 @@ function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
if (route.children && route.children.length > 0) {
|
||||
path.push(route.name)
|
||||
const res = walkInRoutes(route.children)
|
||||
if (!res) {
|
||||
path.pop()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
if (!res) path.pop()
|
||||
else return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
walkInRoutes(routerStore.routes)
|
||||
selectedKeys.value = path
|
||||
}
|
||||
|
||||
watch(() => currentRoute.name, syncSelectedKeys, { immediate: true })
|
||||
|
||||
function isSupportMenuRoute(item: RouteRecordRaw): boolean {
|
||||
return item.name === 'support' || item.meta?.permissionsKey === 'support'
|
||||
|
||||
@@ -100,6 +100,8 @@ interface TableOutput<T> {
|
||||
|
||||
interface BaseTableEmit {
|
||||
reload: () => void
|
||||
exportExcel?: () => Promise<void>
|
||||
exportPdf?: () => Promise<void>
|
||||
}
|
||||
|
||||
export type {
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
showServerUnavailableOverlay,
|
||||
} from '@/utils/serverUnavailable'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { mutationBlockMessage } from '@/utils/adminPageAccess'
|
||||
import { readAdminAccessState } from '@/utils/adminAccessState'
|
||||
//import { isToken } from '@/utils/is'
|
||||
//import router from '@/router'
|
||||
//import { getToken, removeToken } from '@/utils/useUtility'
|
||||
@@ -58,6 +60,18 @@ _axios.interceptors.request.use(
|
||||
//@ts-ignore
|
||||
config.headers['Authorization'] = 'Bearer ' + token
|
||||
}
|
||||
const routeName = readAdminAccessState().routeName
|
||||
if (routeName) {
|
||||
//@ts-ignore
|
||||
config.headers['X-Admin-Page'] = routeName
|
||||
}
|
||||
}
|
||||
const blocked = mutationBlockMessage(String(config.method || 'get'), config.url)
|
||||
if (blocked) {
|
||||
message.warning({ content: blocked, key: 'admin-page-denied' })
|
||||
const error = new Error(blocked) as Error & { pageAccessDenied?: boolean }
|
||||
error.pageAccessDenied = true
|
||||
return Promise.reject(error)
|
||||
}
|
||||
return config
|
||||
},
|
||||
@@ -77,6 +91,15 @@ _axios.interceptors.response.use(
|
||||
return response.data
|
||||
},
|
||||
async function (error) {
|
||||
const deniedText = String(error?.message || '')
|
||||
if (
|
||||
error?.pageAccessDenied ||
|
||||
deniedText === 'شما به این صفحه دسترسی ندارید' ||
|
||||
deniedText === 'شما مجوز ویرایش در این صفحه را ندارید' ||
|
||||
deniedText === 'شما مجوز حذف در این صفحه را ندارید'
|
||||
) {
|
||||
return Promise.reject(error)
|
||||
}
|
||||
const router = useRouter()
|
||||
//console.log('this is axios error', error)
|
||||
/* if (error.response.data && error.response.data.code) {
|
||||
@@ -109,7 +132,12 @@ _axios.interceptors.response.use(
|
||||
await router.push({ name: 'login' })
|
||||
} else if (error.response && error.response.status == 403) {
|
||||
if (!error.config?.meta?.silent) {
|
||||
message.error('شما دسترسی لازم برای انجام این عملیات را ندارید (403)')
|
||||
const apiMessage = error.response.data?.message
|
||||
message.error(
|
||||
typeof apiMessage === 'string' && apiMessage.trim()
|
||||
? apiMessage
|
||||
: 'شما دسترسی لازم برای انجام این عملیات را ندارید'
|
||||
)
|
||||
}
|
||||
} else if (error.response && error.response.status == 422) {
|
||||
if (!error.config?.meta?.silent) {
|
||||
|
||||
+29
-1
@@ -14,6 +14,14 @@ import { setupRoutes } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { setupPinia } from '@core/plugins/pinia'
|
||||
import { initStoreModeFromSettings } from '@/utils/config'
|
||||
import { message } from 'ant-design-vue'
|
||||
import {
|
||||
canOpenRoute,
|
||||
firstAllowedInBranch,
|
||||
firstAllowedRouteName,
|
||||
notifyPageDenied
|
||||
} from '@/utils/adminPageAccess'
|
||||
import { setCurrentAdminRoute } from '@/utils/adminAccessState'
|
||||
|
||||
const init = async () => {
|
||||
const app = createApp(App)
|
||||
@@ -57,9 +65,29 @@ const init = async () => {
|
||||
const token = getToken()
|
||||
if (token) {
|
||||
if (to.name == 'login') {
|
||||
return next({ name: 'dashboard' })
|
||||
return next({ name: firstAllowedRouteName() || 'dashboardMain' })
|
||||
}
|
||||
if (canOpenRoute(to.name)) {
|
||||
setCurrentAdminRoute(String(to.name || ''))
|
||||
return next()
|
||||
}
|
||||
const redirectedFrom = to.redirectedFrom?.name
|
||||
if (redirectedFrom) {
|
||||
const branchTarget = firstAllowedInBranch(String(redirectedFrom))
|
||||
if (branchTarget && branchTarget !== String(to.name)) {
|
||||
return next({ name: branchTarget })
|
||||
}
|
||||
}
|
||||
if (from.name && String(from.name) !== 'login') {
|
||||
notifyPageDenied()
|
||||
return next(false)
|
||||
}
|
||||
const first = firstAllowedRouteName()
|
||||
if (first && first !== String(to.name)) {
|
||||
return next({ name: first })
|
||||
}
|
||||
message.warning({ content: 'شما به این صفحه دسترسی ندارید', key: 'admin-page-denied' })
|
||||
return next(false)
|
||||
} else {
|
||||
if (['login', '404'].includes(to.name as string)) {
|
||||
return next()
|
||||
|
||||
@@ -41,4 +41,15 @@ export interface TotalAccounting {
|
||||
withdraw?: Withdraw
|
||||
customer?: AccountingCustomerRef
|
||||
customer_to?: AccountingCustomerRef
|
||||
order?: {
|
||||
id?: number
|
||||
direction?: number
|
||||
product_id?: number | null
|
||||
product?: {
|
||||
id?: number
|
||||
title?: string
|
||||
[key: string]: any
|
||||
} | null
|
||||
[key: string]: any
|
||||
} | null
|
||||
}
|
||||
@@ -26,6 +26,7 @@ export interface ThemeImagePair {
|
||||
|
||||
export interface AppBannersValue {
|
||||
slider: IBenefits[]
|
||||
assetsBanner: IBenefits[]
|
||||
homeAsset: ThemeImagePair
|
||||
piggyCreate: ThemeImagePair
|
||||
/** اسلایدر بنر بالای صفحهٔ محصولات — تعداد آزاد */
|
||||
@@ -47,6 +48,7 @@ export function emptyThemePair(): ThemeImagePair {
|
||||
export function emptyAppBanners(): AppBannersValue {
|
||||
return {
|
||||
slider: [],
|
||||
assetsBanner: [],
|
||||
homeAsset: emptyThemePair(),
|
||||
piggyCreate: emptyThemePair(),
|
||||
productsHero: [],
|
||||
@@ -100,6 +102,9 @@ export function mergeAppBannersFromLegacy(
|
||||
): AppBannersValue {
|
||||
return {
|
||||
slider: primary.slider.length ? primary.slider : legacy.slider,
|
||||
assetsBanner: (primary.assetsBanner ?? []).length
|
||||
? primary.assetsBanner
|
||||
: legacy.assetsBanner ?? [],
|
||||
homeAsset: mergePair(primary.homeAsset, legacy.homeAsset),
|
||||
piggyCreate: mergePair(primary.piggyCreate, legacy.piggyCreate),
|
||||
productsHero: (primary.productsHero ?? []).some(pairHasImage)
|
||||
@@ -151,6 +156,7 @@ export function parseAppBanners(value: string | Record<string, unknown> | null |
|
||||
const obj = parsed as Record<string, unknown>
|
||||
return {
|
||||
slider: parseSlider(obj.slider),
|
||||
assetsBanner: parseSlider(obj.assetsBanner),
|
||||
homeAsset: normalizePair(obj.homeAsset),
|
||||
piggyCreate: normalizePair(obj.piggyCreate),
|
||||
productsHero: normalizeProductsHero(obj),
|
||||
@@ -171,6 +177,7 @@ export function parseSettingsProfileBanners(value: string | null | undefined): S
|
||||
export function serializeAppBanners(data: AppBannersValue): string {
|
||||
return JSON.stringify({
|
||||
slider: data.slider ?? [],
|
||||
assetsBanner: data.assetsBanner ?? [],
|
||||
homeAsset: { ...data.homeAsset },
|
||||
piggyCreate: { ...data.piggyCreate },
|
||||
productsHero: (data.productsHero ?? []).map((pair) => ({ ...pair })),
|
||||
|
||||
+17
-2
@@ -1,6 +1,16 @@
|
||||
export interface GiftcardCustomer {
|
||||
id: number
|
||||
name: string
|
||||
mobile: string
|
||||
}
|
||||
|
||||
export interface Giftcard {
|
||||
id: number
|
||||
customer_id: any
|
||||
name?: string
|
||||
mobile?: string
|
||||
customer?: GiftcardCustomer
|
||||
show_in_app?: number | boolean
|
||||
count: number
|
||||
amount: number
|
||||
total: number
|
||||
@@ -35,9 +45,14 @@ export interface AssignedTo {
|
||||
mobile: string
|
||||
}
|
||||
|
||||
export type GiftCardAssignMode = 'customer' | 'public'
|
||||
|
||||
export interface GiftcardInput {
|
||||
mobile: string
|
||||
name: string
|
||||
assignMode: GiftCardAssignMode
|
||||
customer_id?: number
|
||||
show_in_app?: number
|
||||
mobile?: string
|
||||
name?: string
|
||||
count: number
|
||||
amount: number
|
||||
unit: string
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ export interface last {
|
||||
sell: number
|
||||
buy: number
|
||||
price_last: number
|
||||
/** آخرین مظنه ذخیرهشده در جدول prices — برای fallback محصول */
|
||||
/** آخرین قیمت ذخیرهشده در جدول prices — برای fallback محصول */
|
||||
last_historical?: number
|
||||
}
|
||||
@@ -15,6 +15,7 @@ export interface PriceSyncLogItem {
|
||||
export interface PriceSyncLog {
|
||||
id: number
|
||||
source: string
|
||||
source_label?: string | null
|
||||
source_url?: string | null
|
||||
liquid_gold_price: number
|
||||
products_updated: number
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Const } from '@/model/const'
|
||||
import type { PageAccessMap } from '@/utils/adminPageAccess'
|
||||
|
||||
export interface User {
|
||||
active?: boolean
|
||||
@@ -12,6 +13,7 @@ export interface User {
|
||||
lname?: string
|
||||
mobile?: number
|
||||
name?: string
|
||||
n_code?: string
|
||||
sts?: number
|
||||
token_sms?: string
|
||||
user_type?: string
|
||||
@@ -19,6 +21,8 @@ export interface User {
|
||||
settings?: Const[]
|
||||
sms_billing_enabled?: boolean
|
||||
sms_panel_access?: boolean
|
||||
/** null = دسترسی کامل */
|
||||
page_access?: PageAccessMap | null
|
||||
}
|
||||
|
||||
export interface AddId {
|
||||
|
||||
@@ -84,6 +84,10 @@ export interface Withdraw {
|
||||
date_at?: string
|
||||
sts?: number
|
||||
type?: number
|
||||
receipt?: string | null
|
||||
receipt_url?: string | null
|
||||
deposit_identifier?: string | null
|
||||
reject_reason?: string | null
|
||||
bank_account_id?: number | null
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<Item
|
||||
title="مقدار"
|
||||
:value="`${selectedItem?.amount ?? '-'} ${
|
||||
selectedItem?.product?.unit === 'گرم' ? 'گرم' : 'عدد'
|
||||
selectedItem?.product?.unit === 'عدد' ? 'عدد' : 'کیلوگرم'
|
||||
}`"
|
||||
/>
|
||||
<Item title="قیمت کل برای مشتری" :value="usePrice(selectedItem?.total_price ?? 0)" />
|
||||
@@ -37,7 +37,7 @@
|
||||
<Item title="میزان پرداخت شده" :value="usePrice(selectedItem?.payment_amount ?? 0)" />
|
||||
<Item title="میزان مبلغ باقیمانده" :value="usePrice(selectedItem?.payment_remind ?? 0)" />
|
||||
<Item
|
||||
v-if="selectedItem?.product?.unit === 'گرم'"
|
||||
v-if="selectedItem?.product?.unit === 'کیلوگرم' || selectedItem?.product?.unit === 'گرم'"
|
||||
title="قیمت هر مثقال"
|
||||
:value="usePrice(parseInt((selectedItem?.price * 4.331800000515843).toFixed(0)))"
|
||||
/>
|
||||
|
||||
@@ -47,10 +47,10 @@
|
||||
تراز ریالی (ریال)
|
||||
</div>
|
||||
<div class="bg-blue rounded text-white py-1 flex justify-center items-center">
|
||||
{{ m('تراز طلایی (گرم)') }}
|
||||
{{ m('تراز طلایی (کیلوگرم)') }}
|
||||
</div>
|
||||
<div class="bg-blue rounded text-white py-1 flex justify-center items-center">
|
||||
تراز مظنه (ریال)
|
||||
تراز قیمت (ریال)
|
||||
</div>
|
||||
<div class="bg-blue rounded text-white py-1 flex justify-center items-center">
|
||||
تراز افجو
|
||||
@@ -146,7 +146,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="min-w-[100px]">
|
||||
<label class="text-[8px] mb-0"> در مظنه : </label>
|
||||
<label class="text-[8px] mb-0"> در قیمت : </label>
|
||||
<label class="text-[12px] mb-0 text-center">
|
||||
{{ usePrice(order?.price_in_mesghal ?? 0, true, '') }}
|
||||
</label>
|
||||
|
||||
@@ -80,7 +80,7 @@ const rows = computed(() => {
|
||||
{
|
||||
key: 'sood',
|
||||
label: 'سود اختلاف قیمت',
|
||||
hint: 'فاصله مظنه و قیمت مشتری',
|
||||
hint: 'فاصله قیمت و قیمت مشتری',
|
||||
value: sood.value,
|
||||
color: '#10b981',
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<p class="montzar-simple__hint">آبشده در این بازه</p>
|
||||
<p class="montzar-simple__value montzar-simple__value--inline">
|
||||
<bdi class="montzar-simple__amount number-ltr">{{ formatGram(data.summary.local_all.buy_gold) }}</bdi>
|
||||
<span class="montzar-simple__unit">گرم</span>
|
||||
<span class="montzar-simple__unit">کیلوگرم</span>
|
||||
</p>
|
||||
</article>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<p class="montzar-simple__hint">آبشده در این بازه</p>
|
||||
<p class="montzar-simple__value montzar-simple__value--inline">
|
||||
<bdi class="montzar-simple__amount number-ltr">{{ formatGram(data.summary.local_all.sell_gold) }}</bdi>
|
||||
<span class="montzar-simple__unit">گرم</span>
|
||||
<span class="montzar-simple__unit">کیلوگرم</span>
|
||||
</p>
|
||||
</article>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</p>
|
||||
<p v-if="uncoveredGold > 0" class="montzar-simple__sub-line">
|
||||
<bdi class="number-ltr">{{ formatGram(uncoveredGold) }}</bdi>
|
||||
<span>گرم</span>
|
||||
<span>کیلوگرم</span>
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
@@ -89,14 +89,14 @@
|
||||
<p v-if="data.mandeh" class="montzar-simple__more-line">
|
||||
مانده حساب نزد همکار الان:
|
||||
<b class="number-ltr" dir="ltr">
|
||||
{{ formatGram(data.mandeh.gold_abs) }} گرم ·
|
||||
{{ formatGram(data.mandeh.gold_abs) }} کیلوگرم ·
|
||||
{{ formatDashboardAmount(data.mandeh.cash_abs) }} ریال
|
||||
</b>
|
||||
({{ data.mandeh.gold_state }} / {{ data.mandeh.rial_state }})
|
||||
</p>
|
||||
<p v-if="data.colleague_available" class="montzar-simple__more-line">
|
||||
اختلاف گرم دفتر همکار با سفارشهای ثبتشده این بازه:
|
||||
<b class="number-ltr" dir="ltr">{{ formatSignedGram(data.summary.diff_site_gold) }} گرم</b>
|
||||
اختلاف کیلوگرم دفتر همکار با سفارشهای ثبتشده این بازه:
|
||||
<b class="number-ltr" dir="ltr">{{ formatSignedGram(data.summary.diff_site_gold) }} کیلوگرم</b>
|
||||
</p>
|
||||
<div class="montzar-simple__actions mt-1">
|
||||
<a-button
|
||||
@@ -137,7 +137,7 @@
|
||||
<th>زمان</th>
|
||||
<th>خرید/فروش</th>
|
||||
<th>مشتری</th>
|
||||
<th>گرم</th>
|
||||
<th>کیلوگرم</th>
|
||||
<th>ریال</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -163,7 +163,7 @@
|
||||
<th>زمان</th>
|
||||
<th>خرید/فروش</th>
|
||||
<th>مشتری</th>
|
||||
<th>گرم</th>
|
||||
<th>کیلوگرم</th>
|
||||
<th>نزد همکار؟</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -215,11 +215,11 @@
|
||||
<b>{{ diffCodeLabel(diff.code) }}</b>
|
||||
<p class="m-0 mt-1">{{ diff.reason }}</p>
|
||||
<div v-if="diff.local" class="montzar-simple__diff-meta">
|
||||
سفارش اپ شماره {{ diff.local.id }} · {{ formatGram(diff.local.amount) }} گرم
|
||||
سفارش اپ شماره {{ diff.local.id }} · {{ formatGram(diff.local.amount) }} کیلوگرم
|
||||
</div>
|
||||
<div v-if="diff.colleague" class="montzar-simple__diff-meta">
|
||||
دفتر همکار: {{ diff.colleague.desc || '—' }} ·
|
||||
{{ formatSignedGram(diff.colleague.net_gold ?? 0) }} گرم
|
||||
{{ formatSignedGram(diff.colleague.net_gold ?? 0) }} کیلوگرم
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!(data?.diffs?.length)" class="montzar-simple__empty">مورد اختلافی نیست</div>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</p>
|
||||
<p class="dashboard-profit-split__value">
|
||||
<span class="dashboard-profit-split__amount">{{ formatGram(item.grams) }}</span>
|
||||
<span class="dashboard-profit-split__unit">{{ item.unit || 'گرم' }}</span>
|
||||
<span class="dashboard-profit-split__unit">{{ item.unit || 'کیلوگرم' }}</span>
|
||||
</p>
|
||||
<p class="dashboard-profit-split__sub">≈ {{ formatDashboardAmount(item.value_rial) }} ریال</p>
|
||||
</article>
|
||||
@@ -78,11 +78,11 @@
|
||||
</p>
|
||||
<p class="dashboard-profit-split__value">
|
||||
<span class="dashboard-profit-split__amount">{{ formatGram(profitGoldGrams) }}</span>
|
||||
<span class="dashboard-profit-split__unit">گرم</span>
|
||||
<span class="dashboard-profit-split__unit">کیلوگرم</span>
|
||||
</p>
|
||||
<p class="dashboard-profit-split__sub">≈ {{ formatDashboardAmount(profitGoldValueRial) }} ریال</p>
|
||||
<p v-if="showProfitConversion && profitGoldConvertedGram > 0" class="dashboard-profit-split__note">
|
||||
شامل {{ formatGram(profitGoldConvertedGram) }} گرم از تبدیل سود ریالی
|
||||
شامل {{ formatGram(profitGoldConvertedGram) }} کیلوگرم از تبدیل سود ریالی
|
||||
</p>
|
||||
</article>
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
</p>
|
||||
<p class="dashboard-profit-split__sub">
|
||||
<template v-if="showProfitConversion && profitRialConverted > 0">
|
||||
{{ formatGram(profitGoldConvertedGram) }} گرم تبدیلشده به طلا
|
||||
{{ formatGram(profitGoldConvertedGram) }} کیلوگرم تبدیلشده به طلا
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ dailyRows.length }} روز دارای معامله
|
||||
@@ -123,7 +123,7 @@
|
||||
سود {{ col.title }}
|
||||
</th>
|
||||
<th v-if="!quantityProductColumns.length" class="px-2 py-2 text-right">
|
||||
{{ metalProfitLabel }} (گرم)
|
||||
{{ metalProfitLabel }} (کیلوگرم)
|
||||
</th>
|
||||
<th class="px-2 py-2 text-right">سود ریالی (ریال)</th>
|
||||
<th class="px-2 py-2 text-right">سود اختلاف قیمت (ریال)</th>
|
||||
@@ -185,7 +185,7 @@
|
||||
<span class="text-sm font-bold dashboard-text">سندهای تبدیل سود ریالی به طلا</span>
|
||||
<span v-if="conversions.length" class="dashboard-text-muted text-xs">
|
||||
جمع تبدیلشده در بازه: {{ formatDashboardAmount(conversionsTotalRial) }} ریال →
|
||||
{{ formatGram(conversionsTotalGram) }} گرم
|
||||
{{ formatGram(conversionsTotalGram) }} کیلوگرم
|
||||
</span>
|
||||
</div>
|
||||
<a-spin :spinning="conversionsLoading">
|
||||
@@ -203,8 +203,8 @@
|
||||
<div class="flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm">
|
||||
<span class="font-bold dashboard-text">{{ formatDashboardAmount(item.rial_amount) }} ریال</span>
|
||||
<span class="dashboard-text-muted">←</span>
|
||||
<span class="font-bold dashboard-profit">{{ formatGram(item.gram_amount) }} گرم</span>
|
||||
<span class="dashboard-text-muted text-xs">(مظنه {{ formatDashboardAmount(item.unit_price) }})</span>
|
||||
<span class="font-bold dashboard-profit">{{ formatGram(item.gram_amount) }} کیلوگرم</span>
|
||||
<span class="dashboard-text-muted text-xs">(قیمت {{ formatDashboardAmount(item.unit_price) }})</span>
|
||||
</div>
|
||||
<div class="dashboard-text-muted mt-0.5 text-[11px]">
|
||||
{{ jalaliDate(item.converted_at) }}
|
||||
@@ -259,7 +259,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="dashboard-profit-split__field">
|
||||
<label>قیمت هر گرم (مظنه)</label>
|
||||
<label>قیمت هر کیلوگرم</label>
|
||||
<a-input-number
|
||||
v-model:value="form.unit_price"
|
||||
:min="0"
|
||||
@@ -271,7 +271,7 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="dashboard-profit-split__field">
|
||||
<label>وزن معادل (گرم)</label>
|
||||
<label>وزن معادل (کیلوگرم)</label>
|
||||
<a-input-number
|
||||
v-model:value="form.gram_amount"
|
||||
:min="0"
|
||||
@@ -293,7 +293,7 @@
|
||||
<a-textarea
|
||||
v-model:value="form.description"
|
||||
:rows="2"
|
||||
placeholder="مثلاً: از فلانجا ۲ گرم طلا خریده شد"
|
||||
placeholder="مثلاً: از فلانجا ۲ کیلوگرم مس خریده شد"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -364,8 +364,8 @@ const sectionHelp: DashboardHelp = {
|
||||
'سود هر محصول مقداری = جمع کارمزدِ کسرشده از کیف همان محصول | سود ریالی = جمع کارمزدِ کسرشده از ریال',
|
||||
}
|
||||
const goldHelp: DashboardHelp = {
|
||||
description: m('مجموع کارمزدهای کسرشده از طلا بهعلاوهٔ گرم سندهای «تبدیل سود ریالی به طلا» در همین بازه.'),
|
||||
formula: m('کارمزد طلا (گرم) + گرم تبدیلشده از سود ریالی'),
|
||||
description: m('مجموع کارمزدهای کسرشده از طلا بهعلاوهٔ کیلوگرم سندهای «تبدیل سود ریالی به طلا» در همین بازه.'),
|
||||
formula: m('کارمزد طلا (کیلوگرم) + کیلوگرم تبدیلشده از سود ریالی'),
|
||||
}
|
||||
const quantityProductHelp: DashboardHelp = {
|
||||
description:
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
>
|
||||
<span>{{ item.title }}</span>
|
||||
<span class="dashboard-income-summary__breakdown-val">
|
||||
{{ formatGram(item.grams) }} {{ item.unit || 'گرم' }} ≈
|
||||
{{ formatGram(item.grams) }} {{ item.unit || 'کیلوگرم' }} ≈
|
||||
{{ formatDashboardAmount(item.value_rial) }} ریال
|
||||
</span>
|
||||
</span>
|
||||
@@ -49,7 +49,7 @@
|
||||
<span v-else class="dashboard-income-summary__breakdown-row">
|
||||
<span>{{ metalFeeLabel }}</span>
|
||||
<span class="dashboard-income-summary__breakdown-val">
|
||||
{{ formatGram(goldFeeGrams) }} گرم ≈ {{ formatDashboardAmount(goldFeeRial) }} ریال
|
||||
{{ formatGram(goldFeeGrams) }} کیلوگرم ≈ {{ formatDashboardAmount(goldFeeRial) }} ریال
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -101,7 +101,7 @@ function formatGram(value: number) {
|
||||
const commissionHelp: DashboardHelp = {
|
||||
description:
|
||||
'کارمزد ترکیبی از دو نوع معامله است: در معاملههای مبلغمحور (مشتری مبلغ ریالی ثابت زده) کارمزد از کیف همان محصول مقداری کسر میشود، و در معاملههای وزنمحور از ریال. این مبلغ مجموع کارمزد ریالی بهعلاوهٔ معادل ریالی کارمزد مقداری است.',
|
||||
formula: 'کارمزد = کارمزد ریالی + جمع (گرم کارمزد هر محصول مقداری × قیمت همان محصول)',
|
||||
formula: 'کارمزد = کارمزد ریالی + جمع (کیلوگرم کارمزد هر محصول مقداری × قیمت همان محصول)',
|
||||
}
|
||||
|
||||
const rows = computed(() => [
|
||||
|
||||
@@ -20,7 +20,7 @@ interface Prop {
|
||||
color: string
|
||||
title: string
|
||||
count?: number
|
||||
unit: 'نفر' | 'گرم'
|
||||
unit: 'نفر' | 'کیلوگرم' | 'گرم'
|
||||
}
|
||||
|
||||
const props = defineProps<Prop>()
|
||||
|
||||
@@ -236,7 +236,7 @@ export function useDashboardPage() {
|
||||
if (metalId != null) {
|
||||
return formatMetalWeightFromGrams(value ?? 0, metalId)
|
||||
}
|
||||
return `${Number(value ?? 0).toLocaleString('fa-IR', { maximumFractionDigits: 3 })} گرم`
|
||||
return `${Number(value ?? 0).toLocaleString('fa-IR', { maximumFractionDigits: 3 })} کیلوگرم`
|
||||
}
|
||||
|
||||
function directionLabel(direction?: number) {
|
||||
@@ -312,14 +312,14 @@ export function useDashboardPage() {
|
||||
tickAmount: mobile ? 4 : 6,
|
||||
labels: {
|
||||
formatter: (v: number) =>
|
||||
mobile ? Number(v).toLocaleString('fa-IR') : `${Number(v).toLocaleString('fa-IR')} گرم`,
|
||||
mobile ? Number(v).toLocaleString('fa-IR') : `${Number(v).toLocaleString('fa-IR')} کیلوگرم`,
|
||||
style: { fontSize: mobile ? '10px' : '11px' },
|
||||
maxWidth: mobile ? 40 : 64,
|
||||
offsetX: 0,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
y: { formatter: (v: number) => `${Number(v).toLocaleString('fa-IR')} گرم` },
|
||||
y: { formatter: (v: number) => `${Number(v).toLocaleString('fa-IR')} کیلوگرم` },
|
||||
},
|
||||
legend: { position: 'top', fontSize: mobile ? '10px' : '11px' },
|
||||
dataLabels: { enabled: false },
|
||||
@@ -374,7 +374,7 @@ export function useDashboardPage() {
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'مظنه',
|
||||
name: 'قیمت',
|
||||
data: priceSeries.value.map((p) => [p.timestamp, chartPointRial(p.value)]),
|
||||
},
|
||||
],
|
||||
@@ -520,7 +520,7 @@ export function useDashboardPage() {
|
||||
shared: true,
|
||||
intersect: false,
|
||||
y: {
|
||||
formatter: (val: number) => `${Number(val).toLocaleString('fa-IR')} گرم`,
|
||||
formatter: (val: number) => `${Number(val).toLocaleString('fa-IR')} کیلوگرم`,
|
||||
},
|
||||
x: {
|
||||
formatter: (_val: number, opts?: { dataPointIndex?: number }) =>
|
||||
@@ -533,9 +533,9 @@ export function useDashboardPage() {
|
||||
fontSize: mobile ? '10px' : '11px',
|
||||
},
|
||||
series: [
|
||||
{ name: 'خرید (گرم)', data: items.map((p) => p.transaction_sum_gold_buy ?? 0) },
|
||||
{ name: 'خرید (کیلوگرم)', data: items.map((p) => p.transaction_sum_gold_buy ?? 0) },
|
||||
{
|
||||
name: 'فروش (گرم)',
|
||||
name: 'فروش (کیلوگرم)',
|
||||
data: items.map((p) => Math.abs(p.total_negative_gold_sell ?? 0)),
|
||||
},
|
||||
],
|
||||
|
||||
@@ -17,8 +17,8 @@ function help(description: string, formula: string): DashboardHelp {
|
||||
}
|
||||
|
||||
export const dashboardHero = help(
|
||||
'آخرین قیمت پایه هر گرم طلا در سیستم.',
|
||||
`قیمت هر مثقال = قیمت هر گرم × ${MESGHAL_FACTOR}`
|
||||
'آخرین قیمت پایه هر کیلوگرم طلا در سیستم.',
|
||||
`قیمت هر مثقال = قیمت هر کیلوگرم × ${MESGHAL_FACTOR}`
|
||||
)
|
||||
|
||||
export const dashboardGateway = help(
|
||||
@@ -45,7 +45,7 @@ export const dashboardKpi = {
|
||||
),
|
||||
goldBalance: help(
|
||||
'تراز وزنی طلا از سفارشات موفق؛ مثبت یعنی به مشتری بیشتر فروختهاید.',
|
||||
'تراز طلا = گرم فروش − گرم خرید (سفارش موفق)'
|
||||
'تراز طلا = کیلوگرم فروش − کیلوگرم خرید (سفارش موفق)'
|
||||
),
|
||||
cashBalance: help(
|
||||
'تراز ریالی همان سفارشات موفق؛ ورود و خروج نقد از معاملات.',
|
||||
@@ -53,13 +53,13 @@ export const dashboardKpi = {
|
||||
),
|
||||
mazanehBalance: help(
|
||||
'میانگین موزون قیمت معاملات، تبدیلشده به مثقال.',
|
||||
`(جمع مبلغ معاملات ÷ جمع گرم) × ${MESGHAL_FACTOR}`
|
||||
`(جمع مبلغ معاملات ÷ جمع کیلوگرم) × ${MESGHAL_FACTOR}`
|
||||
),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
export const dashboardTradingIncomeSummary = help(
|
||||
'در بازهٔ انتخابی، درآمد معاملات به سه بخش دیده میشود: سود اختلاف قیمت، کارمزد (ترکیبی از کارمزد ریالی و معادل ریالی کارمزد طلایی)، و جمع این دو. همهٔ مبالغ به ریال هستند (نه تومان).',
|
||||
'جمع سود = سود اختلاف قیمت + [کارمزد ریالی + (گرم کارمزد طلایی × قیمت روز)]'
|
||||
'جمع سود = سود اختلاف قیمت + [کارمزد ریالی + (کیلوگرم کارمزد طلایی × قیمت روز)]'
|
||||
)
|
||||
|
||||
export const dashboardDateRange = help(
|
||||
@@ -74,7 +74,7 @@ export const dashboardDateMetrics = {
|
||||
),
|
||||
netIncome: help(
|
||||
'شاخص قدیمی: اختلاف قیمت اصلی و پرداختی منهای ارزش هدایا — با «جمع سود معاملات» یکی نیست.',
|
||||
'تراز قیمت−پرداخت = جمع |قیمت اصلی − پرداختی| − (گرم هدیه × مظنه)'
|
||||
'تراز قیمت−پرداخت = جمع |قیمت اصلی − پرداختی| − (کیلوگرم هدیه × قیمت)'
|
||||
),
|
||||
totalTradingProfit: help(
|
||||
'همان «جمع سود معاملات» در خلاصه بالا — اختلاف قیمت + کارمزد.',
|
||||
@@ -82,7 +82,7 @@ export const dashboardDateMetrics = {
|
||||
),
|
||||
gifts: help(
|
||||
'طلای پاداشی که در این بازه به مشتریان داده شده: پاداش معرفی، پاداش ثبتنام و سود زیرمجموعه. شارژ دستی طلا و معاملات اینجا شمرده نمیشوند.',
|
||||
'گرم هدیه = جمع طلای تراکنشهای پاداش معرفی/ثبتنام و سود زیرمجموعه'
|
||||
'کیلوگرم هدیه = جمع طلای تراکنشهای پاداش معرفی/ثبتنام و سود زیرمجموعه'
|
||||
),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -93,15 +93,15 @@ export const dashboardCharts = {
|
||||
),
|
||||
buySellVolume: help(
|
||||
'مقدار طلای خرید و فروش مشتری در هر روز (فقط سفارش موفق).',
|
||||
'هر روز: گرم خرید مشتری و گرم فروش به مشتری'
|
||||
'هر روز: کیلوگرم خرید مشتری و کیلوگرم فروش به مشتری'
|
||||
),
|
||||
priceChart: help(
|
||||
'روند تغییر قیمت پایه هر گرم در ۲۴ ساعت، هفته یا ماه.',
|
||||
'روند تغییر قیمت پایه هر کیلوگرم در ۲۴ ساعت، هفته یا ماه.',
|
||||
'نمودار = قیمت پایه در هر لحظه'
|
||||
),
|
||||
productActivity: help(
|
||||
'مقایسه حجم خرید و فروش هر محصول در بازه انتخابی.',
|
||||
'خرید = جمع گرم مثبت | فروش = جمع گرم منفی (معاملات همان بازه)'
|
||||
'خرید = جمع کیلوگرم مثبت | فروش = جمع کیلوگرم منفی (معاملات همان بازه)'
|
||||
),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -111,8 +111,8 @@ export const dashboardOrders = {
|
||||
'هر ستون = تعداد سفارش در آن ساعت (جمع چند روز اخیر)'
|
||||
),
|
||||
recent: help(
|
||||
'۱۴ سفارش آخر با جزئیات مظنه و سود.',
|
||||
'مظنه = قیمت پایه | قیمت مشتری = مظنه ± اختلاف قیمت | سود/گرم = همان اختلاف قیمت'
|
||||
'۱۴ سفارش آخر با جزئیات قیمت و سود.',
|
||||
'قیمت = قیمت پایه | قیمت مشتری = قیمت ± اختلاف قیمت | سود/کیلوگرم = همان اختلاف قیمت'
|
||||
),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -130,17 +130,17 @@ export const dashboardCustomerMetrics = {
|
||||
|
||||
export const dashboardWallet = help(
|
||||
'مجموع موجودی طلا و ریال همه مشتریان (بدهی اپ به کاربران). این عدد دفتر اکانت همکار نیست.',
|
||||
'ارزش طلا به ریال = جمع گرم × مظنه لحظهای'
|
||||
'ارزش طلا به ریال = جمع کیلوگرم × قیمت لحظهای'
|
||||
)
|
||||
|
||||
export const dashboardWalletMetrics = {
|
||||
gold: help(
|
||||
'مجموع طلای موجود در کیف همه مشتریان — بدهی به مشتری؛ با ماندهٔ پنل همکار یکی نیست.',
|
||||
'جمع گرم طلا در کیفها'
|
||||
'جمع کیلوگرم طلا در کیفها'
|
||||
),
|
||||
cash: help(
|
||||
'مجموع ریال موجود در کیف همه مشتریان — شارژ/مانده مشتری؛ با ماندهٔ ریالی همکار یکی نیست.',
|
||||
'جمع ریال در کیفها'
|
||||
),
|
||||
goldToCash: help('ارزش ریالی کل طلای مشتریان با مظنه فعلی.', 'جمع گرم × قیمت هر گرم'),
|
||||
goldToCash: help('ارزش ریالی کل طلای مشتریان با قیمت فعلی.', 'جمع کیلوگرم × قیمت هر کیلوگرم'),
|
||||
} as const satisfies Record<string, DashboardHelp>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="dashboard-hero__price min-w-0">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<DashboardLabelWithHelp
|
||||
label="مظنه"
|
||||
label="قیمت"
|
||||
:help="heroHelp"
|
||||
size="xs"
|
||||
text-class="text-[11px]"
|
||||
@@ -91,7 +91,7 @@
|
||||
<DashboardStatCard
|
||||
tone="violet"
|
||||
icon="vuesax-linear:chart-2"
|
||||
title="تراز مظنه"
|
||||
title="تراز قیمت"
|
||||
subtitle="میانگین موزون"
|
||||
:value="formatDashboardAmount(balance?.mazanehBalance)"
|
||||
:unit="DASHBOARD_RIAL_UNIT"
|
||||
@@ -187,7 +187,7 @@
|
||||
<div class="mb-3 flex flex-wrap items-start justify-between gap-2">
|
||||
<DashboardSectionHeader
|
||||
class="!mb-0 min-w-0 flex-1"
|
||||
title="نمودار مظنه"
|
||||
title="نمودار قیمت"
|
||||
:help="copy.charts.priceChart"
|
||||
/>
|
||||
<a-radio-group
|
||||
@@ -331,9 +331,9 @@
|
||||
<th class="px-2 py-2 text-right">نوع</th>
|
||||
<th class="px-2 py-2 text-right">مشتری</th>
|
||||
<th class="px-2 py-2 text-right">مقدار</th>
|
||||
<th class="px-2 py-2 text-right">مظنه/گرم</th>
|
||||
<th class="px-2 py-2 text-right">قیمت/کیلوگرم</th>
|
||||
<th class="px-2 py-2 text-right">قیمت مشتری</th>
|
||||
<th class="px-2 py-2 text-right">سود اختلاف قیمت/گرم</th>
|
||||
<th class="px-2 py-2 text-right">سود اختلاف قیمت/کیلوگرم</th>
|
||||
<th class="px-2 py-2 text-right">سود کل اختلاف قیمت</th>
|
||||
<th class="px-2 py-2 text-right">کارمزد</th>
|
||||
<th class="px-2 py-2 text-right">وضعیت</th>
|
||||
@@ -546,7 +546,7 @@ const heroHelp = computed(() =>
|
||||
isCopperMainMetal.value
|
||||
? {
|
||||
description: 'آخرین قیمت پایه هر کیلوگرم مس در سیستم.',
|
||||
formula: 'مظنه بر حسب کیلوگرم نمایش داده میشود؛ مثقال برای مس کاربرد ندارد.',
|
||||
formula: 'قیمت بر حسب کیلوگرم نمایش داده میشود؛ مثقال برای مس کاربرد ندارد.',
|
||||
}
|
||||
: copy.hero
|
||||
)
|
||||
@@ -591,8 +591,8 @@ const dateRangeMetrics = computed(() => [
|
||||
help: dashboardDateMetrics.netIncome,
|
||||
},
|
||||
{
|
||||
label: 'هدایا (گرم)',
|
||||
value: `${finance.value?.Gifts ?? '0'} گرم`,
|
||||
label: 'هدایا (کیلوگرم)',
|
||||
value: `${finance.value?.Gifts ?? '0'} کیلوگرم`,
|
||||
help: dashboardDateMetrics.gifts,
|
||||
},
|
||||
])
|
||||
@@ -688,7 +688,7 @@ const walletMetricItems = computed(() => [
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1279px) {
|
||||
/* دسکتاپ باریک: مظنه بالا، دکمهها زیرش در ردیف مرتب — نه قاطی کنار هم */
|
||||
/* دسکتاپ باریک: قیمت بالا، دکمهها زیرش در ردیف مرتب — نه قاطی کنار هم */
|
||||
.dashboard-hero__row {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
|
||||
@@ -101,6 +101,7 @@ import OtpInput from 'vue3-otp-input'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { setupRoutes } from '@/router'
|
||||
import { getConfigApp, initStoreModeFromSettings } from '@/utils/config'
|
||||
import { firstAllowedRouteName } from '@/utils/adminPageAccess'
|
||||
|
||||
//define emit
|
||||
const emits = defineEmits(['enter'])
|
||||
@@ -175,7 +176,12 @@ const onUserPassFormFinish = async () => {
|
||||
}*/
|
||||
//router.removeRoute('usersMain')
|
||||
//router.removeRoute('users')
|
||||
await router.push({ name: 'dashboard' })
|
||||
const landing = firstAllowedRouteName()
|
||||
if (!landing) {
|
||||
message.warning({ content: 'شما به این صفحه دسترسی ندارید', key: 'admin-page-denied' })
|
||||
return
|
||||
}
|
||||
await router.push({ name: landing })
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
/* if (e?.response.status === 422) {
|
||||
|
||||
@@ -31,13 +31,11 @@ function enterTest() {
|
||||
.login-page__toggle {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
inset-inline-start: 16px;
|
||||
z-index: 1001;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 4px 10px 4px 6px;
|
||||
border-radius: 9999px;
|
||||
background: var(--admin-bg-elevated);
|
||||
border: 1px solid var(--admin-border);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<MobileDetailRow label="زمان ثبت" :value="row.created_at ? toJalali(row.created_at) : '-'" />
|
||||
<MobileDetailRow label="نقد (ریال)" :value="usePrice(row.cash ?? 0, true, '')" />
|
||||
<MobileDetailRow :label="metalLabel.goldUnit()" :value="`${row.gold ?? 0}`" />
|
||||
<MobileDetailRow label="توضیحات" full-width :value="row.note || '-'" />
|
||||
<MobileDetailRow label="توضیحات" full-width :value="formatAccountingNote(row)" />
|
||||
</MobileInfoGrid>
|
||||
</template>
|
||||
</MobileDetailSheet>
|
||||
@@ -24,6 +24,7 @@ import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { formatAccountingNote } from '@/pages/menuPages/accounting/utils/accountingDisplay'
|
||||
|
||||
const props = defineProps<{ visible: boolean; item: TotalAccounting | null }>()
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="truncate text-sm font-700 text-gray-900">{{ customerName }}</div>
|
||||
<div class="text-xs text-gray-400">{{ createdAtLabel }}</div>
|
||||
</div>
|
||||
<div v-if="item.note" class="text-xs text-gray-600">{{ item.note }}</div>
|
||||
<div v-if="noteLabel" class="text-xs text-gray-600">{{ noteLabel }}</div>
|
||||
<div class="flex gap-3 text-xs">
|
||||
<span class="text-gray-600">نقد: <span class="font-600 text-gray-900">{{ cashLabel }}</span></span>
|
||||
<span class="text-gray-600">{{ metalLabel.goldUnit() }}: <span class="font-600 text-gray-900">{{ goldLabel }}</span></span>
|
||||
@@ -20,6 +20,7 @@ import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { formatAccountingNote } from '@/pages/menuPages/accounting/utils/accountingDisplay'
|
||||
|
||||
const props = defineProps<{ item: TotalAccounting }>()
|
||||
|
||||
@@ -28,5 +29,9 @@ defineEmits<{ (e: 'open', item: TotalAccounting): void }>()
|
||||
const customerName = computed(() => props.item.customer_to?.name || '-')
|
||||
const createdAtLabel = computed(() => (props.item.created_at ? toJalali(props.item.created_at) : '-'))
|
||||
const cashLabel = computed(() => usePrice(props.item.cash ?? 0, true, ''))
|
||||
const goldLabel = computed(() => `${props.item.gold ?? 0} گرم`)
|
||||
const goldLabel = computed(() => `${props.item.gold ?? 0} کیلوگرم`)
|
||||
const noteLabel = computed(() => {
|
||||
const formatted = formatAccountingNote(props.item)
|
||||
return formatted !== '-' ? formatted : ''
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.pargar_ref && !row.customer?.pargar_account_id"
|
||||
v-if="can('register') && !row.pargar_ref && !row.customer?.pargar_account_id"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -88,6 +88,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -90,7 +90,7 @@ function waitLabel(minutes: number): string {
|
||||
function amountLabel(row: StuckOutboundRow): string {
|
||||
if (row.amount == null) return '—'
|
||||
if (row.type === 'wallet_cash') return usePrice(Math.abs(row.amount))
|
||||
return `${Math.abs(row.amount).toFixed(4)} گرم`
|
||||
return `${Math.abs(row.amount).toFixed(4)} کیلوگرم`
|
||||
}
|
||||
|
||||
async function load() {
|
||||
|
||||
@@ -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">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.tahesab_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.tahesab_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.zarin_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.zarin_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<div class="flex justify-center gap-2">
|
||||
|
||||
<!-- دکمه ۱: اطلاعات کلی (همیشه نمایان) -->
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<!-- دکمه ۲: ثبت مشتری در پرگار (فقط اگر سند هنوز ثبت نشده و مشتری کد ندارد) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
v-if="can('register') && canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<!-- دکمه ۳: ارسال به پرگار (فقط اگر هنوز در پرگار ثبت نشده) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record)"
|
||||
v-if="can('send') && canRetryPargar(record)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -82,7 +82,7 @@
|
||||
<div v-if="tx.remainGold || tx.remainRial" class="flex justify-between gap-2">
|
||||
<span class="text-gray-500">مانده</span>
|
||||
<span class="text-left">
|
||||
{{ tx.remainGold ? `${tx.remainGold} گرم` : '' }}
|
||||
{{ tx.remainGold ? `${tx.remainGold} کیلوگرم` : '' }}
|
||||
{{ tx.remainRial ? `${tx.remainRial} ریال` : '' }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -138,6 +138,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/pargarDisplay'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingPargarDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="اسناد شایگان" :help="help">
|
||||
<template #extra>
|
||||
<a-button size="small" :loading="healthLoading" @click="runHealth">تست اتصال</a-button>
|
||||
</template>
|
||||
|
||||
<a-alert
|
||||
v-if="healthMessage"
|
||||
:type="healthOk ? 'success' : 'error'"
|
||||
:message="healthMessage"
|
||||
show-icon
|
||||
closable
|
||||
class="mb-2"
|
||||
@close="healthMessage = ''"
|
||||
/>
|
||||
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit">
|
||||
<template #status="{ record }">
|
||||
<a-tag :color="statusColor(record.sync_status)">{{ statusLabel(record.sync_status) }}</a-tag>
|
||||
</template>
|
||||
<template #ops="{ record }">
|
||||
<div class="flex justify-center">
|
||||
<a-tooltip
|
||||
v-if="record.sync_status !== 'success'"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="retry(record)"
|
||||
>
|
||||
<template #title><span>ارسال مجدد</span></template>
|
||||
<Icon icon="vuesax-linear:send-2" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { shayeganHealth, shayeganRetry, shayeganTable } from '@/api/shayegan'
|
||||
|
||||
const help =
|
||||
'وضعیت ارسال به حسابگر. تست اتصال فقط خواندنی است و سند آزمایشی در CYPRSD04 نمیسازد.'
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
customer: 'ثبت مشتری',
|
||||
trade: 'معامله',
|
||||
wallet_cash: 'کیف ریالی',
|
||||
wallet_gold: 'کیف محصول'
|
||||
}
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
success: 'موفق',
|
||||
failed: 'ناموفق',
|
||||
timeout: 'تایماوت',
|
||||
pending: 'در انتظار'
|
||||
}
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const healthLoading = ref(false)
|
||||
const healthOk = ref(false)
|
||||
const healthMessage = ref('')
|
||||
|
||||
const columns = [
|
||||
{ title: 'شناسه', dataIndex: 'id', key: 'id', width: 80, type: 'Number', filterable: false, sortable: false },
|
||||
{
|
||||
title: 'مشتری',
|
||||
dataIndex: 'customer.name',
|
||||
key: 'customer.name',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => customerLabel(r.record)
|
||||
},
|
||||
{
|
||||
title: 'نوع',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
type: 'Text',
|
||||
customRender: (r: any) => typeLabel(r.record?.type)
|
||||
},
|
||||
{
|
||||
title: 'مبلغ/مقدار',
|
||||
dataIndex: 'amount',
|
||||
key: 'amount',
|
||||
type: 'Number',
|
||||
filterable: false,
|
||||
customRender: (r: any) => (r.record?.amount == null || r.record?.amount === '' ? '-' : usePrice(r.record.amount, true, ''))
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'sync_status',
|
||||
key: 'sync_status',
|
||||
slot: 'status',
|
||||
type: 'Text'
|
||||
},
|
||||
{ title: 'شماره شایگان', dataIndex: 'shayegan_number', key: 'shayegan_number', type: 'Text' },
|
||||
{ title: 'توضیح', dataIndex: 'desc', key: 'desc', type: 'Text' },
|
||||
{
|
||||
title: 'زمان',
|
||||
dataIndex: 'created_at',
|
||||
key: 'created_at',
|
||||
type: 'DateTime',
|
||||
filterable: false,
|
||||
customRender: (r: any) => (r.record?.created_at ? toJalali(r.record.created_at) : '-')
|
||||
},
|
||||
{
|
||||
title: 'عملیات',
|
||||
dataIndex: 'ops',
|
||||
key: 'ops',
|
||||
slot: 'ops',
|
||||
width: 110,
|
||||
filterable: false,
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
|
||||
function asTable(res: any, params: TableInput) {
|
||||
if (res?.query) {
|
||||
return {
|
||||
rows: Array.isArray(res.rows) ? res.rows : [],
|
||||
query: {
|
||||
...params,
|
||||
...res.query,
|
||||
filters: res.query.filters ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
const rows = Array.isArray(res)
|
||||
? res
|
||||
: Array.isArray(res?.data)
|
||||
? res.data
|
||||
: Array.isArray(res?.rows)
|
||||
? res.rows
|
||||
: []
|
||||
return {
|
||||
rows,
|
||||
query: {
|
||||
page: Number(res?.current_page ?? params.page ?? 1),
|
||||
limit: Number(res?.per_page ?? params.limit ?? 20),
|
||||
total: Number(res?.total ?? rows.length),
|
||||
filters: params.filters ?? [],
|
||||
search: params.search ?? '',
|
||||
select: params.select ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const tblProps = {
|
||||
columns,
|
||||
defaultPageLimit: 20,
|
||||
api: async (params: TableInput) => {
|
||||
try {
|
||||
return asTable(await shayeganTable(params), params)
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || 'خطا در دریافت اسناد شایگان')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function customerLabel(record?: any) {
|
||||
if (record?.customer?.name?.trim()) return record.customer.name.trim()
|
||||
if (record?.customer?.fname || record?.customer?.lname) {
|
||||
const fullName = `${record?.customer?.fname || ''} ${record?.customer?.lname || ''}`.trim()
|
||||
if (fullName) return fullName
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
|
||||
function typeLabel(type?: string | null) {
|
||||
if (!type) return '-'
|
||||
return TYPE_LABELS[type] ?? type
|
||||
}
|
||||
|
||||
function statusLabel(status?: string | null) {
|
||||
if (!status) return '-'
|
||||
return STATUS_LABELS[status] ?? status
|
||||
}
|
||||
|
||||
function statusColor(status?: string) {
|
||||
if (status === 'success') return 'green'
|
||||
if (status === 'failed') return 'red'
|
||||
if (status === 'timeout') return 'orange'
|
||||
return 'blue'
|
||||
}
|
||||
|
||||
async function runHealth() {
|
||||
healthLoading.value = true
|
||||
healthMessage.value = ''
|
||||
try {
|
||||
const res: any = await shayeganHealth()
|
||||
healthOk.value = !!res?.ok
|
||||
healthMessage.value = res?.message || (res?.ok ? 'اتصال برقرار است' : 'اتصال ناموفق')
|
||||
} catch (e: any) {
|
||||
healthOk.value = false
|
||||
healthMessage.value = e?.response?.data?.message || e?.message || 'خطای تست اتصال'
|
||||
} finally {
|
||||
healthLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function retry(record: any) {
|
||||
const isTimeout = record.sync_status === 'timeout'
|
||||
Modal.confirm({
|
||||
title: 'ارسال مجدد به شایگان',
|
||||
content: isTimeout
|
||||
? 'این سند timeout شده. فقط اگر در حسابگر ثبت نشده، تأیید کنید.'
|
||||
: 'سند دوباره به شایگان ارسال شود؟',
|
||||
okText: 'ارسال',
|
||||
cancelText: 'انصراف',
|
||||
onOk: async () => {
|
||||
try {
|
||||
await shayeganRetry(record.id, isTimeout)
|
||||
message.success('انجام شد')
|
||||
await reload()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'خطا')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function fetch() {
|
||||
await reload()
|
||||
}
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
@@ -79,12 +79,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -93,6 +93,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -111,13 +112,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -127,7 +128,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id"
|
||||
v-if="can('send') && !record.tahesab_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -221,6 +222,9 @@ import {
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const docSyncStore = useTahesabDocSyncStore()
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -90,6 +90,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -108,13 +109,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -124,7 +125,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id"
|
||||
v-if="can('send') && !record.zarin_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -216,6 +217,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingZarinDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BaseTableColumn } from '@core/type/baseTable'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { formatAccountingNote } from '@/pages/menuPages/accounting/utils/accountingDisplay'
|
||||
|
||||
/**
|
||||
* ستونهای دفترکل (گزارشات) — مستقل از هر سیستم حسابداری بیرونی.
|
||||
@@ -45,7 +46,8 @@ export function getAccountingColumns(): BaseTableColumn[] {
|
||||
title: 'توضیحات',
|
||||
dataIndex: 'note',
|
||||
key: 'note',
|
||||
type: 'Text'
|
||||
type: 'Text',
|
||||
customRender: (record: any) => formatAccountingNote(record)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
<ATabPane v-if="pargarEnabled" key="pargar" tab="اسناد پرگار" />
|
||||
<ATabPane v-if="pargarEnabled" key="pargar-customer-sync" tab="همگام سازی مشتریان در پرگار" />
|
||||
<ATabPane v-if="pargarEnabled" key="pargar-wallet-sync" tab="مانده کیف پرگار" />
|
||||
<ATabPane v-if="shayeganEnabled" key="shayegan" tab="اسناد شایگان" />
|
||||
<ATabPane v-if="shayeganEnabled" key="shayegan-charges" tab="واریزیهای شایگان" />
|
||||
</ATabs>
|
||||
<tbl v-if="activeTab === 'reports'" ref="table" class="min-h-0 flex-1" />
|
||||
<tahesabTbl v-else-if="tahesabEnabled && activeTab === 'tahesab'" ref="tahesabTable" class="min-h-0 flex-1" />
|
||||
@@ -28,6 +30,8 @@
|
||||
<pargarTbl v-else-if="pargarEnabled && activeTab === 'pargar'" ref="pargarTable" class="min-h-0 flex-1" />
|
||||
<pargarCustomerSync v-else-if="pargarEnabled && activeTab === 'pargar-customer-sync'" class="shrink-0" />
|
||||
<pargarWalletSync v-else-if="pargarEnabled && activeTab === 'pargar-wallet-sync'" class="shrink-0" />
|
||||
<shayeganTbl v-else-if="shayeganEnabled && activeTab === 'shayegan'" ref="shayeganTable" class="min-h-0 flex-1" />
|
||||
<shayeganChargesTab v-else-if="shayeganEnabled && activeTab === 'shayegan-charges'" class="min-h-0 flex-1" />
|
||||
</div>
|
||||
</BasicMainCard>
|
||||
<BasicModal
|
||||
@@ -66,7 +70,7 @@
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
:label="`قیمت ${form.direction === 1 ? 'خرید' : 'فروش'} هر گرم`"
|
||||
:label="`قیمت ${form.direction === 1 ? 'خرید' : 'فروش'} هر کیلوگرم`"
|
||||
name="price"
|
||||
:rules="inputRules()"
|
||||
>
|
||||
@@ -122,7 +126,7 @@
|
||||
<a-form-item name="goldValue" :rules="inputRulesNumber()">
|
||||
<BasicInput
|
||||
v-model:value="form.goldValue"
|
||||
addon-before="گرم"
|
||||
addon-before="کیلوگرم"
|
||||
addon-bg-color="#0A1B37"
|
||||
addon-text-color="white"
|
||||
:place-holder="metalLabel.goldPlaceholder()"
|
||||
@@ -154,7 +158,8 @@
|
||||
// import BasicInfoModal from '@/components/BasicInfoModal'
|
||||
import { inputLenRules, inputRules, inputRulesNumber } from '@/utils/inputRules'
|
||||
import { useStaticApiListsStore } from '@/store/staticApisStore'
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import tbl from './components/table.vue'
|
||||
import tahesabTbl from './components/tahesabTable.vue'
|
||||
import customerSync from './components/TahesabCustomerSync.vue'
|
||||
@@ -162,6 +167,8 @@ import tahesabWalletSync from './components/TahesabWalletBulkSync.vue'
|
||||
import zarinTbl from './components/zarinTable.vue'
|
||||
import zarinCustomerSync from './components/ZarinCustomerSync.vue'
|
||||
import zarinWalletSync from './components/ZarinWalletBulkSync.vue'
|
||||
import shayeganTbl from './components/shayeganTable.vue'
|
||||
import shayeganChargesTab from './components/ShayeganChargesTab.vue'
|
||||
import pargarTbl from './components/pargarTable.vue'
|
||||
import pargarCustomerSync from './components/PargarCustomerSync.vue'
|
||||
import pargarWalletSync from './components/PargarWalletBulkSync.vue'
|
||||
@@ -183,15 +190,26 @@ import type { last } from '@/model/price'
|
||||
import { createOrder } from '@/api/order'
|
||||
import { getCashBalance, getGoldBalance } from '@/components/mobile/utils/wallet'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting } from '@/utils/config'
|
||||
import { initAccountingSettingsFromApi, tahesabEnabledSetting, zarinEnabledSetting, pargarEnabledSetting, shayeganEnabledSetting } from '@/utils/config'
|
||||
|
||||
//loading
|
||||
const route = useRoute()
|
||||
const loading = ref<boolean>(false)
|
||||
const submitError = ref('')
|
||||
const activeTab = ref<'reports' | 'tahesab' | 'customer-sync' | 'tahesab-wallet-sync' | 'zarin' | 'zarin-customer-sync' | 'zarin-wallet-sync' | 'pargar' | 'pargar-customer-sync' | 'pargar-wallet-sync'>('reports')
|
||||
const activeTab = ref<'reports' | 'tahesab' | 'customer-sync' | 'tahesab-wallet-sync' | 'zarin' | 'zarin-customer-sync' | 'zarin-wallet-sync' | 'pargar' | 'pargar-customer-sync' | 'pargar-wallet-sync' | 'shayegan' | 'shayegan-charges'>((route.query.tab as any) || 'reports')
|
||||
const tahesabEnabled = tahesabEnabledSetting
|
||||
const zarinEnabled = zarinEnabledSetting
|
||||
const pargarEnabled = pargarEnabledSetting
|
||||
const shayeganEnabled = shayeganEnabledSetting
|
||||
|
||||
watch(
|
||||
() => route.query.tab,
|
||||
(tab) => {
|
||||
if (tab && typeof tab === 'string') {
|
||||
activeTab.value = tab as any
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
//define store
|
||||
const store = useStaticApiListsStore()
|
||||
@@ -304,7 +322,7 @@ function info(val: Order) {
|
||||
infoParams.itemsTitle = 'اطلاعات کاربری'
|
||||
infoParams.items = [
|
||||
{
|
||||
key: 'مقدار (گرم)',
|
||||
key: 'مقدار (کیلوگرم)',
|
||||
value: val.amount ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -324,7 +342,7 @@ function info(val: Order) {
|
||||
value: usePrice(val.total_price_original ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'سود هر گرم (ریال)',
|
||||
key: 'سود هر کیلوگرم (ریال)',
|
||||
value: usePrice(val.fee ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -345,7 +363,7 @@ function info(val: Order) {
|
||||
},*/
|
||||
{
|
||||
key: metalLabel.goldCommission(),
|
||||
value: val.service_charge ?? '-' + ' گرم'
|
||||
value: val.service_charge ?? '-' + ' کیلوگرم'
|
||||
},
|
||||
/* {
|
||||
key: 'تاریخ تولد',
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
|
||||
export function formatAccountingNote(arg: any): string {
|
||||
if (arg == null) return '-'
|
||||
|
||||
const record = arg?.record ? arg.record : arg
|
||||
const order = record?.order
|
||||
const productTitle = order?.product?.title
|
||||
|
||||
const direction = Number(order?.direction ?? record?.direction)
|
||||
if (productTitle && (direction === 1 || direction === 2)) {
|
||||
return `${direction === 1 ? 'خرید' : 'فروش'} ${productTitle}`
|
||||
}
|
||||
|
||||
const rawNote = record?.note ?? arg?.text ?? arg?.value
|
||||
if (rawNote) {
|
||||
const defaultMetal = metalLabel.goldUnit() || 'مس'
|
||||
return String(rawNote).replace(/طلای آبشده|آبشده/g, defaultMetal)
|
||||
}
|
||||
|
||||
if (direction === 1 || direction === 2) {
|
||||
const defaultMetal = metalLabel.goldUnit() || 'مس'
|
||||
return `${direction === 1 ? 'خرید' : 'فروش'} ${defaultMetal}`
|
||||
}
|
||||
|
||||
return '-'
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('recipients')" placement="bottom">
|
||||
<template #title>گیرندگان</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:profile-2user"
|
||||
@@ -36,7 +36,7 @@
|
||||
@click="emits('recipients', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('readers')" placement="bottom">
|
||||
<template #title>بازدیدکنندگان</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:people"
|
||||
@@ -45,7 +45,7 @@
|
||||
@click="emits('readers', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="!isSystemRecord(record)" placement="bottom">
|
||||
<a-tooltip v-if="can('edit') && !isSystemRecord(record)" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -54,7 +54,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:close-circle' : 'vuesax-linear:tick-circle'"
|
||||
@@ -63,7 +63,7 @@
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -91,6 +91,9 @@ import {
|
||||
APP_NOTIFICATION_SOURCE_TABS,
|
||||
type AppNotificationSourceFilter,
|
||||
} from '@/model/appNotifications'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -18,19 +18,21 @@
|
||||
<div class="truncate font-bold text-slate-800 dark:text-slate-100">{{ item.name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ item.code }}</div>
|
||||
</div>
|
||||
<a-switch :checked="item.is_active" size="small" @change="emits('toggle', item)" />
|
||||
<a-switch v-if="can('toggle')" :checked="item.is_active" size="small" @change="emits('toggle', item)" />
|
||||
</div>
|
||||
<div class="line-clamp-2 text-sm text-slate-600 dark:text-slate-300">{{ item.body }}</div>
|
||||
<div class="flex items-center justify-between text-xs text-gray-500">
|
||||
<span>ارسال {{ Number(item.sent_count ?? 0) }} · ناموفق {{ Number(item.failed_count ?? 0) }}</span>
|
||||
<div class="flex gap-3">
|
||||
<Icon
|
||||
v-if="can('edit')"
|
||||
icon="vuesax-linear:edit"
|
||||
color="#4572E9"
|
||||
class="cursor-pointer"
|
||||
@click="emits('edit', item)"
|
||||
/>
|
||||
<Icon
|
||||
v-if="can('delete')"
|
||||
icon="vuesax-linear:trash"
|
||||
color="#C53030"
|
||||
class="cursor-pointer"
|
||||
@@ -46,11 +48,11 @@
|
||||
|
||||
<BaseTable v-else class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #is_active="{ record }">
|
||||
<a-switch :checked="record.is_active" size="small" @change="emits('toggle', record)" />
|
||||
<a-switch v-if="can('toggle')" :checked="record.is_active" size="small" @change="emits('toggle', record)" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('preview')" placement="bottom">
|
||||
<template #title>اجرای آزمایشی</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:play"
|
||||
@@ -59,7 +61,7 @@
|
||||
@click="emits('runNow', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('log')" placement="bottom">
|
||||
<template #title>لاگ ارسال</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:document-text"
|
||||
@@ -68,7 +70,7 @@
|
||||
@click="emits('sends', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -77,7 +79,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -104,6 +106,9 @@ import { getAutomationsTable } from '@/api/automations'
|
||||
import type { Automation } from '@/model/automations'
|
||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||
import { automationsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="banner-image-upload">
|
||||
<div class="banner-image-upload fix-capture" @pointerdown="ensureGalleryCapture" @click="ensureGalleryCapture">
|
||||
<a-upload
|
||||
v-if="!displayUrl"
|
||||
class="banner-image-upload__zone"
|
||||
class="banner-image-upload__zone fix-capture"
|
||||
name="file"
|
||||
accept="image/*"
|
||||
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
@@ -37,8 +37,9 @@
|
||||
</div>
|
||||
<div class="banner-image-upload__bar">
|
||||
<a-upload
|
||||
class="fix-capture"
|
||||
name="file"
|
||||
accept="image/*"
|
||||
accept="image/jpeg,image/png,image/webp,image/jpg,.jpg,.jpeg,.png,.webp"
|
||||
:show-upload-list="false"
|
||||
:action="uploadURL"
|
||||
:headers="fileHeader"
|
||||
@@ -63,11 +64,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch, onMounted, nextTick } from 'vue'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { uploadURL } from '@root/config'
|
||||
import { getToken } from '@/utils'
|
||||
import { fileUrlCandidates, normalizeUploadFileResponse, toAbsoluteFileUrl } from '@/utils/file'
|
||||
import { fixFileCapture } from '@/utils/fixFileCapture'
|
||||
import {
|
||||
createImageBeforeUpload,
|
||||
createImageCustomRequest
|
||||
@@ -89,11 +92,22 @@ const candidateIndex = ref(0)
|
||||
const candidates = computed(() => fileUrlCandidates(props.imageUrl))
|
||||
const displayUrl = computed(() => candidates.value[candidateIndex.value] ?? '')
|
||||
|
||||
function ensureGalleryCapture() {
|
||||
fixFileCapture()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fixFileCapture()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.imageUrl,
|
||||
() => {
|
||||
previewFailed.value = false
|
||||
candidateIndex.value = 0
|
||||
nextTick(() => {
|
||||
fixFileCapture()
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -120,6 +120,119 @@
|
||||
</article>
|
||||
</div>
|
||||
</a-collapse-panel>
|
||||
|
||||
<a-collapse-panel key="assets">
|
||||
<template #header>
|
||||
<div class="banners-page__collapse-header">
|
||||
<BaseIcon icon="vuesax-linear:image" size="18" class="banners-page__collapse-icon" />
|
||||
<div class="banners-page__collapse-text">
|
||||
<span class="banners-page__collapse-title">بنر صفحه داراییها</span>
|
||||
<span class="banners-page__collapse-desc">تصویر بنر میانی در صفحهٔ داراییهای اپ مشتری (زیر نمودار و دکمههای عملیات)</span>
|
||||
</div>
|
||||
<a-badge
|
||||
:count="state.assetsBanner?.length ?? 0"
|
||||
:number-style="{ backgroundColor: '#d4af37', color: '#fff', fontSize: '11px' }"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="banners-page__panel-actions">
|
||||
<BaseButton size="small" type="primary" @click="addAssetsRow">
|
||||
<span>افزودن بنر</span>
|
||||
<BaseIcon icon="vuesax-linear:add" size="17" />
|
||||
</BaseButton>
|
||||
<BaseButton type="primary" :loading="saving" @click="handleSubmit">
|
||||
ذخیره تغییرات
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
<div v-if="!state.assetsBanner?.length" class="banners-page__empty">
|
||||
<div class="banners-page__empty-inner">
|
||||
<BaseIcon icon="vuesax-linear:image" size="48" class="banners-page__empty-icon" />
|
||||
<p class="banners-page__empty-title">هنوز بنر داراییها تنظیم نشده است</p>
|
||||
<p class="banners-page__empty-text">بنر جدید بسازید تا جایگزین تصویر پیشفرض صفحهٔ داراییها در اپ مشتری شود</p>
|
||||
<BaseButton type="primary" @click="addAssetsRow">
|
||||
<span>افزودن بنر</span>
|
||||
<BaseIcon icon="vuesax-linear:add" size="17" />
|
||||
</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="banners-page__list">
|
||||
<article
|
||||
v-for="(item, index) in state.assetsBanner"
|
||||
:key="index"
|
||||
class="banner-card"
|
||||
:class="{ 'banner-card--hidden': !item.show }"
|
||||
>
|
||||
<header class="banner-card__head">
|
||||
<div class="banner-card__head-start">
|
||||
<span class="banner-card__index">{{ index + 1 }}</span>
|
||||
<div>
|
||||
<div class="banner-card__title">بنر دارایی {{ index + 1 }}</div>
|
||||
<div class="banner-card__meta">
|
||||
<span class="banner-card__pill" :class="{ 'banner-card__pill--off': !item.show }">
|
||||
{{ item.show ? 'فعال در اپ' : 'مخفی' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="banner-card__head-end">
|
||||
<label class="banner-card__switch">
|
||||
<span>نمایش</span>
|
||||
<a-switch v-model:checked="item.show" size="small" />
|
||||
<AdminFieldHelp :text="bannersShowHelp" />
|
||||
</label>
|
||||
<button type="button" class="banner-card__remove" title="حذف بنر" @click="removeAssetsRow(index)">
|
||||
<BaseIcon icon="vuesax-linear:trash" size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="banner-card__content">
|
||||
<div class="banner-card__preview-wrap">
|
||||
<AdminLabelWithHelp label="پیشنمایش تصویر" :help="bannersImageSectionHelp" />
|
||||
<div class="banner-card__preview">
|
||||
<BannerImageUpload
|
||||
:image-url="item.icon"
|
||||
@upload="onAssetsUpload(index, $event)"
|
||||
@remove="onAssetsRemove(index)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="banner-card__fields" :class="{ 'banner-card__fields--stack': item.typeClick === 'modal' }">
|
||||
<div class="banner-card__field">
|
||||
<AdminLabelWithHelp label="بعد از کلیک مشتری" :help="clickEventHelp(item.typeClick)" />
|
||||
<BasicSelect
|
||||
v-model:value="item.typeClick"
|
||||
:items="typeList"
|
||||
value-name="lable"
|
||||
key-name="value"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="item.typeClick === 'link'" class="banner-card__field banner-card__field--wide">
|
||||
<AdminLabelWithHelp label="آدرس لینک یا نام صفحه" :help="bannersLinkHelp" />
|
||||
<BasicInput v-model:value="item.link" placeholder="buyProduct یا https://example.com" />
|
||||
</div>
|
||||
|
||||
<div v-if="item.typeClick === 'modal'" class="banner-card__field banner-card__field--wide">
|
||||
<AdminLabelWithHelp label="متن پیام" :help="bannersModalHelp" />
|
||||
<a-textarea
|
||||
:value="htmlToPlain(item.modalText)"
|
||||
:rows="7"
|
||||
class="banner-card__message"
|
||||
placeholder="متن پیامی که مشتری در پنجرهٔ بازشو میبیند..."
|
||||
@update:value="item.modalText = plainToHtml($event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
|
||||
<SettingsProfileBanners v-if="showThemeBanners" />
|
||||
@@ -148,14 +261,14 @@ import { onMounted, ref, watch } from 'vue'
|
||||
|
||||
const showThemeBanners = isModularUiVariant()
|
||||
const { state, saving, save, load, saveSoon } = useAppBannersAdmin()
|
||||
/** اگر اسلایدری هست، پنل را باز نگه دار تا خالی بهنظر نرسد */
|
||||
const sliderActiveKey = ref<(string | number)[]>(['slider'])
|
||||
/** پنلهای اسلایدر و داراییها بهصورت پیشفرض باز باشند */
|
||||
const sliderActiveKey = ref<(string | number)[]>(['slider', 'assets'])
|
||||
|
||||
watch(
|
||||
() => state.slider.length,
|
||||
(len) => {
|
||||
if (len > 0 && !sliderActiveKey.value.includes('slider')) {
|
||||
sliderActiveKey.value = ['slider']
|
||||
sliderActiveKey.value = [...sliderActiveKey.value, 'slider']
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -231,6 +344,39 @@ function onSliderRemove(index: number) {
|
||||
saveSoon('تصویر اسلاید حذف شد')
|
||||
}
|
||||
|
||||
function addAssetsRow() {
|
||||
if (!Array.isArray(state.assetsBanner)) {
|
||||
state.assetsBanner = []
|
||||
}
|
||||
state.assetsBanner.push({
|
||||
icon: null,
|
||||
show: true,
|
||||
caption: null,
|
||||
link: 'buyProduct',
|
||||
typeClick: 'link',
|
||||
modalText: null,
|
||||
})
|
||||
}
|
||||
|
||||
function removeAssetsRow(index: number) {
|
||||
state.assetsBanner.splice(index, 1)
|
||||
saveSoon('بنر دارایی حذف شد')
|
||||
}
|
||||
|
||||
function onAssetsUpload(index: number, url: string) {
|
||||
const item = state.assetsBanner[index]
|
||||
if (!item) return
|
||||
item.icon = url
|
||||
saveSoon('تصویر بنر دارایی ذخیره شد')
|
||||
}
|
||||
|
||||
function onAssetsRemove(index: number) {
|
||||
const item = state.assetsBanner[index]
|
||||
if (!item) return
|
||||
item.icon = null
|
||||
saveSoon('تصویر بنر دارایی حذف شد')
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
await save('اطلاعات با موفقیت ذخیره شد')
|
||||
}
|
||||
@@ -257,6 +403,10 @@ async function handleSubmit() {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.banners-page__collapse :deep(.ant-collapse-item + .ant-collapse-item) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.banners-page__collapse :deep(.ant-collapse-item) {
|
||||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
</div>
|
||||
|
||||
<MobileIconButton
|
||||
v-if="can('toggle')"
|
||||
:icon="item.sts === 2 ? 'vuesax-linear:card-tick' : 'vuesax-linear:card-remove'"
|
||||
:color="item.sts === 2 ? '#16A34A' : '#DC2626'"
|
||||
:size="20"
|
||||
@click="$emit('toggleSts', item)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="can('delete')"
|
||||
icon="vuesax-linear:trash"
|
||||
color="#DC2626"
|
||||
:size="20"
|
||||
@@ -34,6 +36,9 @@
|
||||
import type { Card } from '@/model/card'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
type AccountRow = Card & { sts_str?: string; created_at?: string; customer_id?: number }
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center items-center">
|
||||
<a-tooltip
|
||||
v-if="can('toggle')"
|
||||
:key="record.sts"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -25,7 +26,7 @@
|
||||
:color="record.sts !== 2 ? 'red' : 'green'"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom" class="cursor-pointer" @click="emits('delete', record.id)">
|
||||
<template #title>
|
||||
<span>حذف کارت</span>
|
||||
</template>
|
||||
@@ -63,6 +64,9 @@ import type { Card } from '@/model/card'
|
||||
import AccountMobileCardList from './AccountMobileCardList.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { cardsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const mobileListRef = ref<null | { fetch: () => Promise<void> }>(null)
|
||||
|
||||
@@ -99,7 +99,7 @@ export function getColleagueOrderColumns(): BaseTableColumn[] {
|
||||
type: 'Text'
|
||||
},
|
||||
{
|
||||
title: 'مقدار مشتری (گرم)',
|
||||
title: 'مقدار مشتری (کیلوگرم)',
|
||||
dataIndex: 'customer_amount',
|
||||
key: 'customer_amount',
|
||||
type: 'Number',
|
||||
@@ -107,7 +107,7 @@ export function getColleagueOrderColumns(): BaseTableColumn[] {
|
||||
customRender: ({ record }) => record.customer_amount ?? record.amount ?? '-'
|
||||
},
|
||||
{
|
||||
title: 'مقدار نزد همکار (گرم)',
|
||||
title: 'مقدار نزد همکار (کیلوگرم)',
|
||||
dataIndex: 'colleague_amount',
|
||||
key: 'colleague_amount',
|
||||
type: 'Number',
|
||||
@@ -124,7 +124,7 @@ export function getColleagueOrderColumns(): BaseTableColumn[] {
|
||||
return usePrice(record.service_charge_price ?? 0, true, '')
|
||||
}
|
||||
const gold = record.service_charge ?? 0
|
||||
return `${gold} گرم`
|
||||
return `${gold} کیلوگرم`
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -142,7 +142,7 @@ export function getColleagueOrderColumns(): BaseTableColumn[] {
|
||||
customRender: ({ record }) => usePrice(record.total_price ?? 0, true, '')
|
||||
},
|
||||
{
|
||||
title: 'نرخ همکار (ریال/گرم)',
|
||||
title: 'نرخ همکار (ریال/کیلوگرم)',
|
||||
dataIndex: 'colleague_unit_price',
|
||||
key: 'colleague_unit_price',
|
||||
type: 'Text',
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
<a-form-item label="شرط اجرا" name="price_condition" :rules="inputRules()">
|
||||
<a-radio-group v-model:value="form.price_condition">
|
||||
<a-radio value="gte">مساوی یا بیشتر از مظنه هدف</a-radio>
|
||||
<a-radio value="lte">مساوی یا کمتر از مظنه هدف</a-radio>
|
||||
<a-radio value="gte">مساوی یا بیشتر از قیمت هدف</a-radio>
|
||||
<a-radio value="lte">مساوی یا کمتر از قیمت هدف</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="مظنه هدف" name="trigger_price" :rules="inputRulesNumber()">
|
||||
<a-form-item label="قیمت هدف" name="trigger_price" :rules="inputRulesNumber()">
|
||||
<BasicInput
|
||||
v-model:value="form.trigger_price"
|
||||
type="price"
|
||||
@@ -44,7 +44,7 @@
|
||||
/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="مقدار (گرم یا تعداد)" name="amount" :rules="inputRulesNumber()">
|
||||
<a-form-item label="مقدار (کیلوگرم یا تعداد)" name="amount" :rules="inputRulesNumber()">
|
||||
<BasicInput v-model:value="form.amount" type="number" placeholder="مقدار" />
|
||||
</a-form-item>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<BaseTable v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -22,7 +22,7 @@
|
||||
@click="emits('edit', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom">
|
||||
<template #title>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</template>
|
||||
<Icon
|
||||
:icon="record.is_active ? 'vuesax-linear:eye-slash' : 'vuesax-linear:eye'"
|
||||
@@ -31,7 +31,7 @@
|
||||
@click="emits('toggle', record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom">
|
||||
<a-tooltip v-if="can('delete')" placement="bottom">
|
||||
<template #title>حذف</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:trash"
|
||||
@@ -54,6 +54,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { cols } from '../hooks/conditionalOrdersColumns'
|
||||
import { getConditionalOrdersTable } from '@/api/conditionalOrders'
|
||||
import { conditionalOrdersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export const cols: BaseTableColumn[] = [
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'مظنه هدف',
|
||||
title: 'قیمت هدف',
|
||||
dataIndex: 'trigger_price',
|
||||
key: 'trigger_price',
|
||||
type: 'Number'
|
||||
@@ -64,7 +64,7 @@ export const cols: BaseTableColumn[] = [
|
||||
key: 'amount',
|
||||
customRender: ({ record }) => {
|
||||
if (record.number != null && Number(record.number) > 0) return `${record.number} عدد`
|
||||
if (record.amount != null && Number(record.amount) > 0) return `${record.amount} گرم`
|
||||
if (record.amount != null && Number(record.amount) > 0) return `${record.amount} کیلوگرم`
|
||||
return '-'
|
||||
},
|
||||
},
|
||||
|
||||
@@ -210,7 +210,7 @@ import SettingCard from './SettingCard.vue'
|
||||
import { configurationPageIntro, websiteSettingsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { refreshAppModeMenu } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings, 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 {
|
||||
EDITABLE_SETTING_GROUPS,
|
||||
SYSTEM_SETTING_GROUPS,
|
||||
@@ -718,6 +718,11 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
setPriceTriggerEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_gift_card') {
|
||||
setGiftCardEnabledFromSettings(isSwitchOn(value))
|
||||
refreshMenuAfterStoreChange()
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_notification') {
|
||||
setAppNotificationEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
|
||||
@@ -15,6 +15,12 @@ export type SettingGroupDef = {
|
||||
|
||||
/** گروههای صفحه تنظیمات عادی (فقط can_edit=1) */
|
||||
export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
{
|
||||
id: 'digipay_installment',
|
||||
title: 'خرید اقساطی دیجیپی',
|
||||
icon: 'vuesax-linear:calendar',
|
||||
match: (k) => k === 'enable_digipay_installment' || k.startsWith('digipay_')
|
||||
},
|
||||
{
|
||||
id: 'general',
|
||||
title: 'عمومی و برند',
|
||||
@@ -265,6 +271,12 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
icon: 'vuesax-linear:document-text',
|
||||
match: (k) => k.startsWith('pargar_') || k === 'send_to_pargar'
|
||||
},
|
||||
{
|
||||
id: 'accounting_shayegan',
|
||||
title: 'حسابداری شایگان',
|
||||
icon: 'vuesax-linear:receipt-item',
|
||||
match: (k) => k.startsWith('shayegan_')
|
||||
},
|
||||
{
|
||||
id: 'price_channel',
|
||||
title: 'ارسال قیمت به کانال',
|
||||
@@ -304,9 +316,19 @@ export function resolveSettingMenu(
|
||||
row: { key?: string; menu?: string | null },
|
||||
groups: SettingGroupDef[]
|
||||
): string {
|
||||
const key = row.key || ''
|
||||
const fromKey = getSettingGroupId(key, groups)
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (menu && groups.some((g) => g.id === menu)) return menu
|
||||
return getSettingGroupId(row.key || '', groups)
|
||||
if (menu && groups.some((g) => g.id === menu)) {
|
||||
// menu= misc اشتباه در DB نباید shayegan_/zarin_/… را از گروه اختصاصی پنهان کند
|
||||
if (menu === 'misc' && fromKey !== 'misc') {
|
||||
return fromKey
|
||||
}
|
||||
|
||||
return menu
|
||||
}
|
||||
|
||||
return fromKey
|
||||
}
|
||||
|
||||
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمیآیند */
|
||||
|
||||
@@ -289,6 +289,7 @@ export const SETTING_TYPE_OPTIONS = [
|
||||
]
|
||||
|
||||
const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
closed_message: 'longtext',
|
||||
chart_use_local_data: 'switch',
|
||||
price_provider: 'select',
|
||||
referral_id: 'switch',
|
||||
@@ -648,11 +649,11 @@ const SETTING_UNIT_BY_KEY: Record<string, string> = {
|
||||
minimum_sell: 'ریال',
|
||||
price_channel_diff: 'ریال',
|
||||
referral_bonus_amount: 'ریال',
|
||||
gold_credit_penalty_amount: 'ریال / گرم',
|
||||
gift_for_referrer: 'گرم',
|
||||
gift_for_referral: 'گرم',
|
||||
gold_credit_min_balance_gram: 'گرم',
|
||||
change_mesghal: 'گرم',
|
||||
gold_credit_penalty_amount: 'ریال / کیلوگرم',
|
||||
gift_for_referrer: 'کیلوگرم',
|
||||
gift_for_referral: 'کیلوگرم',
|
||||
gold_credit_min_balance_gram: 'کیلوگرم',
|
||||
change_mesghal: 'کیلوگرم',
|
||||
fee_service_charge_percentage: 'درصد (اعشاری)',
|
||||
gold_credit_grace_hours: 'ساعت',
|
||||
gold_credit_default_months: 'ماه',
|
||||
@@ -735,6 +736,8 @@ export function parseSwitchHelp(help: string | undefined | null): SwitchHelpPart
|
||||
|
||||
/** توضیحات fallback — وقتی در کاتالوگ تعریف شده، بر description دیتابیس اولویت دارد */
|
||||
const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
closed_message:
|
||||
'متنی که هنگام بسته بودن فروشگاه در صفحه اصلی و هنگام معامله به کاربر نمایش داده میشود. اگر خالی باشد، پیام پیشفرض سیستم نشان داده میشود.',
|
||||
name_fa:
|
||||
'نام فارسی برند که در پیامکها، عنوان صفحات و بخشهای عمومی اپ به مشتری نشان داده میشود.',
|
||||
login_hero_eyebrow:
|
||||
@@ -762,13 +765,13 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
auto_active_customer:
|
||||
'روشن: بعد از ثبتنام، کاربر میتواند وارد اپ شود (بدون تأیید دستی ادمین). خاموش: ورود فقط بعد از فعالسازی دستی شما در پنل. این سوییچ اجازهٔ خرید/فروش نمیدهد — معامله فقط بعد از احراز هویت (is_legal) ممکن است.',
|
||||
close_price:
|
||||
'سوییچ اصلی ساعت کاری. خاموش: محدودیت ساعت اعمال نمیشود — اگر مظنه زنده باشد قیمت نشان داده میشود؛ اگر نباشد با «نمایش آخرین قیمت ذخیرهشده» آخرین قیمت میآید وگرنه «مظنه در دسترس نیست». روشن: فقط داخل بازهٔ یکسان یا برنامهٔ هفتگی همین منطق مظنه اعمال میشود؛ خارج از بازه با سوییچ «نمایش قیمت صفحه اصلی خارج از ساعت کاری» یا پیام «فروشگاه بسته است». خرید/فروش خارج از ساعت همیشه بسته است.',
|
||||
'سوییچ اصلی ساعت کاری. خاموش: محدودیت ساعت اعمال نمیشود — اگر قیمت زنده باشد قیمت نشان داده میشود؛ اگر نباشد با «نمایش آخرین قیمت ذخیرهشده» آخرین قیمت میآید وگرنه «قیمت در دسترس نیست». روشن: فقط داخل بازهٔ یکسان یا برنامهٔ هفتگی همین منطق قیمت اعمال میشود؛ خارج از بازه با سوییچ «نمایش قیمت صفحه اصلی خارج از ساعت کاری» یا پیام «فروشگاه بسته است». خرید/فروش خارج از ساعت همیشه بسته است.',
|
||||
startDay:
|
||||
'ساعت شروع فعالیت روزانه فروشگاه. فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن باشد و برنامه «یکسان برای همه روزها» باشد اعمال میشود.',
|
||||
endDay:
|
||||
'ساعت پایان فعالیت روزانه فروشگاه. فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن باشد و برنامه «یکسان برای همه روزها» باشد اعمال میشود.',
|
||||
show_last_price:
|
||||
'وقتی مظنه زنده نیست (و فروشگاه از نظر ساعت بسته حساب نمیشود): روشن = آخرین قیمت ذخیرهشده نشان داده شود. خاموش = پیام «مظنه در دسترس نیست».',
|
||||
'وقتی قیمت زنده نیست (و فروشگاه از نظر ساعت بسته حساب نمیشود): روشن = آخرین قیمت ذخیرهشده نشان داده شود. خاموش = پیام «قیمت در دسترس نیست».',
|
||||
show_home_price_when_closed:
|
||||
'فقط وقتی «بستن خودکار خارج از ساعت کاری» روشن است و الان خارج از بازه هستید. روشن: آخرین قیمت روی صفحه اصلی نشان داده میشود (معامله بسته میماند). خاموش: پیام «فروشگاه بسته است».',
|
||||
show_gold_ounce_price:
|
||||
@@ -794,7 +797,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
fee_service_charge_percentage:
|
||||
'درصد کارمزد هر معامله (اعشاری؛ مثلاً ۰٫۰۰۵). روی همهٔ سفارشها اعمال میشود و با اختلاف قیمت محصول یا buy_fee/sell_fee قاطی نمیشود. محصول مقداری: اگر مبلغ ریالی قفل باشد کارمزد از فلز، اگر وزن قفل باشد از ریال. محصول تعدادی: کارمزد فقط از ریال.',
|
||||
fee_deduct_from_gold:
|
||||
'این کلید دیگر روی محاسبه اثری ندارد. مبنای کارمزد اکنون فیلدی است که مشتری وارد میکند: اگر «مبلغ ریالی» را وارد کند (مثلاً دقیقاً ۱۰۰ میلیون ریال) همان مبلغ معامله میشود و کارمزد از طلا کسر میشود؛ اگر «وزن» را وارد کند (مثلاً دقیقاً ۲ گرم) همان وزن معامله میشود و کارمزد از ریال کسر میشود. این قانون برای خرید و فروش یکسان است.',
|
||||
'این کلید دیگر روی محاسبه اثری ندارد. مبنای کارمزد اکنون فیلدی است که مشتری وارد میکند: اگر «مبلغ ریالی» را وارد کند (مثلاً دقیقاً ۱۰۰ میلیون ریال) همان مبلغ معامله میشود و کارمزد از طلا کسر میشود؛ اگر «وزن» را وارد کند (مثلاً دقیقاً ۲ کیلوگرم) همان وزن معامله میشود و کارمزد از ریال کسر میشود. این قانون برای خرید و فروش یکسان است.',
|
||||
require_zero_main_gold_before_other_buy:
|
||||
'روشن: اگر مانده طلای کیف اصلی صفر یا زیر صفر باشد (بدهی)، مشتری ابتدا باید آبشده/مانده کیف اصلی را صفر کند و بعد میتواند محصول دیگر بخرد. خاموش: بدون این محدودیت. معامله خودِ محصولات کیف اصلی همیشه مجاز است.',
|
||||
fee_free:
|
||||
@@ -838,9 +841,9 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
referral_id:
|
||||
'روشن: وارد کردن کد معرف در ثبتنام اجباری است. خاموش: کد معرف اختیاری است.',
|
||||
gift_for_referrer:
|
||||
'مقدار پاداش (گرم) به کیف معرف. صفر = بدون پاداش. خرید پوشش از همکار با کلید «خرید پاداش معرفی از همکار» کنترل میشود.',
|
||||
'مقدار پاداش (کیلوگرم) به کیف معرف. صفر = بدون پاداش. خرید پوشش از همکار با کلید «خرید پاداش معرفی از همکار» کنترل میشود.',
|
||||
gift_for_referral:
|
||||
'مقدار پاداش (گرم) به معرفشونده. صفر = بدون پاداش. خرید پوشش از همکار با کلید «خرید پاداش معرفی از همکار» کنترل میشود.',
|
||||
'مقدار پاداش (کیلوگرم) به معرفشونده. صفر = بدون پاداش. خرید پوشش از همکار با کلید «خرید پاداش معرفی از همکار» کنترل میشود.',
|
||||
register_referral_sms_to_referrer:
|
||||
'روشن: پس از ثبتنام کاربر جدید، پیامک اطلاعرسانی برای معرف ارسال میشود. خاموش: پیامکی برای معرف ارسال نمیشود.',
|
||||
register_referral_bonus_message:
|
||||
@@ -1015,7 +1018,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
enable_gold_credit:
|
||||
'روشن: زیرمنوی اعتبار در مشتریان و صفحه اعتبار در اپ مشتری فعال میشود. خاموش: غیرفعال. فقط از سوپرادمین قابل تغییر است.',
|
||||
customer_special_pricing:
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی مظنه و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی قیمت و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
profit_gold_api_enabled:
|
||||
'روشن: محاسبه سود طلا از API خارجی فعال است. خاموش: محاسبه سود از API خارجی انجام نمیشود (حالت پیشفرض اکثر نصبها).',
|
||||
main_wallet_products:
|
||||
@@ -1087,7 +1090,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
zarin_gorohe_kar:
|
||||
'کد gorooheKar هنگام ساخت/جستجوی کار در زرین. اگر چند پنل یک زرین دارند، برای هر پنل گروه کار متفاوت بگذارید.',
|
||||
zarin_name_g:
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون مظنه فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون قیمت فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
zarin_uid_prefix:
|
||||
'پیشوند عددی uid برای جلوگیری از تداخل بین چند پنل روی یک زرین. فقط عدد (مثلاً ۱۱).',
|
||||
zarin_idbank:
|
||||
@@ -1101,7 +1104,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
main_product_price:
|
||||
'تنظیم قدیمی — از «منبع قیمت» استفاده کنید. روشن نگه داشتن توصیه نمیشود.',
|
||||
price_channel_enabled:
|
||||
'روشن: بعد از هر تغییر قیمت، مظنه بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
'روشن: بعد از هر تغییر قیمت، قیمت بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
price_channel_access:
|
||||
'روشن: گروه «ارسال قیمت به کانال» در تنظیمات عادی پنل دیده میشود. خاموش: مخفی است (فقط از تنظیمات پیشرفته).',
|
||||
price_channel_messengers:
|
||||
@@ -1127,11 +1130,12 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
rubika_bot_token:
|
||||
'توکن ربات روبیکا برای ارسال قیمت به کانال. محرمانه نگه دارید.',
|
||||
change_mesghal:
|
||||
'وزن هر مثقال به گرم؛ برای نمایش خط «هر مثقال» در پیام کانال (مثقال = قیمت هر گرم × این عدد، پیشفرض ۴٫۳۳۱۸).'
|
||||
'وزن هر مثقال به کیلوگرم؛ برای نمایش خط «هر مثقال» در پیام کانال (مثقال = قیمت هر کیلوگرم × این عدد، پیشفرض ۴٫۳۳۱۸).'
|
||||
}
|
||||
|
||||
/** برچسب فارسی — وقتی در کاتالوگ تعریف شده، بر title_fa دیتابیس اولویت دارد */
|
||||
export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
closed_message: 'متن پیام بسته بودن فروشگاه',
|
||||
close_price: 'بستن خودکار خارج از ساعت کاری',
|
||||
startDay: 'ساعت شروع',
|
||||
endDay: 'ساعت پایان',
|
||||
@@ -1196,7 +1200,7 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
gold_credit_penalty_amount: 'مبلغ جریمه روزانه اعتبار طلایی',
|
||||
gold_credit_grace_hours: 'مهلت پرداخت بعد از سررسید (ساعت)',
|
||||
gold_credit_default_months: 'تعداد ماه پیشفرض اعتبار طلایی',
|
||||
gold_credit_min_balance_gram: 'حداقل موجودی طلا برای درخواست (گرم)',
|
||||
gold_credit_min_balance_gram: 'حداقل موجودی طلا برای درخواست (کیلوگرم)',
|
||||
gold_credit_overdue_sms_enabled: 'SMS هشدار سررسید اعتبار طلایی',
|
||||
gold_credit_admin_sms_enabled: 'پیامک ادمین اعتبار طلایی',
|
||||
gold_credit_upcoming_sms_enabled: 'یادآوری سررسید قسط اعتبار',
|
||||
@@ -1304,7 +1308,7 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
price_channel_rubika_to: 'مقصد ارسال روبیکا',
|
||||
price_channel_message_text: 'قالب متن پیام کانال',
|
||||
rubika_bot_token: 'توکن بات روبیکا',
|
||||
change_mesghal: 'وزن مثقال (گرم)'
|
||||
change_mesghal: 'وزن مثقال (کیلوگرم)'
|
||||
}
|
||||
|
||||
/** غیرقابل ویرایش در پنل عادی (can_edit=0) — در تنظیمات پیشرفته قابل ویرایش (ادمین دیپلوی) */
|
||||
|
||||
@@ -49,8 +49,8 @@ const PRICE_CHANNEL_DEFAULT = [
|
||||
'%عنوان',
|
||||
'📅 %تاریخ 🕐 %ساعت',
|
||||
'',
|
||||
'🔴 خرید گرم: %گرم_خرید',
|
||||
'🟢 فروش گرم: %گرم_فروش',
|
||||
'🔴 خرید کیلوگرم: %گرم_خرید',
|
||||
'🟢 فروش کیلوگرم: %گرم_فروش',
|
||||
'🔴 خرید مثقال: %مثقال_خرید',
|
||||
'🟢 فروش مثقال: %مثقال_فروش',
|
||||
'',
|
||||
@@ -96,8 +96,8 @@ export const TEMPLATE_FIELD_CONFIGS: Record<string, TemplateFieldConfig> = {
|
||||
title: 'قیمت تابلو',
|
||||
color: '#d4af37',
|
||||
items: [
|
||||
{ token: 'گرم_خرید', label: 'خرید هر گرم', help: 'قیمت خرید هر گرم' },
|
||||
{ token: 'گرم_فروش', label: 'فروش هر گرم', help: 'قیمت فروش هر گرم (عدد بزرگ صفحهٔ اصلی اپ)' },
|
||||
{ token: 'گرم_خرید', label: 'خرید هر کیلوگرم', help: 'قیمت خرید هر کیلوگرم' },
|
||||
{ token: 'گرم_فروش', label: 'فروش هر کیلوگرم', help: 'قیمت فروش هر کیلوگرم (عدد بزرگ صفحهٔ اصلی اپ)' },
|
||||
{ token: 'مثقال_خرید', label: 'خرید هر مثقال', help: 'قیمت خرید هر مثقال' },
|
||||
{ token: 'مثقال_فروش', label: 'فروش هر مثقال', help: 'قیمت فروش هر مثقال' },
|
||||
],
|
||||
|
||||
@@ -7,6 +7,7 @@ export const TRADING_HOURS_SETTING_KEYS = [
|
||||
'show_home_price_when_closed',
|
||||
'show_gold_ounce_price',
|
||||
'trading_hours_by_day',
|
||||
'closed_message',
|
||||
] as const
|
||||
|
||||
export type TradingHoursSettingKey = (typeof TRADING_HOURS_SETTING_KEYS)[number]
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<MobileCardList
|
||||
v-model:search="search"
|
||||
:loading="loading"
|
||||
:has-more="hasMore"
|
||||
:show-empty="!loading && items.length === 0"
|
||||
empty-text="درخواستی یافت نشد"
|
||||
search-placeholder="جستجو مشتری، موبایل یا وضعیت"
|
||||
show-refresh
|
||||
@search="reload"
|
||||
@refresh="reload"
|
||||
@load-more="loadMore"
|
||||
>
|
||||
<CopperConvertMobileListItem
|
||||
v-for="item in items"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:busy="busyId === item.id"
|
||||
:can-edit="can('edit')"
|
||||
@approve="approve(item)"
|
||||
@reject="reject(item)"
|
||||
/>
|
||||
</MobileCardList>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import MobileCardList from '@/components/mobile/MobileCardList.vue'
|
||||
import { useMobileTableList } from '@/components/mobile/composables/useMobileTableList'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
import { fetchCopperConvertTable, useCopperConvertActions } from '../copperConvertTable'
|
||||
import CopperConvertMobileListItem from './CopperConvertMobileListItem.vue'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
const { loading, search, items, hasMore, reload, loadMore, fetch } = useMobileTableList({
|
||||
fetchApi: fetchCopperConvertTable
|
||||
})
|
||||
const { busyId, approve, reject } = useCopperConvertActions(reload)
|
||||
|
||||
onMounted(() => {
|
||||
void reload()
|
||||
})
|
||||
|
||||
defineExpose({ fetch })
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<MobileCard>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-700 text-gray-900">{{ item.customer_name }}</div>
|
||||
<div class="text-xs text-gray-500">{{ item.customer_mobile || '-' }}</div>
|
||||
</div>
|
||||
<CustomTag class="shrink-0" :text-color="colors.text" :bg-color="colors.bg">
|
||||
{{ item.status_label }}
|
||||
</CustomTag>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-x-3 gap-y-1 text-xs">
|
||||
<span class="text-gray-600">دارایی: <span class="font-600 text-gray-900">{{ item.source_label }}</span></span>
|
||||
<span class="text-gray-600">واحد: <span class="font-600 text-gray-900">{{ item.asset_unit }}</span></span>
|
||||
<span class="text-gray-600">حلقه ۱.۵: <span class="font-600 text-gray-900">{{ item.wire15_rings }}</span></span>
|
||||
<span class="text-gray-600">حلقه ۲.۵: <span class="font-600 text-gray-900">{{ item.wire25_rings }}</span></span>
|
||||
<span class="text-gray-600">مقدار فروش: <span class="font-600 text-gray-900">{{ item.consumed_amount }}</span></span>
|
||||
<span class="text-gray-600">مانده: <span class="font-600 text-gray-900">{{ item.leftover_amount }}</span></span>
|
||||
</div>
|
||||
|
||||
<div class="text-xs text-gray-400">{{ item.created_label }}</div>
|
||||
|
||||
<div v-if="item.status === 'pending' && canEdit" class="grid grid-cols-2 gap-2">
|
||||
<BaseButton type="primary" size="small" :loading="busy" @click="$emit('approve')">تأیید</BaseButton>
|
||||
<BaseButton size="small" :loading="busy" @click="$emit('reject')">رد</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</MobileCard>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { statusColors, type CopperConvertTableRow } from '../copperConvertTable'
|
||||
|
||||
const props = defineProps<{
|
||||
item: CopperConvertTableRow
|
||||
busy?: boolean
|
||||
canEdit?: boolean
|
||||
}>()
|
||||
|
||||
defineEmits<{
|
||||
(e: 'approve'): void
|
||||
(e: 'reject'): void
|
||||
}>()
|
||||
|
||||
const colors = computed(() => statusColors(props.item.status))
|
||||
</script>
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div class="min-w-0 w-full max-w-full overflow-x-hidden">
|
||||
<BasicShowContext title="درخواست تبدیل" :help="copperConvertPageIntro">
|
||||
<div v-if="!isMobile" class="min-w-0 w-full max-w-full overflow-x-auto">
|
||||
<BaseTable v-bind="tblProps" @register="submit">
|
||||
<template #status="{ record }">
|
||||
<div class="flex justify-center">
|
||||
<CustomTag :text-color="statusColors(record.status).text" :bg-color="statusColors(record.status).bg">
|
||||
{{ record.status_label }}
|
||||
</CustomTag>
|
||||
</div>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div v-if="record.status === 'pending' && can('edit')" class="flex justify-center gap-2">
|
||||
<BaseButton type="primary" size="small" :loading="busyId === record.id" @click="approve(record)">
|
||||
تأیید
|
||||
</BaseButton>
|
||||
<BaseButton size="small" :loading="busyId === record.id" @click="reject(record)">رد</BaseButton>
|
||||
</div>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</BaseTable>
|
||||
</div>
|
||||
<CopperConvertMobileCardList v-else />
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { BaseTableColumn } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { copperConvertPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
import CopperConvertMobileCardList from './CopperConvertMobileCardList.vue'
|
||||
import { fetchCopperConvertTable, statusColors, useCopperConvertActions } from '../copperConvertTable'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
const [submit, reload] = useBaseTable()
|
||||
const { busyId, approve, reject } = useCopperConvertActions(reload)
|
||||
|
||||
const columns: BaseTableColumn[] = [
|
||||
{
|
||||
title: 'شناسه',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
type: 'Number',
|
||||
width: 80,
|
||||
sortField: 'id',
|
||||
filterField: 'id'
|
||||
},
|
||||
{
|
||||
title: 'مشتری',
|
||||
dataIndex: 'customer_name',
|
||||
key: 'customer_name',
|
||||
type: 'Text',
|
||||
sortField: 'customer_name',
|
||||
filterField: 'customer_name'
|
||||
},
|
||||
{
|
||||
title: 'موبایل',
|
||||
dataIndex: 'customer_mobile',
|
||||
key: 'customer_mobile',
|
||||
type: 'Text',
|
||||
sortField: 'customer_mobile',
|
||||
filterField: 'customer_mobile'
|
||||
},
|
||||
{
|
||||
title: 'دارایی',
|
||||
dataIndex: 'source_label',
|
||||
key: 'source_label',
|
||||
type: 'Text',
|
||||
sortField: 'source_label',
|
||||
filterField: 'source_label'
|
||||
},
|
||||
{
|
||||
title: 'حلقه ۱.۵',
|
||||
dataIndex: 'wire15_rings',
|
||||
key: 'wire15_rings',
|
||||
type: 'Number',
|
||||
sortField: 'wire15_rings',
|
||||
filterField: 'wire15_rings'
|
||||
},
|
||||
{
|
||||
title: 'حلقه ۲.۵',
|
||||
dataIndex: 'wire25_rings',
|
||||
key: 'wire25_rings',
|
||||
type: 'Number',
|
||||
sortField: 'wire25_rings',
|
||||
filterField: 'wire25_rings'
|
||||
},
|
||||
{
|
||||
title: 'مقدار فروش',
|
||||
dataIndex: 'consumed_amount',
|
||||
key: 'consumed_amount',
|
||||
type: 'Number',
|
||||
sortField: 'consumed_amount',
|
||||
filterField: 'consumed_amount'
|
||||
},
|
||||
{
|
||||
title: 'مانده',
|
||||
dataIndex: 'leftover_amount',
|
||||
key: 'leftover_amount',
|
||||
type: 'Number',
|
||||
sortField: 'leftover_amount',
|
||||
filterField: 'leftover_amount'
|
||||
},
|
||||
{
|
||||
title: 'واحد',
|
||||
dataIndex: 'asset_unit',
|
||||
key: 'asset_unit',
|
||||
type: 'Text',
|
||||
sortField: 'asset_unit',
|
||||
filterField: 'asset_unit'
|
||||
},
|
||||
{
|
||||
title: 'وضعیت',
|
||||
dataIndex: 'status_label',
|
||||
key: 'status',
|
||||
type: 'Text',
|
||||
sortField: 'status_label',
|
||||
filterField: 'status_label',
|
||||
slot: 'status'
|
||||
},
|
||||
{
|
||||
title: 'تاریخ',
|
||||
dataIndex: 'created_label',
|
||||
key: 'created_label',
|
||||
type: 'Text',
|
||||
sortField: 'created_at',
|
||||
filterField: 'created_label'
|
||||
},
|
||||
{
|
||||
title: 'عملیات',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
slot: 'action',
|
||||
filterable: false,
|
||||
sortable: false
|
||||
}
|
||||
]
|
||||
|
||||
const tblProps = ref({
|
||||
columns,
|
||||
api: fetchCopperConvertTable
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,170 @@
|
||||
import { ref } from 'vue'
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import type { Filter, TableInput, TableOutput } from '@core/type/baseTable'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
approveCopperConvertRequest,
|
||||
getCopperConvertRequests,
|
||||
rejectCopperConvertRequest,
|
||||
type CopperConvertRequestRow
|
||||
} from '@/api/copperConvert'
|
||||
|
||||
export type CopperConvertTableRow = CopperConvertRequestRow & {
|
||||
source_label: string
|
||||
status_label: string
|
||||
created_label: string
|
||||
}
|
||||
|
||||
const numericKeys = new Set(['id', 'wire15_rings', 'wire25_rings', 'consumed_amount', 'leftover_amount'])
|
||||
|
||||
export function sourceLabel(source: string) {
|
||||
if (source === 'katod') return 'کاتد'
|
||||
if (source === 'maftoul') return 'مفتول'
|
||||
if (source === 'shamsh') return 'شمش'
|
||||
return source
|
||||
}
|
||||
|
||||
export function statusLabel(status: string) {
|
||||
if (status === 'pending') return 'در انتظار'
|
||||
if (status === 'approved') return 'تأیید شده'
|
||||
if (status === 'rejected') return 'رد شده'
|
||||
return status
|
||||
}
|
||||
|
||||
export function statusColors(status: string) {
|
||||
if (status === 'approved') return { text: '#25855A', bg: '#E3F4E9' }
|
||||
if (status === 'rejected') return { text: '#C53030', bg: '#FECACA' }
|
||||
return { text: '#B45309', bg: '#FEF3C7' }
|
||||
}
|
||||
|
||||
function decorate(row: CopperConvertRequestRow): CopperConvertTableRow {
|
||||
return {
|
||||
...row,
|
||||
source_label: sourceLabel(row.source),
|
||||
status_label: statusLabel(row.status),
|
||||
created_label: row.created_at ? toJalali(row.created_at) : '-'
|
||||
}
|
||||
}
|
||||
|
||||
function asText(value: unknown) {
|
||||
return value == null ? '' : String(value).toLowerCase()
|
||||
}
|
||||
|
||||
function matchFilter(row: Record<string, unknown>, filter: Filter) {
|
||||
const raw = row[filter.field]
|
||||
const op = filter.op
|
||||
const value = filter.value
|
||||
if (op === 'null') return raw == null || raw === ''
|
||||
if (op === 'nn') return raw != null && raw !== ''
|
||||
if (value === '' || value == null) return true
|
||||
if (op === 'bet' && Array.isArray(value)) {
|
||||
const n = Number(raw)
|
||||
return n >= Number(value[0]) && n <= Number(value[1])
|
||||
}
|
||||
if (op === 'in' && Array.isArray(value)) {
|
||||
return value.map(String).includes(String(raw ?? ''))
|
||||
}
|
||||
const text = asText(raw)
|
||||
const needle = asText(value)
|
||||
if (op === 'eq') return text === needle
|
||||
if (op === 'not') return text !== needle
|
||||
if (op === 'sw') return text.startsWith(needle)
|
||||
if (op === 'ew') return text.endsWith(needle)
|
||||
if (op === 'has' || op == null) return text.includes(needle)
|
||||
const left = Number(raw)
|
||||
const right = Number(value)
|
||||
if (!Number.isFinite(left) || !Number.isFinite(right)) return false
|
||||
if (op === 'gt') return left > right
|
||||
if (op === 'lt') return left < right
|
||||
if (op === 'gte') return left >= right
|
||||
if (op === 'lte') return left <= right
|
||||
return true
|
||||
}
|
||||
|
||||
function queryRows(rows: CopperConvertTableRow[], params: TableInput): TableOutput<CopperConvertTableRow> {
|
||||
const search = (params.search ?? '').trim().toLowerCase()
|
||||
let list = rows.filter((row) => {
|
||||
if (!search) return true
|
||||
return [row.customer_name, row.customer_mobile, row.source_label, row.status_label, row.asset_unit, row.created_label]
|
||||
.join(' ')
|
||||
.toLowerCase()
|
||||
.includes(search)
|
||||
})
|
||||
for (const filter of params.filters ?? []) {
|
||||
if (!filter.field) continue
|
||||
list = list.filter((row) => matchFilter(row as unknown as Record<string, unknown>, filter))
|
||||
}
|
||||
const sortKey = params.sort?.key
|
||||
if (sortKey) {
|
||||
const dir = params.sort?.order === 'desc' ? -1 : 1
|
||||
list = [...list].sort((a, b) => {
|
||||
const av = (a as Record<string, unknown>)[sortKey]
|
||||
const bv = (b as Record<string, unknown>)[sortKey]
|
||||
if (numericKeys.has(sortKey)) return (Number(av) - Number(bv)) * dir
|
||||
return String(av ?? '').localeCompare(String(bv ?? ''), 'fa') * dir
|
||||
})
|
||||
}
|
||||
const page = params.page || 1
|
||||
const limit = params.limit || 10
|
||||
return {
|
||||
rows: list.slice((page - 1) * limit, page * limit),
|
||||
query: {
|
||||
...params,
|
||||
page,
|
||||
limit,
|
||||
total: list.length,
|
||||
search: params.search ?? null,
|
||||
filters: params.filters ?? []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchCopperConvertTable(params: TableInput) {
|
||||
const data = await getCopperConvertRequests()
|
||||
const rows = (Array.isArray(data) ? data : []).map(decorate)
|
||||
return queryRows(rows, params)
|
||||
}
|
||||
|
||||
export function useCopperConvertActions(reload: () => unknown) {
|
||||
const busyId = ref(0)
|
||||
|
||||
function approve(row: CopperConvertRequestRow) {
|
||||
Modal.confirm({
|
||||
title: 'تأیید تبدیل',
|
||||
content: 'دارایی مشتری فروخته و حلقههای سیم برای او خریداری شود؟',
|
||||
okText: 'تأیید',
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
busyId.value = row.id
|
||||
try {
|
||||
await approveCopperConvertRequest(row.id)
|
||||
message.success('تبدیل ثبت شد')
|
||||
await reload()
|
||||
} finally {
|
||||
busyId.value = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function reject(row: CopperConvertRequestRow) {
|
||||
Modal.confirm({
|
||||
title: 'رد درخواست',
|
||||
content: 'این درخواست تبدیل رد شود؟',
|
||||
okText: 'رد',
|
||||
cancelText: 'انصراف',
|
||||
async onOk() {
|
||||
busyId.value = row.id
|
||||
try {
|
||||
await rejectCopperConvertRequest(row.id)
|
||||
message.success('درخواست رد شد')
|
||||
await reload()
|
||||
} finally {
|
||||
busyId.value = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { busyId, approve, reject }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<BasicMainCard>
|
||||
<div class="flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden">
|
||||
<tbl class="min-h-0 flex-1" />
|
||||
</div>
|
||||
</BasicMainCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import tbl from './components/table.vue'
|
||||
</script>
|
||||
@@ -4,12 +4,14 @@
|
||||
<div class="flex min-w-0 flex-1 items-center gap-2">
|
||||
<BaseIcon icon="vuesax-linear:user" size="20" color="#6b7280" />
|
||||
<button
|
||||
v-if="can('info')"
|
||||
type="button"
|
||||
class="truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900 cursor-pointer"
|
||||
@click.stop="$emit('info', item)"
|
||||
>
|
||||
{{ item.name || '-' }}
|
||||
</button>
|
||||
<span v-else class="truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||
</div>
|
||||
|
||||
<div class="shrink-0 text-sm text-gray-600">{{ item.mobile || '-' }}</div>
|
||||
@@ -19,6 +21,7 @@
|
||||
{{ item.type_str || 'کاربر' }}
|
||||
</span>
|
||||
<MobileIconButton
|
||||
v-if="can('restore')"
|
||||
icon="vuesax-linear:archive-slash"
|
||||
color="#e3bf00"
|
||||
:size="20"
|
||||
@@ -34,6 +37,9 @@
|
||||
import type { Customer } from '@/model/customer'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import MobileIconButton from '@/components/mobile/MobileIconButton.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
item: Customer
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<BaseTable v-if="!isMobile" class="h-full min-h-0 min-w-0" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<a-tooltip v-if="can('restore')" :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<template #title>
|
||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||
</template>
|
||||
@@ -20,7 +20,7 @@
|
||||
</a-popconfirm>
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title><span>مشخصات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
@@ -52,6 +52,9 @@ import useBaseTable from '@core/components/BaseTable/hooks/useBaseTable'
|
||||
import type { TableInput } from '@core/type/baseTable'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { customersArchivePageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'charge'])
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
title="نام قلک"
|
||||
:value="item?.fund ? item?.fund?.title : metalLabel.goldWallet()"
|
||||
/>
|
||||
<BasicInfoItem :title="metalLabel.goldAmount()" :value="`${item?.gold} گرم`" />
|
||||
<BasicInfoItem :title="metalLabel.goldAmount()" :value="`${item?.gold} کیلوگرم`" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -97,7 +97,9 @@ const visibleProxy = computed({
|
||||
function currentCodeOf(customer: Customer | null): string {
|
||||
if (!customer) return ''
|
||||
if (props.provider === 'pargar') return displayAccountingCode(customer.pargar_account_id)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin') return displayAccountingCode(customer.moshtari_code)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin' || props.provider === 'shayegan') {
|
||||
return displayAccountingCode(customer.moshtari_code)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -163,7 +165,7 @@ async function onDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
|
||||
async function submit() {
|
||||
if (!props.customer?.id) return
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin') {
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin' && props.provider !== 'shayegan') {
|
||||
message.error('حسابداری فعال نیست.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
</section>
|
||||
|
||||
<BaseButton
|
||||
v-if="can('charge')"
|
||||
class="customer-mobile-sheet__charge-btn"
|
||||
size="middle"
|
||||
type="primary"
|
||||
@@ -39,7 +40,7 @@
|
||||
|
||||
<div class="customer-mobile-sheet__actions">
|
||||
<BaseButton
|
||||
v-if="accountingCodeLabel"
|
||||
v-if="can('accountingCode') && accountingCodeLabel"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:card-edit"
|
||||
@@ -47,14 +48,14 @@
|
||||
>
|
||||
کد حسابداری
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
<BaseButton v-if="can('info')" size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
مشخصات
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
<BaseButton v-if="can('edit')" size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
ویرایش
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerLevelProfitEnabled"
|
||||
v-if="can('referral') && customerLevelProfitEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:hierarchy-2"
|
||||
@@ -62,11 +63,11 @@
|
||||
>
|
||||
سود چندسطحی
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
<BaseButton v-if="can('archive')" size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
بایگانی
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerDirectSmsEnabled"
|
||||
v-if="can('sms') && customerDirectSmsEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:sms"
|
||||
@@ -75,7 +76,7 @@
|
||||
پیامک
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="!row.is_legal"
|
||||
v-if="can('approve') && !row.is_legal"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:user-search"
|
||||
@@ -84,6 +85,7 @@
|
||||
تایید
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('active')"
|
||||
size="small"
|
||||
:type="row.active ? 'default' : 'primary'"
|
||||
:icon="row.active ? 'vuesax-linear:user-remove' : 'vuesax-linear:user-tick'"
|
||||
@@ -92,6 +94,7 @@
|
||||
{{ row.active ? 'غیرفعال' : 'فعال' }}
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('trade')"
|
||||
size="small"
|
||||
:type="row.trade_active === 1 ? 'default' : 'primary'"
|
||||
:icon="row.trade_active === 1 ? 'vuesax-linear:box-remove' : 'vuesax-linear:box-tick'"
|
||||
@@ -135,6 +138,9 @@ import {
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode } from '@/utils/accountingCode'
|
||||
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
<div class="min-w-0 flex-1 space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
v-if="can('info')"
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900"
|
||||
@click.stop="$emit('info', item)"
|
||||
>
|
||||
{{ item.name || '-' }}
|
||||
</button>
|
||||
<span v-else class="min-w-0 flex-1 truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||
<span
|
||||
class="inline-block h-2.5 w-2.5 shrink-0 rounded-full"
|
||||
:class="item.active ? 'bg-green-500' : 'bg-red-500'"
|
||||
@@ -41,6 +43,7 @@
|
||||
عملیات
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('edit')"
|
||||
type="default"
|
||||
size="small"
|
||||
class="min-w-[4.5rem]"
|
||||
@@ -57,6 +60,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { Customer } from '@/model/customer'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
item: Customer
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<div v-if="tx.remainGold || tx.remainRial" class="flex justify-between gap-2">
|
||||
<span class="text-gray-500">مانده</span>
|
||||
<span class="text-left">
|
||||
{{ tx.remainGold ? `${tx.remainGold} گرم` : '' }}
|
||||
{{ tx.remainGold ? `${tx.remainGold} کیلوگرم` : '' }}
|
||||
{{ tx.remainRial ? `${tx.remainRial} ریال` : '' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -86,7 +86,7 @@ const props = withDefaults(
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
const resolvedUnit = computed(
|
||||
() => props.unitLabel ?? (props.variant === 'money' ? 'ریال' : 'گرم'),
|
||||
() => props.unitLabel ?? (props.variant === 'money' ? 'ریال' : 'کیلوگرم'),
|
||||
)
|
||||
const isMoney = computed(() => props.isMoney ?? props.variant === 'money')
|
||||
/** نقدی و تعدادی — بدون اعشار */
|
||||
|
||||
@@ -127,7 +127,7 @@ const isIntegerOnlyTarget = computed(() => {
|
||||
const chargeUnitLabel = computed(() => {
|
||||
if (props.selectedTarget?.kind === 'money') return 'ریال'
|
||||
if (isIntegerOnlyTarget.value) return 'عدد'
|
||||
return props.selectedTarget?.unit ?? 'گرم'
|
||||
return props.selectedTarget?.unit ?? 'کیلوگرم'
|
||||
})
|
||||
|
||||
function filterCustomer(input: string, option?: { label?: string }) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{{ displayName }}
|
||||
</span>
|
||||
<span class="bg-amber-50 text-amber-800 px-3 py-1.5 rounded-full font-medium">
|
||||
اعتبار: {{ credit.gold_amount }} گرم
|
||||
اعتبار: {{ credit.gold_amount }} کیلوگرم
|
||||
</span>
|
||||
<span class="bg-blue-50 text-blue-800 px-3 py-1.5 rounded-full font-medium">
|
||||
{{ credit.months }} ماه
|
||||
@@ -22,7 +22,7 @@
|
||||
{{ statusLabel(credit.status) }}
|
||||
</span>
|
||||
<span class="bg-slate-100 text-slate-700 px-3 py-1.5 rounded-full font-medium">
|
||||
پرداختشده: {{ Number(credit.paid_gold ?? 0).toFixed(4) }} گرم
|
||||
پرداختشده: {{ Number(credit.paid_gold ?? 0).toFixed(4) }} کیلوگرم
|
||||
</span>
|
||||
<span
|
||||
v-if="Number(credit.paid_rial) > 0"
|
||||
@@ -51,7 +51,7 @@
|
||||
جریمه دیرکرد:
|
||||
{{
|
||||
credit.penalty_type === 'gold'
|
||||
? `${credit.penalty_amount} گرم در روز`
|
||||
? `${credit.penalty_amount} کیلوگرم در روز`
|
||||
: `${Number(credit.penalty_amount || 0).toLocaleString('fa-IR')} ریال در روز`
|
||||
}}
|
||||
· مهلت {{ credit.grace_hours ?? 24 }} ساعت
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="flex justify-between items-center mb-4 flex-wrap gap-2">
|
||||
<div v-if="creditSummary" class="flex gap-2 flex-wrap text-sm">
|
||||
<span class="bg-amber-50 text-amber-800 px-3 py-1 rounded-full font-medium">
|
||||
اعتبار: {{ creditSummary.gold_amount }} گرم
|
||||
اعتبار: {{ creditSummary.gold_amount }} کیلوگرم
|
||||
</span>
|
||||
<span class="bg-blue-50 text-blue-800 px-3 py-1 rounded-full font-medium">
|
||||
{{ creditSummary.months }} ماه
|
||||
@@ -37,7 +37,7 @@
|
||||
جریمه:
|
||||
{{
|
||||
creditSummary.penalty_type === 'gold'
|
||||
? `${creditSummary.penalty_amount} گرم/روز`
|
||||
? `${creditSummary.penalty_amount} کیلوگرم/روز`
|
||||
: `${Number(creditSummary.penalty_amount || 0).toLocaleString('fa-IR')} ریال/روز`
|
||||
}}
|
||||
· مهلت {{ creditSummary.grace_hours ?? 24 }}س
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
>
|
||||
<a-form :model="form" ref="formRef" autocomplete="off" layout="vertical">
|
||||
<div class="grid md:grid-cols-2 gap-3">
|
||||
<a-form-item label="مقدار طلا (گرم)" name="gold_amount" :rules="inputRules('مقدار طلا')">
|
||||
<a-form-item label="مقدار طلا (کیلوگرم)" name="gold_amount" :rules="inputRules('مقدار طلا')">
|
||||
<BasicInput v-model:value="form.gold_amount" type="number" @change="loadPreview" />
|
||||
</a-form-item>
|
||||
<a-form-item label="تعداد ماه" name="months" :rules="inputRules('تعداد ماه')">
|
||||
@@ -35,7 +35,7 @@
|
||||
<BasicInput
|
||||
v-model:value="form.interest_value"
|
||||
type="number"
|
||||
:addon-before="form.interest_type === 'percent' ? '%' : 'گرم'"
|
||||
:addon-before="form.interest_type === 'percent' ? '%' : 'کیلوگرم'"
|
||||
@change="loadPreview"
|
||||
/>
|
||||
</a-form-item>
|
||||
@@ -83,7 +83,7 @@
|
||||
<BasicInput
|
||||
v-model:value="form.penalty_amount"
|
||||
type="number"
|
||||
:addon-before="form.penalty_type === 'gold' ? 'گرم' : 'ریال'"
|
||||
:addon-before="form.penalty_type === 'gold' ? 'کیلوگرم' : 'ریال'"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="مهلت بعد از سررسید (ساعت)" name="grace_hours">
|
||||
@@ -111,7 +111,7 @@
|
||||
<div class="grid grid-cols-3 gap-2 text-center text-sm mb-2 font-medium text-gray-600">
|
||||
<div>ماه</div>
|
||||
<div>مبلغ (سوت)</div>
|
||||
<div>جمع (گرم)</div>
|
||||
<div>جمع (کیلوگرم)</div>
|
||||
</div>
|
||||
<div
|
||||
v-for="item in preview.slice(0, 6)"
|
||||
@@ -127,7 +127,7 @@
|
||||
</div>
|
||||
<div class="mt-3 pt-3 border-t border-amber-100 flex justify-between font-bold text-amber-900">
|
||||
<span>مجموع قابل پرداخت:</span>
|
||||
<span>{{ totalPayable?.toFixed(4) }} گرم</span>
|
||||
<span>{{ totalPayable?.toFixed(4) }} کیلوگرم</span>
|
||||
</div>
|
||||
</div>
|
||||
</BasicModal>
|
||||
@@ -190,7 +190,7 @@ const totalPayable = ref(0)
|
||||
const interestTypes: Item[] = [
|
||||
{ key: 'none', value: 'بدون سود' },
|
||||
{ key: 'percent', value: 'درصد ماهانه' },
|
||||
{ key: 'fixed_gram', value: 'گرم ثابت در ماه' },
|
||||
{ key: 'fixed_gram', value: 'کیلوگرم ثابت در ماه' },
|
||||
]
|
||||
|
||||
const deliveryMethods: Item[] = [
|
||||
@@ -201,7 +201,7 @@ const deliveryMethods: Item[] = [
|
||||
|
||||
const penaltyTypes: Item[] = [
|
||||
{ key: 'rial', value: 'ریالی (روزانه)' },
|
||||
{ key: 'gold', value: 'طلایی (گرم روزانه)' },
|
||||
{ key: 'gold', value: 'طلایی (کیلوگرم روزانه)' },
|
||||
]
|
||||
|
||||
function defaultForm(): GoldCreditForm {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
</template>
|
||||
<template #accountingCode="{ record }">
|
||||
<button
|
||||
v-if="can('accountingCode')"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 border-none bg-transparent p-0 text-sm cursor-pointer"
|
||||
style="color: var(--admin-text)"
|
||||
@@ -29,10 +30,11 @@
|
||||
<span dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||
<Icon icon="vuesax-linear:edit-2" size="16" color="#4572E9" />
|
||||
</button>
|
||||
<span v-else dir="ltr">{{ accountingCodeOf(record) }}</span>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="gap-2 hidden md:flex justify-center">
|
||||
<a-tooltip :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<a-tooltip v-if="can('archive')" :key="record.is_archive" placement="bottom" class="cursor-pointer">
|
||||
<template #title>
|
||||
<span>{{ record.is_archive ? 'بیرون بردن از بایگانی' : 'بایگانی کردن' }}</span>
|
||||
</template>
|
||||
@@ -47,6 +49,7 @@
|
||||
</a-popconfirm>
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('active')"
|
||||
:key="record.active"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -60,12 +63,12 @@
|
||||
:color="record.active ? '#54AD06' : '#ad0627'"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('chargeWallet', record)">
|
||||
<a-tooltip v-if="can('charge')" placement="bottom" class="cursor-pointer" @click="emits('chargeWallet', record)">
|
||||
<template #title><span>شارژ کیف پول</span></template>
|
||||
<Icon icon="vuesax-linear:wallet-add" color="#9333ea" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
v-if="can('tahesab') && tahesabEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openTahesabRegister(record)"
|
||||
@@ -74,7 +77,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#CA8A04" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
v-if="can('zarin') && zarinEnabled && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openZarinRegister(record)"
|
||||
@@ -83,7 +86,16 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#0284C7" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="pargarEnabled && !isValidAccountingCode(record.pargar_account_id)"
|
||||
v-if="shayeganEnabled && accountingProvider === 'shayegan' && !isValidAccountingCode(record.moshtari_code)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openShayeganRegister(record)"
|
||||
>
|
||||
<template #title><span>در شایگان ثبت نشده — کلیک برای ثبت</span></template>
|
||||
<Icon icon="vuesax-linear:profile-add" color="#0D9488" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('pargar') && pargarEnabled && !isValidAccountingCode(record.pargar_account_id)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openPargarRegister(record)"
|
||||
@@ -92,7 +104,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="accountingEnabled"
|
||||
v-if="can('accountingCode') && accountingEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openAccountingCodeEdit(record)"
|
||||
@@ -100,16 +112,16 @@
|
||||
<template #title><span>ویرایش کد حسابداری</span></template>
|
||||
<Icon icon="vuesax-linear:card-edit" color="#0d9488" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<a-tooltip v-if="can('info')" placement="bottom" class="cursor-pointer" @click="emits('info', record)">
|
||||
<template #title><span>مشخصات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title><span>ویرایش</span></template>
|
||||
<Icon icon="vuesax-linear:edit" color="#4572E9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="customerLevelProfitEnabled"
|
||||
v-if="can('referral') && customerLevelProfitEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openLevelProfit(record)"
|
||||
@@ -118,6 +130,7 @@
|
||||
<Icon icon="vuesax-linear:hierarchy-2" color="#ca8a04" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="can('trade')"
|
||||
:key="record.trade_active"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@@ -132,7 +145,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="customerDirectSmsEnabled"
|
||||
v-if="can('sms') && customerDirectSmsEnabled"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openDirectSms(record)"
|
||||
@@ -141,7 +154,7 @@
|
||||
<Icon icon="vuesax-linear:sms" color="#0ea5e9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.is_legal"
|
||||
v-if="can('approve') && !record.is_legal"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openConfirmUser(record)"
|
||||
@@ -233,6 +246,13 @@
|
||||
:customer-name="pargarCustomer?.name"
|
||||
@success="fetch"
|
||||
/>
|
||||
<ShayeganCustomerRegisterModal
|
||||
v-if="shayeganEnabled && accountingProvider === 'shayegan'"
|
||||
v-model="shayeganRegisterVisible"
|
||||
:customer-id="shayeganCustomer?.id"
|
||||
:customer-name="shayeganCustomer?.name"
|
||||
@success="fetch"
|
||||
/>
|
||||
</BasicShowContext>
|
||||
</div>
|
||||
</template>
|
||||
@@ -262,10 +282,12 @@ import { isMobile } from '@core/utils/is'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import ZarinRetryModal from '@/components/ZarinRetryModal.vue'
|
||||
import PargarRetryModal from '@/components/PargarRetryModal.vue'
|
||||
import ShayeganCustomerRegisterModal from '@/components/ShayeganCustomerRegisterModal.vue'
|
||||
import {
|
||||
tahesabEnabledSetting,
|
||||
zarinEnabledSetting,
|
||||
pargarEnabledSetting,
|
||||
shayeganEnabledSetting,
|
||||
accountingProviderSetting,
|
||||
customerDirectSmsEnabledSetting,
|
||||
customerLevelProfitEnabledSetting,
|
||||
@@ -274,6 +296,9 @@ import {
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||
import { customersPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const emits = defineEmits(['delete', 'edit', 'add', 'info', 'chargeWallet'])
|
||||
@@ -290,6 +315,10 @@ const zarinEnabled = zarinEnabledSetting
|
||||
const pargarRegisterVisible = ref(false)
|
||||
const pargarCustomer = ref<Customer>()
|
||||
const pargarEnabled = pargarEnabledSetting
|
||||
const shayeganRegisterVisible = ref(false)
|
||||
const shayeganCustomer = ref<Customer>()
|
||||
const shayeganEnabled = shayeganEnabledSetting
|
||||
const accountingProvider = accountingProviderSetting
|
||||
const customerDirectSmsEnabled = customerDirectSmsEnabledSetting
|
||||
const customerLevelProfitEnabled = customerLevelProfitEnabledSetting
|
||||
const levelProfitVisible = ref(false)
|
||||
@@ -298,13 +327,13 @@ const accountingCodeVisible = ref(false)
|
||||
const accountingCodeCustomer = ref<Customer | null>(null)
|
||||
const accountingEnabled = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||
})
|
||||
|
||||
function accountingCodeOf(record: Customer) {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(record.pargar_account_id)
|
||||
if (provider === 'tahesab' || provider === 'zarin') return displayAccountingCode(record.moshtari_code)
|
||||
if (provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') return displayAccountingCode(record.moshtari_code)
|
||||
return '-'
|
||||
}
|
||||
|
||||
@@ -397,6 +426,11 @@ function openPargarRegister(user: Customer) {
|
||||
pargarRegisterVisible.value = true
|
||||
}
|
||||
|
||||
function openShayeganRegister(user: Customer) {
|
||||
shayeganCustomer.value = user
|
||||
shayeganRegisterVisible.value = true
|
||||
}
|
||||
|
||||
function handleArchive(customer: Customer) {
|
||||
Modal.confirm({
|
||||
title: 'آیا مشتری را بایگانی می کنید؟',
|
||||
|
||||
@@ -14,7 +14,7 @@ export type CustomerColumnOptions = {
|
||||
}
|
||||
|
||||
function accountingCodeColumn(provider: AccountingProvider | undefined): BaseTableColumn | null {
|
||||
if (provider === 'pargar' || provider === 'tahesab' || provider === 'zarin') {
|
||||
if (provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') {
|
||||
const field = provider === 'pargar' ? 'pargar_account_id' : 'moshtari_code'
|
||||
return {
|
||||
title: 'کد حسابداری',
|
||||
|
||||
@@ -66,7 +66,7 @@ export const cols: BaseTableColumn[] = [
|
||||
const parts: string[] = []
|
||||
if (days) parts.push(`${days} روز`)
|
||||
if (r.penalty_rial > 0) parts.push(`${Number(r.penalty_rial).toLocaleString('fa-IR')} ریال`)
|
||||
if (r.penalty_gold > 0) parts.push(`${Number(r.penalty_gold).toFixed(4)} گرم`)
|
||||
if (r.penalty_gold > 0) parts.push(`${Number(r.penalty_gold).toFixed(4)} کیلوگرم`)
|
||||
return parts.join(' / ')
|
||||
},
|
||||
},
|
||||
@@ -94,7 +94,7 @@ export const creditCols: BaseTableColumn[] = [
|
||||
type: 'Text',
|
||||
},
|
||||
{
|
||||
title: 'مقدار (گرم)',
|
||||
title: 'مقدار (کیلوگرم)',
|
||||
dataIndex: 'gold_amount',
|
||||
key: 'gold_amount',
|
||||
type: 'Number',
|
||||
@@ -155,7 +155,7 @@ export const requestCols: BaseTableColumn[] = [
|
||||
type: 'Text',
|
||||
},
|
||||
{
|
||||
title: 'مقدار درخواست (گرم)',
|
||||
title: 'مقدار درخواست (کیلوگرم)',
|
||||
dataIndex: 'requested_gold',
|
||||
key: 'requested_gold',
|
||||
type: 'Number',
|
||||
|
||||
@@ -495,7 +495,7 @@ function infoOrder(val: Order) {
|
||||
infoParams.itemsTitle = 'اطلاعات کاربری'
|
||||
infoParams.items = [
|
||||
{
|
||||
key: 'مقدار (گرم)',
|
||||
key: 'مقدار (کیلوگرم)',
|
||||
value: val.amount ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -515,7 +515,7 @@ function infoOrder(val: Order) {
|
||||
value: usePrice(val.total_price_original ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'سود هر گرم (ریال)',
|
||||
key: 'سود هر کیلوگرم (ریال)',
|
||||
value: usePrice(val.fee ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -533,7 +533,7 @@ function infoOrder(val: Order) {
|
||||
{
|
||||
key: 'کارمزد (طلا)',
|
||||
value: val.service_charge != null && val.service_charge !== ''
|
||||
? `${val.service_charge} گرم`
|
||||
? `${val.service_charge} کیلوگرم`
|
||||
: '-'
|
||||
},
|
||||
{
|
||||
@@ -775,7 +775,7 @@ const userInfo = ref<Customer>()
|
||||
|
||||
const accountingCodeVisible = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||
})
|
||||
|
||||
const conditionalOrderEnabled = computed(() => conditionalOrderEnabledSetting.value)
|
||||
@@ -797,7 +797,7 @@ function onConditionalOrderUpdated(payload: {
|
||||
const accountingCodeValue = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(userInfo.value?.pargar_account_id)
|
||||
if (provider === 'tahesab' || provider === 'zarin') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
if (provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
return '-'
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<BasicShowContext title="خرید اقساطی" :help="digipayInstallmentPageIntro">
|
||||
<div class="flex flex-col gap-2 p-2.5">
|
||||
<div class="text-sm font-bold">ثبت اعتبار بعد از دیجیپی</div>
|
||||
<p class="text-xs opacity-70">
|
||||
کاربر اول با لینک تنظیمات به دیجیپی میرود. بعد از احراز، مانده اعتبارش را اینجا بنویسید تا در اپ بتواند مس بخرد.
|
||||
</p>
|
||||
<a-form layout="vertical" class="sm:grid sm:grid-cols-2 sm:gap-2" @finish="save">
|
||||
<a-form-item label="موبایل مشتری" name="mobile" :rules="[{ required: true, message: 'موبایل را وارد کنید' }]">
|
||||
<a-input v-model:value="form.mobile" placeholder="09..." />
|
||||
</a-form-item>
|
||||
<a-form-item label="مانده ۴ قسط (تومان)" name="plan4">
|
||||
<a-input-number v-model:value="form.plan4_toman" class="w-full" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label="مانده ۱۲ قسط (تومان)" name="plan12">
|
||||
<a-input-number v-model:value="form.plan12_toman" class="w-full" :min="0" />
|
||||
</a-form-item>
|
||||
<a-form-item label=" " class="flex items-end">
|
||||
<a-button type="primary" html-type="submit" :loading="saving">ثبت اعتبار</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
<div class="mt-2 text-sm font-bold">خریدهای اخیر</div>
|
||||
<a-table
|
||||
size="small"
|
||||
row-key="id"
|
||||
:loading="loading"
|
||||
:data-source="rows"
|
||||
:pagination="false"
|
||||
:columns="columns"
|
||||
/>
|
||||
</div>
|
||||
</BasicShowContext>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import { digipayInstallmentPageIntro } from '@/utils/adminHelpCopy'
|
||||
|
||||
const form = reactive({ mobile: '', plan4_toman: 0, plan12_toman: 0 })
|
||||
const saving = ref(false)
|
||||
const loading = ref(false)
|
||||
const rows = ref<Record<string, unknown>[]>([])
|
||||
|
||||
const columns = [
|
||||
{ title: 'مشتری', dataIndex: 'name' },
|
||||
{ title: 'موبایل', dataIndex: 'mobile' },
|
||||
{ title: 'طرح', dataIndex: 'plan' },
|
||||
{ title: 'مبلغ مس (تومان)', dataIndex: 'amount_toman' },
|
||||
{ title: 'کارمزد (تومان)', dataIndex: 'fee_toman' },
|
||||
{ title: 'مقدار', dataIndex: 'grams' }
|
||||
]
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await useAxios.post('/admin/digipay_installment/orders')
|
||||
rows.value = res?.data?.data || res?.data || []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
try {
|
||||
await useAxios.post('/admin/digipay_installment/credit', {
|
||||
mobile: form.mobile,
|
||||
plan4_toman: form.plan4_toman || 0,
|
||||
plan12_toman: form.plan12_toman || 0
|
||||
})
|
||||
message.success('اعتبار ثبت شد')
|
||||
await load()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'ثبت اعتبار انجام نشد')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex gap-3 justify-center items-center">
|
||||
<a-tooltip placement="top">
|
||||
<a-tooltip v-if="can('detail')" placement="top">
|
||||
<template #title>جزئیات</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:eye"
|
||||
@@ -24,7 +24,7 @@
|
||||
@click.stop="openDetails(record)"
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-tooltip v-if="record.status === 'active'" placement="top">
|
||||
<a-tooltip v-if="can('edit') && record.status === 'active'" placement="top">
|
||||
<template #title>ویرایش</template>
|
||||
<Icon
|
||||
icon="vuesax-linear:edit"
|
||||
@@ -86,6 +86,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { getCustomersList } from '@/api/customer'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { Item } from '@/model/Item'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
const modalVisible = ref(false)
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
<BaseTable v-bind="tblProps" @register="registerTable" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div v-if="record.status === 'pending'" class="flex gap-2 justify-center">
|
||||
<BaseButton type="primary" size="small" @click.stop="openApprove(record)">
|
||||
<BaseButton v-if="can('approve')" type="primary" size="small" @click.stop="openApprove(record)">
|
||||
تأیید
|
||||
</BaseButton>
|
||||
<BaseButton size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
||||
<BaseButton v-if="can('reject')" size="small" danger @click.stop="openReject(record)">رد</BaseButton>
|
||||
</div>
|
||||
<span v-else class="text-gray-400 text-xs">—</span>
|
||||
</template>
|
||||
@@ -46,6 +46,9 @@ import {
|
||||
} from '@/api/goldCredit'
|
||||
import GoldCreditModal from '@/pages/menuPages/customers/base/components/goldCreditModal.vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [registerTable, reload] = useBaseTable()
|
||||
const loading = ref(false)
|
||||
|
||||
@@ -21,7 +21,7 @@ import { computed } from 'vue'
|
||||
import BasicMenu from '@/components/BasicMenu/index.vue'
|
||||
import { useRouterStore } from '@core/stores/router'
|
||||
import { get } from 'lodash'
|
||||
import { customerSpecialPricingEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
||||
import { customerSpecialPricingEnabledSetting, digipayInstallmentEnabledSetting, goldCreditEnabledSetting, initWalletSettingsFromApi } from '@/utils/config'
|
||||
|
||||
initWalletSettingsFromApi()
|
||||
|
||||
@@ -36,6 +36,7 @@ const menu = computed(() => {
|
||||
.filter((child) => {
|
||||
if (child.name === 'customerMain_specialPrice') return customerSpecialPricingEnabledSetting.value
|
||||
if (child.name === 'customerMain_goldCredit') return goldCreditEnabledSetting.value
|
||||
if (child.name === 'customerMain_digipayInstallment') return digipayInstallmentEnabledSetting.value
|
||||
return true
|
||||
})
|
||||
.sort((a, b) => (a.meta?.order ?? 99) - (b.meta?.order ?? 99))
|
||||
|
||||
@@ -391,7 +391,21 @@ async function submitEdit() {
|
||||
await editFormRef.value?.validate()
|
||||
if (!editId.value) return
|
||||
actionLoading.value = true
|
||||
await updateCustomer(editId.value, editForm.value as Customer)
|
||||
const payload: Partial<Customer> = {
|
||||
fname: editForm.value.fname,
|
||||
lname: editForm.value.lname,
|
||||
mobile: editForm.value.mobile,
|
||||
birth_date: editForm.value.birth_date,
|
||||
phone_number: editForm.value.phone_number,
|
||||
province: editForm.value.province,
|
||||
city: editForm.value.city,
|
||||
n_code: editForm.value.n_code,
|
||||
}
|
||||
const password = String(editForm.value.password || '').trim()
|
||||
if (password !== '') {
|
||||
payload.password = password
|
||||
}
|
||||
await updateCustomer(editId.value, payload as Customer)
|
||||
message.success('ویرایش با موفقیت انجام شد')
|
||||
editVisible.value = false
|
||||
await load()
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<div class="flex items-center justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title><span>ویرایش</span></template>
|
||||
<Icon icon="vuesax-linear:edit-2" color="#4572E9" />
|
||||
</a-tooltip>
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('toggle', record)">
|
||||
<a-tooltip v-if="can('toggle')" placement="bottom" class="cursor-pointer" @click="emits('toggle', record)">
|
||||
<template #title>
|
||||
<span>{{ record.is_active ? 'غیرفعال کردن' : 'فعال کردن' }}</span>
|
||||
</template>
|
||||
@@ -29,6 +29,7 @@
|
||||
/>
|
||||
</a-tooltip>
|
||||
<a-popconfirm
|
||||
v-if="can('delete')"
|
||||
title="پکیج حذف شود؟"
|
||||
ok-text="تایید"
|
||||
cancel-text="انصراف"
|
||||
@@ -56,6 +57,9 @@ import { getSpecialPricePackageColumns } from '../hooks/specialPriceColumns'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { ref } from 'vue'
|
||||
import { specialPricePageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'add'): void
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
</template>
|
||||
<template #action="{ column, record }">
|
||||
<div class="gap-2 flex justify-center">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<a-tooltip v-if="can('edit')" placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
|
||||
<template #title>
|
||||
<span>ویرایش</span>
|
||||
</template>
|
||||
@@ -30,6 +30,9 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { cols } from '../hooks/discountColumns'
|
||||
import { getDiscountTable } from '@/api/discount'
|
||||
import { discountPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const [submit, reload] = useBaseTable()
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ function unitTagClass(row: Giftcardcode) {
|
||||
}
|
||||
|
||||
function amountLabel(row: Giftcardcode) {
|
||||
return `${row.amount ?? 0} ${row.unit === 2 ? 'گرم' : 'ریال'}`
|
||||
return `${row.amount ?? 0} ${row.unit === 2 ? 'کیلوگرم' : 'ریال'}`
|
||||
}
|
||||
|
||||
function dateLabel(value?: string) {
|
||||
|
||||
@@ -58,5 +58,5 @@ const unitTagClass = computed(() =>
|
||||
: 'border-green-300 bg-green-50 text-green-700'
|
||||
)
|
||||
|
||||
const amountLabel = computed(() => `${props.item.amount ?? 0} ${props.item.unit === 2 ? 'گرم' : 'ریال'}`)
|
||||
const amountLabel = computed(() => `${props.item.amount ?? 0} ${props.item.unit === 2 ? 'کیلوگرم' : 'ریال'}`)
|
||||
</script>
|
||||
|
||||
@@ -11,7 +11,39 @@
|
||||
@cancel="close"
|
||||
@close="close"
|
||||
>
|
||||
<div v-if="isMobile" class="mb-3 text-base font-700">لیست کدهای کارت هدیه</div>
|
||||
<div class="mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="min-w-0 space-y-1">
|
||||
<p v-if="giftCardCustomer" class="m-0 text-13px font-600" style="color: var(--admin-text)">
|
||||
مشتری: {{ giftCardCustomer.name }} — <span dir="ltr">{{ giftCardCustomer.mobile }}</span>
|
||||
</p>
|
||||
<p v-else class="m-0 text-13px font-600" style="color: var(--admin-text)">
|
||||
کد عمومی — بدون مشتری مشخص
|
||||
</p>
|
||||
<p class="m-0 text-13px text-[var(--admin-text-secondary)]">
|
||||
{{ codes.length }} کد — دانلود به صورت اکسل یا PDF
|
||||
</p>
|
||||
</div>
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
placement="bottomLeft"
|
||||
:overlay-style="{ zIndex: SELECT_DROPDOWN_Z_INDEX }"
|
||||
>
|
||||
<BaseButton
|
||||
type="default"
|
||||
size="small"
|
||||
icon="vuesax-linear:document-download"
|
||||
:disabled="!codes.length"
|
||||
>
|
||||
دانلود
|
||||
</BaseButton>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleDownload">
|
||||
<a-menu-item key="excel">اکسل (CSV)</a-menu-item>
|
||||
<a-menu-item key="pdf">PDF</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
class="hidden md:block"
|
||||
@@ -22,6 +54,21 @@
|
||||
>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'index'">{{ index + 1 }}</template>
|
||||
<template v-else-if="column.key === 'code'">
|
||||
<div class="flex items-center justify-center gap-1" dir="ltr">
|
||||
<span class="font-mono text-xs">{{ record.code || '-' }}</span>
|
||||
<a-tooltip v-if="record.code" title="کپی کد">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex cursor-pointer items-center border-none bg-transparent p-0"
|
||||
aria-label="کپی کد"
|
||||
@click="copyCode(record.code)"
|
||||
>
|
||||
<Icon icon="vuesax-linear:copy" :size="16" color="#4572E9" />
|
||||
</button>
|
||||
</a-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'sts'">
|
||||
<CustomTag v-if="record.sts === 1" textColor="#ca8a04" bgColor="#fef3c7">فعال</CustomTag>
|
||||
<CustomTag v-else-if="record.sts === 2" textColor="#25855A" bgColor="#E3F4E9">استفاده شده</CustomTag>
|
||||
@@ -32,7 +79,7 @@
|
||||
<CustomTag v-else textColor="#25855A" bgColor="#E3F4E9">ریالی</CustomTag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'amount'">
|
||||
{{ record.amount }} {{ record.unit === 2 ? 'گرم' : 'ریال' }}
|
||||
{{ record.amount }} {{ record.unit === 2 ? 'کیلوگرم' : 'ریال' }}
|
||||
</template>
|
||||
<template v-else-if="column.key === 'expiry_date'">
|
||||
{{ record.expiry_date ? toJalali(record.expiry_date) : '-' }}
|
||||
@@ -63,19 +110,31 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Giftcardcode } from '@/model/giftCard'
|
||||
import type { Giftcard, Giftcardcode } from '@/model/giftCard'
|
||||
import BasicActionSheet from '@/components/BasicActionSheet.vue'
|
||||
import CustomTag from '@/components/CustomTag.vue'
|
||||
import { useMobileDetailSheet } from '@/components/mobile/composables/useMobileDetailSheet'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { metalLabel } from '@/utils/adminMetalLabels'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import GiftCardCodeMobileDetailSheet from './GiftCardCodeMobileDetailSheet.vue'
|
||||
import GiftCardCodeMobileListItem from './GiftCardCodeMobileListItem.vue'
|
||||
import {
|
||||
downloadGiftCardCodesExcel,
|
||||
downloadGiftCardCodesPdf,
|
||||
type GiftCardCodesExportMeta
|
||||
} from '../utils/exportGiftCardCodes'
|
||||
import { resolveGiftCardCustomer } from '../utils/giftCardCustomer'
|
||||
import { SELECT_DROPDOWN_Z_INDEX } from '@/constants/overlayZIndex'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useClipboard } from '@vueuse/core'
|
||||
|
||||
const { copy, isSupported } = useClipboard()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
codes: Giftcardcode[]
|
||||
giftCard?: Giftcard | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -97,11 +156,54 @@ const columns = [
|
||||
{ title: 'وضعیت', dataIndex: 'sts', key: 'sts' },
|
||||
{ title: 'تاریخ انقضا', dataIndex: 'expiry_date', key: 'expiry_date' },
|
||||
{ title: 'تاریخ استفاده', dataIndex: 'used_at', key: 'used_at' },
|
||||
{ title: 'نام کاربر اختصاص داده شده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
||||
{ title: 'شماره موبایل کاربر اختصاص داده شده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
||||
{ title: 'نام استفادهکننده', dataIndex: 'assigned_to.name', key: 'assigned_to_name' },
|
||||
{ title: 'موبایل استفادهکننده', dataIndex: 'assigned_to.mobile', key: 'assigned_to_mobile' }
|
||||
]
|
||||
|
||||
function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
async function copyCode(code?: string) {
|
||||
const value = String(code ?? '').trim()
|
||||
if (!value) return
|
||||
try {
|
||||
if (isSupported.value) await copy(value)
|
||||
else {
|
||||
const el = document.createElement('textarea')
|
||||
el.value = value
|
||||
el.style.position = 'fixed'
|
||||
el.style.opacity = '0'
|
||||
document.body.appendChild(el)
|
||||
el.select()
|
||||
document.execCommand('copy')
|
||||
document.body.removeChild(el)
|
||||
}
|
||||
message.success('کد کپی شد')
|
||||
} catch {
|
||||
message.error('کپی انجام نشد')
|
||||
}
|
||||
}
|
||||
|
||||
const giftCardCustomer = computed(() => resolveGiftCardCustomer(props.giftCard))
|
||||
|
||||
const exportMeta = computed<GiftCardCodesExportMeta>(() => ({
|
||||
id: props.giftCard?.id,
|
||||
unit: props.giftCard?.unit,
|
||||
count: props.giftCard?.count,
|
||||
customerName: giftCardCustomer.value?.name,
|
||||
customerMobile: giftCardCustomer.value?.mobile,
|
||||
createdAt: props.giftCard?.created_at
|
||||
}))
|
||||
|
||||
function handleDownload({ key }: { key: string }) {
|
||||
if (!props.codes.length) return
|
||||
if (key === 'excel') {
|
||||
downloadGiftCardCodesExcel(props.codes, exportMeta.value)
|
||||
return
|
||||
}
|
||||
if (key === 'pdf') {
|
||||
downloadGiftCardCodesPdf(props.codes, exportMeta.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user