index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="exchange-view">
  3. <div class="headline">
  4. <span>汇率管理</span>
  5. <div class="search_time">
  6. <a @click="updateItem()"><i class="border_radius">+</i>新增汇率</a>
  7. </div>
  8. </div>
  9. <ctable
  10. :headArr="headArr"
  11. :StyleWidth="StyleWidth"
  12. :data="tableData"
  13. :totalElements="totalElements"
  14. @handleCurrentChange="handleCurrentChange"
  15. :currentPage="currentPage"
  16. :controlArray="controlArray"
  17. @updateItem="updateItem"
  18. @clickTwo="clickTwo"
  19. >
  20. </ctable>
  21. <exchange-alert :AlertTitle="AlertTitle"
  22. @closeAlert="closeAlert"
  23. :chooseItem="chooseItem"
  24. ref="exchangeAlert"
  25. :IslookOrUpdate="IslookOrUpdate">
  26. </exchange-alert>
  27. </div>
  28. </template>
  29. <script>
  30. import { clone, Vuehttp } from '@/utils/tools'
  31. import { Ctable } from '@/components/base/table'
  32. import { CtableClass } from '@/utils/CtableClass'
  33. import { exchangeAlert } from '@/components/severPage'
  34. export default {
  35. name: 'ExchangeView',
  36. data(){
  37. return {
  38. currentPage: 1,
  39. count: 10,
  40. chooseItem: {},
  41. IslookOrUpdate: 'update'
  42. }
  43. },
  44. fetch({store}) {
  45. return !store.state.exchange.currencyList.data.content ? Promise.all([
  46. store.dispatch('loadexchangeInfo', {count: 10, page: 1}),
  47. store.dispatch('loadexchangeCurrencyList')
  48. ]) : ''
  49. },
  50. components: {
  51. Ctable,
  52. exchangeAlert
  53. },
  54. computed: {
  55. headArr() {
  56. return ['发布时间', '货币名称', '汇率', '操作']
  57. },
  58. StyleWidth() {
  59. return [298, 310, 400, 156]
  60. },
  61. tableData() {
  62. return CtableClass(this.getHttpResource, [['时间戳', 'createTime'], 'currencyName', 'rate', '操作'])
  63. },
  64. getHttpResource() {
  65. return this.$store.state.exchange.list.data.content.content
  66. },
  67. totalElements() {
  68. return this.$store.state.exchange.list.data.content.totalElements
  69. },
  70. controlArray() {
  71. return [['修改', 'updateItem']]
  72. },
  73. AlertTitle() {
  74. return this.IslookOrUpdate === 'add' ? '新增汇率' : (this.IslookOrUpdate === 'update' ? '修改信息' : '查看信息')
  75. }
  76. },
  77. methods: {
  78. // 分页调整数据
  79. handleCurrentChange (page) {
  80. this.currentPage = page
  81. this.$store.dispatch('loadexchangeInfo', {count: 10, page: this.currentPage})
  82. },
  83. updateItem(index) {
  84. this.chooseItem = {}
  85. this.IslookOrUpdate = 'add'
  86. if (index !== undefined) {
  87. this.IslookOrUpdate = 'update'
  88. this.chooseItem = clone(this.getHttpResource[index])
  89. }
  90. this.$refs.exchangeAlert.show()
  91. },
  92. closeAlert(tp, item) {
  93. if (tp === 'save') {
  94. let params = {
  95. RemittanceAccount: {
  96. currencyName: item.currencyName,
  97. rate: item.rate
  98. }
  99. }
  100. let url = '/facilitator/exchangeRate/persist'
  101. if (this.IslookOrUpdate === 'update') {
  102. params = {
  103. RemittanceAccount: item
  104. }
  105. }
  106. Vuehttp(params, url).then(res => {
  107. if (res.data.code !== 1) {
  108. this.$message.error(res.data.message)
  109. } else {
  110. this.$refs.exchangeAlert.hide()
  111. this.handleCurrentChange(1)
  112. }
  113. })
  114. } else {
  115. this.$refs.exchangeAlert.hide()
  116. }
  117. },
  118. clickTwo(index) {
  119. // this.IslookOrUpdate = 'look'
  120. // this.AlertTitle = '查看信息'
  121. // this.chooseItem = clone(this.getHttpResource[index])
  122. // this.$refs.exchangeAlert.show()
  123. }
  124. }
  125. }
  126. </script>
  127. <style scoped type="text/scss" lang="scss">
  128. </style>