added charge for all product

This commit is contained in:
2026-07-11 11:42:12 +03:30
parent 65fe1c3996
commit 2647a50698
12 changed files with 463 additions and 478 deletions
+14 -123
View File
@@ -6,8 +6,7 @@
@info="info"
@edit="edit"
@add="add"
@chargeMoney="walletMoneyCharge"
@chargeGold="walletGoldCharge"
@chargeWallet="openWalletCharge"
/>
<!-- <BasicMenu :menu="menu" width="13rem" @onChange="tabSelected" />
@@ -236,67 +235,11 @@
</a-tab-pane>
</a-tabs>
</BasicActionSheet>
<BasicActionSheet
v-if="isMobile"
v-model:visible="showMoneyWalletCharge"
:title="moneyChargeTitle"
modal-width="24rem"
:loading="loading"
:show-button="true"
:show-cancel="true"
:show-ok="true"
:ok-text="moneyChargeOkText"
cancel-text="انصراف"
@ok="chargeMoneyWallet"
@close="showMoneyWalletCharge = false"
>
<CustomerWalletBalancePanel v-if="formCharge.customer_id" :customer-id="formCharge.customer_id" class="mb-3" />
<WalletChargeForm ref="moneyChargeFormRef" :model-value="formCharge" variant="money" />
</BasicActionSheet>
<BasicModal
v-else
v-model:visible="showMoneyWalletCharge"
width="28rem"
:title="moneyChargeTitle"
:ok-text="moneyChargeOkText"
@ok="chargeMoneyWallet"
:loading="loading"
@close="showMoneyWalletCharge = false"
>
<CustomerWalletBalancePanel v-if="formCharge.customer_id" :customer-id="formCharge.customer_id" class="mb-3" />
<WalletChargeForm ref="moneyChargeFormRef" :model-value="formCharge" variant="money" />
</BasicModal>
<BasicActionSheet
v-if="isMobile"
v-model:visible="showGoldWalletCharge"
:title="goldChargeTitle"
modal-width="24rem"
:loading="loading"
:show-button="true"
:show-cancel="true"
:show-ok="true"
:ok-text="goldChargeOkText"
cancel-text="انصراف"
@ok="chargeGoldWallet"
@close="showGoldWalletCharge = false"
>
<CustomerWalletBalancePanel v-if="formCharge.customer_id" :customer-id="formCharge.customer_id" class="mb-3" />
<WalletChargeForm ref="goldChargeFormRef" :model-value="formCharge" variant="gold" />
</BasicActionSheet>
<BasicModal
v-else
v-model:visible="showGoldWalletCharge"
width="28rem"
:title="goldChargeTitle"
:ok-text="goldChargeOkText"
@ok="chargeGoldWallet"
:loading="loading"
@close="showGoldWalletCharge = false"
>
<CustomerWalletBalancePanel v-if="formCharge.customer_id" :customer-id="formCharge.customer_id" class="mb-3" />
<WalletChargeForm ref="goldChargeFormRef" :model-value="formCharge" variant="gold" />
</BasicModal>
<WalletChargeModal
v-model:visible="showWalletCharge"
:customer-id="chargeCustomerId"
@success="onWalletChargeSuccess"
/>
<BasicInfoModal
v-model:visible="userInfoOrderVisible"
@close="userInfoOrderVisible = false"
@@ -327,9 +270,7 @@ import { cloneDeep } from 'lodash'
import type { Item } from '@/model/Item'
import type { Customer } from '@/model/customer'
import { createCustomer, deleteCustomer, updateCustomer } from '@/api/customer'
import type { Charge } from '@/model/wallet'
import customers from '@/router/routes/customers'
import { chargeWallet } from '@/api/wallet'
import { usePrice } from '@core/utils/usePrice'
import jalaliday from 'jalaliday'
import ordersTbl from '@/pages/menuPages/orders/components/table.vue'
@@ -340,15 +281,8 @@ import ReferralsTable from '@/pages/menuPages/customers/base/components/referral
import type { Order } from '@/model/order'
import Icon from '@core/components/BaseIcon/src/Icon.vue'
import { isMobile } from '@core/utils/is'
import WalletChargeForm from './components/WalletChargeForm.vue'
import WalletChargeModal from './components/WalletChargeModal.vue'
import CustomerWalletBalancePanel from '@/components/customer/CustomerWalletBalancePanel.vue'
import {
buildChargePayload,
createEmptyChargeForm,
walletChargeOkText,
walletChargeSuccessMessage,
walletChargeTitle
} from './utils/walletChargeForm'
import { metalLabel } from '@/utils/adminMetalLabels'
import type { DashboardHelp } from '@/pages/dashboard/dashboardSectionCopy'
import DashboardLabelWithHelp from '@/pages/dashboard/components/DashboardLabelWithHelp.vue'
@@ -448,21 +382,13 @@ const customerItems: Array<Item> = [
]
//wallet
const showMoneyWalletCharge = ref<boolean>(false)
const showGoldWalletCharge = ref<boolean>(false)
const showWalletCharge = ref<boolean>(false)
const chargeCustomerId = ref<number | null>(null)
const userInfoOrderVisible = ref<boolean>(false)
//form
const form = ref<Partial<Customer>>({})
const formRef = ref<FormInstance>()
const formCharge = ref<Charge>({})
const moneyChargeFormRef = ref<InstanceType<typeof WalletChargeForm>>()
const goldChargeFormRef = ref<InstanceType<typeof WalletChargeForm>>()
const moneyChargeTitle = computed(() => walletChargeTitle('money', formCharge.value.direction))
const goldChargeTitle = computed(() => walletChargeTitle('gold', formCharge.value.direction))
const moneyChargeOkText = computed(() => walletChargeOkText(formCharge.value.direction))
const goldChargeOkText = computed(() => walletChargeOkText(formCharge.value.direction))
//info
let infoParams = reactive<Info>({})
@@ -587,48 +513,13 @@ async function add() {
loading.value = false
}
function resetFormCharge(customerId: number) {
formCharge.value = createEmptyChargeForm(customerId)
function openWalletCharge(val: Customer) {
chargeCustomerId.value = val.id
showWalletCharge.value = true
}
async function walletMoneyCharge(val: Customer) {
resetFormCharge(val.id)
showMoneyWalletCharge.value = true
}
async function walletGoldCharge(val: Customer) {
resetFormCharge(val.id)
showGoldWalletCharge.value = true
}
async function chargeMoneyWallet() {
moneyChargeFormRef.value?.validateFields()?.then(async () => {
try {
loading.value = true
await chargeWallet(buildChargePayload(formCharge.value), 'money')
message.success(walletChargeSuccessMessage(formCharge.value.direction))
showMoneyWalletCharge.value = false
} catch (e) {
console.log(e)
} finally {
loading.value = false
}
})
}
async function chargeGoldWallet() {
goldChargeFormRef.value?.validateFields()?.then(async () => {
try {
loading.value = true
await chargeWallet(buildChargePayload(formCharge.value), 'gold')
message.success(walletChargeSuccessMessage(formCharge.value.direction))
showGoldWalletCharge.value = false
} catch (e) {
console.log(e)
} finally {
loading.value = false
}
})
function onWalletChargeSuccess() {
table.value?.fetch?.()
}
//reset data