Compare commits

..
10 Commits
Author SHA1 Message Date
mohmdsdgandCursor 0f60c1e1a5 fix(wallet): keep gold and silver asset details separate
Stop merging count_products into inventory cards so silver items are not duplicated and each metal shows its own total.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-06 13:40:41 +03:30
mohmdsdgandCursor 3fc62ba100 fix(products): set direct_price when saving manual pricing
Manual source left direct_price=0 so customer enrich overwrote stored price with live gold buy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-06 11:38:46 +03:30
mohmdsdgandCursor 9ef381f00e feat(tahesab): three-way mande decision UI including push to Tahesab
Clarify overwrite vs keep vs push-to-tahesab, warn when app balance is zero, and update colleague wait-callback help text.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-05 22:30:58 +03:30
mohmdsdgandCursor e0b89223ac feat: website settings menu gated by has_landing
Add تنظیمات وبسایت before پیکربندی with landing_* subsections, and show unit addon on numeric setting fields.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-05 17:01:51 +03:30
mohmdsdgandCursor dec36cc31e feat(products): add list and TV visibility icons in operations
Clarify tooltips for product-list vs TV board, keep the same switches in the editor, and show separate status columns.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-05 10:16:37 +03:30
mohmdsdgandCursor 7c95f1f9d6 feat(tahesab): show remaining-time estimate in sync progress modal
Estimate ETA from processed throughput for customer export and document sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 20:24:44 +03:30
mohmdsdgandCursor 11f60f205a feat(tahesab): add local status reset before resending wiped documents
Confirm and call reset-local so the pending count includes previously successful rows, then send all as usual.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 13:43:16 +03:30
mohmdsdgandCursor 62a6a91455 feat(tahesab): poll customer sync from any page and reuse the progress modal
Start outbound/inbound on the server; hydrate after refresh so the transfer modal returns without opening accounting.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-03 10:09:54 +03:30
mohmdsdgandCursor 6ab14313dd chore(admin): register TahesabDocSyncProgress in generated component types
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 21:00:22 +03:30
mohmdsdgandCursor ba12569b97 feat(tahesab): minimizable modal for bulk document sync progress
One-click start on customer-sync and documents tabs; poll every 10s, restore the modal after refresh if the server job is still running, and show failed counts with stop.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-02 20:48:14 +03:30
32 changed files with 1912 additions and 151 deletions
+1
View File
@@ -97,6 +97,7 @@ declare module '@vue/runtime-core' {
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']
+11
View File
@@ -2,6 +2,7 @@
<AConfigProvider direction="rtl">
<RouterView />
<CustomerImportProgress />
<TahesabDocSyncProgress />
<GroupSmsSendProgress />
</AConfigProvider>
</template>
@@ -12,8 +13,10 @@ 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 { useUserStore } from '@/store/userStore'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
import { bootstrapAdminChat, useAdminChatService } from '@/utils/adminChat'
import { supportChatMenuEnabledSetting } from '@/utils/config'
@@ -64,7 +67,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>
+3
View File
@@ -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}`)
}
+57 -1
View File
@@ -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,
}
+2 -1
View File
@@ -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
+803
View File
@@ -0,0 +1,803 @@
<template>
<Teleport to="body">
<Transition name="cip-fade">
<div
v-if="store.visible && !store.minimized"
class="cip-overlay"
@click.self="store.active ? store.minimize() : null"
>
<div class="cip-modal" :class="store.finished ? `cip-modal--${outcomeInfo.tone}` : null">
<div class="cip-modal__head">
<div class="cip-modal__title">
<Icon :icon="headIcon" :size="18" />
<span>{{ headTitle }}</span>
</div>
<div class="cip-modal__head-actions">
<button
v-if="store.active"
class="cip-icon-btn"
title="کوچک کردن"
@click="store.minimize()"
>
<Icon icon="vuesax-linear:minus" :size="18" />
</button>
<button v-else class="cip-icon-btn" title="بستن" @click="store.dismiss()">
<Icon icon="vuesax-linear:close-circle" :size="18" />
</button>
</div>
</div>
<div v-if="store.active" class="cip-modal__body">
<div class="cip-counter">
<span class="cip-counter__done">{{ store.state.processed }}</span>
<span class="cip-counter__sep">/</span>
<span class="cip-counter__total">{{ store.state.total }}</span>
</div>
<div class="cip-counter__label">{{ runningLabel }}</div>
<div class="cip-track">
<div class="cip-track__fill" :style="{ width: store.percent + '%' }" />
</div>
<div class="cip-percent">{{ store.percent }}٪</div>
<div v-if="etaLabel" class="cip-eta">{{ etaLabel }}</div>
<div class="cip-current">
<a-spin size="small" />
<span class="cip-current__name">{{ store.state.current || '...' }}</span>
</div>
<div class="cip-stats">
<div class="cip-stat cip-stat--ok">
<Icon icon="vuesax-linear:tick-circle" :size="14" />
{{ store.state.success }} موفق
</div>
<div v-if="store.state.failed" class="cip-stat cip-stat--fail">
<Icon icon="vuesax-linear:close-circle" :size="14" />
{{ store.state.failed }} ناموفق
</div>
</div>
</div>
<div v-else class="cip-modal__body cip-report">
<div class="cip-report__hero" :class="`cip-report__hero--${outcomeInfo.tone}`">
<Icon :icon="outcomeInfo.icon" :size="34" />
</div>
<div class="cip-report__title">{{ outcomeInfo.text }}</div>
<div class="cip-report__subtitle">{{ reportSubtitle }}</div>
<div class="cip-report__cards">
<div class="cip-rcard cip-rcard--ok">
<Icon icon="vuesax-linear:tick-circle" :size="20" />
<div class="cip-rcard__num">{{ store.state.success }}</div>
<div class="cip-rcard__label">{{ doneCardLabel }}</div>
</div>
<div class="cip-rcard" :class="store.state.failed ? 'cip-rcard--fail' : 'cip-rcard--muted'">
<Icon icon="vuesax-linear:close-circle" :size="20" />
<div class="cip-rcard__num">{{ store.state.failed }}</div>
<div class="cip-rcard__label">به خطا خورد</div>
</div>
</div>
<div v-if="store.state.errors.length" class="cip-report__errors">
<div class="cip-report__errors-head">
<Icon icon="vuesax-linear:close-circle" :size="14" />
جزئیات خطا ({{ store.state.errors.length }})
</div>
<div class="cip-report__errors-list">
<div v-for="(e, i) in store.state.errors" :key="i" class="cip-erow">
<span class="cip-erow__name">{{ e.label }}</span>
<span class="cip-erow__msg">{{ e.error }}</span>
</div>
</div>
</div>
</div>
<div class="cip-modal__foot">
<a-button v-if="store.active" danger size="small" @click="store.stop()">توقف</a-button>
<a-button v-if="store.active" size="small" @click="store.minimize()">کوچک کردن</a-button>
<a-button v-if="store.finished" type="primary" size="small" @click="store.dismiss()">
بستن گزارش
</a-button>
</div>
</div>
</div>
</Transition>
<Transition name="cip-slide">
<button
v-if="store.visible && store.minimized"
class="cip-mini tds-mini"
:class="store.finished ? `cip-mini--${outcomeInfo.tone}` : null"
@click="store.expand()"
>
<span class="cip-mini__ring">
<svg viewBox="0 0 36 36" class="cip-mini__svg">
<circle class="cip-mini__bg" cx="18" cy="18" r="15.5" />
<circle class="cip-mini__fg" cx="18" cy="18" r="15.5" :style="ringStyle" />
</svg>
<span class="cip-mini__pct">
<template v-if="store.finished">
<Icon :icon="outcomeInfo.icon" :size="16" />
</template>
<template v-else>{{ store.percent }}</template>
</span>
</span>
<span class="cip-mini__text">
<span class="cip-mini__title">
<template v-if="store.finished">{{ outcomeInfo.text }}</template>
<template v-else>{{ runningMiniTitle }}</template>
</span>
<span class="cip-mini__count">
<template v-if="store.finished">
{{ store.state.success }} موفق · {{ store.state.failed }} خطا
</template>
<template v-else>{{ store.state.processed }} از {{ store.state.total }}</template>
</span>
<span v-if="store.active && etaLabel" class="cip-mini__eta">{{ etaLabel }}</span>
</span>
<span class="cip-mini__bar">
<span class="cip-mini__bar-fill" :style="{ width: store.percent + '%' }" />
</span>
</button>
</Transition>
</Teleport>
</template>
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
const store = useTahesabDocSyncStore()
const runStartedAt = ref<number | null>(null)
const runStartProcessed = ref(0)
const tick = ref(Date.now())
let tickTimer: ReturnType<typeof setInterval> | null = null
function formatEta(seconds: number): string {
if (!Number.isFinite(seconds) || seconds <= 0) return 'به‌زودی'
const rounded = Math.ceil(seconds)
if (rounded < 60) return `حدود ${rounded} ثانیه`
const mins = Math.ceil(rounded / 60)
if (mins < 60) return `حدود ${mins} دقیقه`
const hours = Math.floor(mins / 60)
const remMins = mins % 60
if (remMins === 0) return `حدود ${hours} ساعت`
return `حدود ${hours} ساعت و ${remMins} دقیقه`
}
function resetEtaClock() {
runStartedAt.value = Date.now()
runStartProcessed.value = store.state.processed
}
function startTick() {
if (tickTimer) return
tickTimer = setInterval(() => {
tick.value = Date.now()
}, 1000)
}
function stopTick() {
if (!tickTimer) return
clearInterval(tickTimer)
tickTimer = null
}
watch(
() => store.active,
(active) => {
if (active) {
resetEtaClock()
startTick()
return
}
runStartedAt.value = null
stopTick()
},
{ immediate: true },
)
watch(
() => store.state.stage,
() => {
if (store.active) resetEtaClock()
},
)
const etaLabel = computed(() => {
void tick.value
if (!store.active) return ''
const { processed, total } = store.state
const remaining = Math.max(0, total - processed)
if (remaining <= 0) return 'در حال اتمام…'
if (!runStartedAt.value) return ''
const deltaProcessed = processed - runStartProcessed.value
const elapsedSec = (Date.now() - runStartedAt.value) / 1000
if (deltaProcessed < 2 || elapsedSec < 4) {
return 'در حال محاسبه زمان باقی‌مانده…'
}
const secPerItem = elapsedSec / deltaProcessed
return `تخمین باقی‌مانده: ${formatEta(secPerItem * remaining)}`
})
const stage = computed(() => store.stage)
function outcomeMap() {
if (stage.value === 'customers_in') {
return {
success: { icon: 'vuesax-linear:tick-circle', text: 'ورود مشتریان تمام شد', tone: 'ok' as const },
error: { icon: 'vuesax-linear:close-circle', text: 'ورود مشتریان ناموفق بود', tone: 'fail' as const },
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان وارد نشدند', tone: 'warn' as const },
canceled: { icon: 'vuesax-linear:info-circle', text: 'ورود متوقف شد', tone: 'warn' as const },
running: { icon: 'vuesax-linear:import', text: 'ورود از ته‌حساب', tone: 'ok' as const },
}
}
if (stage.value === 'customers_out') {
return {
success: { icon: 'vuesax-linear:tick-circle', text: 'ثبت مشتریان تمام شد', tone: 'ok' as const },
error: { icon: 'vuesax-linear:close-circle', text: 'ثبت مشتریان ناموفق بود', tone: 'fail' as const },
partial: { icon: 'vuesax-linear:danger', text: 'بعضی مشتریان ثبت نشدند', tone: 'warn' as const },
canceled: { icon: 'vuesax-linear:info-circle', text: 'ثبت متوقف شد', tone: 'warn' as const },
running: { icon: 'vuesax-linear:profile-2user', text: 'ثبت در ته‌حساب', tone: 'ok' as const },
}
}
return {
success: { icon: 'vuesax-linear:tick-circle', text: 'ارسال سندها تمام شد', tone: 'ok' as const },
error: { icon: 'vuesax-linear:close-circle', text: 'ارسال سندها ناموفق بود', tone: 'fail' as const },
partial: { icon: 'vuesax-linear:danger', text: 'بعضی سندها به خطا خورد', tone: 'warn' as const },
canceled: { icon: 'vuesax-linear:info-circle', text: 'ارسال متوقف شد', tone: 'warn' as const },
running: { icon: 'vuesax-linear:document-upload', text: 'ارسال سند به ته‌حساب', tone: 'ok' as const },
}
}
const outcomeInfo = computed(() => outcomeMap()[store.outcome])
const runningIcon = computed(() => {
if (stage.value === 'customers_in') return 'vuesax-linear:import'
if (stage.value === 'customers_out') return 'vuesax-linear:profile-2user'
return 'vuesax-linear:document-upload'
})
const headIcon = computed(() => (store.finished ? outcomeInfo.value.icon : runningIcon.value))
const headTitle = computed(() => {
if (store.finished) {
if (stage.value === 'customers_in') return 'گزارش ورود مشتریان'
if (stage.value === 'customers_out') return 'گزارش ثبت مشتریان'
return 'گزارش ارسال سندها'
}
if (stage.value === 'customers_in') return 'ورود مشتریان از ته‌حساب'
if (stage.value === 'customers_out') return 'ثبت مشتریان در ته‌حساب'
return 'ارسال سندها به ته‌حساب'
})
const runningLabel = computed(() => {
if (stage.value === 'customers_in') return 'در حال وارد کردن مشتریان از ته‌حساب…'
if (stage.value === 'customers_out') return 'در حال ثبت مشتریان پنل در ته‌حساب…'
return 'در حال ارسال سندها به ته‌حساب…'
})
const runningMiniTitle = computed(() => {
if (stage.value === 'customers_in') return 'ورود از ته‌حساب'
if (stage.value === 'customers_out') return 'ثبت مشتری در ته‌حساب'
return 'ارسال سند به ته‌حساب'
})
const unit = computed(() => (stage.value === 'docs' ? 'سند' : 'مشتری'))
const doneCardLabel = computed(() => (stage.value === 'docs' ? 'ارسال شد' : 'ثبت شد'))
const reportSubtitle = computed(() => {
const docs = store.state.doc_total
? `سندها: ${store.state.doc_success} موفق` + (store.state.doc_failed ? `، ${store.state.doc_failed} خطا. ` : '. ')
: ''
return `${docs}از ${store.state.total} ${unit.value}، ${store.state.processed} مورد پردازش شد`
})
const RING_CIRC = 2 * Math.PI * 15.5
const ringStyle = computed(() => ({
strokeDasharray: `${RING_CIRC}`,
strokeDashoffset: `${RING_CIRC * (1 - store.percent / 100)}`,
}))
onMounted(() => {
void store.hydrate()
})
onUnmounted(() => {
stopTick()
})
</script>
<style scoped lang="less">
/* ─── مدال ─── */
.cip-overlay {
position: fixed;
inset: 0;
z-index: 2200;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
background: rgba(15, 23, 42, 0.55);
backdrop-filter: blur(2px);
}
.cip-modal {
width: 100%;
max-width: 420px;
border-radius: 16px;
background: var(--admin-bg-surface);
border: 1px solid var(--admin-border-strong);
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
overflow: hidden;
&__head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #0ea5e9 100%);
color: #fff;
}
&--ok .cip-modal__head {
background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}
&--warn .cip-modal__head {
background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
}
&--fail .cip-modal__head {
background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}
&__title {
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
font-weight: 700;
}
&__head-actions {
display: flex;
gap: 4px;
}
&__body {
padding: 20px 18px 8px;
display: flex;
flex-direction: column;
align-items: center;
}
&__foot {
display: flex;
justify-content: flex-end;
gap: 8px;
padding: 12px 16px 16px;
}
}
.cip-icon-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border: none;
border-radius: 8px;
background: rgba(255, 255, 255, 0.18);
color: #fff;
cursor: pointer;
transition: background 0.15s;
&:hover {
background: rgba(255, 255, 255, 0.32);
}
}
.cip-counter {
display: flex;
align-items: baseline;
gap: 4px;
font-weight: 800;
line-height: 1;
&__done {
font-size: 38px;
color: #7c3aed;
}
&__sep {
font-size: 24px;
color: var(--admin-text-muted);
}
&__total {
font-size: 24px;
color: var(--admin-text-secondary);
}
}
.cip-counter__label {
margin-top: 6px;
font-size: 13px;
color: var(--admin-text-secondary);
}
.cip-track {
width: 100%;
height: 9px;
margin-top: 16px;
border-radius: 99px;
background: var(--admin-bg-muted);
overflow: hidden;
&__fill {
height: 100%;
border-radius: 99px;
background: linear-gradient(90deg, #7c3aed, #0ea5e9);
transition: width 0.35s ease;
}
}
.cip-percent {
align-self: flex-end;
margin-top: 6px;
font-size: 12px;
font-weight: 700;
color: var(--admin-text-secondary);
}
.cip-eta {
align-self: flex-end;
margin-top: 4px;
font-size: 11px;
font-weight: 600;
color: var(--admin-text-muted);
text-align: right;
}
.cip-current {
display: flex;
align-items: center;
gap: 8px;
margin-top: 12px;
max-width: 100%;
&__name {
font-size: 12px;
color: var(--admin-text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.cip-stats {
display: flex;
gap: 10px;
margin-top: 14px;
}
.cip-stat {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 12px;
font-weight: 700;
padding: 3px 12px;
border-radius: 99px;
&--ok {
background: rgba(16, 185, 129, 0.15);
color: #059669;
}
&--fail {
background: rgba(239, 68, 68, 0.12);
color: #dc2626;
}
}
/* ─── گزارش پایانی ─── */
.cip-report {
padding-top: 22px;
&__hero {
display: flex;
align-items: center;
justify-content: center;
width: 64px;
height: 64px;
border-radius: 50%;
&--ok {
background: rgba(16, 185, 129, 0.14);
color: #059669;
}
&--warn {
background: rgba(245, 158, 11, 0.16);
color: #d97706;
}
&--fail {
background: rgba(239, 68, 68, 0.13);
color: #dc2626;
}
}
&__title {
margin-top: 12px;
font-size: 16px;
font-weight: 800;
color: var(--admin-text);
text-align: center;
}
&__subtitle {
margin-top: 4px;
font-size: 12px;
color: var(--admin-text-secondary);
text-align: center;
}
&__cards {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
width: 100%;
margin-top: 18px;
}
&__errors {
width: 100%;
margin-top: 16px;
}
&__errors-head {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px;
font-weight: 700;
color: #dc2626;
margin-bottom: 6px;
}
&__errors-list {
max-height: 160px;
overflow-y: auto;
border-radius: 10px;
border: 1px solid var(--admin-border);
background: var(--admin-bg-muted);
}
}
.cip-rcard {
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
padding: 14px 10px;
border-radius: 12px;
border: 1px solid transparent;
&__num {
font-size: 26px;
font-weight: 800;
line-height: 1.1;
}
&__label {
font-size: 11px;
font-weight: 600;
}
&--ok {
background: rgba(16, 185, 129, 0.1);
border-color: rgba(16, 185, 129, 0.25);
color: #059669;
}
&--fail {
background: rgba(239, 68, 68, 0.09);
border-color: rgba(239, 68, 68, 0.22);
color: #dc2626;
}
&--muted {
background: var(--admin-bg-muted);
border-color: var(--admin-border);
color: var(--admin-text-muted);
}
}
.cip-erow {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
padding: 8px 12px;
font-size: 12px;
border-bottom: 1px solid var(--admin-border);
&:last-child {
border-bottom: none;
}
&__name {
font-weight: 700;
color: var(--admin-text);
white-space: nowrap;
}
&__msg {
color: #dc2626;
text-align: left;
flex: 1;
word-break: break-word;
}
}
/* ─── کوچک‌شده ─── */
.cip-mini {
position: fixed;
top: 64px;
left: 50%;
transform: translateX(-50%);
z-index: 2100;
display: flex;
align-items: center;
gap: 10px;
padding: 8px 16px 8px 10px;
border: 1px solid var(--admin-border-strong);
border-radius: 99px;
background: var(--admin-bg-surface);
box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
cursor: pointer;
transition: transform 0.15s, box-shadow 0.15s;
@media (max-width: 767px) {
top: 58px;
max-width: calc(100vw - 24px);
}
&:hover {
transform: translateX(-50%) translateY(1px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
&__ring {
position: relative;
width: 34px;
height: 34px;
flex-shrink: 0;
}
&__svg {
width: 100%;
height: 100%;
transform: rotate(-90deg);
}
&__bg {
fill: none;
stroke: var(--admin-bg-muted);
stroke-width: 3.5;
}
&__fg {
fill: none;
stroke: #7c3aed;
stroke-width: 3.5;
stroke-linecap: round;
transition: stroke-dashoffset 0.35s ease;
}
&__pct {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 11px;
font-weight: 800;
color: #7c3aed;
}
&__text {
display: flex;
flex-direction: column;
line-height: 1.3;
min-width: 0;
}
&__title {
font-size: 12px;
font-weight: 700;
color: var(--admin-text);
white-space: nowrap;
}
&__count {
font-size: 11px;
color: var(--admin-text-secondary);
white-space: nowrap;
}
&__eta {
font-size: 10px;
font-weight: 600;
color: var(--admin-text-muted);
white-space: nowrap;
}
&__bar {
position: absolute;
left: 14px;
right: 14px;
bottom: 3px;
height: 2px;
border-radius: 99px;
background: var(--admin-bg-muted);
overflow: hidden;
}
&__bar-fill {
display: block;
height: 100%;
border-radius: 99px;
background: #7c3aed;
transition: width 0.35s ease;
}
/* رنگ بر اساس نتیجه */
&--ok {
.cip-mini__fg,
.cip-mini__bar-fill {
stroke: #10b981;
background: #10b981;
}
.cip-mini__pct {
color: #059669;
}
}
&--warn {
.cip-mini__fg,
.cip-mini__bar-fill {
stroke: #f59e0b;
background: #f59e0b;
}
.cip-mini__pct {
color: #d97706;
}
}
&--fail {
.cip-mini__fg,
.cip-mini__bar-fill {
stroke: #ef4444;
background: #ef4444;
}
.cip-mini__pct {
color: #dc2626;
}
}
}
.tds-mini.cip-mini {
top: 112px;
@media (max-width: 767px) {
top: 106px;
}
}
/* ─── انیمیشن‌ها ─── */
.cip-fade-enter-active,
.cip-fade-leave-active {
transition: opacity 0.3s ease;
}
.cip-fade-enter-from,
.cip-fade-leave-to {
opacity: 0;
}
.cip-slide-enter-active,
.cip-slide-leave-active {
transition: opacity 0.3s ease, transform 0.3s ease;
}
.cip-slide-enter-from,
.cip-slide-leave-to {
opacity: 0;
transform: translateX(-50%) translateY(-12px);
}
</style>
@@ -95,7 +95,7 @@
>
<div class="customer-wallet-balance__detail-group-title">
<span class="customer-wallet-balance__group-dot" aria-hidden="true" />
<span>{{ metal.label }}</span>
<span>{{ minimalMetalLabel(metal) }}</span>
</div>
<div
v-for="line in linesForMetal(metal.metal_id)"
@@ -234,9 +234,21 @@ function targetToneClass(target: ChargeTarget) {
}
}
function uniqueInventoryCards() {
const cards = summary.value?.inventory_cards ?? []
const seen = new Set<number>()
const unique: WalletInventoryCard[] = []
for (const card of cards) {
const id = Number(card.product_id)
if (!id || seen.has(id)) continue
seen.add(id)
unique.push(card)
}
return unique
}
function inventoryCards() {
if (!summary.value) return [] as WalletInventoryCard[]
return [...(summary.value.inventory_cards ?? []), ...(summary.value.count_products ?? [])]
return uniqueInventoryCards()
}
function isCountChargeTarget(target: ChargeTarget) {
@@ -310,22 +322,33 @@ function formatCard(card: WalletInventoryCard) {
return `${qty.toLocaleString('fa-IR', { maximumFractionDigits: 3 })} ${card.unit || 'گرم'}`
}
function linesForMetal(metalId: number) {
const cards = summary.value?.inventory_cards ?? []
const countCards = summary.value?.count_products ?? []
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
function formatMetalGroupTotal(metalId: number, metalCards: WalletInventoryCard[], metal?: WalletMetalTotal) {
const allCount = metalCards.length > 0 && metalCards.every((card) => card.display_type === 'count')
if (allCount) {
const qty = metalCards.reduce((sum, card) => sum + Number(card.quantity ?? 0), 0)
return `${qty.toLocaleString('fa-IR')} عدد`
}
if (metal) {
return formatMetalTotal(metal)
}
return formatMetalDisplayValue(0, metalId)
}
const productLines = [...cards, ...countCards]
.filter((card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0)
.map((card) => ({
key: `card-${card.product_id}`,
label: card.title,
value: formatCard(card)
}))
function linesForMetal(metalId: number) {
const metal = summary.value?.metal_totals?.find((row) => row.metal_id === metalId)
const metalCards = uniqueInventoryCards().filter(
(card) => Number(card.metal_id) === metalId && Number(card.quantity ?? 0) > 0
)
const productLines = metalCards.map((card) => ({
key: `card-${card.product_id}`,
label: card.title,
value: formatCard(card)
}))
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)
})
}
+2 -1
View File
@@ -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()
@@ -79,6 +79,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
})
})
@@ -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>
@@ -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
@@ -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"
@@ -207,6 +209,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 +220,9 @@ import {
} from '@/pages/menuPages/accounting/utils/accountingDocAmounts'
import { toJalali } from '@core/utils/useDataTime'
import { accountingTahesabDocsIntro } from '@/utils/adminHelpCopy'
import { useTahesabDocSyncStore } from '@/store/tahesabDocSyncStore'
const docSyncStore = useTahesabDocSyncStore()
const props = defineProps<{
customerId?: number
@@ -386,17 +392,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 {
@@ -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')
+48 -10
View File
@@ -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, 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)
@@ -701,6 +731,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)
}))
@@ -158,7 +158,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
)
},
@@ -310,7 +310,7 @@ export function resolveSettingMenu(
}
/** این کلیدها صفحهٔ جدا دارند و در لیست تنظیمات عادی/پیشرفته نمی‌آیند */
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites'])
export const OTHER_PAGE_SETTING_MENUS = new Set(['trading_hours', 'capture_sites', 'website_settings'])
export function getSettingSubsectionId(
key: string,
@@ -207,6 +207,7 @@ export const SUPERADMIN_OWNED_SETTING_KEYS = new Set([
'jibit_enabled',
'permision__enabled',
'show_to_users_chat',
'has_landing',
])
export function isSuperAdminOwnedSettingKey(key?: string | null): boolean {
@@ -324,7 +325,7 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
minimum_sell: 'price',
gift_for_referrer: 'number',
gift_for_referral: 'number',
referral_bonus_amount: 'text',
referral_bonus_amount: 'price',
montzar_product_id: 'number',
montzar_account_zarin: 'text',
montzar_account_tahesab: 'text',
@@ -429,7 +430,19 @@ const KEY_TYPE_FALLBACK: Record<string, SettingFieldType> = {
pargar_item_id_gold: 'number',
support_messengers: 'longtext',
show_to_users_chat: 'switch',
has_landing: 'switch',
has_chat: 'switch',
landing_site: 'longtext',
landing_header: 'longtext',
landing_hero: 'longtext',
landing_live_price: 'longtext',
landing_calculator: 'longtext',
landing_feature: 'longtext',
landing_steps: 'longtext',
landing_trust: 'longtext',
landing_faq: 'longtext',
landing_buttom_cta: 'longtext',
landing_footer: 'longtext',
chat_api: 'text',
chat_api_key: 'text',
chat_upload_url: 'text',
@@ -623,6 +636,45 @@ export function formatValueForSave(
return value ?? ''
}
/** واحد نمایش روی فیلدهای عددی — شناسه/پورت واحد ندارند */
const SETTING_UNIT_BY_KEY: Record<string, string> = {
buy_fee: 'ریال',
sell_fee: 'ریال',
fee_single: 'ریال',
fee_conditional_order: 'ریال',
min_withdraw: 'ریال',
min_deposit: 'ریال',
min_first_buy: 'ریال',
minimum_sell: 'ریال',
price_channel_diff: 'ریال',
referral_bonus_amount: 'ریال',
gold_credit_penalty_amount: 'ریال / گرم',
gift_for_referrer: 'گرم',
gift_for_referral: 'گرم',
gold_credit_min_balance_gram: 'گرم',
change_mesghal: 'گرم',
fee_service_charge_percentage: 'درصد (اعشاری)',
gold_credit_grace_hours: 'ساعت',
gold_credit_default_months: 'ماه',
price_channel_min_seconds: 'ثانیه',
referral_limit: 'دعوت',
fee_free: 'سفارش',
}
export function getSettingUnitLabel(
key?: string,
type?: SettingFieldType,
): string {
const k = (key ?? '').trim()
if (k && SETTING_UNIT_BY_KEY[k]) {
return SETTING_UNIT_BY_KEY[k]
}
if (type === 'price') {
return 'ریال'
}
return ''
}
export function switchLabels(key: string | undefined): { on: string; off: string } {
if (key === REFERRAL_REQUIRED_KEY) {
return { on: 'اجباری', off: 'اختیاری' }
@@ -800,7 +852,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
referral_limit:
'حداکثر تعداد دعوت مجاز برای هر کاربر. خالی = بدون محدودیت.',
referral_bonus_amount:
'مبلغ یا مقدار پاداش معرف برای نمایش در پیامک‌ها و متن‌های دعوت.',
'مبلغ پاداش معرف (ریال) برای نمایش در پیامک‌ها و متن‌های دعوت. واحد روی خود فیلد مشخص است.',
jibit_verification:
'روشن: هنگام ثبت یا ویرایش کارت بانکی، تطبیق با سرویس احراز هویت جیبیت انجام می‌شود. خاموش: کارت بدون تطبیق جیبیت ثبت می‌شود.',
register_jibit_verify:
@@ -832,7 +884,7 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
montzar_open_sell:
'وضعیت واقعی از سرویس خارجی خوانده می‌شود. روشن: ثبت سفارش فروش از طریق قیمت همکار مجاز است. خاموش: ثبت سفارش فروش از طریق قیمت همکار غیرفعال است.',
montzar_order_wait_callback:
'روشن (پیش‌فرض): بعد از ارسال سفارش به همکار، تا کالبک وضعیت (تأیید=۲ / رد=۴ یا ۶) یا استعلام مسیر وضعیت صبر می‌شود و کیف ثبت نمی‌شود. خاموش: مثل قبل با همان پاسخ HTTP همکار سفارش قطعی می‌شود.',
'با منبع قیمت همکار، سفارش همیشه تا کالبک یا استعلام وضعیت در انتظار می‌ماند و کیف بعد از تأیید ثبت می‌شود. خاموش بودن این سوییچ دیگر مسیر قطعی بلافاصله را باز نمی‌کند. در رد همکار، SMS به ادمین‌های دارای ارسال پیامک می‌رود.',
montzar_order_status_path:
'مسیر GET روی دامنه همکار (montzar_base_url) برای استعلام وضعیت اگر کالبک نرسید. پیش‌فرض /server/customer/order — با شماره سفارش همکار می‌شود /server/customer/order/40000.',
montzar_closed:
@@ -863,6 +915,19 @@ const KEY_HELP_FALLBACK: Record<string, string> = {
'فقط مواردی که در این لیست ثبت شوند در منوی شناور پشتیبانی اپ مشتری نمایش داده می‌شوند. برای تماس تلفنی یا پیامک، نوع «تماس تلفنی» / «پیامک» را با شماره اضافه کنید. لیست می‌تواند خالی باشد؛ اگر چت فعال باشد، پشتیبانی مستقیم به صفحه چت می‌رود.',
show_to_users_chat:
'روشن: قابلیت چت پشتیبانی برای این دیپلوی فعال است (منوی ادمین و پیش‌نیاز نمایش به کاربر). خاموش: چت در ادمین و اپ کاربر مخفی است و سوییچ «چت پشتیبانی» (has_chat) از تنظیمات عادی هم برداشته می‌شود.',
has_landing:
'روشن: منوی تنظیمات وبسایت در ادمین و تنظیمات لندینگ برای اپ کاربر فعال است. خاموش: منو مخفی است.',
landing_site: 'محتوای تنظیمات کلی لندینگ وبسایت.',
landing_header: 'محتوای هدر و ناوبری لندینگ.',
landing_hero: 'محتوای سکشن هیرو لندینگ.',
landing_live_price: 'لیبل‌ها و متن قیمت لحظه‌ای لندینگ.',
landing_calculator: 'عنوان و متن ماشین حساب لندینگ.',
landing_feature: 'متن امکانات لندینگ (چرا نیازی طلا).',
landing_steps: 'متن مراحل شروع لندینگ.',
landing_trust: 'متن اعتماد و مجوزها (بدون اینماد).',
landing_faq: 'سوالات متداول لندینگ.',
landing_buttom_cta: 'متن دعوت به اقدام پایین صفحه لندینگ.',
landing_footer: 'محتوای فوتر لندینگ.',
has_chat:
'روشن: چت پشتیبانی در اپ مشتری نمایش داده می‌شود (فقط وقتی show_to_users_chat هم روشن باشد). خاموش: دکمه و صفحه چت برای کاربر مخفی است.',
chat_api:
@@ -1119,6 +1184,8 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
minimum_sell: 'حداقل مبلغ فروش (ریال)',
referral_id: 'کد معرف اجباری',
referral_bonus_amount: 'مقدار پاداش معرف',
gift_for_referrer: 'پاداش معرف',
gift_for_referral: 'پاداش معرف‌شونده',
referral_gift_on_first_order: 'پاداش معرف پس از اولین سفارش',
referral_gift_buy_from_montzar: 'خرید پاداش معرفی از همکار',
open_register: 'ثبت‌نام باز',
@@ -1187,7 +1254,19 @@ export const KEY_LABEL_FALLBACK: Record<string, string> = {
zarin_idbank: 'کد حساب بانک زرین',
support_messengers: 'پیام‌رسان‌های پشتیبانی',
show_to_users_chat: 'نمایش چت به کاربران',
has_landing: 'لندینگ وبسایت',
has_chat: 'چت پشتیبانی',
landing_site: 'تنظیمات کلی سایت',
landing_header: 'هدر و ناوبری',
landing_hero: 'هیرو',
landing_live_price: 'لیبل‌های قیمت لحظه‌ای',
landing_calculator: 'عنوان ماشین حساب',
landing_feature: 'امکانات (چرا نیازی طلا)',
landing_steps: 'مراحل شروع',
landing_trust: 'اعتماد و مجوزها',
landing_faq: 'سوالات متداول',
landing_buttom_cta: 'سکشن پایین صفحه لندینگ برای معرفی',
landing_footer: 'فوتر',
chat_api: 'API چت',
chat_api_key: 'کلید API چت',
chat_upload_url: 'آدرس آپلود فایل چت',
@@ -1286,7 +1365,7 @@ export const SETTING_LOCKED_KEYS = new Set([
'price_channel_bale_to', 'price_channel_telegram_to', 'price_channel_rubika_to',
'unit',
'wss_enabled',
'show_to_users_chat', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
'show_to_users_chat', 'has_landing', 'chat_api', 'chat_api_key', 'chat_upload_url', 'chat_download_url'
])
/** قابل ویرایش در پنل عادی — هم‌تراز deploy_settings_const.sql */
@@ -1326,6 +1405,8 @@ export const SETTING_EDITABLE_KEYS = new Set([
'support_messengers', 'support_messenger_text',
'do_send_liman',
'has_chat',
'landing_site', 'landing_header', 'landing_hero', 'landing_live_price', 'landing_calculator',
'landing_feature', 'landing_steps', 'landing_trust', 'landing_faq', 'landing_buttom_cta', 'landing_footer',
'text_about', 'text_rule', 'about_software', 'enamad_url', 'enamad_logo',
'login_hero_eyebrow', 'login_hero_title',
'login_hero_feature_1', 'login_hero_feature_2', 'login_hero_feature_3', 'login_hero_feature_4',
@@ -1336,10 +1417,14 @@ export const SETTING_EDITABLE_KEYS = new Set([
])
/** عنوان فارسی — کاتالوگ پنل بر title_fa دیتابیس اولویت دارد */
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa'>): string {
export function resolveSettingTitle(row: Pick<Const, 'key' | 'title_fa' | 'type'>): string {
const key = (row.key ?? '').trim()
if (key && KEY_LABEL_FALLBACK[key]) return KEY_LABEL_FALLBACK[key]
return row.title_fa?.trim() || key || '—'
const base = (key && KEY_LABEL_FALLBACK[key]) ? KEY_LABEL_FALLBACK[key] : (row.title_fa?.trim() || key || '—')
const unit = getSettingUnitLabel(key, resolveSettingFieldType(row))
if (!unit || base.includes(unit) || base.includes(`(${unit})`)) {
return base
}
return `${base} (${unit})`
}
/** توضیح — کاتالوگ پنل بر description دیتابیس اولویت دارد */
@@ -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"
@@ -120,8 +121,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 +136,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 +150,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) {
@@ -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,27 +157,34 @@ import BasicModal from '@/components/BasicModal.vue'
import { isMobile } from '@core/utils/is'
import type { TahesabPreviewDoc } from '@/api/tahesab'
const props = defineProps<{
visible: boolean
appGold?: number | null
appCash?: number | null
tahesabGold?: number | null
tahesabCash?: number | null
sourceGold?: number | null
sourceCash?: number | null
goldDelta?: number | null
rialDelta?: number | null
sourceLabel?: string
walletDocs?: TahesabPreviewDoc[]
tahesabDocs?: TahesabPreviewDoc[]
}>()
export type MandeDecisionMode = 'overwrite' | 'keep' | 'push'
const props = withDefaults(
defineProps<{
visible: boolean
appGold?: number | null
appCash?: number | null
tahesabGold?: number | null
tahesabCash?: number | null
sourceGold?: number | null
sourceCash?: number | null
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>
+20 -5
View File
@@ -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"
@@ -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
}
@@ -496,11 +496,19 @@
<div class="grid gap-4 md:grid-cols-2">
<div class="product-visibility-panel">
<div class="product-visibility-row">
<span class="text-sm">نمایش در لیست محصولات</span>
<DashboardLabelWithHelp
label="نمایش در لیست محصولات"
:help="showInListHelp"
size="sm"
/>
<a-switch v-model:checked="form.show_in_list" />
</div>
<div class="product-visibility-row">
<span class="text-sm">نمایش در تابلو TV</span>
<DashboardLabelWithHelp
label="نمایش در تابلو TV"
:help="showOnTvHelp"
size="sm"
/>
<a-switch v-model:checked="form.show_on_tv" />
</div>
</div>
@@ -770,11 +778,13 @@ const cashFeeSellHelp: DashboardHelp = {
}
const showOnTvHelp: DashboardHelp = {
description: 'روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده می‌شود.',
description:
'مستقل از لیست محصولات است. روشن: این محصول در صفحه تابلو قیمت مشتری (/tv) نمایش داده می‌شود؛ حتی اگر در لیست محصولات خاموش باشد.',
}
const showInListHelp: DashboardHelp = {
description: 'روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده می‌شود.',
description:
'مستقل از تابلو TV است. روشن: این محصول در صفحه لیست محصولات اپ مشتری نمایش داده می‌شود. همان آیکون تیک/ضربدر در ستون عملیات همین وضعیت را عوض می‌کند.',
}
const autoOpenHelp: DashboardHelp = {
@@ -945,6 +955,7 @@ watch(
props.form.price_formula_enabled = false
props.form.reading_method = null
props.form.price_offset_percent = 0
props.form.direct_price = 1
} else if (option === '3') {
// قیمت اپ: مرجع خارجی ندارد، متغیر (هر گرم × وزن)
props.form.reading_method = null
@@ -24,6 +24,7 @@
@toggleBuy="$emit('toggleBuy', $event)"
@toggleSell="$emit('toggleSell', $event)"
@toggleActive="$emit('toggleActive', $event)"
@toggleShowOnTv="$emit('toggleShowOnTv', $event)"
@edit="$emit('edit', $event)"
@archive="$emit('archive', $event)"
/>
@@ -43,6 +44,7 @@ defineEmits<{
(e: 'toggleBuy', item: Product): void
(e: 'toggleSell', item: Product): void
(e: 'toggleActive', item: Product): void
(e: 'toggleShowOnTv', item: Product): void
(e: 'archive', item: Product): void
}>()
@@ -24,12 +24,20 @@
/>
<MobileIconButton
plain
:key="`active-${row.id}-${row.active}`"
:icon="row.active ? 'vuesax-linear:tick-circle' : 'vuesax-linear:close-circle'"
:color="row.active ? '#16A34A' : '#DC2626'"
:key="`list-${row.id}-${row.show_in_list ?? row.active}`"
:icon="(row.show_in_list ?? row.active) ? 'vuesax-linear:tick-circle' : 'vuesax-linear:close-circle'"
:color="(row.show_in_list ?? row.active) ? '#16A34A' : '#DC2626'"
:size="22"
@click="$emit('toggleActive', row)"
/>
<MobileIconButton
plain
:key="`tv-${row.id}-${row.show_on_tv}`"
icon="vuesax-linear:monitor"
:color="row.show_on_tv ? '#16A34A' : '#DC2626'"
:size="22"
@click="$emit('toggleShowOnTv', row)"
/>
</div>
</div>
</template>
@@ -103,6 +111,7 @@ const emit = defineEmits<{
(e: 'toggleBuy', item: Product): void
(e: 'toggleSell', item: Product): void
(e: 'toggleActive', item: Product): void
(e: 'toggleShowOnTv', item: Product): void
(e: 'edit', item: Product): void
(e: 'archive', item: Product): void
}>()
@@ -36,7 +36,9 @@ defineEmits<{
(e: 'edit', item: Product): void
}>()
const statusDotClass = computed(() => (props.item.active ? 'bg-green-500' : 'bg-red-400'))
const statusDotClass = computed(() =>
(props.item.show_in_list ?? props.item.active) ? 'bg-green-500' : 'bg-red-400',
)
const priceLabel = computed(() => (props.item.price ? usePrice(props.item.price) : '-'))
</script>
@@ -75,20 +75,37 @@
@click="activeSell(record)"
/>
</a-tooltip>
<a-tooltip class="cursor-pointer" :key="`active-${record.id}-${record.active}`">
<template v-if="!record.active" #title><span>فعال کردن محصول</span></template>
<template v-else #title><span>غیر فعال کردن محصول</span></template>
<a-tooltip class="cursor-pointer" :key="`list-${record.id}-${record.show_in_list ?? record.active}`">
<template v-if="!(record.show_in_list ?? record.active)" #title>
<span>فعال کردن نمایش در لیست محصولات</span>
</template>
<template v-else #title>
<span>غیرفعال کردن نمایش در لیست محصولات</span>
</template>
<BaseIcon
v-if="!record.active"
v-if="!(record.show_in_list ?? record.active)"
icon="vuesax-linear:close-circle"
color="#DC2626"
@click="activeProduct(record)"
@click="toggleShowInList(record)"
/>
<BaseIcon
v-else
icon="vuesax-linear:tick-circle"
color="#16A34A"
@click="activeProduct(record)"
@click="toggleShowInList(record)"
/>
</a-tooltip>
<a-tooltip class="cursor-pointer" :key="`tv-${record.id}-${record.show_on_tv}`">
<template v-if="!record.show_on_tv" #title>
<span>فعال کردن نمایش در تابلو TV</span>
</template>
<template v-else #title>
<span>غیرفعال کردن نمایش در تابلو TV</span>
</template>
<BaseIcon
icon="vuesax-linear:monitor"
:color="record.show_on_tv ? '#16A34A' : '#DC2626'"
@click="toggleShowOnTv(record)"
/>
</a-tooltip>
<a-tooltip placement="bottom" class="cursor-pointer" @click="emits('edit', record)">
@@ -118,7 +135,8 @@
@edit="emits('edit', $event)"
@toggleBuy="activeBuy"
@toggleSell="activeSell"
@toggleActive="activeProduct"
@toggleActive="toggleShowInList"
@toggleShowOnTv="toggleShowOnTv"
@archive="handleArchive"
/>
</div>
@@ -137,6 +155,7 @@ import {
changeActiveProduct,
changeBuyActiveProduct,
changeSellActiveProduct,
changeShowOnTvProduct,
getCustomerTable,
setActiveTime
} from '@/api/product'
@@ -232,12 +251,18 @@ const activeBuy = (product: Product) =>
await fetch()
})
const activeProduct = (product: Product) =>
confirmToggle('آیا مطمئن به انجام این عملیات هستید؟', async () => {
const toggleShowInList = (product: Product) =>
confirmToggle('نمایش این محصول در لیست محصولات تغییر می‌کند. آیا مطمئن هستید؟', async () => {
await changeActiveProduct(product.id)
await fetch()
})
const toggleShowOnTv = (product: Product) =>
confirmToggle('نمایش این محصول در تابلو TV تغییر می‌کند. آیا مطمئن هستید؟', async () => {
await changeShowOnTvProduct(product.id)
await fetch()
})
function handleArchive(product: Product) {
confirmToggle(
'آیا این محصول بایگانی شود؟ نمایش، خرید و فروش آن غیرفعال می‌شود.',
@@ -104,21 +104,44 @@ export function getProductColumns(): BaseTableColumn[] {
},
...(isStoreApp() ? [inventoryColumn] : []),
{
title: 'وضعیت محصول',
dataIndex: 'active',
key: 'active',
title: 'وضعیت لیست',
dataIndex: 'show_in_list',
key: 'show_in_list',
type: 'Boolean',
customRender: (record) => (
<div class="flex justify-center">
<CustomTag
class="px-3 font-bold py-1"
textColor={record?.record.active ? '#65a30d' : '#dc2626'}
bgColor={record?.record.active ? '#ecfccb' : '#fee2e2'}
>
{record?.record.active ? 'باز' : 'بسته'}
</CustomTag>
</div>
)
customRender: (record) => {
const on = record?.record.show_in_list ?? record?.record.active
return (
<div class="flex justify-center">
<CustomTag
class="px-3 font-bold py-1"
textColor={on ? '#65a30d' : '#dc2626'}
bgColor={on ? '#ecfccb' : '#fee2e2'}
>
{on ? 'باز' : 'بسته'}
</CustomTag>
</div>
)
}
},
{
title: 'تابلو TV',
dataIndex: 'show_on_tv',
key: 'show_on_tv',
type: 'Boolean',
customRender: (record) => {
const on = !!record?.record.show_on_tv
return (
<div class="flex justify-center">
<CustomTag
class="px-3 font-bold py-1"
textColor={on ? '#65a30d' : '#dc2626'}
bgColor={on ? '#ecfccb' : '#fee2e2'}
>
{on ? 'روشن' : 'خاموش'}
</CustomTag>
</div>
)
}
},
{
title: 'عملیات',
@@ -602,9 +602,11 @@ async function saveProduct() {
payload.price_formula = String(payload.price_formula ?? '').trim() || '((P)/MG)*W+100000'
delete payload.price
} else if (methodOption.value === '1') {
// دستی: direct_price=1 تا enrich وزن‌محور مظنهٔ زنده را روی price ذخیره‌شده ننویسد
payload.reading_method = null
payload.price_offset_percent = 0
payload.app_price = false
payload.direct_price = 1
payload.price_formula_enabled = false
} else if (methodOption.value === '3') {
// قیمت اپ: بدون مرجع خارجی، متغیر (هر گرم × وزن)، قیمت دستی نگه نمی‌دارد
@@ -0,0 +1,63 @@
<template>
<div class="website-settings">
<BasicMainCard>
<div class="flex h-full min-h-0 flex-col md:flex-row">
<BasicMenu
width="100%"
:menu="menu"
mode="horizontal"
class="website-settings__menu website-settings__menu--mobile overflow-auto md:hidden"
/>
<BasicMenu
width="17rem"
:menu="menu"
class="website-settings__menu website-settings__menu--side hidden min-w-[17rem] overflow-auto md:inline"
/>
<RouterView
:key="route.name"
class="mt-5 min-h-0 w-full flex-1 overflow-hidden md:mr-5 md:mt-0"
/>
</div>
</BasicMainCard>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import BasicMenu from '@/components/BasicMenu/index.vue'
import { useRouterStore } from '@core/stores/router'
import { get } from 'lodash'
import type { RouteRecordRaw } from 'vue-router'
const routerStore = useRouterStore()
const route = useRoute()
const menu = computed(() => {
const item = routerStore.routes.find((row) => row.name === 'websiteSettings')
const children = get(item, 'children[0].children', []) as RouteRecordRaw[]
return children
.filter((child) => !child.meta?.hideMenu)
.sort((a, b) => (Number(a.meta?.order) || 99) - (Number(b.meta?.order) || 99))
})
</script>
<style scoped lang="less">
.website-settings__menu {
:deep(.ant-menu-item),
:deep(.ant-menu-submenu-title) {
height: auto !important;
min-height: 2.5rem;
line-height: 1.35 !important;
white-space: normal !important;
padding-block: 0.55rem !important;
}
:deep(.ant-menu-title-content) {
white-space: normal !important;
overflow: visible !important;
text-overflow: clip !important;
line-height: 1.35;
}
}
</style>
+52
View File
@@ -0,0 +1,52 @@
import type { RouteRecordRaw } from 'vue-router'
import { hasLandingSetting } from '@/utils/config'
import { LANDING_SETTING_SECTIONS } from '@/pages/menuPages/configuration/landingSettings'
const websiteSettings: RouteRecordRaw = {
name: 'websiteSettings',
path: '/website-settings',
component: () => import('@core/layouts/BasicLayout.vue'),
redirect: { name: 'websiteLandingSite' },
meta: {
icon: 'vuesax-linear:global',
permissionsKey: 'config',
title: 'تنظیمات وبسایت',
disabled: false,
hideMenu: false,
hideChildren: true,
order: 7.4
},
beforeEnter() {
if (!hasLandingSetting.value) {
return { name: 'configuration' }
}
},
children: [
{
name: 'websiteSettingsMain',
path: '',
component: () => import('@/pages/menuPages/websiteSettings/index.vue'),
redirect: { name: 'websiteLandingSite' },
meta: {
permissionsKey: 'config',
icon: 'vuesax-linear:global',
title: 'تنظیمات وبسایت',
disabled: false,
hideMenu: true
},
children: LANDING_SETTING_SECTIONS.map((section, index) => ({
name: section.name,
path: section.path,
component: () => import('@/pages/menuPages/configuration/index.vue'),
props: { mode: 'landing' as const, landingPrefix: section.prefix },
meta: {
icon: section.icon,
title: section.title,
order: index + 1
}
}))
}
]
}
export default websiteSettings
+231
View File
@@ -0,0 +1,231 @@
import { computed, ref } from 'vue'
import { defineStore } from 'pinia'
import {
getTahesabPendingSummary,
startTahesabDocSync,
startTahesabCustomerInbound,
startTahesabCustomerOutbound,
stopTahesabDocSync,
resetTahesabLocalDocs,
type TahesabDocSyncState,
} from '@/api/tahesab'
export type DocSyncOutcome = 'running' | 'success' | 'error' | 'partial' | 'canceled'
const POLL_DOCS_MS = 10_000
const POLL_CUSTOMERS_MS = 3_000
function emptyState(): TahesabDocSyncState {
return {
running: false,
finished: false,
stopped: false,
stage: 'docs',
percent: 0,
total: 0,
processed: 0,
success: 0,
failed: 0,
current: '',
errors: [],
doc_total: 0,
doc_success: 0,
doc_failed: 0,
}
}
export const useTahesabDocSyncStore = defineStore('tahesabDocSync', () => {
const state = ref<TahesabDocSyncState>(emptyState())
const visible = ref(false)
const minimized = ref(false)
const starting = ref(false)
const resetting = ref(false)
const message = ref('')
let timer: ReturnType<typeof setInterval> | null = null
const active = computed(() => state.value.running)
const finished = computed(() => state.value.finished && !state.value.running)
const percent = computed(() => state.value.percent)
const stage = computed(() => state.value.stage || 'docs')
const outcome = computed<DocSyncOutcome>(() => {
if (state.value.running) return 'running'
if (state.value.stopped) return 'canceled'
if (state.value.failed === 0) return 'success'
if (state.value.success === 0 && state.value.failed > 0) return 'error'
return 'partial'
})
function pollMs() {
const s = state.value.stage
return s === 'customers_out' || s === 'customers_in' ? POLL_CUSTOMERS_MS : POLL_DOCS_MS
}
function apply(snapshot?: TahesabDocSyncState | null) {
if (!snapshot) return
const wasVisible = visible.value
state.value = { ...emptyState(), ...snapshot }
if (snapshot.running) {
visible.value = true
restartPoll()
return
}
stopPoll()
if (snapshot.finished && wasVisible) {
visible.value = true
}
}
function startPoll() {
if (timer) return
timer = setInterval(() => {
void hydrate()
}, pollMs())
}
function restartPoll() {
stopPoll()
startPoll()
}
function stopPoll() {
if (timer) {
clearInterval(timer)
timer = null
}
}
async function hydrate(retries = 2) {
try {
const summary = await getTahesabPendingSummary()
apply(summary.doc_sync)
} catch {
if (retries > 0) {
window.setTimeout(() => {
void hydrate(retries - 1)
}, 1500)
}
}
}
async function start() {
if (starting.value) return
if (state.value.running) {
visible.value = true
minimized.value = false
restartPoll()
return
}
starting.value = true
try {
const res = await startTahesabDocSync()
message.value = res.message || ''
apply(res.doc_sync)
visible.value = true
minimized.value = false
} finally {
starting.value = false
}
}
async function startOutbound() {
if (starting.value) return
if (state.value.running) {
visible.value = true
minimized.value = false
restartPoll()
return
}
starting.value = true
try {
const res = await startTahesabCustomerOutbound()
message.value = res.message || ''
apply(res.doc_sync)
visible.value = true
minimized.value = false
} finally {
starting.value = false
}
}
async function startInbound() {
if (starting.value) return
if (state.value.running) {
visible.value = true
minimized.value = false
restartPoll()
return
}
starting.value = true
try {
const res = await startTahesabCustomerInbound()
message.value = res.message || ''
apply(res.doc_sync)
visible.value = true
minimized.value = false
} finally {
starting.value = false
}
}
async function stop() {
const res = await stopTahesabDocSync()
message.value = res.message || ''
apply(res.doc_sync)
window.setTimeout(() => {
void hydrate()
}, 3000)
}
function minimize() {
minimized.value = true
}
function expand() {
minimized.value = false
}
function dismiss() {
if (state.value.running) return
visible.value = false
minimized.value = false
}
async function resetLocal() {
if (resetting.value || state.value.running) return null
resetting.value = true
try {
const res = await resetTahesabLocalDocs()
message.value = res.message || ''
apply(res.summary?.doc_sync)
visible.value = false
minimized.value = false
return res
} finally {
resetting.value = false
}
}
return {
state,
visible,
minimized,
starting,
resetting,
message,
active,
finished,
percent,
stage,
outcome,
apply,
hydrate,
start,
startOutbound,
startInbound,
resetLocal,
stop,
minimize,
expand,
dismiss,
}
})
+3
View File
@@ -246,6 +246,9 @@ export const captureSitesPageIntro =
export const configurationPageIntro =
'تنظیمات کلی سامانه (کلید–مقدار). با جستجو و فیلتر نوع فیلد، مورد را پیدا کنید؛ بعد از تغییر ذخیره کنید. روی آیکون i کنار هر تنظیم توضیح همان فیلد را ببینید.'
export const websiteSettingsPageIntro =
'متن و تنظیمات صفحهٔ لندینگ وبسایت. هر زیرمنو کلیدهای همان بخش را نشان می‌دهد؛ بعد از تغییر ذخیره می‌شود و در اپ کاربر با get_settings در دسترس است.'
export const accountingReportsPageIntro =
'گزارش‌های حسابداری داخلی پنل. برای اسناد و همگام‌سازی مشتریان از تب‌های ته‌حساب / زرین / پرگار استفاده کنید.'
+17 -1
View File
@@ -86,6 +86,9 @@ export const supportChatMenuEnabledSetting = ref(false)
/** reactive — سوییچ دیپلوی show_to_users_chat (برای مخفی کردن has_chat در تنظیمات عادی) */
export const showToUsersChatSetting = ref(false)
/** reactive — منوی تنظیمات وبسایت وقتی has_landing روشن است */
export const hasLandingSetting = ref(false)
/** reactive — سوییچ دیپلوی price_channel_access (گروه کانال در تنظیمات عادی) */
export const priceChannelAccessSetting = ref(false)
@@ -215,6 +218,10 @@ export function setShowToUsersChatFromSettings(value: boolean): void {
showToUsersChatSetting.value = value
}
export function setHasLandingFromSettings(value: boolean): void {
hasLandingSetting.value = value
}
export function setPriceChannelAccessFromSettings(value: boolean): void {
priceChannelAccessSetting.value = value
}
@@ -313,7 +320,7 @@ export function invalidateSettingsBootstrap(): void {
}
/**
* اعمال مستقیم ۱۵ دسترسی سوپرادمین روی فلگ‌های منو/UI
* اعمال مستقیم ۱۶ دسترسی سوپرادمین روی فلگ‌های منو/UI
* (پاسخ refresh-superadmin.items یا ردیف‌های get_settings).
*/
export function applySuperAdminAccessFlagsFromItems(
@@ -333,6 +340,7 @@ export function applySuperAdminAccessFlagsFromItems(
applyPriceTriggerEnabledFromRows(rows)
applyAppNotificationEnabledFromRows(rows)
applySupportChatMenuEnabledFromRows(rows)
applyHasLandingFromRows(rows)
}
export function applyConditionalOrderEnabledFromRows(
@@ -377,6 +385,13 @@ export function applyAppNotificationEnabledFromRows(
if (row) setAppNotificationEnabledFromSettings(isSwitchOn(row.value))
}
export function applyHasLandingFromRows(
rows: Array<{ key?: string; value?: string | null }>
) {
const row = rows.find((item) => item.key === 'has_landing')
if (row) setHasLandingFromSettings(isSwitchOn(row.value))
}
export function applyPriceProviderFromRows(
rows: Array<{ key?: string; value?: string | null }>
) {
@@ -419,6 +434,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
applyPriceTriggerEnabledFromRows(list)
applyAppNotificationEnabledFromRows(list)
applySupportChatMenuEnabledFromRows(list)
applyHasLandingFromRows(list)
applyPriceProviderFromRows(list)
applyPriceChannelAccessFromRows(list)
setCachedMainMetal(mainMetalRow?.value)