exchange-rate.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="app-container">
  3. <div v-loading="loading" class="white-box">
  4. <el-table :data="conversionsList" stripe style="width: 100%;">
  5. <el-table-column prop="NAME" :label="$t('exchangeRateConfig.currencyType')" />
  6. <el-table-column prop="PRODUCT_RATE" :label="$t('exchangeRateConfig.ProductExchangeRate')" min-width="90px;" />
  7. <el-table-column prop="BONUSES_RATE" :label="$t('exchangeRateConfig.BonusExchangeRate')" min-width="90px;" />
  8. <!-- <el-table-column :label="$t('common.createdAt')" min-width="100px;">-->
  9. <!-- <template slot-scope="{row}">-->
  10. <!-- {{ row.CREATED_AT | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}-->
  11. <!-- </template>-->
  12. <!-- </el-table-column>-->
  13. <!-- <el-table-column :label="$t('common.updatedAt')" min-width="100px;">-->
  14. <!-- <template slot-scope="{row}">-->
  15. <!-- {{ row.UPDATED_AT | parseTime('{y}-{m}-{d} {h}:{i}:{s}') }}-->
  16. <!-- </template>-->
  17. <!-- </el-table-column>-->
  18. <el-table-column :label="$t('common.action')" min-width="100px;">
  19. <template slot-scope="scope">
  20. <el-button type="primary" size="mini" icon="el-icon-edit" plain @click="edit(scope.row)">{{ $t('common.edit') }}</el-button>
  21. </template>
  22. </el-table-column>
  23. </el-table>
  24. </div>
  25. <!-- 编辑 -->
  26. <el-dialog v-loading="editLoading" :title="$t('config.modifyExchangeRate')" :visible.sync="dialog" :width="screenWidth" style="margin-top: -80px">
  27. <el-form ref="editForm" :model="editForm" :label-position="labelPosition" label-width="130px" style="width: 100%; margin-top: -30px; margin-bottom: -15px;">
  28. <el-row :gutter="3">
  29. <el-col :xs="24" :sm="24" :lg="12">
  30. <el-input v-show="false" v-model="editForm.ID" size="small" type="text" />
  31. <el-form-item :label="$t('exchangeRateConfig.ProductExchangeRate')" prop="Product_Exchange_Rate" style="margin-bottom: 10px; width: 100%;">
  32. <el-input-number v-model.trim="editForm.product_rate" :precision="6" :min="0" size="small" type="text" style="min-width: 300px;" readonly />
  33. </el-form-item>
  34. <el-form-item :label="$t('exchangeRateConfig.BonusExchangeRate')" prop="Bonus_Exchange_Rate" style="margin-bottom: 10px; width: 100%;">
  35. <el-input-number v-model="editForm.bonuses_rate" :precision="6" :min="0" size="small" type="text" style="min-width: 300px;" />
  36. </el-form-item>
  37. <el-form-item :label="$t('config.refreshShopPrice')" style="min-width: 420px;" >
  38. <el-switch v-model="editForm.synchronize" /> <div class="synchronize break-word">( {{$t('config.refreshProductPricePrompt')}} )</div>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-form-item style="margin-bottom: 15px;">
  43. <el-button type="warning" size="mini" @click="dialog = false">{{ $t('table.cancel') }}</el-button>
  44. <el-button type="primary" size="mini" @click="editSubmit">{{ $t('table.confirm') }}</el-button>
  45. </el-form-item>
  46. </el-form>
  47. </el-dialog>
  48. </div>
  49. </template>
  50. <script>
  51. import {
  52. fetchCurrencyConversionsList, setCurrencyConversions, fetchCurrenciesList
  53. } from '@/api/config'
  54. import { getScreenWidth } from '@/utils'
  55. export default {
  56. name: 'Currencies',
  57. data() {
  58. return {
  59. form: {
  60. CONFIG_NAME: '',
  61. VALUE: 0,
  62. TITLE: ''
  63. },
  64. loading: true,
  65. submitButtonStat: false,
  66. synchronize: false,
  67. screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
  68. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  69. conversionsList: [],
  70. editLoading: false,
  71. editForm: {
  72. from_currency_id: '149',
  73. to_currency_id: '',
  74. product_rate: '',
  75. bonuses_rate: '',
  76. synchronize: false,
  77. },
  78. dialog: false,
  79. }
  80. },
  81. created() {
  82. this.fetchData()
  83. },
  84. methods: {
  85. fetchData() {
  86. this.loading = true
  87. fetchCurrencyConversionsList().then(response => {
  88. this.conversionsList = response
  89. setTimeout(() => {
  90. this.loading = false
  91. }, 0.5 * 1000)
  92. })
  93. },
  94. edit(data){
  95. this.editForm = {
  96. from_currency_id: '149',
  97. to_currency_id: data.ID,
  98. product_rate: data.PRODUCT_RATE,
  99. bonuses_rate: data.BONUSES_RATE,
  100. synchronize: false,
  101. }
  102. this.dialog = true
  103. },
  104. editSubmit(){
  105. setCurrencyConversions(this.editForm).then(response => {
  106. this.$message({
  107. message: response.data,
  108. type: 'success'
  109. })
  110. this.dialog = false
  111. this.fetchData()
  112. }).catch(error => {
  113. this.$message({
  114. message: error,
  115. type: 'warning'
  116. })
  117. })
  118. },
  119. onSubmit() {
  120. this.$confirm(this.$t('config.confirmToChangeExchangeRate'), this.$t('common.hint'), {
  121. confirmButtonText: this.$t('common.confirm'),
  122. cancelButtonText: this.$t('common.cancel'),
  123. type: 'warning'
  124. }).then(() => {
  125. this.submitButtonStat = true
  126. const param = this.form
  127. param.synchronize = this.synchronize
  128. updateExchangeRateConfig(param).then(response => {
  129. this.$message({
  130. message: response.data,
  131. type: 'success'
  132. })
  133. setTimeout(() => {
  134. this.submitButtonStat = false
  135. }, 0.5 * 1000)
  136. this.fetchData()
  137. }).catch(error => {
  138. this.$message({
  139. message: error,
  140. type: 'warning'
  141. })
  142. this.submitButtonStat = false
  143. this.fetchData()
  144. })
  145. }).catch(() => {
  146. this.submitButtonStat = false
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped>
  153. .app-main {
  154. padding: 15px;
  155. }
  156. .app-container {
  157. padding: 0;
  158. }
  159. .white-box {
  160. padding: 15px;
  161. }
  162. .form-page {
  163. width: 100%;
  164. }
  165. .synchronize{
  166. color: #F56C6C;
  167. }
  168. ::v-deep .el-form-item__label{
  169. word-wrap:break-word;
  170. word-break: break-word;
  171. overflow-wrap: break-word;
  172. }
  173. </style>