all customer fixing added
This commit is contained in:
@@ -113,47 +113,6 @@
|
||||
: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"
|
||||
@@ -252,8 +211,6 @@ import {
|
||||
changeCustomerActivation,
|
||||
changeCustomerArchive,
|
||||
changeCustomerOrderActivation,
|
||||
changeCustomerConditionalOrderActive,
|
||||
updateCustomerConditionalOrderLimit,
|
||||
confirmUser,
|
||||
getCustomerTable
|
||||
} from '@/api/customer'
|
||||
@@ -427,49 +384,6 @@ 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">
|
||||
|
||||
@@ -188,6 +188,41 @@
|
||||
{{ userInfo?.trade_active === 1 ? 'مجاز' : 'غیر مجاز' }}
|
||||
</CustomTag>
|
||||
</BasicInfoItem>
|
||||
<template v-if="conditionalOrderEnabled">
|
||||
<BasicInfoItem title="سفارش شرطی" class="col-span-2 md:col-span-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<CustomTag
|
||||
:textColor="userInfo?.conditional_order_active ? '#25855A' : '#C53030'"
|
||||
:bgColor="userInfo?.conditional_order_active ? '#E3F4E9' : '#FECACA'"
|
||||
class="font-bold px-4"
|
||||
>
|
||||
{{ userInfo?.conditional_order_active ? 'مجاز' : 'غیر مجاز' }}
|
||||
</CustomTag>
|
||||
<BaseButton
|
||||
size="small"
|
||||
type="default"
|
||||
:loading="conditionalOrderLoading"
|
||||
@click="toggleConditionalOrderActive"
|
||||
>
|
||||
{{ userInfo?.conditional_order_active ? 'محدود کردن' : 'مجاز کردن' }}
|
||||
</BaseButton>
|
||||
</div>
|
||||
</BasicInfoItem>
|
||||
<BasicInfoItem title="سقف سفارش شرطی" class="col-span-2 md:col-span-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-bold">
|
||||
{{
|
||||
userInfo?.conditional_order_limit
|
||||
? `${userInfo.conditional_order_limit} عدد`
|
||||
: 'نامحدود'
|
||||
}}
|
||||
</span>
|
||||
<BaseButton size="small" type="default" @click="editConditionalOrderLimit">
|
||||
ویرایش سقف
|
||||
</BaseButton>
|
||||
</div>
|
||||
</BasicInfoItem>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="userInfo?.id && isMobile" class="mt-2 space-y-2">
|
||||
@@ -279,7 +314,7 @@ import { confirmDeleteItem } from '@/utils/confirmModal'
|
||||
import { cloneDeep } from 'lodash'
|
||||
import type { Item } from '@/model/Item'
|
||||
import type { Customer } from '@/model/customer'
|
||||
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
|
||||
import { createCustomer, deleteCustomer, updateCustomer, changeCustomerConditionalOrderActive, updateCustomerConditionalOrderLimit } from '@/api/customer'
|
||||
import customers from '@/router/routes/customers'
|
||||
import { usePrice } from '@core/utils/usePrice'
|
||||
import jalaliday from 'jalaliday'
|
||||
@@ -300,11 +335,15 @@ import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
|
||||
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
|
||||
import {
|
||||
accountingProviderSetting,
|
||||
initAccountingSettingsFromApi
|
||||
conditionalOrderEnabledSetting,
|
||||
initAccountingSettingsFromApi,
|
||||
initWalletSettingsFromApi
|
||||
} from '@/utils/config'
|
||||
import { displayAccountingCode, isValidAccountingCode } from '@/utils/accountingCode'
|
||||
import { syncCustomerWalletFromPargar, type PargarSyncWalletResult } from '@/api/pargar'
|
||||
import PargarWalletSyncAction from './components/PargarWalletSyncAction.vue'
|
||||
import { MODAL_ABOVE_ACTION_SHEET_Z_INDEX } from '@/constants/overlayZIndex'
|
||||
import { Modal } from 'ant-design-vue'
|
||||
|
||||
const fnameHelp: DashboardHelp = {
|
||||
description: 'نام کوچک مشتری که در اپ و پنل نمایش داده میشود.',
|
||||
@@ -539,7 +578,7 @@ const deleteItem = (id: number) => confirmDeleteItem('کاربر', id, deleteCus
|
||||
//define selects
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
await initAccountingSettingsFromApi()
|
||||
await Promise.allSettled([initAccountingSettingsFromApi(), initWalletSettingsFromApi()])
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
@@ -564,6 +603,59 @@ const accountingCodeVisible = computed(() => {
|
||||
return provider === 'pargar' || provider === 'tahesab'
|
||||
})
|
||||
|
||||
const conditionalOrderEnabled = conditionalOrderEnabledSetting
|
||||
const conditionalOrderLoading = ref(false)
|
||||
|
||||
async function toggleConditionalOrderActive() {
|
||||
if (!userInfo.value?.id || conditionalOrderLoading.value) return
|
||||
conditionalOrderLoading.value = true
|
||||
try {
|
||||
const res = await changeCustomerConditionalOrderActive(userInfo.value.id)
|
||||
userInfo.value.conditional_order_active = Boolean(
|
||||
res?.conditional_order_active ?? !userInfo.value.conditional_order_active
|
||||
)
|
||||
refreshTable()
|
||||
message.success('مجوز سفارش شرطی بهروز شد')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
conditionalOrderLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function editConditionalOrderLimit() {
|
||||
if (!userInfo.value?.id) return
|
||||
const current = userInfo.value.conditional_order_limit
|
||||
Modal.confirm({
|
||||
title: 'سقف تعداد سفارش شرطی',
|
||||
content: `برای «${userInfo.value.name || userInfo.value.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()
|
||||
}
|
||||
const res = await updateCustomerConditionalOrderLimit(userInfo.value!.id, limit)
|
||||
userInfo.value!.conditional_order_limit =
|
||||
res?.conditional_order_limit ?? limit
|
||||
refreshTable()
|
||||
message.success('سقف سفارش شرطی ذخیره شد')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const accountingCodeValue = computed(() => {
|
||||
const provider = accountingProviderSetting.value
|
||||
if (provider === 'pargar') return displayAccountingCode(userInfo.value?.pargar_account_id)
|
||||
|
||||
Reference in New Issue
Block a user