fix some bugs

This commit is contained in:
2026-07-21 22:26:46 +03:30
parent 7c2248bb00
commit 2f64c6cce7
24 changed files with 707 additions and 16 deletions
@@ -7,11 +7,11 @@
<div class="pargar-wallet-sync__copy min-w-0 flex-1">
<p class="pargar-wallet-sync__title">همگام‌سازی با پرگار</p>
<p class="pargar-wallet-sync__hint">
{{
canSync
? 'اول اسنادِ اعمال‌نشده، بعد هم‌ترازی مانده — خودکار از پرگار کیف عوض نمی‌شود'
: 'ابتدا کد حسابداری پرگار را برای این مشتری ثبت کنید'
}}
{{
canSync
? 'موجودی را با ماندهٔ پرگار یکی می‌کند — تاریخچهٔ اسناد روی کیف replay نمی‌شود'
: 'ابتدا کد حسابداری پرگار را برای این مشتری ثبت کنید'
}}
</p>
</div>
</div>
@@ -21,10 +21,10 @@
size="small"
class="pargar-wallet-sync__btn"
:loading="loading"
:disabled="!canSync"
:disabled="!canSync || loading"
@click="$emit('sync')"
>
همگام‌سازی مانده و اسناد
همگام‌سازی مانده از پرگار
</a-button>
</div>
</template>
@@ -113,6 +113,47 @@
:color="record.trade_active === 1 ? '#54AD06' : '#ad0627'"
/>
</a-tooltip>
<a-tooltip
:key="`co-${record.conditional_order_active}-${record.id}`"
placement="bottom"
class="cursor-pointer"
@click="changeConditionalOrderActiveFunction(record.id)"
>
<template #title>
<span>
{{
record.conditional_order_active
? 'محدود کردن سفارش شرطی'
: 'مجاز کردن سفارش شرطی'
}}
</span>
</template>
<Icon
:icon="
record.conditional_order_active
? 'vuesax-linear:timer'
: 'vuesax-linear:timer-pause'
"
:color="record.conditional_order_active ? '#54AD06' : '#ad0627'"
/>
</a-tooltip>
<a-tooltip
placement="bottom"
class="cursor-pointer"
@click="openConditionalOrderLimit(record)"
>
<template #title>
<span>
سقف سفارش شرطی
{{
record.conditional_order_limit
? `(${record.conditional_order_limit})`
: '(نامحدود)'
}}
</span>
</template>
<Icon icon="vuesax-linear:slider-horizontal" color="#4572E9" />
</a-tooltip>
<a-tooltip
v-if="customerDirectSmsEnabled"
placement="bottom"
@@ -211,6 +252,8 @@ import {
changeCustomerActivation,
changeCustomerArchive,
changeCustomerOrderActivation,
changeCustomerConditionalOrderActive,
updateCustomerConditionalOrderLimit,
confirmUser,
getCustomerTable
} from '@/api/customer'
@@ -384,6 +427,49 @@ async function changeCustomerOrderActivationFunction(id: number) {
loading.value = false
}
}
async function changeConditionalOrderActiveFunction(id: number) {
try {
loading.value = true
await changeCustomerConditionalOrderActive(id)
await fetch()
message.success('مجوز سفارش شرطی به‌روز شد')
} catch (e) {
console.error(e)
} finally {
loading.value = false
}
}
function openConditionalOrderLimit(customer: Customer) {
const current = customer.conditional_order_limit
Modal.confirm({
title: 'سقف تعداد سفارش شرطی',
content: `برای «${customer.name || customer.id}» عدد سقف را وارد کنید (خالی = نامحدود). فعلی: ${
current ? current : 'نامحدود'
}`,
okText: 'ذخیره',
cancelText: 'انصراف',
centered: true,
zIndex: MODAL_ABOVE_ACTION_SHEET_Z_INDEX,
onOk: async () => {
const raw = window.prompt(
'سقف تعداد تریگر pending (خالی = نامحدود):',
current != null ? String(current) : ''
)
if (raw === null) return
const trimmed = raw.trim()
const limit = trimmed === '' ? null : Number(trimmed)
if (limit !== null && (!Number.isFinite(limit) || limit < 1)) {
message.error('عدد نامعتبر است')
return Promise.reject()
}
await updateCustomerConditionalOrderLimit(customer.id, limit)
await fetch()
message.success('سقف سفارش شرطی ذخیره شد')
},
})
}
</script>
<style lang="less">
@@ -44,7 +44,8 @@ export const cols: BaseTableColumn[] = [
dataIndex: 'product.title',
key: 'product.title',
type: 'Text',
customRender: (record: any) => record.record?.product?.title ?? '-'
customRender: (record: any) =>
record.record?.product_title || record.record?.product?.title || '-'
},
{
title: 'موجودی',
+3 -1
View File
@@ -596,12 +596,13 @@ async function refreshWalletPanels() {
}
async function syncPargarWallet() {
if (!userInfo.value?.id || !pargarWalletCanSync.value) return
if (!userInfo.value?.id || !pargarWalletCanSync.value || pargarSyncLoading.value) return
pargarSyncLoading.value = true
try {
const res = await syncCustomerWalletFromPargar(userInfo.value.id)
const applied =
res.ok ||
(res.result?.documents?.acknowledged ?? 0) > 0 ||
(res.result?.documents?.applied ?? 0) > 0 ||
Boolean(res.result?.mande?.applied)
@@ -620,6 +621,7 @@ async function syncPargarWallet() {
const status = (e as { response?: { status?: number } })?.response?.status
const applied =
Boolean(data?.ok) ||
(data?.result?.documents?.acknowledged ?? 0) > 0 ||
(data?.result?.documents?.applied ?? 0) > 0 ||
Boolean(data?.result?.mande?.applied)