transfer-list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="app-container" v-loading="listLoading">
  3. <div class="filter-container">
  4. <el-row :gutter="20">
  5. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  6. <el-date-picker
  7. v-model="listQuery.dateRange[0]"
  8. type="date"
  9. :placeholder="$t('common.startDate')"
  10. value-format="yyyy-MM-dd"
  11. clearable
  12. style="width: 100%; margin: 10px 0;">
  13. </el-date-picker>
  14. </el-col>
  15. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  16. <el-date-picker
  17. v-model="listQuery.dateRange[1]"
  18. type="date"
  19. :placeholder="$t('common.endDate')"
  20. value-format="yyyy-MM-dd"
  21. clearable
  22. style="width: 100%; margin: 10px 0;">
  23. </el-date-picker>
  24. </el-col>
  25. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  26. <el-select size="small" v-model="listQuery.outWallet" :placeholder="$t('finance.transferOutAccountHint')" clearable class="filter-item" style="width: 100%; margin: 10px 0;">
  27. <el-option v-for="(item, key) in walletType" :label="item.label" :value="item.type" :key="key"></el-option>
  28. </el-select>
  29. </el-col>
  30. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  31. <el-select size="small" v-model="listQuery.inWallet" :placeholder="$t('finance.transferInAccountHint')" clearable class="filter-item" style="width: 100%; margin: 10px 0;">
  32. <el-option v-for="(item, key) in walletType" :label="item.label" :value="item.type" :key="key"></el-option>
  33. </el-select>
  34. </el-col>
  35. </el-row>
  36. <el-row :gutter="20">
  37. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  38. <el-input size="small" v-model="listQuery.userName" clearable :placeholder="$t('finance.receiveMemberCodeHint')" class="filter-item" style="width: 100%; margin: 10px 0;"></el-input>
  39. </el-col>
  40. <el-col :xs="24" :sm="24" :lg="6" :span="6">
  41. <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>
  42. </el-col>
  43. <el-col :xs="24" :sm="24" :lg="12" :span="12">
  44. <div class="grid-content bg-purple" align="right" style="width: 100%; margin: 10px 0;">
  45. <el-button size="small" type="primary" @click="getList">{{ $t('common.select') }}</el-button>
  46. <el-button size="small" type="warning" @click="handleFilterClear">{{ $t('common.reset') }}</el-button>
  47. </div>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. <el-table
  52. :data="list"
  53. border
  54. fit
  55. highlight-current-row
  56. >
  57. <el-table-column align="center" min-width="150px" :label="$t('finance.transferAccounts')" prop="OUT_WALLET_NAME"></el-table-column>
  58. <el-table-column align="center" min-width="190px" :label="$t('finance.receivingMemberCode')" prop="LAST_IN_USER_NAME"></el-table-column>
  59. <el-table-column align="center" min-width="200px" :label="$t('finance.receivingMemberName')" prop="LAST_IN_REAL_NAME"></el-table-column>
  60. <el-table-column align="center" min-width="170px" :label="$t('finance.transferIntoAccount')" prop="IN_WALLET_NAME"></el-table-column>
  61. <el-table-column align="center" min-width="150px" :label="$t('finance.transferAmount')" prop="ORI_AMOUNT">
  62. <template slot-scope="{row}">
  63. <span>{{ tool.formatPrice(row.ORI_AMOUNT) | toThousandFilter }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column align="center" min-width="150px" :label="$t('finance.serviceCharge')" prop="FEE" v-if="showFee">
  67. <template slot-scope="{row}">
  68. <span>{{ tool.formatPrice(row.FEE) | toThousandFilter}}</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column align="center" min-width="150px" :label="$t('finance.actualAmountTransferredInto')" prop="AMOUNT" v-if="showFee">
  72. <template slot-scope="{row}">
  73. <span>{{ tool.formatPrice(row.AMOUNT) | toThousandFilter}}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column min-width="160px" align="center" :label="$t('finance.transferTime')" prop="CREATED_AT">
  77. <template slot-scope="{row}">
  78. <span>{{ tool.convertToNigeriaTime(row.CREATED_AT) }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column align="center" min-width="150px" :label="$t('finance.remark')" prop="REMARK"></el-table-column>
  82. </el-table>
  83. <div class="white-box-footer" style="margin-top: 5px;">
  84. <el-button size="small" type="primary" @click="handleApplyTransfer">{{ $t('finance.applyTransfer') }}</el-button>
  85. <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
  86. </div>
  87. <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;">
  88. <el-form ref="form" :model="form" :label-position="labelPosition" v-loading="loading" style="margin-top: -20px; margin-bottom: -30px;">
  89. <el-row :gutter="5">
  90. <el-col :xs="24" :sm="24" :lg="24">
  91. <el-form-item :label="$t('finance.transferType')" prop="type" :placeholder="$t('finance.selectTransferType')" required>
  92. <el-select v-model="form.type" class="filter-item" style="width: 100%">
  93. <el-option v-for="(item,key) in transferConfig" :key="key" :label="item.outName + ' To ' + item.inName" :value="item.typeId" />
  94. </el-select>
  95. </el-form-item>
  96. <el-form-item :label="$t('finance.currentAvailableBonus')">
  97. <el-input v-model="balance" readonly disabled>
  98. <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
  99. </el-input>
  100. </el-form-item>
  101. <el-form-item :label="$t('finance.currentAvailableEcoin')">
  102. <el-input v-model="cash" readonly disabled>
  103. <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
  104. </el-input>
  105. </el-form-item>
  106. <el-form-item :label="$t('finance.currentTransferRatio')" v-if="false">
  107. <el-input v-model="transferProp" readonly>
  108. <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
  109. </el-input>
  110. </el-form-item>
  111. <el-form-item :label="$t('finance.maximumTransferAmount')" v-if="false">
  112. <el-input v-model="maxAmount" readonly>
  113. <!-- <template slot="append">{{ $t('currency.naira') }}</template>-->
  114. </el-input>
  115. </el-form-item>
  116. <el-form-item :label="$t('finance.memberCode')" prop="toUserName" required>
  117. <el-input size="small" v-model="form.toUserName" type="text" @change="fetchMember"></el-input>
  118. </el-form-item>
  119. <el-form-item :label="$t('finance.memberName')" prop="toRealName" v-show="form.toRealName !== null">
  120. <el-input size="small" v-model="form.toRealName" type="text" disabled></el-input>
  121. </el-form-item>
  122. <el-form-item :label="$t('finance.transferAmount')" prop="amount" required>
  123. <el-input v-model.number="form.amount" type="number" :min="minAmount" :max="maxAmount" @change="chkReal"></el-input>
  124. </el-form-item>
  125. <el-form-item :label="$t('finance.transferAmount')" v-show="fee > 0">
  126. <el-tag type="info">{{ fee }}%</el-tag>
  127. </el-form-item>
  128. <el-form-item :label="$t('finance.actualAmountTransferredInto')" v-show="fee > 0">
  129. <el-tag type="warning">{{ realAmount }}</el-tag>
  130. </el-form-item>
  131. <el-form-item :label="$t('finance.remark')" prop="remark">
  132. <el-input size="small" v-model="form.remark" type="text"></el-input>
  133. </el-form-item>
  134. <el-form-item>
  135. <el-button type="warning" size="small" @click="onCancel">{{ $t('table.cancel') }}</el-button>
  136. <el-button type="primary" size="small" @click="onSubmit('form')">{{ $t('table.confirm') }}</el-button>
  137. </el-form-item>
  138. </el-col>
  139. </el-row>
  140. </el-form>
  141. </el-dialog>
  142. </div>
  143. </template>
  144. <script>
  145. import {
  146. fetchApplyTransfer,
  147. fetchBalance,
  148. fetchChkTransferUser,
  149. fetchTransferCode,
  150. fetchTransferList
  151. } from '@/api/finance'
  152. import waves from '@/directive/waves'
  153. import Pagination from '@/components/Pagination'
  154. import tool from "@/utils/tool"
  155. import usersInfo from "@/utils/usersInfo"
  156. import {formatAmount, getScreenWidth} from "@/utils"
  157. import {fetchFullInfo} from "@/api/user"
  158. export default {
  159. name: 'Transfer',
  160. components: { Pagination },
  161. directives: { waves },
  162. data() {
  163. return {
  164. tool: tool,
  165. list: [],
  166. total: 0,
  167. listLoading: true,
  168. listQuery: {
  169. page: 1,
  170. pageSize: 20,
  171. inWallet: '',
  172. outWallet: '',
  173. realName: '',
  174. userName: '',
  175. dateRange: [],
  176. },
  177. showFee: false,
  178. walletType: [
  179. {
  180. type: 'bonus',
  181. label: 'Bonus'
  182. },
  183. {
  184. type: 'cash',
  185. label: 'Ecoin'
  186. },
  187. ],
  188. dialog: false,
  189. loading: false,
  190. form: {
  191. type: 1,
  192. toUserName: '',
  193. toRealName: null,
  194. amount: 0,
  195. payPassword: '',
  196. remark: '',
  197. transferCode: '',
  198. },
  199. userInfo: {
  200. TRANSFER_PROP: 100
  201. },
  202. transferConfig: [],
  203. minAmount: 0,
  204. maxAmount: 0,
  205. transferProp: 0,
  206. fee: 0,
  207. cash: 0,
  208. balance: 0,
  209. realAmount: 0,
  210. minAmountAllow: 5000,
  211. submitButtonStat: false,
  212. screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
  213. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  214. }
  215. },
  216. created() {
  217. this.getList()
  218. },
  219. mounted() {
  220. this.applyTransfer()
  221. this.fetchBalance()
  222. },
  223. methods: {
  224. getList() {
  225. this.listLoading = true
  226. fetchTransferList(this.listQuery).then(response => {
  227. this.list = response.data.list
  228. this.total = response.data.totalCount
  229. this.showFee = response.data.showFee
  230. setTimeout(() => {
  231. this.listLoading = false
  232. }, 0.5 * 1000)
  233. })
  234. },
  235. handleFilterClear(){
  236. this.listQuery.page = 1
  237. this.listQuery.pageSize = 20
  238. this.listQuery.inWallet = ''
  239. this.listQuery.outWallet = ''
  240. this.listQuery.realName = ''
  241. this.listQuery.userName = ''
  242. this.listQuery.dateRange = []
  243. this.getList()
  244. },
  245. handleApplyTransfer() {
  246. // 获取转账码
  247. fetchTransferCode().then(response => {
  248. this.form.transferCode = response.data.transferCode
  249. }).catch((err) => {
  250. this.$message({
  251. message: err,
  252. type: 'error',
  253. duration: 3 * 1000
  254. })
  255. return false
  256. })
  257. this.dialog = true
  258. },
  259. applyTransfer() {
  260. this.loading = true
  261. fetchChkTransferUser().then(response => {
  262. this.userInfo = response.data.userInfo
  263. this.transferConfig = response.data.transferConfig
  264. this.minAmount = response.data.minAmount
  265. // 奖金转现金
  266. this.fee = this.transferConfig[this.form.type - 1].fee
  267. setTimeout(() => {
  268. this.loading = false
  269. }, 0.5 * 1000)
  270. })
  271. },
  272. fetchBalance() {
  273. fetchBalance().then(response => {
  274. this.balance = response.data.bonus
  275. this.cash = response.data.cash
  276. this.maxAmount = parseFloat(tool.formatPrice(this.balance * this.userInfo.TRANSFER_PROP * 0.01))
  277. this.transferProp = this.userInfo.TRANSFER_PROP
  278. })
  279. },
  280. fetchMember() {
  281. let toUserName = this.form.toUserName.trim()
  282. // 不允许向自己转账
  283. if (usersInfo.userName() === toUserName) {
  284. this.form.toUserName = ''
  285. this.$message({
  286. message: this.$t('finance.transferNotAllow'),
  287. type: 'error'
  288. })
  289. return false
  290. }
  291. this.listLoading = true
  292. fetchFullInfo({ userName: toUserName }).then(response => {
  293. this.form.toRealName = response.data.REAL_NAME
  294. this.listLoading = false
  295. })
  296. },
  297. chkReal () {
  298. this.realAmount = tool.formatPrice(this.form.amount * (100 - this.fee) * 0.01)
  299. if (this.realAmount < this.minAmountAllow) {
  300. this.$message({
  301. message: this.$t('finance.lessTransferHint').replace('%s', this.minAmountAllow + ' NGN'),
  302. type: 'error',
  303. duration: 3 * 1000
  304. })
  305. return false
  306. }
  307. return true
  308. },
  309. onSubmit() {
  310. if (this.chkReal() === false) {
  311. return false
  312. }
  313. this.$prompt(this.$t('finance.enterPasswordTips'), this.$t('common.hint'), {
  314. confirmButtonText: this.$t('common.confirm'),
  315. cancelButtonText: this.$t('common.cancel'),
  316. inputType: 'password',
  317. inputPattern: /\S+/,
  318. inputErrorMessage: this.$t('finance.enterPasswordTips'),
  319. }).then(({ value }) => {
  320. this.form.payPassword = value.trim()
  321. this.loading = true
  322. fetchApplyTransfer(this.form).then(response => {
  323. this.$refs['form'].resetFields()
  324. this.$message({
  325. message: response.data,
  326. type: 'success',
  327. duration: 3 * 1000
  328. })
  329. this.submitButtonStat = false
  330. this.dialog = false
  331. this.handleFilterClear()
  332. this.getList()
  333. }).catch((err) => {
  334. this.$message({
  335. message: err,
  336. type: 'error',
  337. duration: 3 * 1000
  338. })
  339. this.submitButtonStat = false
  340. this.loading = false
  341. })
  342. })
  343. },
  344. onCancel() {
  345. this.dialog = false
  346. this.$refs['form'].resetFields()
  347. },
  348. }
  349. }
  350. </script>