transportation-config.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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('transportationConfig.countryName')" />
  6. <el-table-column prop="currency.CODE" :label="$t('exchangeRateConfig.currencyType')" />
  7. <el-table-column prop="free_shipping" :label="$t('transportationConfig.freeShipping')" min-width="90px;" />
  8. <el-table-column prop="freight" :label="$t('transportationConfig.free')" min-width="90px;" />
  9. <el-table-column :label="$t('common.action')" min-width="100px;">
  10. <template slot-scope="scope">
  11. <el-button type="primary" size="mini" icon="el-icon-edit" plain @click="edit(scope.row)">{{ $t('common.edit') }}</el-button>
  12. </template>
  13. </el-table-column>
  14. </el-table>
  15. </div>
  16. <!-- 编辑 -->
  17. <el-dialog v-loading="editLoading" :title="$t('config.modifyShippingRates')" :visible.sync="dialog" :width="screenWidth" style="margin-top: -80px">
  18. <el-form ref="editForm" :model="editForm" :label-position="labelPosition" label-width="130px" style="width: 100%; margin-top: -30px; margin-bottom: -15px;">
  19. <el-row :gutter="3">
  20. <el-col :xs="24" :sm="24" :lg="12">
  21. <el-input v-show="false" v-model="editForm.ID" size="small" type="text" />
  22. <el-form-item :label="$t('transportationConfig.freeShipping')" prop="freeShipping" style="margin-bottom: 10px; width: 100%;">
  23. <el-input-number v-model.trim="editForm.freeShipping" :precision="0" :controls="false" :min="0" size="small" style="min-width: 300px;" />
  24. </el-form-item>
  25. <el-form-item :label="$t('transportationConfig.free')" prop="free" style="margin-bottom: 10px; width: 100%;">
  26. <el-input-number v-model.trim="editForm.freight" :precision="0" :controls="false" :min="0" size="small" style="min-width: 300px;" />
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-form-item style="margin-bottom: 15px;">
  31. <el-button type="warning" size="mini" @click="dialog = false">{{ $t('table.cancel') }}</el-button>
  32. <el-button type="primary" size="mini" @click="editSubmit">{{ $t('table.confirm') }}</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script>
  39. import {
  40. fetchTransportationList, setTransportation
  41. } from '@/api/config'
  42. import { getScreenWidth } from '@/utils'
  43. export default {
  44. name: 'transportation',
  45. data() {
  46. return {
  47. form: {
  48. CONFIG_NAME: '',
  49. VALUE: 0,
  50. TITLE: ''
  51. },
  52. loading: true,
  53. submitButtonStat: false,
  54. synchronize: false,
  55. screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
  56. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  57. conversionsList: [],
  58. editLoading: false,
  59. editForm: {
  60. countryId: "",
  61. freight: "",
  62. freeShipping: "",
  63. },
  64. dialog: false,
  65. }
  66. },
  67. created() {
  68. this.fetchData()
  69. },
  70. methods: {
  71. fetchData() {
  72. this.loading = true
  73. fetchTransportationList().then(response => {
  74. this.conversionsList = response
  75. setTimeout(() => {
  76. this.loading = false
  77. }, 0.5 * 1000)
  78. })
  79. },
  80. edit(data){
  81. this.editForm = {
  82. countryId: data.ID,
  83. freight: data.freight,
  84. freeShipping: data.free_shipping,
  85. }
  86. this.dialog = true
  87. },
  88. editSubmit(){
  89. setTransportation(this.editForm).then(response => {
  90. this.$message({
  91. message: response.data,
  92. type: 'success'
  93. })
  94. this.dialog = false
  95. this.fetchData()
  96. }).catch(error => {
  97. this.$message({
  98. message: error,
  99. type: 'warning'
  100. })
  101. })
  102. },
  103. }
  104. }
  105. </script>
  106. <style scoped>
  107. .app-main {
  108. padding: 15px;
  109. }
  110. .app-container {
  111. padding: 0;
  112. }
  113. .white-box {
  114. padding: 15px;
  115. }
  116. .form-page {
  117. width: 100%;
  118. }
  119. ::v-deep .el-input-number .el-input__inner {
  120. text-align: left;
  121. }
  122. </style>