Compare commits
31
Commits
4d8d35c37d
..
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 | ||
|
|
0f60c1e1a5 | ||
|
|
3fc62ba100 | ||
|
|
9ef381f00e | ||
|
|
e0b89223ac | ||
|
|
dec36cc31e | ||
|
|
7c95f1f9d6 | ||
|
|
11f60f205a | ||
|
|
62a6a91455 | ||
|
|
6ab14313dd | ||
|
|
ba12569b97 |
Vendored
+3
@@ -92,11 +92,14 @@ declare module '@vue/runtime-core' {
|
||||
PargarRetryModal: typeof import('./src/components/PargarRetryModal.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
ShayeganChargeAlertHost: typeof import('./src/components/ShayeganChargeAlertHost.vue')['default']
|
||||
ShayeganCustomerRegisterModal: typeof import('./src/components/ShayeganCustomerRegisterModal.vue')['default']
|
||||
SmsCreditWidget: typeof import('./src/components/SmsCreditWidget.vue')['default']
|
||||
SmsNegativeBalanceHost: typeof import('./src/components/SmsNegativeBalanceHost.vue')['default']
|
||||
SmsNegativeBalanceModal: typeof import('./src/components/SmsNegativeBalanceModal.vue')['default']
|
||||
SubscriptionExpiryHost: typeof import('./src/components/SubscriptionExpiryHost.vue')['default']
|
||||
SubscriptionExpiryModal: typeof import('./src/components/SubscriptionExpiryModal.vue')['default']
|
||||
TahesabDocSyncProgress: typeof import('./src/components/TahesabDocSyncProgress.vue')['default']
|
||||
TahesabRetryModal: typeof import('./src/components/TahesabRetryModal.vue')['default']
|
||||
ThemeMenuSection: typeof import('./src/core/components/ThemeMenuSection.vue')['default']
|
||||
ThemeToggle: typeof import('./src/core/components/ThemeToggle.vue')['default']
|
||||
|
||||
+13
@@ -2,7 +2,9 @@
|
||||
<AConfigProvider direction="rtl">
|
||||
<RouterView />
|
||||
<CustomerImportProgress />
|
||||
<TahesabDocSyncProgress />
|
||||
<GroupSmsSendProgress />
|
||||
<ShayeganChargeAlertHost />
|
||||
</AConfigProvider>
|
||||
</template>
|
||||
|
||||
@@ -12,8 +14,11 @@ import { message } from 'ant-design-vue'
|
||||
import { useConfigStore } from '@/store/configStore'
|
||||
import { initDarkmode } from '@core/stores/darkmode'
|
||||
import CustomerImportProgress from '@/components/CustomerImportProgress.vue'
|
||||
import TahesabDocSyncProgress from '@/components/TahesabDocSyncProgress.vue'
|
||||
import GroupSmsSendProgress from '@/components/GroupSmsSendProgress.vue'
|
||||
import ShayeganChargeAlertHost from '@/components/ShayeganChargeAlertHost.vue'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
@@ -64,7 +69,15 @@ watch(latestIncomingNotification, (payload) => {
|
||||
|
||||
onMounted(async () => {
|
||||
await config.getConfigData()
|
||||
void useTahesabDocSyncStore().hydrate()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => userStore.userInfo?.id,
|
||||
(id) => {
|
||||
if (id) void useTahesabDocSyncStore().hydrate()
|
||||
},
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="less"></style>
|
||||
|
||||
+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}`)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ export const changeSellActiveProduct = async (id?: number) => {
|
||||
export const changeActiveProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/active/${id}`)
|
||||
}
|
||||
export const changeShowOnTvProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/show_on_tv/${id}`)
|
||||
}
|
||||
export const changeVisibilityProduct = async (id: number) => {
|
||||
return await useAxios.get(`/admin/product/hide/${id}`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import useAxios from '@core/utils/useAxios'
|
||||
import type { TableInput, TableOutput } from '@core/type/baseTable'
|
||||
|
||||
export interface ShayeganRecord {
|
||||
id?: number | null
|
||||
customer_id?: number | null
|
||||
customer?: {
|
||||
id?: number
|
||||
name?: string
|
||||
fname?: string
|
||||
lname?: string
|
||||
mobile?: string
|
||||
moshtari_code?: string
|
||||
} | null
|
||||
order_id?: number | null
|
||||
withdraw_id?: number | null
|
||||
amount?: number | null
|
||||
desc?: string | null
|
||||
type?: string | null
|
||||
sync_status?: 'pending' | 'success' | 'failed' | 'timeout' | string
|
||||
sync_log?: string | null
|
||||
shayegan_number?: string | null
|
||||
shayegan_guid?: string | null
|
||||
endpoint?: string | null
|
||||
created_at?: string | null
|
||||
}
|
||||
|
||||
export const shayeganHealth = async () =>
|
||||
await useAxios.get<{
|
||||
ok: boolean
|
||||
message?: string
|
||||
http_status?: number | null
|
||||
timeout?: boolean
|
||||
body?: unknown
|
||||
}>('/admin/shayegan/health')
|
||||
|
||||
export const shayeganTable = async (params: TableInput) =>
|
||||
await useAxios.post<TableOutput<ShayeganRecord>>('/admin/shayegan/table', params)
|
||||
|
||||
export const shayeganShow = async (id: number | string) =>
|
||||
await useAxios.get<ShayeganRecord>(`/admin/shayegan/${id}`)
|
||||
|
||||
export const shayeganRetry = async (id: number | string, force = false) =>
|
||||
await useAxios.post<{ ok: boolean; message?: string; row?: ShayeganRecord }>(
|
||||
`/admin/shayegan/${id}/retry`,
|
||||
{ force }
|
||||
)
|
||||
|
||||
export const registerCustomerInShayegan = async (customerId: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string }>(
|
||||
`/admin/customer/${customerId}/shayegan/register`
|
||||
)
|
||||
|
||||
export interface ShayeganInboundChargeRecord {
|
||||
id: number
|
||||
customer_id?: number | null
|
||||
customer_tafsil?: string | null
|
||||
shayegan_number?: string | null
|
||||
amount: number
|
||||
description?: string | null
|
||||
source?: string
|
||||
status: 'pending' | 'approved' | 'rejected'
|
||||
approved_at?: string | null
|
||||
rejected_at?: string | null
|
||||
reject_reason?: string | null
|
||||
customer?: {
|
||||
id: number
|
||||
name?: string
|
||||
fname?: string
|
||||
lname?: string
|
||||
mobile?: string
|
||||
n_code?: string
|
||||
moshtari_code?: string
|
||||
} | null
|
||||
approver?: {
|
||||
id: number
|
||||
name?: string
|
||||
} | null
|
||||
created_at?: string | null
|
||||
}
|
||||
|
||||
export const getPendingShayeganCharges = async () =>
|
||||
await useAxios.get<{ ok: boolean; charges: ShayeganInboundChargeRecord[] }>(
|
||||
'/admin/shayegan/charges/pending'
|
||||
)
|
||||
|
||||
export const getShayeganChargesTable = async (params: TableInput & { status?: string }) =>
|
||||
await useAxios.post<TableOutput<ShayeganInboundChargeRecord>>(
|
||||
'/admin/shayegan/charges/table',
|
||||
params
|
||||
)
|
||||
|
||||
export const approveShayeganCharge = async (id: number | string) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; charge?: ShayeganInboundChargeRecord }>(
|
||||
`/admin/shayegan/charges/${id}/approve`
|
||||
)
|
||||
|
||||
export const rejectShayeganCharge = async (id: number | string, reason?: string) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; charge?: ShayeganInboundChargeRecord }>(
|
||||
`/admin/shayegan/charges/${id}/reject`,
|
||||
{ reason }
|
||||
)
|
||||
|
||||
export const syncShayeganCharges = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; new_count?: number }>(
|
||||
'/admin/shayegan/charges/sync'
|
||||
)
|
||||
|
||||
+57
-1
@@ -34,11 +34,31 @@ export const getTahesabDetail = async (id: number) =>
|
||||
export const retryTahesabSanad = async (id: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; tahesab?: TahesabRecord }>(`/admin/tahesab/${id}/retry`)
|
||||
|
||||
export interface TahesabDocSyncState {
|
||||
running: boolean
|
||||
finished: boolean
|
||||
stopped: boolean
|
||||
stage?: 'docs' | 'customers_out' | 'customers_in'
|
||||
percent: number
|
||||
total: number
|
||||
processed: number
|
||||
success: number
|
||||
failed: number
|
||||
current: string
|
||||
errors: { label?: string; error?: string }[]
|
||||
doc_total?: number
|
||||
doc_success?: number
|
||||
doc_failed?: number
|
||||
started_at?: string | null
|
||||
finished_at?: string | null
|
||||
}
|
||||
|
||||
export interface TahesabPendingSummary {
|
||||
failed_rows: number
|
||||
missing_withdraws: number
|
||||
missing_orders: number
|
||||
total: number
|
||||
doc_sync?: TahesabDocSyncState
|
||||
}
|
||||
|
||||
export interface TahesabSyncAllResult {
|
||||
@@ -71,6 +91,34 @@ export const syncAllTahesabPending = async (limit = 80, customerId?: number) =>
|
||||
...(customerId ? { customer_id: customerId } : {})
|
||||
})
|
||||
|
||||
export const startTahesabDocSync = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/doc-sync/start'
|
||||
)
|
||||
|
||||
export const stopTahesabDocSync = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/doc-sync/stop'
|
||||
)
|
||||
|
||||
export const resetTahesabLocalDocs = async () =>
|
||||
await useAxios.post<{
|
||||
ok: boolean
|
||||
message: string
|
||||
cleared: number
|
||||
summary: TahesabPendingSummary
|
||||
}>('/admin/tahesab/doc-sync/reset-local')
|
||||
|
||||
export const startTahesabCustomerOutbound = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/customer-sync/outbound/start'
|
||||
)
|
||||
|
||||
export const startTahesabCustomerInbound = async () =>
|
||||
await useAxios.post<{ ok: boolean; message: string; doc_sync: TahesabDocSyncState }>(
|
||||
'/admin/tahesab/customer-sync/inbound/start'
|
||||
)
|
||||
|
||||
export const registerCustomerInTahesab = async (customerId: number) =>
|
||||
await useAxios.post<{ ok: boolean; message: string; moshtari_code?: string | number }>(
|
||||
`/admin/customer/${customerId}/tahesab/register`
|
||||
@@ -129,6 +177,7 @@ export interface CustomerSyncStatus {
|
||||
last_page: number
|
||||
total: number
|
||||
}
|
||||
doc_sync?: TahesabDocSyncState
|
||||
}
|
||||
|
||||
export const getCustomerSyncStatus = async (params?: {
|
||||
@@ -205,13 +254,20 @@ export interface TahesabWalletSyncResult {
|
||||
/** همگامسازی مانده یک مشتری با تهحساب */
|
||||
export const syncCustomerWalletFromTahesab = async (
|
||||
customerId: number,
|
||||
opts?: { overwrite?: boolean; keep?: boolean; ask_if_conflict?: boolean; always_ask?: boolean }
|
||||
opts?: {
|
||||
overwrite?: boolean
|
||||
keep?: boolean
|
||||
push_to_tahesab?: boolean
|
||||
ask_if_conflict?: boolean
|
||||
always_ask?: boolean
|
||||
}
|
||||
) =>
|
||||
await useAxios.post<TahesabWalletSyncResult>(
|
||||
`/admin/customer/${customerId}/tahesab/sync-wallet`,
|
||||
{
|
||||
overwrite: opts?.overwrite ?? false,
|
||||
keep: opts?.keep ?? false,
|
||||
push_to_tahesab: opts?.push_to_tahesab ?? false,
|
||||
ask_if_conflict: opts?.ask_if_conflict ?? true,
|
||||
always_ask: opts?.always_ask ?? false,
|
||||
}
|
||||
|
||||
@@ -28,6 +28,12 @@ export const exportWithdrawReport = async (params: TableInput & { flow_type?: st
|
||||
export const completeWithdraw = async (params: Withdraw) =>
|
||||
await useAxios.post<boolean>('/admin/wallet/withdraw/complete', params)
|
||||
|
||||
export const approveDeposit = async (params: { id: number; tracked_number?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/approve', params)
|
||||
|
||||
export const rejectDeposit = async (params: { id: number; reject_reason?: string }) =>
|
||||
await useAxios.post<{ message: string; withdraw: Withdraw }>('/admin/wallet/deposit/reject', params)
|
||||
|
||||
export const updateSts = async (id: number, sts: Object) => {
|
||||
return await useAxios.put(`/admin/wallet/withdraw/${id}`, sts)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
import { defineProps } from 'vue'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { confirmMenuAccess } from '@/utils/adminPageAccess'
|
||||
|
||||
interface Prop {
|
||||
menu: RouteRecordRaw[]
|
||||
@@ -30,7 +31,7 @@ interface Prop {
|
||||
const router = useRouter()
|
||||
|
||||
function handleClickMenu(item: RouteRecordRaw) {
|
||||
//debugger
|
||||
if (!confirmMenuAccess(item.name)) return
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<AMenu
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
:selectedKeys="selectedKeys"
|
||||
:style="{ width: props.width }"
|
||||
:mode="props.mode"
|
||||
:theme="resolvedTheme"
|
||||
@@ -49,10 +49,13 @@ const props = withDefaults(defineProps<Prop>(), {
|
||||
})
|
||||
|
||||
const resolvedTheme = computed(() => props.theme ?? menuTheme.value)
|
||||
onMounted(() => {
|
||||
selectedKeys.value = [router.currentRoute.value.name as string]
|
||||
//emits('onChange', '1')
|
||||
})
|
||||
watch(
|
||||
() => router.currentRoute.value.name,
|
||||
(name) => {
|
||||
selectedKeys.value = name ? [String(name)] : []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
@@ -29,7 +29,7 @@ import BasicMobileOverflowMenu from '@/components/BasicMobileOverflowMenu.vue'
|
||||
import { sortBy } from 'lodash'
|
||||
import { computed } from 'vue'
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
import { hasLandingSetting, supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
const BOTTOM_NAV_PRIORITY: (string | symbol)[] = ['dashboard', 'customers', 'orders', 'transactions']
|
||||
|
||||
@@ -44,6 +44,7 @@ const allMenuItems = computed(() =>
|
||||
if (item.name === 'support' || item.meta?.permissionsKey === 'support') {
|
||||
return supportChatMenuEnabledSetting.value
|
||||
}
|
||||
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||
return true
|
||||
}),
|
||||
(item) => item.meta?.order
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<div v-if="activeCharges.length > 0" class="shayegan-alert-container">
|
||||
<transition-group name="slide-down" tag="div" class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="charge in activeCharges"
|
||||
:key="charge.id"
|
||||
class="shayegan-charge-card shadow-lg"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="bell-icon-pulse flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-600">
|
||||
<Icon icon="vuesax-bold:notification-bing" size="20" />
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-bold text-gray-800 text-sm">
|
||||
واریزی جدید از سیستم حسابداری شایگان
|
||||
</div>
|
||||
<div class="text-xs text-gray-500 mt-0.5">
|
||||
سند شایگان: {{ charge.shayegan_number || '-' }} · تفصیلی: {{ charge.customer_tafsil || charge.customer?.moshtari_code || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="text-gray-400 hover:text-gray-600 p-1 text-sm rounded cursor-pointer border-0 bg-transparent"
|
||||
title="بستن موقت"
|
||||
@click="dismissCharge(charge.id)"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="my-2.5 rounded-md bg-amber-50/80 p-2.5 text-sm text-amber-900 border border-amber-200">
|
||||
حساب شخص <b>{{ charge.customer?.name || 'نامشخص' }}</b> از طریق پنل حسابداری مقدار <b>{{ formatPrice(charge.amount) }} ریال</b> شارژ شد
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between gap-2 pt-1 border-t border-gray-100">
|
||||
<div class="text-[11px] text-gray-400">
|
||||
{{ formatTime(charge.created_at) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a-button
|
||||
size="small"
|
||||
type="primary"
|
||||
class="!bg-emerald-600 !border-emerald-600 hover:!bg-emerald-700 text-white font-medium"
|
||||
:loading="approvingId === charge.id"
|
||||
@click="handleApprove(charge)"
|
||||
>
|
||||
تأیید و شارژ کیف پول
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
danger
|
||||
:disabled="approvingId === charge.id"
|
||||
@click="handleReject(charge)"
|
||||
>
|
||||
رد
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
type="link"
|
||||
class="text-xs text-gray-500"
|
||||
@click="goToAccountingTab"
|
||||
>
|
||||
لیست کامل
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import {
|
||||
getPendingShayeganCharges,
|
||||
approveShayeganCharge,
|
||||
rejectShayeganCharge,
|
||||
type ShayeganInboundChargeRecord
|
||||
} from '@/api/shayegan'
|
||||
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const activeCharges = ref<ShayeganInboundChargeRecord[]>([])
|
||||
const dismissedIds = ref<number[]>([])
|
||||
const approvingId = ref<number | null>(null)
|
||||
let pollTimer: any = null
|
||||
|
||||
function formatPrice(val: number) {
|
||||
return usePrice(val, true, '')
|
||||
}
|
||||
|
||||
function formatTime(dt?: string | null) {
|
||||
return dt ? toJalali(dt) : ''
|
||||
}
|
||||
|
||||
function dismissCharge(id: number) {
|
||||
if (!dismissedIds.value.includes(id)) {
|
||||
dismissedIds.value.push(id)
|
||||
}
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== id)
|
||||
}
|
||||
|
||||
async function fetchPending() {
|
||||
if (!userStore.userInfo?.id) return
|
||||
try {
|
||||
const res = await getPendingShayeganCharges()
|
||||
if (res && res.ok && Array.isArray(res.charges)) {
|
||||
// فقط مواردی که هنوز dismiss نشدهاند یا تازه آمدهاند
|
||||
activeCharges.value = res.charges.filter(c => !dismissedIds.value.includes(c.id))
|
||||
}
|
||||
} catch {
|
||||
// خطای شبکه را بیصدا نادیده میگیریم تا مزاحم کاربر نشود
|
||||
}
|
||||
}
|
||||
|
||||
async function handleApprove(charge: ShayeganInboundChargeRecord) {
|
||||
approvingId.value = charge.id
|
||||
try {
|
||||
const res = await approveShayeganCharge(charge.id)
|
||||
if (res && res.ok) {
|
||||
message.success(res.message || `کیف پول شخص ${charge.customer?.name} با موفقیت شارژ شد.`)
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== charge.id)
|
||||
} else {
|
||||
message.error(res?.message || 'خطا در تایید شارژ')
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در تایید شارژ و افزایش کیف پول')
|
||||
} finally {
|
||||
approvingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function handleReject(charge: ShayeganInboundChargeRecord) {
|
||||
Modal.confirm({
|
||||
title: 'رد واریزی شایگان',
|
||||
content: `آیا از رد واریزی ${formatPrice(charge.amount)} ریالی برای ${charge.customer?.name || 'مشتری'} اطمینان دارید؟`,
|
||||
okText: 'بله، رد شود',
|
||||
cancelText: 'انصراف',
|
||||
okType: 'danger',
|
||||
async onOk() {
|
||||
try {
|
||||
const res = await rejectShayeganCharge(charge.id)
|
||||
if (res && res.ok) {
|
||||
message.info(res.message || 'واریزی رد شد.')
|
||||
activeCharges.value = activeCharges.value.filter(c => c.id !== charge.id)
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || 'خطا در رد شارژ')
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goToAccountingTab() {
|
||||
router.push({
|
||||
path: '/menu/accounting',
|
||||
query: { tab: 'shayegan-charges' }
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void fetchPending()
|
||||
// چک کردن خودکار هر ۳۰ ثانیه
|
||||
pollTimer = setInterval(fetchPending, 30000)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (pollTimer) clearInterval(pollTimer)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => userStore.userInfo?.id,
|
||||
(id) => {
|
||||
if (id) void fetchPending()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.shayegan-alert-container {
|
||||
position: fixed;
|
||||
top: 1.5rem;
|
||||
left: 1.5rem;
|
||||
z-index: 9999;
|
||||
max-width: 440px;
|
||||
width: calc(100vw - 3rem);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.shayegan-charge-card {
|
||||
pointer-events: auto;
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-right: 4px solid #f59e0b;
|
||||
border-radius: 0.75rem;
|
||||
padding: 1rem;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.bell-icon-pulse {
|
||||
animation: pulse-ring 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse-ring {
|
||||
0% {
|
||||
transform: scale(0.95);
|
||||
box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
|
||||
}
|
||||
70% {
|
||||
transform: scale(1);
|
||||
box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
|
||||
}
|
||||
100% {
|
||||
transform: scale(0.95);
|
||||
box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.slide-down-enter-active,
|
||||
.slide-down-leave-active {
|
||||
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.slide-down-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
|
||||
.slide-down-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-model:visible="visible"
|
||||
title="ثبت مشتری در شایگان"
|
||||
ok-text="ثبت در شایگان"
|
||||
:loading="loading"
|
||||
width="32rem"
|
||||
@ok="confirm"
|
||||
@close="visible = false"
|
||||
>
|
||||
<div class="space-y-3 text-sm">
|
||||
<div v-for="item in items" :key="item.label" class="flex justify-between gap-3 border-b border-gray-100 pb-2">
|
||||
<span class="text-gray-500">{{ item.label }}</span>
|
||||
<span class="text-left break-all">{{ item.value ?? '-' }}</span>
|
||||
</div>
|
||||
<p class="m-0 text-xs leading-5" style="color: var(--admin-text-secondary)">
|
||||
با تأیید، حساب تفصیلی با معین تنظیمشده در «حسابداری شایگان» ساخته میشود و کد در پروفایل مشتری ذخیره میگردد.
|
||||
</p>
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import { message } from 'ant-design-vue/es'
|
||||
import { registerCustomerInShayegan } from '@/api/shayegan'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
customerId?: number
|
||||
customerName?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}>()
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const visible = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: boolean) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const items = computed(() => [
|
||||
{ label: 'نام مشتری', value: props.customerName },
|
||||
{ label: 'شناسه مشتری', value: props.customerId },
|
||||
])
|
||||
|
||||
async function confirm() {
|
||||
if (!props.customerId) return
|
||||
loading.value = true
|
||||
try {
|
||||
const result = await registerCustomerInShayegan(props.customerId)
|
||||
if (!result.ok) {
|
||||
message.error(result.message || 'ثبت مشتری ناموفق بود')
|
||||
return
|
||||
}
|
||||
message.success(result.message || 'مشتری در شایگان ثبت شد')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,803 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="cip-fade">
|
||||
<div
|
||||
v-if="store.visible && !store.minimized"
|
||||
class="cip-overlay"
|
||||
@click.self="store.active ? store.minimize() : null"
|
||||
>
|
||||
<div class="cip-modal" :class="store.finished ? `cip-modal--${outcomeInfo.tone}` : null">
|
||||
<div class="cip-modal__head">
|
||||
<div class="cip-modal__title">
|
||||
<Icon :icon="headIcon" :size="18" />
|
||||
<span>{{ headTitle }}</span>
|
||||
</div>
|
||||
<div class="cip-modal__head-actions">
|
||||
<button
|
||||
v-if="store.active"
|
||||
class="cip-icon-btn"
|
||||
title="کوچک کردن"
|
||||
@click="store.minimize()"
|
||||
>
|
||||
<Icon icon="vuesax-linear:minus" :size="18" />
|
||||
</button>
|
||||
<button v-else class="cip-icon-btn" title="بستن" @click="store.dismiss()">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="store.active" class="cip-modal__body">
|
||||
<div class="cip-counter">
|
||||
<span class="cip-counter__done">{{ store.state.processed }}</span>
|
||||
<span class="cip-counter__sep">/</span>
|
||||
<span class="cip-counter__total">{{ store.state.total }}</span>
|
||||
</div>
|
||||
<div class="cip-counter__label">{{ runningLabel }}</div>
|
||||
<div class="cip-track">
|
||||
<div class="cip-track__fill" :style="{ width: store.percent + '%' }" />
|
||||
</div>
|
||||
<div class="cip-percent">{{ store.percent }}٪</div>
|
||||
<div v-if="etaLabel" class="cip-eta">{{ etaLabel }}</div>
|
||||
<div class="cip-current">
|
||||
<a-spin size="small" />
|
||||
<span class="cip-current__name">{{ store.state.current || '...' }}</span>
|
||||
</div>
|
||||
<div class="cip-stats">
|
||||
<div class="cip-stat cip-stat--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="14" />
|
||||
{{ store.state.success }} موفق
|
||||
</div>
|
||||
<div v-if="store.state.failed" class="cip-stat cip-stat--fail">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
{{ store.state.failed }} ناموفق
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="cip-modal__body cip-report">
|
||||
<div class="cip-report__hero" :class="`cip-report__hero--${outcomeInfo.tone}`">
|
||||
<Icon :icon="outcomeInfo.icon" :size="34" />
|
||||
</div>
|
||||
<div class="cip-report__title">{{ outcomeInfo.text }}</div>
|
||||
<div class="cip-report__subtitle">{{ reportSubtitle }}</div>
|
||||
<div class="cip-report__cards">
|
||||
<div class="cip-rcard cip-rcard--ok">
|
||||
<Icon icon="vuesax-linear:tick-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.success }}</div>
|
||||
<div class="cip-rcard__label">{{ doneCardLabel }}</div>
|
||||
</div>
|
||||
<div class="cip-rcard" :class="store.state.failed ? 'cip-rcard--fail' : 'cip-rcard--muted'">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="20" />
|
||||
<div class="cip-rcard__num">{{ store.state.failed }}</div>
|
||||
<div class="cip-rcard__label">به خطا خورد</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="store.state.errors.length" class="cip-report__errors">
|
||||
<div class="cip-report__errors-head">
|
||||
<Icon icon="vuesax-linear:close-circle" :size="14" />
|
||||
جزئیات خطا ({{ store.state.errors.length }})
|
||||
</div>
|
||||
<div class="cip-report__errors-list">
|
||||
<div v-for="(e, i) in store.state.errors" :key="i" class="cip-erow">
|
||||
<span class="cip-erow__name">{{ e.label }}</span>
|
||||
<span class="cip-erow__msg">{{ e.error }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cip-modal__foot">
|
||||
<a-button v-if="store.active" danger size="small" @click="store.stop()">توقف</a-button>
|
||||
<a-button v-if="store.active" size="small" @click="store.minimize()">کوچک کردن</a-button>
|
||||
<a-button v-if="store.finished" type="primary" size="small" @click="store.dismiss()">
|
||||
بستن گزارش
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<Transition name="cip-slide">
|
||||
<button
|
||||
v-if="store.visible && store.minimized"
|
||||
class="cip-mini tds-mini"
|
||||
:class="store.finished ? `cip-mini--${outcomeInfo.tone}` : null"
|
||||
@click="store.expand()"
|
||||
>
|
||||
<span class="cip-mini__ring">
|
||||
<svg viewBox="0 0 36 36" class="cip-mini__svg">
|
||||
<circle class="cip-mini__bg" cx="18" cy="18" r="15.5" />
|
||||
<circle class="cip-mini__fg" cx="18" cy="18" r="15.5" :style="ringStyle" />
|
||||
</svg>
|
||||
<span class="cip-mini__pct">
|
||||
<template v-if="store.finished">
|
||||
<Icon :icon="outcomeInfo.icon" :size="16" />
|
||||
</template>
|
||||
<template v-else>{{ store.percent }}</template>
|
||||
</span>
|
||||
</span>
|
||||
<span class="cip-mini__text">
|
||||
<span class="cip-mini__title">
|
||||
<template v-if="store.finished">{{ outcomeInfo.text }}</template>
|
||||
<template v-else>{{ runningMiniTitle }}</template>
|
||||
</span>
|
||||
<span class="cip-mini__count">
|
||||
<template v-if="store.finished">
|
||||
{{ store.state.success }} موفق · {{ store.state.failed }} خطا
|
||||
</template>
|
||||
<template v-else>{{ store.state.processed }} از {{ store.state.total }}</template>
|
||||
</span>
|
||||
<span v-if="store.active && etaLabel" class="cip-mini__eta">{{ etaLabel }}</span>
|
||||
</span>
|
||||
<span class="cip-mini__bar">
|
||||
<span class="cip-mini__bar-fill" :style="{ width: store.percent + '%' }" />
|
||||
</span>
|
||||
</button>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
|
||||
const store = useTahesabDocSyncStore()
|
||||
|
||||
const runStartedAt = ref<number | null>(null)
|
||||
const runStartProcessed = ref(0)
|
||||
const tick = ref(Date.now())
|
||||
let tickTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
function formatEta(seconds: number): string {
|
||||
if (!Number.isFinite(seconds) || seconds <= 0) return 'بهزودی'
|
||||
const rounded = Math.ceil(seconds)
|
||||
if (rounded < 60) return `حدود ${rounded} ثانیه`
|
||||
const mins = Math.ceil(rounded / 60)
|
||||
if (mins < 60) return `حدود ${mins} دقیقه`
|
||||
const hours = Math.floor(mins / 60)
|
||||
const remMins = mins % 60
|
||||
if (remMins === 0) return `حدود ${hours} ساعت`
|
||||
return `حدود ${hours} ساعت و ${remMins} دقیقه`
|
||||
}
|
||||
|
||||
function resetEtaClock() {
|
||||
runStartedAt.value = Date.now()
|
||||
runStartProcessed.value = store.state.processed
|
||||
}
|
||||
|
||||
function startTick() {
|
||||
if (tickTimer) return
|
||||
tickTimer = setInterval(() => {
|
||||
tick.value = Date.now()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
function stopTick() {
|
||||
if (!tickTimer) return
|
||||
clearInterval(tickTimer)
|
||||
tickTimer = null
|
||||
}
|
||||
|
||||
watch(
|
||||
() => store.active,
|
||||
(active) => {
|
||||
if (active) {
|
||||
resetEtaClock()
|
||||
startTick()
|
||||
return
|
||||
}
|
||||
runStartedAt.value = null
|
||||
stopTick()
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
() => store.state.stage,
|
||||
() => {
|
||||
if (store.active) resetEtaClock()
|
||||
},
|
||||
)
|
||||
|
||||
const etaLabel = computed(() => {
|
||||
void tick.value
|
||||
if (!store.active) return ''
|
||||
|
||||
const { processed, total } = store.state
|
||||
const remaining = Math.max(0, total - processed)
|
||||
if (remaining <= 0) return 'در حال اتمام…'
|
||||
if (!runStartedAt.value) return ''
|
||||
|
||||
const deltaProcessed = processed - runStartProcessed.value
|
||||
const elapsedSec = (Date.now() - runStartedAt.value) / 1000
|
||||
if (deltaProcessed < 2 || elapsedSec < 4) {
|
||||
return 'در حال محاسبه زمان باقیمانده…'
|
||||
}
|
||||
|
||||
const secPerItem = elapsedSec / deltaProcessed
|
||||
return `تخمین باقیمانده: ${formatEta(secPerItem * remaining)}`
|
||||
})
|
||||
|
||||
const stage = computed(() => store.stage)
|
||||
|
||||
function outcomeMap() {
|
||||
if (stage.value === 'customers_in') {
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ورود مشتریان تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ورود مشتریان ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان وارد نشدند', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ورود متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:import', text: 'ورود از تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
if (stage.value === 'customers_out') {
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ثبت مشتریان تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ثبت مشتریان ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان ثبت نشدند', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ثبت متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:profile-2user', text: 'ثبت در تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: { icon: 'vuesax-linear:tick-circle', text: 'ارسال سندها تمام شد', tone: 'ok' as const },
|
||||
error: { icon: 'vuesax-linear:close-circle', text: 'ارسال سندها ناموفق بود', tone: 'fail' as const },
|
||||
partial: { icon: 'vuesax-linear:danger', text: 'بعضی سندها به خطا خورد', tone: 'warn' as const },
|
||||
canceled: { icon: 'vuesax-linear:info-circle', text: 'ارسال متوقف شد', tone: 'warn' as const },
|
||||
running: { icon: 'vuesax-linear:document-upload', text: 'ارسال سند به تهحساب', tone: 'ok' as const },
|
||||
}
|
||||
}
|
||||
|
||||
const outcomeInfo = computed(() => outcomeMap()[store.outcome])
|
||||
const runningIcon = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'vuesax-linear:import'
|
||||
if (stage.value === 'customers_out') return 'vuesax-linear:profile-2user'
|
||||
return 'vuesax-linear:document-upload'
|
||||
})
|
||||
const headIcon = computed(() => (store.finished ? outcomeInfo.value.icon : runningIcon.value))
|
||||
const headTitle = computed(() => {
|
||||
if (store.finished) {
|
||||
if (stage.value === 'customers_in') return 'گزارش ورود مشتریان'
|
||||
if (stage.value === 'customers_out') return 'گزارش ثبت مشتریان'
|
||||
return 'گزارش ارسال سندها'
|
||||
}
|
||||
if (stage.value === 'customers_in') return 'ورود مشتریان از تهحساب'
|
||||
if (stage.value === 'customers_out') return 'ثبت مشتریان در تهحساب'
|
||||
return 'ارسال سندها به تهحساب'
|
||||
})
|
||||
const runningLabel = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'در حال وارد کردن مشتریان از تهحساب…'
|
||||
if (stage.value === 'customers_out') return 'در حال ثبت مشتریان پنل در تهحساب…'
|
||||
return 'در حال ارسال سندها به تهحساب…'
|
||||
})
|
||||
const runningMiniTitle = computed(() => {
|
||||
if (stage.value === 'customers_in') return 'ورود از تهحساب'
|
||||
if (stage.value === 'customers_out') return 'ثبت مشتری در تهحساب'
|
||||
return 'ارسال سند به تهحساب'
|
||||
})
|
||||
const unit = computed(() => (stage.value === 'docs' ? 'سند' : 'مشتری'))
|
||||
const doneCardLabel = computed(() => (stage.value === 'docs' ? 'ارسال شد' : 'ثبت شد'))
|
||||
const reportSubtitle = computed(() => {
|
||||
const docs = store.state.doc_total
|
||||
? `سندها: ${store.state.doc_success} موفق` + (store.state.doc_failed ? `، ${store.state.doc_failed} خطا. ` : '. ')
|
||||
: ''
|
||||
return `${docs}از ${store.state.total} ${unit.value}، ${store.state.processed} مورد پردازش شد`
|
||||
})
|
||||
const RING_CIRC = 2 * Math.PI * 15.5
|
||||
const ringStyle = computed(() => ({
|
||||
strokeDasharray: `${RING_CIRC}`,
|
||||
strokeDashoffset: `${RING_CIRC * (1 - store.percent / 100)}`,
|
||||
}))
|
||||
|
||||
onMounted(() => {
|
||||
void store.hydrate()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopTick()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
/* ─── مدال ─── */
|
||||
.cip-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2200;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 16px;
|
||||
background: rgba(15, 23, 42, 0.55);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.cip-modal {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
border-radius: 16px;
|
||||
background: var(--admin-bg-surface);
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
|
||||
overflow: hidden;
|
||||
|
||||
&__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 16px;
|
||||
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0ea5e9 100%);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&--ok .cip-modal__head {
|
||||
background: linear-gradient(135deg, #059669 0%, #10b981 100%);
|
||||
}
|
||||
|
||||
&--warn .cip-modal__head {
|
||||
background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
|
||||
}
|
||||
|
||||
&--fail .cip-modal__head {
|
||||
background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
|
||||
}
|
||||
|
||||
&__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&__head-actions {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
&__body {
|
||||
padding: 20px 18px 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&__foot {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 12px 16px 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-icon-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.32);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
|
||||
&__done {
|
||||
font-size: 38px;
|
||||
color: #7c3aed;
|
||||
}
|
||||
&__sep {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
&__total {
|
||||
font-size: 24px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-counter__label {
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-track {
|
||||
width: 100%;
|
||||
height: 9px;
|
||||
margin-top: 16px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
|
||||
&__fill {
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: linear-gradient(90deg, #7c3aed, #0ea5e9);
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-percent {
|
||||
align-self: flex-end;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text-secondary);
|
||||
}
|
||||
|
||||
.cip-eta {
|
||||
align-self: flex-end;
|
||||
margin-top: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--admin-text-muted);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.cip-current {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
max-width: 100%;
|
||||
|
||||
&__name {
|
||||
font-size: 12px;
|
||||
color: var(--admin-text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.cip-stats {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.cip-stat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
padding: 3px 12px;
|
||||
border-radius: 99px;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.12);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── گزارش پایانی ─── */
|
||||
.cip-report {
|
||||
padding-top: 22px;
|
||||
|
||||
&__hero {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 50%;
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.14);
|
||||
color: #059669;
|
||||
}
|
||||
&--warn {
|
||||
background: rgba(245, 158, 11, 0.16);
|
||||
color: #d97706;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.13);
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
|
||||
&__title {
|
||||
margin-top: 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
color: var(--admin-text);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--admin-text-secondary);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&__cards {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
&__errors {
|
||||
width: 100%;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
&__errors-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #dc2626;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
&__errors-list {
|
||||
max-height: 160px;
|
||||
overflow-y: auto;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--admin-border);
|
||||
background: var(--admin-bg-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-rcard {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
padding: 14px 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&__num {
|
||||
font-size: 26px;
|
||||
font-weight: 800;
|
||||
line-height: 1.1;
|
||||
}
|
||||
&__label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&--ok {
|
||||
background: rgba(16, 185, 129, 0.1);
|
||||
border-color: rgba(16, 185, 129, 0.25);
|
||||
color: #059669;
|
||||
}
|
||||
&--fail {
|
||||
background: rgba(239, 68, 68, 0.09);
|
||||
border-color: rgba(239, 68, 68, 0.22);
|
||||
color: #dc2626;
|
||||
}
|
||||
&--muted {
|
||||
background: var(--admin-bg-muted);
|
||||
border-color: var(--admin-border);
|
||||
color: var(--admin-text-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.cip-erow {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 8px 12px;
|
||||
font-size: 12px;
|
||||
border-bottom: 1px solid var(--admin-border);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&__name {
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
&__msg {
|
||||
color: #dc2626;
|
||||
text-align: left;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── کوچکشده ─── */
|
||||
.cip-mini {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 2100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 8px 16px 8px 10px;
|
||||
border: 1px solid var(--admin-border-strong);
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-surface);
|
||||
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
|
||||
cursor: pointer;
|
||||
transition: transform 0.15s, box-shadow 0.15s;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 58px;
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateX(-50%) translateY(1px);
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
&__ring {
|
||||
position: relative;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
|
||||
&__bg {
|
||||
fill: none;
|
||||
stroke: var(--admin-bg-muted);
|
||||
stroke-width: 3.5;
|
||||
}
|
||||
|
||||
&__fg {
|
||||
fill: none;
|
||||
stroke: #7c3aed;
|
||||
stroke-width: 3.5;
|
||||
stroke-linecap: round;
|
||||
transition: stroke-dashoffset 0.35s ease;
|
||||
}
|
||||
|
||||
&__pct {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
color: #7c3aed;
|
||||
}
|
||||
|
||||
&__text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
line-height: 1.3;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__count {
|
||||
font-size: 11px;
|
||||
color: var(--admin-text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__eta {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: var(--admin-text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__bar {
|
||||
position: absolute;
|
||||
left: 14px;
|
||||
right: 14px;
|
||||
bottom: 3px;
|
||||
height: 2px;
|
||||
border-radius: 99px;
|
||||
background: var(--admin-bg-muted);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&__bar-fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: 99px;
|
||||
background: #7c3aed;
|
||||
transition: width 0.35s ease;
|
||||
}
|
||||
|
||||
/* رنگ بر اساس نتیجه */
|
||||
&--ok {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #10b981;
|
||||
background: #10b981;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
&--warn {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #f59e0b;
|
||||
background: #f59e0b;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #d97706;
|
||||
}
|
||||
}
|
||||
|
||||
&--fail {
|
||||
.cip-mini__fg,
|
||||
.cip-mini__bar-fill {
|
||||
stroke: #ef4444;
|
||||
background: #ef4444;
|
||||
}
|
||||
.cip-mini__pct {
|
||||
color: #dc2626;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tds-mini.cip-mini {
|
||||
top: 112px;
|
||||
|
||||
@media (max-width: 767px) {
|
||||
top: 106px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── انیمیشنها ─── */
|
||||
.cip-fade-enter-active,
|
||||
.cip-fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.cip-fade-enter-from,
|
||||
.cip-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.cip-slide-enter-active,
|
||||
.cip-slide-leave-active {
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
.cip-slide-enter-from,
|
||||
.cip-slide-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(-12px);
|
||||
}
|
||||
</style>
|
||||
@@ -95,7 +95,7 @@
|
||||
>
|
||||
<div class="customer-wallet-balance__detail-group-title">
|
||||
<span class="customer-wallet-balance__group-dot" aria-hidden="true" />
|
||||
<span>{{ metal.label }}</span>
|
||||
<span>{{ minimalMetalLabel(metal) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="line in linesForMetal(metal.metal_id)"
|
||||
@@ -234,9 +234,21 @@ function targetToneClass(target: ChargeTarget) {
|
||||
}
|
||||
}
|
||||
|
||||
function uniqueInventoryCards() {
|
||||
const cards = summary.value?.inventory_cards ?? []
|
||||
const seen = new Set<number>()
|
||||
const unique: WalletInventoryCard[] = []
|
||||
for (const card of cards) {
|
||||
const id = Number(card.product_id)
|
||||
if (!id || seen.has(id)) continue
|
||||
seen.add(id)
|
||||
unique.push(card)
|
||||
}
|
||||
return unique
|
||||
}
|
||||
|
||||
function inventoryCards() {
|
||||
if (!summary.value) return [] as WalletInventoryCard[]
|
||||
return [...(summary.value.inventory_cards ?? []), ...(summary.value.count_products ?? [])]
|
||||
return uniqueInventoryCards()
|
||||
}
|
||||
|
||||
function isCountChargeTarget(target: ChargeTarget) {
|
||||
@@ -307,17 +319,28 @@ 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) {
|
||||
const allCount = metalCards.length > 0 && metalCards.every((card) => card.display_type === 'count')
|
||||
if (allCount) {
|
||||
const qty = metalCards.reduce((sum, card) => sum + Number(card.quantity ?? 0), 0)
|
||||
return `${qty.toLocaleString('fa-IR')} عدد`
|
||||
}
|
||||
if (metal) {
|
||||
return formatMetalTotal(metal)
|
||||
}
|
||||
return formatMetalDisplayValue(0, metalId)
|
||||
}
|
||||
|
||||
function linesForMetal(metalId: number) {
|
||||
const cards = summary.value?.inventory_cards ?? []
|
||||
const countCards = summary.value?.count_products ?? []
|
||||
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
|
||||
const metalCards = uniqueInventoryCards().filter(
|
||||
(card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0
|
||||
)
|
||||
|
||||
const productLines = [...cards, ...countCards]
|
||||
.filter((card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0)
|
||||
.map((card) => ({
|
||||
const productLines = metalCards.map((card) => ({
|
||||
key: `card-${card.product_id}`,
|
||||
label: card.title,
|
||||
value: formatCard(card)
|
||||
@@ -325,7 +348,7 @@ function linesForMetal(metalId: number) {
|
||||
|
||||
const lines: Array<{ key: string; label: string; value: string }> = [...productLines]
|
||||
|
||||
if (metal && Number(metal.melted_weight ?? 0) > 0 && !productLines.some((line) => line.label.includes('آبشده'))) {
|
||||
if (metal && Number(metal.melted_weight ?? 0) > 0 && !metalCards.some((card) => card.is_melted || card.is_main_wallet)) {
|
||||
lines.push({
|
||||
key: 'melted',
|
||||
label: 'موجودی آبشده / کیف اصلی',
|
||||
@@ -333,11 +356,11 @@ function linesForMetal(metalId: number) {
|
||||
})
|
||||
}
|
||||
|
||||
if (metal && lines.length > 1) {
|
||||
if (lines.length > 0) {
|
||||
lines.push({
|
||||
key: 'total',
|
||||
label: 'مجموع',
|
||||
value: formatMetalTotal(metal)
|
||||
label: `مجموع ${minimalMetalLabel(metal ?? { metal_id: metalId } as WalletMetalTotal)}`,
|
||||
value: formatMetalGroupTotal(metalId, metalCards, metal)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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'
|
||||
@@ -36,7 +36,7 @@ import BaseMenuItem from '@core/layouts/composnts/BaseMenuItem.vue'
|
||||
import type { RouteRecordName, RouteRecordRaw } from 'vue-router'
|
||||
import { useRouterStore } from '@core/stores/router'
|
||||
import { useAdminTheme } from '@core/composable/useAdminTheme'
|
||||
import { supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
import { hasLandingSetting, supportChatMenuEnabledSetting } from '@/utils/config'
|
||||
|
||||
const { prefixCls } = usePrefix('basic-menu')
|
||||
const layoutStore = useLayoutStore()
|
||||
@@ -45,9 +45,9 @@ const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
||||
const routerStore = useRouterStore()
|
||||
const { menuTheme } = useAdminTheme()
|
||||
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
function syncSelectedKeys() {
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
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
|
||||
}
|
||||
|
||||
walkInRoutes(routerStore.routes)
|
||||
selectedKeys.value = path
|
||||
watch(() => currentRoute.name, syncSelectedKeys, { immediate: true })
|
||||
|
||||
function isSupportMenuRoute(item: RouteRecordRaw): boolean {
|
||||
return item.name === 'support' || item.meta?.permissionsKey === 'support'
|
||||
@@ -79,6 +78,7 @@ const menu: ComputedRef<RouteRecordRaw[]> = computed(() => {
|
||||
}).filter((item) => {
|
||||
if (item.meta?.hideMenu) return false
|
||||
if (isSupportMenuRoute(item)) return supportChatMenuEnabledSetting.value
|
||||
if (item.name === 'websiteSettings') return hasLandingSetting.value
|
||||
return true
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
+5
-1
@@ -1,4 +1,5 @@
|
||||
import type { Const } from '@/model/const'
|
||||
import type { PageAccessMap } from '@/utils/adminPageAccess'
|
||||
|
||||
export interface User {
|
||||
active?: boolean
|
||||
@@ -12,13 +13,16 @@ export interface User {
|
||||
lname?: string
|
||||
mobile?: number
|
||||
name?: string
|
||||
n_code?: string
|
||||
sts?: number
|
||||
token_sms?: string
|
||||
user_type?: string
|
||||
send_sms?:boolean
|
||||
send_sms?: boolean
|
||||
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>
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TahesabDocSyncBox />
|
||||
|
||||
<!-- ─── تبها ─── -->
|
||||
<div class="cs-tabs">
|
||||
<button
|
||||
@@ -103,8 +105,8 @@
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="syncingPanel"
|
||||
:disabled="!status?.panel_only"
|
||||
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_out')"
|
||||
:disabled="!status?.panel_only && !docSyncStore.active"
|
||||
@click="syncAllPanel"
|
||||
>
|
||||
<template #icon><Icon icon="vuesax-linear:send-2" :size="13" /></template>
|
||||
@@ -241,11 +243,15 @@
|
||||
</a-button>
|
||||
<a-button
|
||||
size="small"
|
||||
:loading="importStore.active"
|
||||
:disabled="!importableCount"
|
||||
:loading="docSyncStore.starting || (docSyncStore.active && docSyncStore.stage === 'customers_in')"
|
||||
:disabled="!importableCount && !docSyncStore.active"
|
||||
@click="importAll"
|
||||
>
|
||||
{{ importStore.active ? 'در حال…' : `وارد کردن همه (${importableCount})` }}
|
||||
{{
|
||||
docSyncStore.active && docSyncStore.stage === 'customers_in'
|
||||
? 'در حال…'
|
||||
: `وارد کردن همه (${importableCount})`
|
||||
}}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -362,7 +368,6 @@ import Icon from '@core/components/BaseIcon/src/Icon.vue'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import {
|
||||
getCustomerSyncStatus,
|
||||
syncPanelToTahesab,
|
||||
importFromTahesab,
|
||||
registerCustomerInTahesab,
|
||||
linkTahesabMatchingPhones,
|
||||
@@ -372,12 +377,13 @@ import {
|
||||
type TahesabOnlyCustomer,
|
||||
type SyncPanelResult,
|
||||
} from '@/api/tahesab'
|
||||
import { useCustomerImportStore } from '@/store/customerImportStore'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import ColleagueAccountingAccounts from '@/pages/menuPages/colleagueOrders/components/ColleagueAccountingAccounts.vue'
|
||||
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||
import { accountingTahesabCustomerSyncIntro } from '@/utils/adminHelpCopy'
|
||||
import AdminFieldHelp from '@/components/AdminFieldHelp.vue'
|
||||
|
||||
const importStore = useCustomerImportStore()
|
||||
const docSyncStore = useTahesabDocSyncStore()
|
||||
|
||||
// ─── state ───
|
||||
const loadingPanel = ref(true) // شروع با true تا اولین load کامل بشه
|
||||
@@ -505,6 +511,7 @@ async function load(panelPage = 1) {
|
||||
} else {
|
||||
status.value = res
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
panelList.value = res.panel_only_list.data
|
||||
panelPagination.value = {
|
||||
page: res.panel_only_list.current_page,
|
||||
@@ -534,6 +541,7 @@ async function loadTahesab() {
|
||||
} else {
|
||||
status.value = res
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
tahesabOnlyList.value = res.tahesab_only_list?.data ?? []
|
||||
mandeFetched.clear()
|
||||
tahesabFetched.value = true
|
||||
@@ -556,6 +564,7 @@ async function loadPanel(page = 1) {
|
||||
status.value.panel_registered = res.panel_registered
|
||||
status.value.panel_only = res.panel_only
|
||||
}
|
||||
docSyncStore.apply(res.doc_sync)
|
||||
panelList.value = res.panel_only_list.data
|
||||
panelPagination.value = {
|
||||
page: res.panel_only_list.current_page,
|
||||
@@ -592,18 +601,15 @@ async function registerOnePanel(customer: PanelOnlyCustomer) {
|
||||
}
|
||||
|
||||
async function syncAllPanel() {
|
||||
syncingPanel.value = true
|
||||
panelSyncResult.value = null
|
||||
showPanelErrors.value = false
|
||||
if (docSyncStore.active) {
|
||||
docSyncStore.expand()
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await syncPanelToTahesab()
|
||||
panelSyncResult.value = res
|
||||
if (res.success) message.success(`${res.success} مشتری ثبت شد`)
|
||||
if (res.failed) message.warning(`${res.failed} مشتری ثبت نشد`)
|
||||
await load(1)
|
||||
panelDone.clear()
|
||||
} catch { message.error('خطا در ارتباط با سرور') }
|
||||
finally { syncingPanel.value = false }
|
||||
await docSyncStore.startOutbound()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ثبت ناموفق بود')
|
||||
}
|
||||
}
|
||||
|
||||
// ─── تب ۲: عملیات ───
|
||||
@@ -695,11 +701,15 @@ async function importSelected() {
|
||||
async function importAll() {
|
||||
const pending = importableList.value
|
||||
if (!pending.length) return
|
||||
if (importStore.active) {
|
||||
importStore.expand()
|
||||
if (docSyncStore.active) {
|
||||
docSyncStore.expand()
|
||||
return
|
||||
}
|
||||
confirmImport(pending, () => importStore.start(pending, 'tahesab'))
|
||||
confirmImport(pending, () => {
|
||||
void docSyncStore.startInbound().catch((e: any) => {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ورود ناموفق بود')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function confirmLinkPhones() {
|
||||
@@ -763,26 +773,21 @@ async function enrichPageMande() {
|
||||
|
||||
watch([tahesabPage, tahesabSearch], () => { void enrichPageMande() })
|
||||
|
||||
// با پیشرفت عملیات سراسری، ردیفهای وارد شده را همینجا هم تیک بزن
|
||||
watch(() => importStore.doneCodes.length, () => {
|
||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
||||
})
|
||||
|
||||
// پس از پایان کامل، آمار و لیست را تازه کن
|
||||
watch(() => importStore.status, async (s, prev) => {
|
||||
if (prev === 'running' && (s === 'done' || s === 'canceled')) {
|
||||
selectedTahesab.clear()
|
||||
if (status.value?.tahesab_only_count != null) {
|
||||
status.value.tahesab_only_count = Math.max(0, status.value.tahesab_only_count - importStore.success)
|
||||
watch(
|
||||
() => docSyncStore.finished,
|
||||
async (done, wasDone) => {
|
||||
if (!done || wasDone) return
|
||||
await load(1)
|
||||
panelDone.clear()
|
||||
if (docSyncStore.stage === 'customers_in') {
|
||||
tahesabFetched.value = false
|
||||
if (activeTab.value === 'tahesab') await loadTahesab()
|
||||
}
|
||||
await loadPanel(panelPagination.value.page)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
load(1)
|
||||
// اگر عملیات سراسری در حال اجراست، ردیفهای انجامشده را همگام کن
|
||||
importStore.doneCodes.forEach(code => tahesabDone.add(code))
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<div
|
||||
class="mb-3 flex w-full flex-col gap-2.5 rounded-xl border border-gray-200 bg-gray-50 px-3.5 py-3 sm:flex-row sm:items-center sm:gap-3"
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="m-0 text-sm font-800 text-gray-800">ارسال سندها به تهحساب</p>
|
||||
<p class="mb-0 mt-1 text-xs leading-relaxed text-gray-500">
|
||||
با یک کلیک همهٔ سفارشها و شارژهای جاافتاده یکییکی و با فاصله به تهحساب میروند.
|
||||
بعد از سندها، مشتریان پنلِ بدون کد هم همانجا ثبت میشوند. پیشرفت را میتوانید کوچک کنید.
|
||||
اگر سندها در تهحساب پاک شده، اول وضعیت محلی را بازنشانی کنید.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex w-full shrink-0 flex-col gap-2 sm:w-auto">
|
||||
<a-button
|
||||
type="primary"
|
||||
class="!w-full sm:!w-auto"
|
||||
:loading="store.starting || store.active"
|
||||
:disabled="store.active || store.resetting"
|
||||
@click="onStart"
|
||||
>
|
||||
{{ store.active ? 'در حال ارسال…' : 'ارسال همه سندها' }}
|
||||
</a-button>
|
||||
<a-button
|
||||
class="!w-full sm:!w-auto"
|
||||
:loading="store.resetting"
|
||||
:disabled="store.active"
|
||||
@click="onReset"
|
||||
>
|
||||
بازنشانی وضعیت محلی
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { createVNode } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
|
||||
const emit = defineEmits<{ refreshed: [] }>()
|
||||
const store = useTahesabDocSyncStore()
|
||||
|
||||
async function onStart() {
|
||||
try {
|
||||
await store.start()
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'شروع ارسال ناموفق بود')
|
||||
}
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
Modal.confirm({
|
||||
title: 'بازنشانی وضعیت محلی؟',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content:
|
||||
'سندهایی که پنل آنها را موفق میداند دوباره در صف ارسال میآیند. خودِ تهحساب عوض نمیشود. کد مشتری پنل دست نمیخورد.',
|
||||
okText: 'بازنشانی کن',
|
||||
cancelText: 'انصراف',
|
||||
centered: true,
|
||||
onOk: runReset,
|
||||
})
|
||||
}
|
||||
|
||||
async function runReset() {
|
||||
try {
|
||||
const res = await store.resetLocal()
|
||||
if (!res) return
|
||||
message.success(res.message || 'وضعیت محلی بهروز شد')
|
||||
if (res.summary?.total) {
|
||||
message.info(`${res.summary.total} سند در صف ارسال است — حالا ارسال همه را بزنید`)
|
||||
}
|
||||
emit('refreshed')
|
||||
} catch (e: any) {
|
||||
message.error(e?.response?.data?.message || e?.message || 'بازنشانی ناموفق بود')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.tahesab_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.tahesab_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryTahesab, tahesabStatusLabel } from '@/pages/menuPages/accounting/utils/tahesabStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<AdminFieldHelp :text="accountingTahesabBalanceSyncIntro" size="sm" />
|
||||
</div>
|
||||
<p class="tw-bulk__hint">
|
||||
همگام تکی: اول سندها و اختلاف را میبینید، بعد تأیید میکنید. دو مانده جمع نمیشوند.
|
||||
همگام تکی: اول سندها و اختلاف را میبینید، بعد یکی از سه مسیر را تأیید میکنید (تهحساب→اپ، اپ→تهحساب حتی اگر اپ صفر باشد، یا نگه داشتن). دو مانده جمع نمیشوند.
|
||||
همگام همه فقط کیف خالی را مینشاند؛ تداخل برای تصمیم دستی میماند.
|
||||
</p>
|
||||
</div>
|
||||
@@ -154,6 +154,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="decisionVisible"
|
||||
source-label="تهحساب"
|
||||
:allow-push="true"
|
||||
:app-gold="decisionResult?.app_gold"
|
||||
:app-cash="decisionResult?.app_cash"
|
||||
:tahesab-gold="decisionResult?.tahesab_gold"
|
||||
@@ -200,7 +201,7 @@ const failed = ref(0)
|
||||
const errors = ref<TahesabBulkWalletSyncChunk['errors']>([])
|
||||
const decisions = ref<TahesabBulkWalletSyncChunk['decisions']>([])
|
||||
const decidingId = ref<number | null>(null)
|
||||
const decidingMode = ref<'overwrite' | 'keep' | null>(null)
|
||||
const decidingMode = ref<'overwrite' | 'keep' | 'push' | null>(null)
|
||||
|
||||
const search = ref('')
|
||||
const page = ref(1)
|
||||
@@ -209,7 +210,7 @@ const listTotal = ref(0)
|
||||
const listLoading = ref(false)
|
||||
const rows = ref<TahesabWalletLinkedRow[]>([])
|
||||
const syncingId = ref<number | null>(null)
|
||||
const syncingMode = ref<'ask' | 'overwrite' | 'keep' | null>(null)
|
||||
const syncingMode = ref<'ask' | 'overwrite' | 'keep' | 'push' | null>(null)
|
||||
const decisionVisible = ref(false)
|
||||
const decisionCustomerId = ref<number | null>(null)
|
||||
const decisionResult = ref<TahesabWalletSyncResult['result'] | null>(null)
|
||||
@@ -321,7 +322,7 @@ async function openReview(customerId: number) {
|
||||
}
|
||||
}
|
||||
|
||||
async function onReviewDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onReviewDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
const customerId = decisionCustomerId.value
|
||||
decisionVisible.value = false
|
||||
if (!customerId) return
|
||||
@@ -337,22 +338,25 @@ function dismissResult() {
|
||||
showDetails.value = false
|
||||
}
|
||||
|
||||
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
||||
async function applyDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||
decidingId.value = customerId
|
||||
decidingMode.value = mode
|
||||
try {
|
||||
const res = await syncCustomerWalletFromTahesab(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
decisions.value = decisions.value.filter(d => d.id !== customerId)
|
||||
needsDecision.value = Math.max(0, decisions.value.length)
|
||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||
else message.success(res.message || 'مانده تهحساب اعمال شد')
|
||||
await loadList()
|
||||
} catch {
|
||||
message.error('اعمال تصمیم ناموفق بود')
|
||||
} catch (e: unknown) {
|
||||
const data = (e as { response?: { data?: { message?: string } } })?.response?.data
|
||||
message.error(data?.message || 'اعمال تصمیم ناموفق بود')
|
||||
} finally {
|
||||
decidingId.value = null
|
||||
decidingMode.value = null
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<MobileSheetHeader :title="sheetTitle" :show-title="isMobile">
|
||||
<template #actions>
|
||||
<MobileIconButton
|
||||
v-if="!row.zarin_id && !row.customer?.moshtari_code"
|
||||
v-if="can('register') && !row.zarin_id && !row.customer?.moshtari_code"
|
||||
plain
|
||||
icon="vuesax-linear:profile-add"
|
||||
color="#7C3AED"
|
||||
@@ -12,7 +12,7 @@
|
||||
@click="$emit('register-customer', row)"
|
||||
/>
|
||||
<MobileIconButton
|
||||
v-if="canRetry(row)"
|
||||
v-if="can('send') && canRetry(row)"
|
||||
plain
|
||||
icon="vuesax-linear:refresh-circle"
|
||||
color="#CA8A04"
|
||||
@@ -60,6 +60,9 @@ import {
|
||||
import { canRetryZarin, zarinStatusLabel } from '@/pages/menuPages/accounting/utils/zarinStatus'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
<div class="flex justify-center gap-2">
|
||||
|
||||
<!-- دکمه ۱: اطلاعات کلی (همیشه نمایان) -->
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<!-- دکمه ۲: ثبت مشتری در پرگار (فقط اگر سند هنوز ثبت نشده و مشتری کد ندارد) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
v-if="can('register') && canRetryPargar(record) && !record.customer?.pargar_account_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
<!-- دکمه ۳: ارسال به پرگار (فقط اگر هنوز در پرگار ثبت نشده) -->
|
||||
<a-tooltip
|
||||
v-if="canRetryPargar(record)"
|
||||
v-if="can('send') && canRetryPargar(record)"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -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>
|
||||
@@ -6,7 +6,7 @@
|
||||
>
|
||||
<template #extra>
|
||||
<a-button
|
||||
v-if="(pending?.total ?? 0) > 0"
|
||||
v-if="customerId && (pending?.total ?? 0) > 0"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="syncing"
|
||||
@@ -16,6 +16,8 @@
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
<TahesabDocSyncBox v-if="!customerId" @refreshed="onDocSyncRefreshed" />
|
||||
|
||||
<div
|
||||
v-if="(pending?.total ?? 0) > 0"
|
||||
class="mb-3 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900"
|
||||
@@ -77,12 +79,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -91,6 +93,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -109,13 +112,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.tahesab_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -125,7 +128,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.tahesab_id"
|
||||
v-if="can('send') && !record.tahesab_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -207,6 +210,7 @@ import { isMobile } from '@core/utils/is'
|
||||
import BasicModal from '@/components/BasicModal.vue'
|
||||
import TahesabRetryModal from '@/components/TahesabRetryModal.vue'
|
||||
import TahesabMobileCardList from '@/pages/menuPages/accounting/components/TahesabMobileCardList.vue'
|
||||
import TahesabDocSyncBox from '@/pages/menuPages/accounting/components/TahesabDocSyncBox.vue'
|
||||
import {
|
||||
tahesabIssueKindLabel,
|
||||
tahesabStatusLabel
|
||||
@@ -217,6 +221,12 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const docSyncStore = useTahesabDocSyncStore()
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
@@ -386,17 +396,24 @@ function openRegister(record: TahesabRecord) {
|
||||
async function loadPending() {
|
||||
try {
|
||||
pending.value = await getTahesabPendingSummary(props.customerId)
|
||||
docSyncStore.apply(pending.value?.doc_sync)
|
||||
} catch {
|
||||
pending.value = null
|
||||
}
|
||||
}
|
||||
|
||||
async function onDocSyncRefreshed() {
|
||||
await loadPending()
|
||||
if (docsView.value === 'failed') await loadFailedDocs()
|
||||
}
|
||||
|
||||
async function loadFailedDocs() {
|
||||
failedLoading.value = true
|
||||
try {
|
||||
const res = await getTahesabPendingDocs(props.customerId, 200)
|
||||
failedRows.value = res.rows || []
|
||||
pending.value = res.summary
|
||||
docSyncStore.apply(res.summary?.doc_sync)
|
||||
} catch {
|
||||
failedRows.value = []
|
||||
} finally {
|
||||
|
||||
@@ -76,12 +76,12 @@
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>جزئیات</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code && record.customer_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -90,6 +90,7 @@
|
||||
<Icon icon="vuesax-linear:profile-add" color="#7C3AED" />
|
||||
</a-tooltip>
|
||||
<a-button
|
||||
v-if="can('send')"
|
||||
type="link"
|
||||
size="small"
|
||||
:loading="syncingRowKey === failedRowKey(record)"
|
||||
@@ -108,13 +109,13 @@
|
||||
<BaseTable :key="docsView" v-bind="tblProps" @register="submit" ref="tbl">
|
||||
<template #action="{ record }">
|
||||
<div class="flex justify-center gap-2">
|
||||
<a-tooltip placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<a-tooltip v-if="can('doc')" placement="bottom" class="cursor-pointer" @click="openInfo(record)">
|
||||
<template #title><span>اطلاعات سند</span></template>
|
||||
<Icon icon="vuesax-linear:stickynote" color="#10913A" />
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id && !record.customer?.moshtari_code"
|
||||
v-if="can('register') && !record.zarin_id && !record.customer?.moshtari_code"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openRegister(record)"
|
||||
@@ -124,7 +125,7 @@
|
||||
</a-tooltip>
|
||||
|
||||
<a-tooltip
|
||||
v-if="!record.zarin_id"
|
||||
v-if="can('send') && !record.zarin_id"
|
||||
placement="bottom"
|
||||
class="cursor-pointer"
|
||||
@click="openSend(record)"
|
||||
@@ -216,6 +217,9 @@ import {
|
||||
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
|
||||
import { toJalali } from '@core/utils/useDataTime'
|
||||
import { accountingZarinDocsIntro } from '@/utils/adminHelpCopy'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
customerId?: number
|
||||
|
||||
@@ -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 '-'
|
||||
},
|
||||
},
|
||||
|
||||
@@ -97,6 +97,7 @@
|
||||
:value="priceValue"
|
||||
:disabled="disabled"
|
||||
class="w-full"
|
||||
:addon-after="unitLabel || undefined"
|
||||
:formatter="(v: string) => `${v}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"
|
||||
:parser="(v: string) => sanitizeNumericString(v, { allowDecimal: false })"
|
||||
@update:value="onPriceChange"
|
||||
@@ -109,6 +110,7 @@
|
||||
inputmode="numeric"
|
||||
allow-clear
|
||||
class="w-full"
|
||||
:addon-after="unitLabel || undefined"
|
||||
@update:value="onPlainNumberChange"
|
||||
@blur="emit('blur')"
|
||||
/>
|
||||
@@ -144,6 +146,7 @@ import TemplateTextField from './TemplateTextField.vue'
|
||||
import ZaarboxPriceKeyField from './ZaarboxPriceKeyField.vue'
|
||||
import { hasTemplateField } from './templateFields'
|
||||
import {
|
||||
getSettingUnitLabel,
|
||||
normalizeTimeValue,
|
||||
parseSelectOptions,
|
||||
resolveSettingFieldType,
|
||||
@@ -182,6 +185,8 @@ const fieldType = computed<SettingFieldType>(() =>
|
||||
})
|
||||
)
|
||||
|
||||
const unitLabel = computed(() => getSettingUnitLabel(props.settingKey, fieldType.value))
|
||||
|
||||
const isZaarboxPriceKey = computed(() => props.settingKey === 'zaarbox_price_key')
|
||||
const isMontzarProductId = computed(() => props.settingKey === 'montzar_product_id')
|
||||
const isMainWalletProducts = computed(() => props.settingKey === 'main_wallet_products')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<BasicShowContent :title="pageTitle" :help="configurationPageIntro" class="h-full">
|
||||
<BasicShowContent :title="pageTitle" :help="pageHelp" class="h-full">
|
||||
<div class="settings-toolbar">
|
||||
<a-input
|
||||
v-model:value="search"
|
||||
@@ -207,10 +207,10 @@ import { loading } from '@/utils'
|
||||
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
|
||||
import SettingValueField from './SettingValueField.vue'
|
||||
import SettingCard from './SettingCard.vue'
|
||||
import { configurationPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { configurationPageIntro, websiteSettingsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { refreshAppModeMenu } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings } from '@/utils/config'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setGiftCardEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings, applyHasLandingFromRows, setHasLandingFromSettings } from '@/utils/config'
|
||||
import {
|
||||
EDITABLE_SETTING_GROUPS,
|
||||
SYSTEM_SETTING_GROUPS,
|
||||
@@ -218,6 +218,12 @@ import {
|
||||
OTHER_PAGE_SETTING_MENUS,
|
||||
type SettingGroupDef
|
||||
} from './settingGroups'
|
||||
import {
|
||||
LANDING_SETTING_GROUPS,
|
||||
isLandingContentKey,
|
||||
landingSectionByPrefix,
|
||||
matchesLandingPrefix
|
||||
} from './landingSettings'
|
||||
import {
|
||||
SETTING_TYPE_OPTIONS,
|
||||
formatValueForSave,
|
||||
@@ -233,8 +239,9 @@ import {
|
||||
} from './settingTypes'
|
||||
import { TRADING_HOURS_SETTING_KEY_SET } from './tradingHoursKeys'
|
||||
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' }>(), {
|
||||
mode: 'editable'
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' | 'landing'; landingPrefix?: string }>(), {
|
||||
mode: 'editable',
|
||||
landingPrefix: ''
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -243,11 +250,24 @@ function refreshMenuAfterStoreChange() {
|
||||
}
|
||||
|
||||
const isSystemMode = computed(() => props.mode === 'system')
|
||||
const pageTitle = computed(() => (isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'))
|
||||
const isLandingMode = computed(() => props.mode === 'landing')
|
||||
const pageTitle = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
return landingSectionByPrefix(props.landingPrefix)?.title ?? 'تنظیمات وبسایت'
|
||||
}
|
||||
return isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'
|
||||
})
|
||||
const pageHelp = computed(() => (isLandingMode.value ? websiteSettingsPageIntro : configurationPageIntro))
|
||||
const refreshingSuperAdmin = ref(false)
|
||||
const settingGroups = computed(() =>
|
||||
isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
)
|
||||
const settingGroups = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
const prefix = props.landingPrefix || ''
|
||||
return prefix
|
||||
? LANDING_SETTING_GROUPS.filter((g) => g.id === prefix)
|
||||
: LANDING_SETTING_GROUPS
|
||||
}
|
||||
return isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
})
|
||||
|
||||
const settingTypeOptions = SETTING_TYPE_OPTIONS
|
||||
|
||||
@@ -327,6 +347,13 @@ const filteredRows = computed(() =>
|
||||
(baseData.value || []).filter((row) => {
|
||||
if (row.id == null || !matchesFilter(row)) return false
|
||||
if (!isSettingVisible(row.key)) return false
|
||||
if (isLandingMode.value) {
|
||||
if (!isEditable(row)) return false
|
||||
const prefix = props.landingPrefix || ''
|
||||
if (prefix) return matchesLandingPrefix(row.key || '', prefix)
|
||||
return isLandingContentKey(row.key)
|
||||
}
|
||||
if (isLandingContentKey(row.key)) return false
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (OTHER_PAGE_SETTING_MENUS.has(menu)) return false
|
||||
if (!menu && !isSystemMode.value && TRADING_HOURS_SETTING_KEY_SET.has(row.key || '')) {
|
||||
@@ -486,7 +513,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.mode,
|
||||
() => [props.mode, props.landingPrefix],
|
||||
() => {
|
||||
search.value = ''
|
||||
filterType.value = undefined
|
||||
@@ -608,6 +635,7 @@ async function initConfig() {
|
||||
applyPriceProviderFromRows(baseData.value)
|
||||
applyPriceChannelAccessFromRows(baseData.value)
|
||||
applySupportChatMenuEnabledFromRows(baseData.value)
|
||||
applyHasLandingFromRows(baseData.value)
|
||||
applyGroupSmsFromRows(baseData.value)
|
||||
applyCustomerSpecialPricingFromRows(baseData.value)
|
||||
applyGoldCreditEnabledFromRows(baseData.value)
|
||||
@@ -616,6 +644,7 @@ async function initConfig() {
|
||||
!isSystemMode.value ||
|
||||
!baseData.value.some((row) => row.key === 'price_provider') ||
|
||||
!baseData.value.some((row) => row.key === 'show_to_users_chat') ||
|
||||
!baseData.value.some((row) => row.key === 'has_landing') ||
|
||||
!baseData.value.some((row) => row.key === 'price_channel_access') ||
|
||||
!baseData.value.some((row) => row.key === 'group_sms') ||
|
||||
!baseData.value.some((row) => row.key === 'customer_special_pricing') ||
|
||||
@@ -627,6 +656,7 @@ async function initConfig() {
|
||||
const rows = Array.isArray(all) ? all : []
|
||||
applyPriceProviderFromRows(rows)
|
||||
applySupportChatMenuEnabledFromRows(rows)
|
||||
applyHasLandingFromRows(rows)
|
||||
applyPriceChannelAccessFromRows(rows)
|
||||
applyGroupSmsFromRows(rows)
|
||||
applyCustomerSpecialPricingFromRows(rows)
|
||||
@@ -688,6 +718,11 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
setPriceTriggerEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_gift_card') {
|
||||
setGiftCardEnabledFromSettings(isSwitchOn(value))
|
||||
refreshMenuAfterStoreChange()
|
||||
return
|
||||
}
|
||||
if (key === 'has_page_notification') {
|
||||
setAppNotificationEnabledFromSettings(isSwitchOn(value))
|
||||
return
|
||||
@@ -701,6 +736,14 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'has_landing') {
|
||||
setHasLandingFromSettings(isSwitchOn(value))
|
||||
const list = userStore.userInfo?.settings
|
||||
if (Array.isArray(list)) {
|
||||
const row = list.find((s: any) => s?.key === key)
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'price_channel_access') {
|
||||
setPriceChannelAccessFromSettings(isSwitchOn(value))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
export type LandingSection = {
|
||||
prefix: string
|
||||
title: string
|
||||
icon: string
|
||||
name: string
|
||||
path: string
|
||||
}
|
||||
|
||||
export const LANDING_SETTING_SECTIONS: LandingSection[] = [
|
||||
{ prefix: 'landing_site', title: 'تنظیمات کلی سایت', icon: 'vuesax-linear:global', name: 'websiteLandingSite', path: 'site' },
|
||||
{ prefix: 'landing_header', title: 'هدر و ناوبری', icon: 'vuesax-linear:menu', name: 'websiteLandingHeader', path: 'header' },
|
||||
{ prefix: 'landing_hero', title: 'هیرو', icon: 'vuesax-linear:image', name: 'websiteLandingHero', path: 'hero' },
|
||||
{ prefix: 'landing_live_price', title: 'لیبلهای قیمت لحظهای', icon: 'vuesax-linear:chart-2', name: 'websiteLandingLivePrice', path: 'live-price' },
|
||||
{ prefix: 'landing_calculator', title: 'عنوان ماشین حساب', icon: 'vuesax-linear:calculator', name: 'websiteLandingCalculator', path: 'calculator' },
|
||||
{ prefix: 'landing_feature', title: 'امکانات (چرا نیازی طلا)', icon: 'vuesax-linear:star', name: 'websiteLandingFeature', path: 'feature' },
|
||||
{ prefix: 'landing_steps', title: 'مراحل شروع', icon: 'vuesax-linear:ranking', name: 'websiteLandingSteps', path: 'steps' },
|
||||
{ prefix: 'landing_trust', title: 'اعتماد و مجوزها', icon: 'vuesax-linear:shield-tick', name: 'websiteLandingTrust', path: 'trust' },
|
||||
{ prefix: 'landing_faq', title: 'سوالات متداول', icon: 'vuesax-linear:message-question', name: 'websiteLandingFaq', path: 'faq' },
|
||||
{ prefix: 'landing_buttom_cta', title: 'سکشن پایین صفحه لندینگ برای معرفی', icon: 'vuesax-linear:arrow-down', name: 'websiteLandingBottomCta', path: 'bottom-cta' },
|
||||
{ prefix: 'landing_footer', title: 'فوتر', icon: 'vuesax-linear:document', name: 'websiteLandingFooter', path: 'footer' }
|
||||
]
|
||||
|
||||
export function matchesLandingPrefix(key: string, prefix: string): boolean {
|
||||
return key === prefix || key.startsWith(`${prefix}_`)
|
||||
}
|
||||
|
||||
export function isLandingContentKey(key?: string | null): boolean {
|
||||
return String(key ?? '').trim().startsWith('landing_')
|
||||
}
|
||||
|
||||
export function landingSectionByPrefix(prefix: string): LandingSection | undefined {
|
||||
return LANDING_SETTING_SECTIONS.find((s) => s.prefix === prefix)
|
||||
}
|
||||
|
||||
export const LANDING_SETTING_GROUPS = LANDING_SETTING_SECTIONS.map((section) => ({
|
||||
id: section.prefix,
|
||||
title: section.title,
|
||||
icon: section.icon,
|
||||
match: (key: string) => matchesLandingPrefix(key, section.prefix)
|
||||
}))
|
||||
@@ -15,6 +15,12 @@ export type SettingGroupDef = {
|
||||
|
||||
/** گروههای صفحه تنظیمات عادی (فقط can_edit=1) */
|
||||
export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
{
|
||||
id: 'digipay_installment',
|
||||
title: 'خرید اقساطی دیجیپی',
|
||||
icon: 'vuesax-linear:calendar',
|
||||
match: (k) => k === 'enable_digipay_installment' || k.startsWith('digipay_')
|
||||
},
|
||||
{
|
||||
id: 'general',
|
||||
title: 'عمومی و برند',
|
||||
@@ -158,7 +164,7 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
icon: 'vuesax-linear:people',
|
||||
// فقط فلگهای مالک سوپرادمین — banner/tracking/نمایش محصول در «تنظیمات» عادیاند
|
||||
match: (k) =>
|
||||
/^(enable_automation|enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|enable_gold_credit|permision__enabled|show_to_users_chat)$/.test(
|
||||
/^(enable_automation|enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|customer_special_pricing|enable_gold_credit|permision__enabled|show_to_users_chat|has_landing)$/.test(
|
||||
k
|
||||
)
|
||||
},
|
||||
@@ -265,6 +271,12 @@ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [
|
||||
icon: 'vuesax-linear:document-text',
|
||||
match: (k) => k.startsWith('pargar_') || k === 'send_to_pargar'
|
||||
},
|
||||
{
|
||||
id: 'accounting_shayegan',
|
||||
title: 'حسابداری شایگان',
|
||||
icon: 'vuesax-linear:receipt-item',
|
||||
match: (k) => k.startsWith('shayegan_')
|
||||
},
|
||||
{
|
||||
id: 'price_channel',
|
||||
title: 'ارسال قیمت به کانال',
|
||||
@@ -304,13 +316,23 @@ export function resolveSettingMenu(
|
||||
row: { key?: string; menu?: string | null },
|
||||
groups: SettingGroupDef[]
|
||||
): string {
|
||||
const key = row.key || ''
|
||||
const fromKey = getSettingGroupId(key, groups)
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (menu && groups.some((g) => g.id === menu)) return menu
|
||||
return getSettingGroupId(row.key || '', groups)
|
||||
if (menu && groups.some((g) => g.id === menu)) {
|
||||
// menu= misc اشتباه در DB نباید shayegan_/zarin_/… را از گروه اختصاصی پنهان کند
|
||||
if (menu === 'misc' && fromKey !== 'misc') {
|
||||
return fromKey
|
||||
}
|
||||
|
||||
return menu
|
||||
}
|
||||
|
||||
return fromKey
|
||||
}
|
||||
|
||||
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمیآیند */
|
||||
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites'])
|
||||
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites', 'website_settings'])
|
||||
|
||||
export function getSettingSubsectionId(
|
||||
key: string,
|
||||
|
||||
@@ -207,6 +207,7 @@ export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
|
||||
'jibit_enabled',
|
||||
'permision__enabled',
|
||||
'show_to_users_chat',
|
||||
'has_landing',
|
||||
])
|
||||
|
||||
export function isSuperAdminOwnedSettingKey(key?: string | null): boolean {
|
||||
@@ -288,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',
|
||||
@@ -324,7 +326,7 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
minimum_sell: 'price',
|
||||
gift_for_referrer: 'number',
|
||||
gift_for_referral: 'number',
|
||||
referral_bonus_amount: 'text',
|
||||
referral_bonus_amount: 'price',
|
||||
montzar_product_id: 'number',
|
||||
montzar_account_zarin: 'text',
|
||||
montzar_account_tahesab: 'text',
|
||||
@@ -429,7 +431,19 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
|
||||
pargar_item_id_gold: 'number',
|
||||
support_messengers: 'longtext',
|
||||
show_to_users_chat: 'switch',
|
||||
has_landing: 'switch',
|
||||
has_chat: 'switch',
|
||||
landing_site: 'longtext',
|
||||
landing_header: 'longtext',
|
||||
landing_hero: 'longtext',
|
||||
landing_live_price: 'longtext',
|
||||
landing_calculator: 'longtext',
|
||||
landing_feature: 'longtext',
|
||||
landing_steps: 'longtext',
|
||||
landing_trust: 'longtext',
|
||||
landing_faq: 'longtext',
|
||||
landing_buttom_cta: 'longtext',
|
||||
landing_footer: 'longtext',
|
||||
chat_api: 'text',
|
||||
chat_api_key: 'text',
|
||||
chat_upload_url: 'text',
|
||||
@@ -623,6 +637,45 @@ export function formatValueForSave(
|
||||
return value ?? ''
|
||||
}
|
||||
|
||||
/** واحد نمایش روی فیلدهای عددی — شناسه/پورت واحد ندارند */
|
||||
const SETTING_UNIT_BY_KEY: Record<string, string> = {
|
||||
buy_fee: 'ریال',
|
||||
sell_fee: 'ریال',
|
||||
fee_single: 'ریال',
|
||||
fee_conditional_order: 'ریال',
|
||||
min_withdraw: 'ریال',
|
||||
min_deposit: 'ریال',
|
||||
min_first_buy: 'ریال',
|
||||
minimum_sell: 'ریال',
|
||||
price_channel_diff: 'ریال',
|
||||
referral_bonus_amount: 'ریال',
|
||||
gold_credit_penalty_amount: 'ریال / کیلوگرم',
|
||||
gift_for_referrer: 'کیلوگرم',
|
||||
gift_for_referral: 'کیلوگرم',
|
||||
gold_credit_min_balance_gram: 'کیلوگرم',
|
||||
change_mesghal: 'کیلوگرم',
|
||||
fee_service_charge_percentage: 'درصد (اعشاری)',
|
||||
gold_credit_grace_hours: 'ساعت',
|
||||
gold_credit_default_months: 'ماه',
|
||||
price_channel_min_seconds: 'ثانیه',
|
||||
referral_limit: 'دعوت',
|
||||
fee_free: 'سفارش',
|
||||
}
|
||||
|
||||
export function getSettingUnitLabel(
|
||||
key?: string,
|
||||
type?: SettingFieldType,
|
||||
): string {
|
||||
const k = (key ?? '').trim()
|
||||
if (k && SETTING_UNIT_BY_KEY[k]) {
|
||||
return SETTING_UNIT_BY_KEY[k]
|
||||
}
|
||||
if (type === 'price') {
|
||||
return 'ریال'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function switchLabels(key: string | undefined): { on: string; off: string } {
|
||||
if (key === REFERRAL_REQUIRED_KEY) {
|
||||
return { on: 'اجباری', off: 'اختیاری' }
|
||||
@@ -683,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:
|
||||
@@ -710,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:
|
||||
@@ -742,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:
|
||||
@@ -786,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:
|
||||
@@ -800,7 +855,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
referral_limit:
|
||||
'حداکثر تعداد دعوت مجاز برای هر کاربر. خالی = بدون محدودیت.',
|
||||
referral_bonus_amount:
|
||||
'مبلغ یا مقدار پاداش معرف برای نمایش در پیامکها و متنهای دعوت.',
|
||||
'مبلغ پاداش معرف (ریال) برای نمایش در پیامکها و متنهای دعوت. واحد روی خود فیلد مشخص است.',
|
||||
jibit_verification:
|
||||
'روشن: هنگام ثبت یا ویرایش کارت بانکی، تطبیق با سرویس احراز هویت جیبیت انجام میشود. خاموش: کارت بدون تطبیق جیبیت ثبت میشود.',
|
||||
register_jibit_verify:
|
||||
@@ -832,7 +887,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
montzar_open_sell:
|
||||
'وضعیت واقعی از سرویس خارجی خوانده میشود. روشن: ثبت سفارش فروش از طریق قیمت همکار مجاز است. خاموش: ثبت سفارش فروش از طریق قیمت همکار غیرفعال است.',
|
||||
montzar_order_wait_callback:
|
||||
'روشن (پیشفرض): بعد از ارسال سفارش به همکار، تا کالبک وضعیت (تأیید=۲ / رد=۴ یا ۶) یا استعلام مسیر وضعیت صبر میشود و کیف ثبت نمیشود. خاموش: مثل قبل با همان پاسخ HTTP همکار سفارش قطعی میشود.',
|
||||
'با منبع قیمت همکار، سفارش همیشه تا کالبک یا استعلام وضعیت در انتظار میماند و کیف بعد از تأیید ثبت میشود. خاموش بودن این سوییچ دیگر مسیر قطعی بلافاصله را باز نمیکند. در رد همکار، SMS به ادمینهای دارای ارسال پیامک میرود.',
|
||||
montzar_order_status_path:
|
||||
'مسیر GET روی دامنه همکار (montzar_base_url) برای استعلام وضعیت اگر کالبک نرسید. پیشفرض /server/customer/order — با شماره سفارش همکار میشود /server/customer/order/40000.',
|
||||
montzar_closed:
|
||||
@@ -863,6 +918,19 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
'فقط مواردی که در این لیست ثبت شوند در منوی شناور پشتیبانی اپ مشتری نمایش داده میشوند. برای تماس تلفنی یا پیامک، نوع «تماس تلفنی» / «پیامک» را با شماره اضافه کنید. لیست میتواند خالی باشد؛ اگر چت فعال باشد، پشتیبانی مستقیم به صفحه چت میرود.',
|
||||
show_to_users_chat:
|
||||
'روشن: قابلیت چت پشتیبانی برای این دیپلوی فعال است (منوی ادمین و پیشنیاز نمایش به کاربر). خاموش: چت در ادمین و اپ کاربر مخفی است و سوییچ «چت پشتیبانی» (has_chat) از تنظیمات عادی هم برداشته میشود.',
|
||||
has_landing:
|
||||
'روشن: منوی تنظیمات وبسایت در ادمین و تنظیمات لندینگ برای اپ کاربر فعال است. خاموش: منو مخفی است.',
|
||||
landing_site: 'محتوای تنظیمات کلی لندینگ وبسایت.',
|
||||
landing_header: 'محتوای هدر و ناوبری لندینگ.',
|
||||
landing_hero: 'محتوای سکشن هیرو لندینگ.',
|
||||
landing_live_price: 'لیبلها و متن قیمت لحظهای لندینگ.',
|
||||
landing_calculator: 'عنوان و متن ماشین حساب لندینگ.',
|
||||
landing_feature: 'متن امکانات لندینگ (چرا نیازی طلا).',
|
||||
landing_steps: 'متن مراحل شروع لندینگ.',
|
||||
landing_trust: 'متن اعتماد و مجوزها (بدون اینماد).',
|
||||
landing_faq: 'سوالات متداول لندینگ.',
|
||||
landing_buttom_cta: 'متن دعوت به اقدام پایین صفحه لندینگ.',
|
||||
landing_footer: 'محتوای فوتر لندینگ.',
|
||||
has_chat:
|
||||
'روشن: چت پشتیبانی در اپ مشتری نمایش داده میشود (فقط وقتی show_to_users_chat هم روشن باشد). خاموش: دکمه و صفحه چت برای کاربر مخفی است.',
|
||||
chat_api:
|
||||
@@ -950,7 +1018,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
enable_gold_credit:
|
||||
'روشن: زیرمنوی اعتبار در مشتریان و صفحه اعتبار در اپ مشتری فعال میشود. خاموش: غیرفعال. فقط از سوپرادمین قابل تغییر است.',
|
||||
customer_special_pricing:
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی مظنه و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
'روشن: زیرمنوی قیمت ویژه در مشتریان و اعمال سود خرید/فروش پکیج روی قیمت و سفارش برای کاربران انتخابشده. خاموش: غیرفعال. فقط از دیپلوی قابل تغییر است.',
|
||||
profit_gold_api_enabled:
|
||||
'روشن: محاسبه سود طلا از API خارجی فعال است. خاموش: محاسبه سود از API خارجی انجام نمیشود (حالت پیشفرض اکثر نصبها).',
|
||||
main_wallet_products:
|
||||
@@ -1022,7 +1090,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
zarin_gorohe_kar:
|
||||
'کد gorooheKar هنگام ساخت/جستجوی کار در زرین. اگر چند پنل یک زرین دارند، برای هر پنل گروه کار متفاوت بگذارید.',
|
||||
zarin_name_g:
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون مظنه فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
'نام گروه حساب مشتریان در زرین (nameG). برای اپ خانگی معمولاً «مشتری نقدی (خریدار)» (گروه ۶). گروه همکار استفاده نشود چون قیمت فرق دارد. فقط از تنظیمات/دیپلوی تغییر میکند.',
|
||||
zarin_uid_prefix:
|
||||
'پیشوند عددی uid برای جلوگیری از تداخل بین چند پنل روی یک زرین. فقط عدد (مثلاً ۱۱).',
|
||||
zarin_idbank:
|
||||
@@ -1036,7 +1104,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
|
||||
main_product_price:
|
||||
'تنظیم قدیمی — از «منبع قیمت» استفاده کنید. روشن نگه داشتن توصیه نمیشود.',
|
||||
price_channel_enabled:
|
||||
'روشن: بعد از هر تغییر قیمت، مظنه بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
'روشن: بعد از هر تغییر قیمت، قیمت بهصورت خودکار به کانالهای پیامرسان انتخابشده ارسال میشود.',
|
||||
price_channel_access:
|
||||
'روشن: گروه «ارسال قیمت به کانال» در تنظیمات عادی پنل دیده میشود. خاموش: مخفی است (فقط از تنظیمات پیشرفته).',
|
||||
price_channel_messengers:
|
||||
@@ -1062,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: 'ساعت پایان',
|
||||
@@ -1119,6 +1188,8 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
minimum_sell: 'حداقل مبلغ فروش (ریال)',
|
||||
referral_id: 'کد معرف اجباری',
|
||||
referral_bonus_amount: 'مقدار پاداش معرف',
|
||||
gift_for_referrer: 'پاداش معرف',
|
||||
gift_for_referral: 'پاداش معرفشونده',
|
||||
referral_gift_on_first_order: 'پاداش معرف پس از اولین سفارش',
|
||||
referral_gift_buy_from_montzar: 'خرید پاداش معرفی از همکار',
|
||||
open_register: 'ثبتنام باز',
|
||||
@@ -1129,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: 'یادآوری سررسید قسط اعتبار',
|
||||
@@ -1187,7 +1258,19 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
|
||||
zarin_idbank: 'کد حساب بانک زرین',
|
||||
support_messengers: 'پیامرسانهای پشتیبانی',
|
||||
show_to_users_chat: 'نمایش چت به کاربران',
|
||||
has_landing: 'لندینگ وبسایت',
|
||||
has_chat: 'چت پشتیبانی',
|
||||
landing_site: 'تنظیمات کلی سایت',
|
||||
landing_header: 'هدر و ناوبری',
|
||||
landing_hero: 'هیرو',
|
||||
landing_live_price: 'لیبلهای قیمت لحظهای',
|
||||
landing_calculator: 'عنوان ماشین حساب',
|
||||
landing_feature: 'امکانات (چرا نیازی طلا)',
|
||||
landing_steps: 'مراحل شروع',
|
||||
landing_trust: 'اعتماد و مجوزها',
|
||||
landing_faq: 'سوالات متداول',
|
||||
landing_buttom_cta: 'سکشن پایین صفحه لندینگ برای معرفی',
|
||||
landing_footer: 'فوتر',
|
||||
chat_api: 'API چت',
|
||||
chat_api_key: 'کلید API چت',
|
||||
chat_upload_url: 'آدرس آپلود فایل چت',
|
||||
@@ -1225,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) — در تنظیمات پیشرفته قابل ویرایش (ادمین دیپلوی) */
|
||||
@@ -1286,7 +1369,7 @@ export const SETTING_LOCKED_KEYS = new Set([
|
||||
'price_channel_bale_to', 'price_channel_telegram_to', 'price_channel_rubika_to',
|
||||
'unit',
|
||||
'wss_enabled',
|
||||
'show_to_users_chat', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
|
||||
'show_to_users_chat', 'has_landing', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
|
||||
])
|
||||
|
||||
/** قابل ویرایش در پنل عادی — همتراز deploy_settings_const.sql */
|
||||
@@ -1326,6 +1409,8 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
||||
'support_messengers', 'support_messenger_text',
|
||||
'do_send_liman',
|
||||
'has_chat',
|
||||
'landing_site', 'landing_header', 'landing_hero', 'landing_live_price', 'landing_calculator',
|
||||
'landing_feature', 'landing_steps', 'landing_trust', 'landing_faq', 'landing_buttom_cta', 'landing_footer',
|
||||
'text_about', 'text_rule', 'about_software', 'enamad_url', 'enamad_logo',
|
||||
'login_hero_eyebrow', 'login_hero_title',
|
||||
'login_hero_feature_1', 'login_hero_feature_2', 'login_hero_feature_3', 'login_hero_feature_4',
|
||||
@@ -1336,10 +1421,14 @@ export const SETTING_EDITABLE_KEYS = new Set([
|
||||
])
|
||||
|
||||
/** عنوان فارسی — کاتالوگ پنل بر title_fa دیتابیس اولویت دارد */
|
||||
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa'>): string {
|
||||
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa' | 'type'>): string {
|
||||
const key = (row.key ?? '').trim()
|
||||
if (key && KEY_LABEL_FALLBACK[key]) return KEY_LABEL_FALLBACK[key]
|
||||
return row.title_fa?.trim() || key || '—'
|
||||
const base = (key && KEY_LABEL_FALLBACK[key]) ? KEY_LABEL_FALLBACK[key] : (row.title_fa?.trim() || key || '—')
|
||||
const unit = getSettingUnitLabel(key, resolveSettingFieldType(row))
|
||||
if (!unit || base.includes(unit) || base.includes(`(${unit})`)) {
|
||||
return base
|
||||
}
|
||||
return `${base} (${unit})`
|
||||
}
|
||||
|
||||
/** توضیح — کاتالوگ پنل بر description دیتابیس اولویت دارد */
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="decisionVisible"
|
||||
:source-label="provider === 'zarin' ? 'زرین' : 'تهحساب'"
|
||||
:allow-push="provider === 'tahesab'"
|
||||
:app-gold="decision?.app_gold"
|
||||
:app-cash="decision?.app_cash"
|
||||
:tahesab-gold="decision?.tahesab_gold ?? decision?.zarin_gold"
|
||||
@@ -96,7 +97,9 @@ const visibleProxy = computed({
|
||||
function currentCodeOf(customer: Customer | null): string {
|
||||
if (!customer) return ''
|
||||
if (props.provider === 'pargar') return displayAccountingCode(customer.pargar_account_id)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin') return displayAccountingCode(customer.moshtari_code)
|
||||
if (props.provider === 'tahesab' || props.provider === 'zarin' || props.provider === 'shayegan') {
|
||||
return displayAccountingCode(customer.moshtari_code)
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -120,8 +123,12 @@ async function saveCode(customerId: number, body: Record<string, string>) {
|
||||
close()
|
||||
}
|
||||
|
||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep') {
|
||||
async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep' | 'push') {
|
||||
if (props.provider === 'zarin') {
|
||||
if (mode === 'push') {
|
||||
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||
return { ok: false, message: 'پشتیبانی نمیشود' }
|
||||
}
|
||||
return syncCustomerWalletFromZarin(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
@@ -131,11 +138,12 @@ async function applyWalletDecision(customerId: number, mode: 'overwrite' | 'keep
|
||||
return syncCustomerWalletFromTahesab(customerId, {
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
ask_if_conflict: false,
|
||||
})
|
||||
}
|
||||
|
||||
async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
const pending = pendingPayload.value
|
||||
decisionVisible.value = false
|
||||
if (!pending) return
|
||||
@@ -144,6 +152,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
await saveCode(pending.customerId, pending.body)
|
||||
const res = await applyWalletDecision(pending.customerId, mode)
|
||||
if (mode === 'keep') message.info(res.message || 'موجودی اپ حفظ شد')
|
||||
else if (mode === 'push') message.success(res.message || 'مانده اپ روی تهحساب اعمال شد')
|
||||
else message.success(res.message || 'مانده حسابداری روی کیف اعمال شد')
|
||||
emit('success')
|
||||
} catch (e) {
|
||||
@@ -156,7 +165,7 @@ async function onDecide(mode: 'overwrite' | 'keep') {
|
||||
|
||||
async function submit() {
|
||||
if (!props.customer?.id) return
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin') {
|
||||
if (props.provider !== 'pargar' && props.provider !== 'tahesab' && props.provider !== 'zarin' && props.provider !== 'shayegan') {
|
||||
message.error('حسابداری فعال نیست.')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
</section>
|
||||
|
||||
<BaseButton
|
||||
v-if="can('charge')"
|
||||
class="customer-mobile-sheet__charge-btn"
|
||||
size="middle"
|
||||
type="primary"
|
||||
@@ -39,7 +40,7 @@
|
||||
|
||||
<div class="customer-mobile-sheet__actions">
|
||||
<BaseButton
|
||||
v-if="accountingCodeLabel"
|
||||
v-if="can('accountingCode') && accountingCodeLabel"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:card-edit"
|
||||
@@ -47,14 +48,14 @@
|
||||
>
|
||||
کد حسابداری
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
<BaseButton v-if="can('info')" size="small" type="default" icon="vuesax-linear:stickynote" @click="closeAndEmit('info', row)">
|
||||
مشخصات
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
<BaseButton v-if="can('edit')" size="small" type="default" icon="vuesax-linear:edit" @click="closeAndEmit('edit', row)">
|
||||
ویرایش
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerLevelProfitEnabled"
|
||||
v-if="can('referral') && customerLevelProfitEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:hierarchy-2"
|
||||
@@ -62,11 +63,11 @@
|
||||
>
|
||||
سود چندسطحی
|
||||
</BaseButton>
|
||||
<BaseButton size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
<BaseButton v-if="can('archive')" size="small" type="default" icon="vuesax-linear:archive-tick" @click="closeAndEmit('archive', row)">
|
||||
بایگانی
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="customerDirectSmsEnabled"
|
||||
v-if="can('sms') && customerDirectSmsEnabled"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:sms"
|
||||
@@ -75,7 +76,7 @@
|
||||
پیامک
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="!row.is_legal"
|
||||
v-if="can('approve') && !row.is_legal"
|
||||
size="small"
|
||||
type="default"
|
||||
icon="vuesax-linear:user-search"
|
||||
@@ -84,6 +85,7 @@
|
||||
تایید
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('active')"
|
||||
size="small"
|
||||
:type="row.active ? 'default' : 'primary'"
|
||||
:icon="row.active ? 'vuesax-linear:user-remove' : 'vuesax-linear:user-tick'"
|
||||
@@ -92,6 +94,7 @@
|
||||
{{ row.active ? 'غیرفعال' : 'فعال' }}
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('trade')"
|
||||
size="small"
|
||||
:type="row.trade_active === 1 ? 'default' : 'primary'"
|
||||
:icon="row.trade_active === 1 ? 'vuesax-linear:box-remove' : 'vuesax-linear:box-tick'"
|
||||
@@ -135,6 +138,9 @@ import {
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode } from '@/utils/accountingCode'
|
||||
import CustomerPresenceBadge from '@/pages/menuPages/customers/base/components/CustomerPresenceBadge.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
<div class="min-w-0 flex-1 space-y-1.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
v-if="can('info')"
|
||||
type="button"
|
||||
class="min-w-0 flex-1 truncate border-none bg-transparent p-0 text-right text-sm font-700 text-gray-900"
|
||||
@click.stop="$emit('info', item)"
|
||||
>
|
||||
{{ item.name || '-' }}
|
||||
</button>
|
||||
<span v-else class="min-w-0 flex-1 truncate text-sm font-700 text-gray-900">{{ item.name || '-' }}</span>
|
||||
<span
|
||||
class="inline-block h-2.5 w-2.5 shrink-0 rounded-full"
|
||||
:class="item.active ? 'bg-green-500' : 'bg-red-500'"
|
||||
@@ -41,6 +43,7 @@
|
||||
عملیات
|
||||
</BaseButton>
|
||||
<BaseButton
|
||||
v-if="can('edit')"
|
||||
type="default"
|
||||
size="small"
|
||||
class="min-w-[4.5rem]"
|
||||
@@ -57,6 +60,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { Customer } from '@/model/customer'
|
||||
import MobileCard from '@/components/mobile/MobileCard.vue'
|
||||
import { usePageActionAccess } from '@/composables/usePageActionAccess'
|
||||
|
||||
const { can } = usePageActionAccess()
|
||||
|
||||
const props = defineProps<{
|
||||
item: Customer
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-model:visible="visibleProxy"
|
||||
:width="isMobile ? '92vw' : '36rem'"
|
||||
:width="isMobile ? '92vw' : '40rem'"
|
||||
title="تصمیم برای مانده حساب"
|
||||
:custom-footer="true"
|
||||
cancel-text="بعداً"
|
||||
@close="close"
|
||||
>
|
||||
<div class="flex flex-col gap-3 text-sm" style="color: var(--admin-text)">
|
||||
<p class="m-0" style="color: var(--admin-text-secondary)">
|
||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند؛ یکی را پس از بررسی سندها تأیید کنید.
|
||||
<p class="m-0 leading-6" style="color: var(--admin-text-secondary)">
|
||||
موجودی اپ با مانده {{ sourceLabel }} فرق دارد. دو مانده جمع نمیشوند — یکی از سه مسیر زیر را انتخاب کنید.
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="appIsEmpty && allowPush"
|
||||
class="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-5 text-amber-900"
|
||||
>
|
||||
موجودی اپ صفر است. اگر «اعمال مانده اپ روی تهحساب» را بزنید، مانده تهحساب با سند تعدیل همتراز صفر اپ میشود.
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-base p-3 space-y-2" style="background: var(--admin-bg-muted)">
|
||||
<div class="flex justify-between gap-2">
|
||||
<span style="color: var(--admin-text-secondary)">موجودی اپ (طلا)</span>
|
||||
@@ -84,12 +92,58 @@
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<a-button type="primary" block :loading="loading === 'overwrite'" :disabled="!!loading" @click="choose('overwrite')">
|
||||
اعمال مانده {{ sourceLabel }} روی کیف
|
||||
</a-button>
|
||||
<a-button block :loading="loading === 'keep'" :disabled="!!loading" @click="choose('keep')">
|
||||
نگه داشتن موجودی فعلی اپ
|
||||
</a-button>
|
||||
<button
|
||||
type="button"
|
||||
class="mande-choice mande-choice--primary"
|
||||
:disabled="!!loading"
|
||||
@click="choose('overwrite')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'overwrite'" size="small" class="me-1" />
|
||||
اعمال مانده {{ sourceLabel }} روی کیف اپ
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
موجودی اپ مثل {{ sourceLabel }} میشود. سند تعدیل روی کیف اپ ثبت میشود.
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="allowPush"
|
||||
type="button"
|
||||
class="mande-choice"
|
||||
:class="appIsEmpty ? 'mande-choice--warn' : 'mande-choice--secondary'"
|
||||
:disabled="!!loading"
|
||||
@click="choose('push')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'push'" size="small" class="me-1" />
|
||||
اعمال مانده اپ روی {{ sourceLabel }}
|
||||
<span v-if="appIsEmpty" class="mande-choice__badge">اپ صفر</span>
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
{{
|
||||
appIsEmpty
|
||||
? `مانده ${sourceLabel} با سند تعدیل همتراز صفر اپ میشود. کیف اپ تغییر نمیکند.`
|
||||
: `مانده ${sourceLabel} مثل موجودی اپ میشود. کیف اپ تغییر نمیکند.`
|
||||
}}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="mande-choice"
|
||||
:disabled="!!loading"
|
||||
@click="choose('keep')"
|
||||
>
|
||||
<span class="mande-choice__title">
|
||||
<a-spin v-if="loading === 'keep'" size="small" class="me-1" />
|
||||
نگه داشتن وضعیت فعلی
|
||||
</span>
|
||||
<span class="mande-choice__hint">
|
||||
نه کیف اپ عوض میشود نه {{ sourceLabel }}؛ اختلاف برای بعد میماند.
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<a-button type="link" block :disabled="!!loading" @click="close">بعداً</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,7 +157,10 @@ import BasicModal from '@/components/BasicModal.vue'
|
||||
import { isMobile } from '@core/utils/is'
|
||||
import type { TahesabPreviewDoc } from '@/api/tahesab'
|
||||
|
||||
const props = defineProps<{
|
||||
export type MandeDecisionMode = 'overwrite' | 'keep' | 'push'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
appGold?: number | null
|
||||
appCash?: number | null
|
||||
@@ -114,16 +171,20 @@ const props = defineProps<{
|
||||
goldDelta?: number | null
|
||||
rialDelta?: number | null
|
||||
sourceLabel?: string
|
||||
/** فقط تهحساب: اجازهٔ نوشتن مانده اپ روی حسابداری */
|
||||
allowPush?: boolean
|
||||
walletDocs?: TahesabPreviewDoc[]
|
||||
tahesabDocs?: TahesabPreviewDoc[]
|
||||
}>()
|
||||
}>(),
|
||||
{ allowPush: false }
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'decide', mode: 'overwrite' | 'keep'): void
|
||||
(e: 'decide', mode: MandeDecisionMode): void
|
||||
}>()
|
||||
|
||||
const loading = ref<'overwrite' | 'keep' | null>(null)
|
||||
const loading = ref<MandeDecisionMode | null>(null)
|
||||
const sourceLabel = computed(() => props.sourceLabel || 'تهحساب')
|
||||
const sourceGoldValue = computed(() => props.sourceGold ?? props.tahesabGold)
|
||||
const sourceCashValue = computed(() => props.sourceCash ?? props.tahesabCash)
|
||||
@@ -140,6 +201,11 @@ const sourceDocs = computed(() => props.tahesabDocs ?? [])
|
||||
const showDocs = computed(
|
||||
() => sourceLabel.value === 'تهحساب' || walletDocs.value.length > 0 || sourceDocs.value.length > 0
|
||||
)
|
||||
const appIsEmpty = computed(() => {
|
||||
const g = Math.abs(Number(props.appGold ?? 0))
|
||||
const c = Math.abs(Number(props.appCash ?? 0))
|
||||
return g < 0.0005 && c < 1
|
||||
})
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
@@ -186,8 +252,75 @@ function close() {
|
||||
visibleProxy.value = false
|
||||
}
|
||||
|
||||
function choose(mode: 'overwrite' | 'keep') {
|
||||
function choose(mode: MandeDecisionMode) {
|
||||
loading.value = mode
|
||||
emit('decide', mode)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.mande-choice {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.25rem;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
border-radius: 0.75rem;
|
||||
border: 1px solid var(--admin-border, #e5e7eb);
|
||||
background: var(--admin-surface, #fff);
|
||||
padding: 0.75rem 0.875rem;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.15s ease, background 0.15s ease;
|
||||
}
|
||||
|
||||
.mande-choice:disabled {
|
||||
opacity: 0.65;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.mande-choice:not(:disabled):hover {
|
||||
border-color: var(--admin-primary, #10913a);
|
||||
}
|
||||
|
||||
.mande-choice--primary {
|
||||
border-color: var(--admin-primary, #10913a);
|
||||
background: color-mix(in srgb, var(--admin-primary, #10913a) 8%, white);
|
||||
}
|
||||
|
||||
.mande-choice--secondary:not(:disabled):hover {
|
||||
background: var(--admin-bg-muted, #f8fafc);
|
||||
}
|
||||
|
||||
.mande-choice--warn {
|
||||
border-color: #f59e0b;
|
||||
background: #fffbeb;
|
||||
}
|
||||
|
||||
.mande-choice__title {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 700;
|
||||
color: var(--admin-text, #111827);
|
||||
}
|
||||
|
||||
.mande-choice__hint {
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.5;
|
||||
color: var(--admin-text-secondary, #6b7280);
|
||||
}
|
||||
|
||||
.mande-choice__badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border-radius: 999px;
|
||||
background: #fef3c7;
|
||||
color: #92400e;
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 700;
|
||||
padding: 0.1rem 0.45rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -308,6 +308,7 @@
|
||||
<TahesabMandeDecisionModal
|
||||
v-model:visible="tahesabDecisionVisible"
|
||||
:source-label="walletDecisionLabel"
|
||||
:allow-push="walletDecisionProvider === 'tahesab'"
|
||||
:app-gold="tahesabDecision?.app_gold"
|
||||
:app-cash="tahesabDecision?.app_cash"
|
||||
:tahesab-gold="tahesabDecision?.tahesab_gold ?? tahesabDecision?.zarin_gold"
|
||||
@@ -494,7 +495,7 @@ function infoOrder(val: Order) {
|
||||
infoParams.itemsTitle = 'اطلاعات کاربری'
|
||||
infoParams.items = [
|
||||
{
|
||||
key: 'مقدار (گرم)',
|
||||
key: 'مقدار (کیلوگرم)',
|
||||
value: val.amount ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -514,7 +515,7 @@ function infoOrder(val: Order) {
|
||||
value: usePrice(val.total_price_original ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
key: 'سود هر گرم (ریال)',
|
||||
key: 'سود هر کیلوگرم (ریال)',
|
||||
value: usePrice(val.fee ?? 0) ?? '-'
|
||||
},
|
||||
{
|
||||
@@ -532,7 +533,7 @@ function infoOrder(val: Order) {
|
||||
{
|
||||
key: 'کارمزد (طلا)',
|
||||
value: val.service_charge != null && val.service_charge !== ''
|
||||
? `${val.service_charge} گرم`
|
||||
? `${val.service_charge} کیلوگرم`
|
||||
: '-'
|
||||
},
|
||||
{
|
||||
@@ -774,7 +775,7 @@ const userInfo = ref<Customer>()
|
||||
|
||||
const accountingCodeVisible = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin'
|
||||
return provider === 'pargar' || provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan'
|
||||
})
|
||||
|
||||
const conditionalOrderEnabled = computed(() => conditionalOrderEnabledSetting.value)
|
||||
@@ -796,7 +797,7 @@ function onConditionalOrderUpdated(payload: {
|
||||
const accountingCodeValue = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(userInfo.value?.pargar_account_id)
|
||||
if (provider === 'tahesab' || provider === 'zarin') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
if (provider === 'tahesab' || provider === 'zarin' || provider === 'shayegan') return displayAccountingCode(userInfo.value?.moshtari_code)
|
||||
return '-'
|
||||
})
|
||||
|
||||
@@ -855,7 +856,7 @@ function openTahesabDecision(result?: TahesabWalletSyncResult['result'], provide
|
||||
tahesabDecisionVisible.value = true
|
||||
}
|
||||
|
||||
async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' | 'push' = 'ask') {
|
||||
if (!userInfo.value?.id || !tahesabWalletCanSync.value || tahesabSyncLoading.value) return
|
||||
tahesabSyncLoading.value = true
|
||||
try {
|
||||
@@ -877,6 +878,7 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
ask_if_conflict: false,
|
||||
overwrite: mode === 'overwrite',
|
||||
keep: mode === 'keep',
|
||||
push_to_tahesab: mode === 'push',
|
||||
})
|
||||
|
||||
if (res.needs_decision || res.result?.needs_decision) {
|
||||
@@ -885,7 +887,14 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
}
|
||||
|
||||
if (res.result?.applied || res.ok) {
|
||||
message.success(res.message || 'مانده از تهحساب روی کیف اعمال شد')
|
||||
message.success(
|
||||
res.message ||
|
||||
(mode === 'push'
|
||||
? 'مانده اپ روی تهحساب اعمال شد'
|
||||
: mode === 'keep'
|
||||
? 'موجودی اپ حفظ شد'
|
||||
: 'مانده از تهحساب روی کیف اعمال شد')
|
||||
)
|
||||
} else {
|
||||
message.info(res.message || 'تغییری برای اعمال نبود')
|
||||
}
|
||||
@@ -902,18 +911,24 @@ async function syncTahesabWallet(mode: 'ask' | 'overwrite' | 'keep' = 'ask') {
|
||||
refreshTable()
|
||||
|
||||
if (data?.result?.applied || data?.ok) {
|
||||
message.success(data?.message || 'مانده از تهحساب روی کیف اعمال شد')
|
||||
message.success(data?.message || 'مانده با تهحساب همتراز شد')
|
||||
} else if (status !== 422) {
|
||||
message.warning(data?.message || 'اعمال مانده از تهحساب ناموفق بود')
|
||||
message.warning(data?.message || 'اعمال مانده با تهحساب ناموفق بود')
|
||||
} else if (data?.message) {
|
||||
message.warning(data.message)
|
||||
}
|
||||
} finally {
|
||||
tahesabSyncLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep') {
|
||||
async function onTahesabMandeDecide(mode: 'overwrite' | 'keep' | 'push') {
|
||||
tahesabDecisionVisible.value = false
|
||||
if (walletDecisionProvider.value === 'zarin') {
|
||||
if (mode === 'push') {
|
||||
message.warning('اعمال مانده اپ روی زرین در این نسخه پشتیبانی نمیشود')
|
||||
return
|
||||
}
|
||||
await syncZarinWallet(mode)
|
||||
return
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user