| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- <template>
- <div class="app-container" v-loading="listLoading">
- <div class="filter-container">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-date-picker
- v-model="listQuery.dateRange[0]"
- type="date"
- :placeholder="$t('common.startDate')"
- value-format="yyyy-MM-dd"
- clearable
- style="width: 100%; margin: 10px 0;">
- </el-date-picker>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-date-picker
- v-model="listQuery.dateRange[1]"
- type="date"
- :placeholder="$t('common.endDate')"
- value-format="yyyy-MM-dd"
- clearable
- style="width: 100%; margin: 10px 0;">
- </el-date-picker>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-select size="small" v-model="listQuery.outWallet" :placeholder="$t('finance.transferOutAccountHint')" clearable class="filter-item" style="width: 100%; margin: 10px 0;">
- <el-option v-for="(item, key) in walletType" :label="item.label" :value="item.type" :key="key"></el-option>
- </el-select>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-select size="small" v-model="listQuery.inWallet" :placeholder="$t('finance.transferInAccountHint')" clearable class="filter-item" style="width: 100%; margin: 10px 0;">
- <el-option v-for="(item, key) in walletType" :label="item.label" :value="item.type" :key="key"></el-option>
- </el-select>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-input size="small" v-model="listQuery.userName" clearable :placeholder="$t('finance.receiveMemberCodeHint')" class="filter-item" style="width: 100%; margin: 10px 0;"></el-input>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="6" :span="6">
- <el-input size="small" v-model="listQuery.realName" clearable :placeholder="$t('finance.receiveMemberNameHint')" class="filter-item" autoComplete="off" style="width: 100%; margin: 10px 0;"></el-input>
- </el-col>
- <el-col :xs="24" :sm="24" :lg="12" :span="12">
- <div class="grid-content bg-purple" align="right" style="width: 100%; margin: 10px 0;">
- <el-button size="small" type="primary" @click="getList">{{ $t('common.select') }}</el-button>
- <el-button size="small" type="warning" @click="handleFilterClear">{{ $t('common.reset') }}</el-button>
- </div>
- </el-col>
- </el-row>
- </div>
- <el-table
- :data="list"
- border
- fit
- highlight-current-row
- >
- <el-table-column align="center" min-width="150px" :label="$t('finance.transferAccounts')" prop="OUT_WALLET_NAME"></el-table-column>
- <el-table-column align="center" min-width="190px" :label="$t('finance.receivingMemberCode')" prop="LAST_IN_USER_NAME"></el-table-column>
- <el-table-column align="center" min-width="200px" :label="$t('finance.receivingMemberName')" prop="LAST_IN_REAL_NAME"></el-table-column>
- <el-table-column align="center" min-width="170px" :label="$t('finance.transferIntoAccount')" prop="IN_WALLET_NAME"></el-table-column>
- <el-table-column align="center" min-width="150px" :label="$t('finance.transferAmount')" prop="ORI_AMOUNT">
- <template slot-scope="{row}">
- <span>{{ tool.formatPrice(row.ORI_AMOUNT) | toThousandFilter }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" min-width="150px" :label="$t('finance.serviceCharge')" prop="FEE" v-if="showFee">
- <template slot-scope="{row}">
- <span>{{ tool.formatPrice(row.FEE) | toThousandFilter}}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" min-width="150px" :label="$t('finance.actualAmountTransferredInto')" prop="AMOUNT" v-if="showFee">
- <template slot-scope="{row}">
- <span>{{ tool.formatPrice(row.AMOUNT) | toThousandFilter}}</span>
- </template>
- </el-table-column>
- <el-table-column min-width="160px" align="center" :label="$t('finance.transferTime')" prop="CREATED_AT">
- <template slot-scope="{row}">
- <span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
- </template>
- </el-table-column>
- <el-table-column align="center" min-width="150px" :label="$t('finance.remark')" prop="REMARK"></el-table-column>
- </el-table>
- <div class="white-box-footer" style="margin-top: 5px;">
- <el-button size="small" type="primary" @click="handleApplyTransfer">{{ $t('finance.applyTransfer') }}</el-button>
- <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
- </div>
- <el-dialog :title="$t('finance.applyTransfer')" :visible.sync="dialog" :width="screenWidth" v-loading="loading" :close-on-click-modal="false" :destroy-on-close="true" style="margin-top: -80px;">
- <el-form ref="form" :model="form" :label-position="labelPosition" v-loading="loading" style="margin-top: -20px; margin-bottom: -30px;">
- <el-row :gutter="5">
- <el-col :xs="24" :sm="24" :lg="24">
- <el-form-item :label="$t('finance.transferType')" prop="type" :placeholder="$t('finance.selectTransferType')" required>
- <el-select v-model="form.type" class="filter-item" style="width: 100%">
- <el-option v-for="(item,key) in transferConfig" :key="key" :label="item.outName + ' To ' + item.inName" :value="item.typeId" />
- </el-select>
- </el-form-item>
- <el-form-item :label="$t('finance.currentAvailableBonus')">
- <el-input v-model="balance" readonly disabled>
- <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.currentAvailableEcoin')">
- <el-input v-model="cash" readonly disabled>
- <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.currentTransferRatio')" v-if="false">
- <el-input v-model="transferProp" readonly>
- <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.maximumTransferAmount')" v-if="false">
- <el-input v-model="maxAmount" readonly>
- <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
- </el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.memberCode')" prop="toUserName" required>
- <el-input size="small" v-model="form.toUserName" type="text" @change="fetchMember"></el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.memberName')" prop="toRealName" v-show="form.toRealName !== null">
- <el-input size="small" v-model="form.toRealName" type="text" disabled></el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.transferAmount')" prop="amount" required>
- <el-input v-model.number="form.amount" type="number" :min="minAmount" :max="maxAmount" @change="chkReal"></el-input>
- </el-form-item>
- <el-form-item :label="$t('finance.transferAmount')" v-show="fee > 0">
- <el-tag type="info">{{ fee }}%</el-tag>
- </el-form-item>
- <el-form-item :label="$t('finance.actualAmountTransferredInto')" v-show="fee > 0">
- <el-tag type="warning">{{ realAmount }}</el-tag>
- </el-form-item>
- <el-form-item :label="$t('finance.remark')" prop="remark">
- <el-input size="small" v-model="form.remark" type="text"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="warning" size="small" @click="onCancel">{{ $t('table.cancel') }}</el-button>
- <el-button type="primary" size="small" @click="onSubmit('form')">{{ $t('table.confirm') }}</el-button>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- fetchApplyTransfer,
- fetchBalance,
- fetchChkTransferUser,
- fetchTransferCode,
- fetchTransferList
- } from '@/api/finance'
- import waves from '@/directive/waves'
- import Pagination from '@/components/Pagination'
- import tool from "@/utils/tool"
- import usersInfo from "@/utils/usersInfo"
- import {formatAmount, getScreenWidth} from "@/utils"
- import {fetchFullInfo} from "@/api/user"
- export default {
- name: 'Transfer',
- components: { Pagination },
- directives: { waves },
- data() {
- return {
- tool: tool,
- list: [],
- total: 0,
- listLoading: true,
- listQuery: {
- page: 1,
- pageSize: 20,
- inWallet: '',
- outWallet: '',
- realName: '',
- userName: '',
- dateRange: [],
- },
- showFee: false,
- walletType: [
- {
- type: 'bonus',
- label: 'Bonus'
- },
- {
- type: 'cash',
- label: 'Ecoin'
- },
- ],
- dialog: false,
- loading: false,
- form: {
- type: 1,
- toUserName: '',
- toRealName: null,
- amount: 0,
- payPassword: '',
- remark: '',
- transferCode: '',
- },
- userInfo: {
- TRANSFER_PROP: 100
- },
- transferConfig: [],
- minAmount: 0,
- maxAmount: 0,
- transferProp: 0,
- fee: 0,
- cash: 0,
- balance: 0,
- realAmount: 0,
- minAmountAllow: 5000,
- submitButtonStat: false,
- screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
- labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
- }
- },
- created() {
- this.getList()
- },
- mounted() {
- this.applyTransfer()
- this.fetchBalance()
- },
- methods: {
- getList() {
- this.listLoading = true
- fetchTransferList(this.listQuery).then(response => {
- this.list = response.data.list
- this.total = response.data.totalCount
- this.showFee = response.data.showFee
- setTimeout(() => {
- this.listLoading = false
- }, 0.5 * 1000)
- })
- },
- handleFilterClear(){
- this.listQuery.page = 1
- this.listQuery.pageSize = 20
- this.listQuery.inWallet = ''
- this.listQuery.outWallet = ''
- this.listQuery.realName = ''
- this.listQuery.userName = ''
- this.listQuery.dateRange = []
- this.getList()
- },
- handleApplyTransfer() {
- // 获取转账码
- fetchTransferCode().then(response => {
- this.form.transferCode = response.data.transferCode
- }).catch((err) => {
- this.$message({
- message: err,
- type: 'error',
- duration: 3 * 1000
- })
- return false
- })
- this.dialog = true
- },
- applyTransfer() {
- this.loading = true
- fetchChkTransferUser().then(response => {
- this.userInfo = response.data.userInfo
- this.transferConfig = response.data.transferConfig
- this.minAmount = response.data.minAmount
- // 奖金转现金
- this.fee = this.transferConfig[this.form.type - 1].fee
- setTimeout(() => {
- this.loading = false
- }, 0.5 * 1000)
- })
- },
- fetchBalance() {
- fetchBalance().then(response => {
- this.balance = response.data.bonus
- this.cash = response.data.cash
- this.maxAmount = parseFloat(tool.formatPrice(this.balance * this.userInfo.TRANSFER_PROP * 0.01))
- this.transferProp = this.userInfo.TRANSFER_PROP
- })
- },
- fetchMember() {
- let toUserName = this.form.toUserName.trim()
- // 不允许向自己转账
- if (usersInfo.userName() === toUserName) {
- this.form.toUserName = ''
- this.$message({
- message: this.$t('finance.transferNotAllow'),
- type: 'error'
- })
- return false
- }
- this.listLoading = true
- fetchFullInfo({ userName: toUserName }).then(response => {
- this.form.toRealName = response.data.REAL_NAME
- this.listLoading = false
- })
- },
- chkReal () {
- this.realAmount = tool.formatPrice(this.form.amount * (100 - this.fee) * 0.01)
- if (this.realAmount < this.minAmountAllow) {
- this.$message({
- message: this.$t('finance.lessTransferHint').replace('%s', this.minAmountAllow + ' NGN'),
- type: 'error',
- duration: 3 * 1000
- })
- return false
- }
- return true
- },
- onSubmit() {
- if (this.chkReal() === false) {
- return false
- }
- this.$prompt(this.$t('finance.enterPasswordTips'), this.$t('common.hint'), {
- confirmButtonText: this.$t('common.confirm'),
- cancelButtonText: this.$t('common.cancel'),
- inputType: 'password',
- inputPattern: /\S+/,
- inputErrorMessage: this.$t('finance.enterPasswordTips'),
- }).then(({ value }) => {
- this.form.payPassword = value.trim()
- this.loading = true
- fetchApplyTransfer(this.form).then(response => {
- this.$refs['form'].resetFields()
- this.$message({
- message: response.data,
- type: 'success',
- duration: 3 * 1000
- })
- this.submitButtonStat = false
- this.dialog = false
- this.handleFilterClear()
- this.getList()
- }).catch((err) => {
- this.$message({
- message: err,
- type: 'error',
- duration: 3 * 1000
- })
- this.submitButtonStat = false
- this.loading = false
- })
- })
- },
- onCancel() {
- this.dialog = false
- this.$refs['form'].resetFields()
- },
- }
- }
- </script>
|