2025-10-05 09:44:14 +03:30
|
|
|
<template>
|
|
|
|
|
<div>
|
2025-10-26 15:55:00 +03:30
|
|
|
<div class="bg-white wrap-fix py-3 px-3 text-black font-bold drop-shadow flex h-12 z-20 justify-between">
|
2025-10-05 09:44:14 +03:30
|
|
|
<div class="flex ">
|
|
|
|
|
<div @click="router.back()" class="cursor-pointer">
|
|
|
|
|
<BasicIcon icon="vuesax-linear:arrow-right-1" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="mr-2">{{ info?.title }}</div>
|
|
|
|
|
</div>
|
2025-10-26 15:55:00 +03:30
|
|
|
<div @click="editShow = true">
|
2025-10-05 09:44:14 +03:30
|
|
|
<BasicIcon icon="vuesax-linear:setting-4" />
|
2025-10-26 15:55:00 +03:30
|
|
|
</div>
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
|
|
|
|
<div class="pt-20 flex flex-col justify-center items-center">
|
|
|
|
|
<a-spin :spinning="loading">
|
|
|
|
|
<div class="bg-sky-100 w-[120px] aspect-square flex justify-center rounded-xl">
|
2025-10-26 15:55:00 +03:30
|
|
|
<img v-if="!loading" :src="itemImg" alt="">
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
|
|
|
|
</a-spin>
|
|
|
|
|
<div class="mt-2 font-bold flex text-xs items-center text-gray-500">
|
2025-10-26 15:55:00 +03:30
|
|
|
<div class="ml-1 text-base text-black">{{ info?.wallet[0]?.gold }}</div>
|
|
|
|
|
گرم
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
2025-10-26 15:55:00 +03:30
|
|
|
<div class="text-gray-400">موجودی قلک {{ info?.title }}</div>
|
2025-10-05 09:44:14 +03:30
|
|
|
<div class="w-full p-5">
|
2025-10-26 15:55:00 +03:30
|
|
|
<div class="w-full flex gap-3">
|
2025-10-05 09:44:14 +03:30
|
|
|
<BasicButton class="w-full !bg-[#F3F0E9] !border-0 !rounded" icon="vuesax-linear:add-square" icon-size="18"
|
|
|
|
|
@click="()=> {transactionShow = true; isDeposit= false}">برداشت
|
|
|
|
|
</BasicButton>
|
|
|
|
|
<BasicButton class="w-full !bg-[#F3F0E9] !border-0 !rounded" icon="vuesax-linear:arrow-up" icon-size="18"
|
|
|
|
|
@click="()=> {transactionShow = true; isDeposit= true}">واریز
|
|
|
|
|
</BasicButton>
|
2025-10-26 15:55:00 +03:30
|
|
|
</div>
|
2025-10-05 09:44:14 +03:30
|
|
|
<div class=" font-bold mt-5">تراکنش ها</div>
|
|
|
|
|
<!-- <a-spin :spinning="loading">-->
|
|
|
|
|
<div class="mt-5 pb-17 overflow-y-scroll h-[54vh]">
|
|
|
|
|
<list-anim v-if="!loading">
|
2025-10-26 15:55:00 +03:30
|
|
|
<Item v-for="item in items" :key="item.id" :item="item" />
|
2025-10-05 09:44:14 +03:30
|
|
|
</list-anim>
|
|
|
|
|
<TransactionSkeleton v-for="i in 8" v-else :key="i" class="mt-1" />
|
|
|
|
|
<empty v-if="items.length === 0 && !loading" text="هیچ تراکنشی یافت نشد" />
|
|
|
|
|
</div>
|
|
|
|
|
<!-- </a-spin>-->
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<BasicActionSheet v-model:show="transactionShow">
|
|
|
|
|
<div class="font-bold text-lg">{{ isDeposit ? 'واریز' : 'برداشت' }}</div>
|
|
|
|
|
<a-form ref="formRef" :model="userFormState" class="!mt-5" name="basic" @finish="transaction()">
|
|
|
|
|
<a-form-item :rules="[required()]" label="مقدار گرم طلا" name="value" class="!block">
|
|
|
|
|
<BasicInput v-model:value="userFormState.value"
|
|
|
|
|
addon-before="گرم" place-holder="گرم"
|
|
|
|
|
type="text" inputmode="decimal"
|
|
|
|
|
size="large" />
|
|
|
|
|
<div v-if="isDeposit" class="mt-2 text-xs font-bold leading-5">
|
|
|
|
|
<div>موجودی کیف طلا: {{ walletStore?.walletInfo?.gold }} گرم</div>
|
2025-10-26 15:55:00 +03:30
|
|
|
<div v-if="info?.wallet[0]?.gold !== 0">
|
|
|
|
|
{{ `موجودی قابل برداشت قلک: ${info?.wallet[0]?.gold ?? 0} گرم` }}
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-26 15:55:00 +03:30
|
|
|
<div v-else class="mt-2 text-xs font-bold">موجودی قلک {{ info.title }}: {{ info?.wallet[0]?.gold }} گرم
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
<a-form-item>
|
|
|
|
|
<BasicButton
|
|
|
|
|
:disabled="transButtonDisable"
|
|
|
|
|
class=" w-full py-2 mt-2"
|
|
|
|
|
html-type="submit"
|
|
|
|
|
type="primary"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<a-spin v-if="loading" size="small" />
|
|
|
|
|
<div v-else>{{ isDeposit ? 'واریز' : 'برداشت' }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</BasicButton>
|
|
|
|
|
<BasicButton class="mb-20 mt-2 w-full" @click="transactionShow = false">بازگشت</BasicButton>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-form>
|
|
|
|
|
</BasicActionSheet>
|
|
|
|
|
<BasicActionSheet v-model:show="editShow">
|
2025-10-26 15:55:00 +03:30
|
|
|
<div class="font-bold text-lg">قلک {{ info?.title }}</div>
|
2025-10-05 09:44:14 +03:30
|
|
|
|
|
|
|
|
<BasicButton class="mt-12 w-full" icon="vuesax-linear:edit"
|
|
|
|
|
icon-size="16" @click="$router.push({name: 'fund_add', query:{id:infoId}})">
|
|
|
|
|
<div class="flex w-full justify-right">ویرایش</div>
|
|
|
|
|
</BasicButton>
|
|
|
|
|
<BasicButton :loading="loading" class="mb-10 mt-2 w-full !text-red-600"
|
|
|
|
|
icon="vuesax-linear:trash"
|
|
|
|
|
icon-size="16"
|
|
|
|
|
@click="deleteFundConfirm">
|
|
|
|
|
<div class="flex w-full justify-right">حذف</div>
|
|
|
|
|
</BasicButton>
|
|
|
|
|
|
|
|
|
|
<BasicButton class="mb-20 mt-2 w-full" type="primary" @click="transactionShow = false">بازگشت</BasicButton>
|
|
|
|
|
</BasicActionSheet>
|
|
|
|
|
<DialogVant v-model:show="showDeleteConfirm" :closeOnClickOverlay="true" :timeOut="-1">
|
|
|
|
|
<!-- <template v-slot:img>
|
|
|
|
|
<img :src="registerDelayImage" alt="" class="opacity-80">
|
|
|
|
|
</template>-->
|
|
|
|
|
|
|
|
|
|
<template v-slot:title>
|
|
|
|
|
<div class="p-5 text-sm">
|
2025-10-26 15:55:00 +03:30
|
|
|
آیا از حذف قلک خود اطمینان دارید؟
|
2025-10-05 09:44:14 +03:30
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<template v-slot:button>
|
|
|
|
|
<div class="text-center text-red" @click="deleteFundFunction">
|
|
|
|
|
حذف
|
|
|
|
|
</div>
|
|
|
|
|
<div class="text-center" @click="showDeleteConfirm = false">
|
|
|
|
|
انصراف
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
</DialogVant>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
|
|
|
|
import router from '@/router'
|
|
|
|
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
|
|
|
import Item from './components/Item.vue'
|
|
|
|
|
import homeImg from '@/assets/img/cash_home.svg'
|
|
|
|
|
import giftImg from '@/assets/img/cash_gift.svg'
|
|
|
|
|
import circulationImg from '@/assets/img/cash_circulation.svg'
|
|
|
|
|
import loveImg from '@/assets/img/cash_love.svg'
|
|
|
|
|
import repairsImg from '@/assets/img/cash_repairs.svg'
|
|
|
|
|
import savingImg from '@/assets/img/cash_saving.svg'
|
|
|
|
|
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
|
|
|
|
|
import { loading } from '@/utils'
|
|
|
|
|
import { deleteFund, fundDeposit, fundWithdraw, getFundById, getFundTransactionTable } from '@/api/fund'
|
|
|
|
|
import type { Fund, FundTransaction } from '@/models/fund'
|
|
|
|
|
import type { TableInput, TableOutput } from '@/models/table'
|
|
|
|
|
import type { Transaction } from '@/models/transaction'
|
|
|
|
|
import Empty from '@/components/empty.vue'
|
|
|
|
|
import { required } from '@/utils/inputRules'
|
|
|
|
|
import type { FormInstance } from 'ant-design-vue'
|
|
|
|
|
import { message } from 'ant-design-vue'
|
|
|
|
|
import BasicActionSheet from '@/components/BasicPacks/BasicActionSheet.vue'
|
|
|
|
|
import BasicInput from '@/components/BasicPacks/BasicInput.vue'
|
|
|
|
|
import { useWalletStore } from '@/store/walletStore'
|
|
|
|
|
import ListAnim from '@/components/ListAnim.vue'
|
|
|
|
|
import TransactionSkeleton from '@/components/TransactionSkeleton.vue'
|
|
|
|
|
import DialogVant from '@/components/DialogVant.vue'
|
|
|
|
|
import { useFundUserStore } from '@/store/fundStore'
|
|
|
|
|
|
2025-10-26 15:55:00 +03:30
|
|
|
const info = ref<Fund>()
|
2025-10-05 09:44:14 +03:30
|
|
|
const items = ref<Transaction[]>([])
|
|
|
|
|
const tableOutput = ref<TableOutput<Transaction> | null>(null)
|
|
|
|
|
const pagination = ref<TableInput>({/*limit: 100, page: 0*/ })
|
|
|
|
|
const transactionShow = ref<boolean>()
|
|
|
|
|
const editShow = ref<boolean>()
|
|
|
|
|
const showDeleteConfirm = ref<boolean>()
|
|
|
|
|
const isDeposit = ref<boolean>()
|
|
|
|
|
const formRef = ref<FormInstance>()
|
|
|
|
|
let fundStore = useFundUserStore()
|
|
|
|
|
let walletStore = useWalletStore()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
initInfo()
|
|
|
|
|
// initTable()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function deleteFundConfirm() {
|
2025-10-26 15:55:00 +03:30
|
|
|
if (info.value?.wallet[0] === undefined || info.value?.wallet[0]?.gold === 0) {
|
2025-10-05 09:44:14 +03:30
|
|
|
showDeleteConfirm.value = true
|
|
|
|
|
} else {
|
2025-10-26 15:55:00 +03:30
|
|
|
message.error('ابتدا قلک خود را خالی کنید')
|
2025-10-05 09:44:14 +03:30
|
|
|
editShow.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function deleteFundFunction() {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
showDeleteConfirm.value = false
|
|
|
|
|
await deleteFund(infoId)
|
|
|
|
|
await fundStore.getMyFund()
|
|
|
|
|
router.back()
|
2025-10-26 15:55:00 +03:30
|
|
|
message.success('قلک با موفقیت حذف شد')
|
2025-10-05 09:44:14 +03:30
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const infoId: number = parseInt(<string>router.currentRoute.value.params.id)
|
|
|
|
|
const userFormState = reactive<FundTransaction>({
|
|
|
|
|
value: undefined,
|
|
|
|
|
fund_id: infoId
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
watch(transactionShow, (n) => !n ? userFormState.value = undefined : '')
|
|
|
|
|
|
|
|
|
|
const transButtonDisable = computed(() => {
|
|
|
|
|
if (!loading.value) {
|
|
|
|
|
if (userFormState.value !== undefined) {
|
|
|
|
|
if (isDeposit.value) {
|
|
|
|
|
return userFormState.value > walletStore?.walletInfo?.gold
|
|
|
|
|
} else {
|
2025-10-26 15:55:00 +03:30
|
|
|
return userFormState.value > info.value?.wallet[0]?.gold
|
2025-10-05 09:44:14 +03:30
|
|
|
}
|
2025-10-26 15:55:00 +03:30
|
|
|
// return isDeposit.value ? userFormState.value > walletStore?.walletInfo?.gold : userFormState.value > info.value?.wallet[0]?.gold
|
2025-10-05 09:44:14 +03:30
|
|
|
} else return true
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async function initInfo() {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
2025-10-26 15:55:00 +03:30
|
|
|
info.value = await getFundById(infoId)
|
2025-10-05 09:44:14 +03:30
|
|
|
//pagination.value.page=0
|
|
|
|
|
await initTable()
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function initTable() {
|
|
|
|
|
if (info.value?.wallet)
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
items.value = []
|
2025-10-26 15:55:00 +03:30
|
|
|
Object.assign(pagination.value, { wallet_id: info.value?.wallet[0]?.id })
|
2025-10-05 09:44:14 +03:30
|
|
|
// pagination.value.fund_id = infoId
|
|
|
|
|
tableOutput.value = await getFundTransactionTable(pagination.value)
|
|
|
|
|
items.value.push(...tableOutput.value.rows)
|
|
|
|
|
// console.log(tableOutput.value)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function transaction() {
|
|
|
|
|
formRef.value?.validateFields().then(async () => {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
userFormState.fund_id = infoId
|
|
|
|
|
isDeposit.value ? await fundDeposit(userFormState) : await fundWithdraw(userFormState)
|
|
|
|
|
await initInfo()
|
|
|
|
|
// await initTable()
|
|
|
|
|
await fundStore.getMyFund()
|
|
|
|
|
await walletStore.getMyWallet()
|
|
|
|
|
fundStore = useWalletStore()
|
|
|
|
|
walletStore = useWalletStore()
|
|
|
|
|
message.success(` با موفقیت${isDeposit.value ? ' واریز' : ' برداشت'} شد`)
|
|
|
|
|
transactionShow.value = false
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const itemImg = computed(() => {
|
|
|
|
|
switch (info.value?.title) {
|
|
|
|
|
case 'خرید لوازم منزل':
|
|
|
|
|
return homeImg
|
|
|
|
|
case 'هدیه':
|
|
|
|
|
return giftImg
|
|
|
|
|
case 'گردش':
|
|
|
|
|
return circulationImg
|
|
|
|
|
case 'ازدواج':
|
|
|
|
|
return loveImg
|
|
|
|
|
case 'تعمیرات':
|
|
|
|
|
return repairsImg
|
|
|
|
|
case 'پس انداز':
|
|
|
|
|
return savingImg
|
|
|
|
|
default:
|
|
|
|
|
return savingImg
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
</style>
|