This commit is contained in:
2026-06-15 22:39:22 +03:30
parent 57a8fb9854
commit 138bfa965e
2 changed files with 13 additions and 35 deletions
@@ -1,6 +1,6 @@
<template> <template>
<a-form <a-form
:model="form" :model="modelValue"
ref="formRef" ref="formRef"
autocomplete="off" autocomplete="off"
class="wallet-charge-form" class="wallet-charge-form"
@@ -8,7 +8,7 @@
> >
<a-form-item label="نوع عملیات" name="direction"> <a-form-item label="نوع عملیات" name="direction">
<a-radio-group <a-radio-group
v-model:value="form.direction" v-model:value="modelValue.direction"
button-style="solid" button-style="solid"
class="wallet-charge-form__direction w-full" class="wallet-charge-form__direction w-full"
> >
@@ -29,29 +29,29 @@
</div> </div>
<a-form-item name="talabBedehi"> <a-form-item name="talabBedehi">
<a-checkbox v-model:checked="form.talabBedehi">طلب/بدهی</a-checkbox> <a-checkbox v-model:checked="modelValue.talabBedehi">طلب/بدهی</a-checkbox>
</a-form-item> </a-form-item>
<a-form-item :label="amountLabel" name="amountAbs" :rules="amountRules"> <a-form-item :label="amountLabel" name="amountAbs" :rules="amountRules">
<BasicInput <BasicInput
v-model:value="form.amountAbs" v-model:value="modelValue.amountAbs"
:addon-before="unit" :addon-before="unit"
:type="variant === 'money' ? 'price' : 'number'" :type="variant === 'money' ? 'price' : 'number'"
:place-holder="amountPlaceholder" :place-holder="amountPlaceholder"
/> />
<div v-if="variant === 'money' && Number(form.amountAbs) > 10" class="wallet-charge-form__hint"> <div v-if="variant === 'money' && Number(modelValue.amountAbs) > 10" class="wallet-charge-form__hint">
معادل {{ usePrice(Number(form.amountAbs) / 10, true, 'تومان') }} معادل {{ usePrice(Number(modelValue.amountAbs) / 10, true, 'تومان') }}
</div> </div>
</a-form-item> </a-form-item>
<a-form-item :label="noteLabel" name="note" :rules="inputRules()"> <a-form-item :label="noteLabel" name="note" :rules="inputRules()">
<BasicInput v-model:value="form.note" :place-holder="notePlaceholder" /> <BasicInput v-model:value="modelValue.note" :place-holder="notePlaceholder" />
</a-form-item> </a-form-item>
</a-form> </a-form>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, watch } from 'vue' import { computed, ref } from 'vue'
import type { FormInstance } from 'ant-design-vue' import type { FormInstance } from 'ant-design-vue'
import type { Charge } from '@/model/wallet' import type { Charge } from '@/model/wallet'
import { inputRules } from '@/utils/inputRules' import { inputRules } from '@/utils/inputRules'
@@ -62,32 +62,10 @@ const props = defineProps<{
modelValue: Charge modelValue: Charge
}>() }>()
const emit = defineEmits<{
'update:modelValue': [value: Charge]
}>()
const form = ref<Charge>({ ...props.modelValue })
watch(
() => props.modelValue,
(value) => {
form.value = { ...value }
},
{ deep: true }
)
watch(
form,
(value) => {
emit('update:modelValue', { ...value })
},
{ deep: true }
)
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const unit = computed(() => (props.variant === 'money' ? 'ریال' : 'گرم')) const unit = computed(() => (props.variant === 'money' ? 'ریال' : 'گرم'))
const isDischarge = computed(() => form.value.direction === 'discharge') const isDischarge = computed(() => props.modelValue.direction === 'discharge')
const formClass = computed(() => const formClass = computed(() =>
isDischarge.value ? 'wallet-charge-form--discharge' : 'wallet-charge-form--charge' isDischarge.value ? 'wallet-charge-form--discharge' : 'wallet-charge-form--charge'
+4 -4
View File
@@ -229,7 +229,7 @@
@ok="chargeMoneyWallet" @ok="chargeMoneyWallet"
@close="showMoneyWalletCharge = false" @close="showMoneyWalletCharge = false"
> >
<WalletChargeForm ref="moneyChargeFormRef" v-model="formCharge" variant="money" /> <WalletChargeForm ref="moneyChargeFormRef" :model-value="formCharge" variant="money" />
</BasicActionSheet> </BasicActionSheet>
<BasicModal <BasicModal
v-else v-else
@@ -241,7 +241,7 @@
:loading="loading" :loading="loading"
@close="showMoneyWalletCharge = false" @close="showMoneyWalletCharge = false"
> >
<WalletChargeForm ref="moneyChargeFormRef" v-model="formCharge" variant="money" /> <WalletChargeForm ref="moneyChargeFormRef" :model-value="formCharge" variant="money" />
</BasicModal> </BasicModal>
<BasicActionSheet <BasicActionSheet
@@ -258,7 +258,7 @@
@ok="chargeGoldWallet" @ok="chargeGoldWallet"
@close="showGoldWalletCharge = false" @close="showGoldWalletCharge = false"
> >
<WalletChargeForm ref="goldChargeFormRef" v-model="formCharge" variant="gold" /> <WalletChargeForm ref="goldChargeFormRef" :model-value="formCharge" variant="gold" />
</BasicActionSheet> </BasicActionSheet>
<BasicModal <BasicModal
v-else v-else
@@ -270,7 +270,7 @@
:loading="loading" :loading="loading"
@close="showGoldWalletCharge = false" @close="showGoldWalletCharge = false"
> >
<WalletChargeForm ref="goldChargeFormRef" v-model="formCharge" variant="gold" /> <WalletChargeForm ref="goldChargeFormRef" :model-value="formCharge" variant="gold" />
</BasicModal> </BasicModal>
<BasicInfoModal <BasicInfoModal
v-model:visible="userInfoOrderVisible" v-model:visible="userInfoOrderVisible"