| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <div class="app-container">
- <div v-loading="loading" class="white-box">
- <el-table :data="conversionsList" stripe style="width: 100%;">
- <el-table-column prop="NAME" :label="$t('transportationConfig.countryName')" />
- <el-table-column prop="currency.CODE" :label="$t('exchangeRateConfig.currencyType')" />
- <el-table-column prop="free_shipping" :label="$t('transportationConfig.freeShipping')" min-width="90px;" />
- <el-table-column prop="freight" :label="$t('transportationConfig.free')" min-width="90px;" />
- <el-table-column :label="$t('common.action')" min-width="100px;">
- <template slot-scope="scope">
- <el-button type="primary" size="mini" icon="el-icon-edit" plain @click="edit(scope.row)">{{ $t('common.edit') }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 编辑 -->
- <el-dialog v-loading="editLoading" :title="$t('config.modifyShippingRates')" :visible.sync="dialog" :width="screenWidth" style="margin-top: -80px">
- <el-form ref="editForm" :model="editForm" :label-position="labelPosition" label-width="130px" style="width: 100%; margin-top: -30px; margin-bottom: -15px;">
- <el-row :gutter="3">
- <el-col :xs="24" :sm="24" :lg="12">
- <el-input v-show="false" v-model="editForm.ID" size="small" type="text" />
- <el-form-item :label="$t('transportationConfig.freeShipping')" prop="freeShipping" style="margin-bottom: 10px; width: 100%;">
- <el-input-number v-model.trim="editForm.freeShipping" :precision="0" :controls="false" :min="0" size="small" style="min-width: 300px;" />
- </el-form-item>
- <el-form-item :label="$t('transportationConfig.free')" prop="free" style="margin-bottom: 10px; width: 100%;">
- <el-input-number v-model.trim="editForm.freight" :precision="0" :controls="false" :min="0" size="small" style="min-width: 300px;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-form-item style="margin-bottom: 15px;">
- <el-button type="warning" size="mini" @click="dialog = false">{{ $t('table.cancel') }}</el-button>
- <el-button type="primary" size="mini" @click="editSubmit">{{ $t('table.confirm') }}</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- fetchTransportationList, setTransportation
- } from '@/api/config'
- import { getScreenWidth } from '@/utils'
- export default {
- name: 'transportation',
- data() {
- return {
- form: {
- CONFIG_NAME: '',
- VALUE: 0,
- TITLE: ''
- },
- loading: true,
- submitButtonStat: false,
- synchronize: false,
- screenWidth: getScreenWidth() > 600 ? '500px' : getScreenWidth() + 'px',
- labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
- conversionsList: [],
- editLoading: false,
- editForm: {
- countryId: "",
- freight: "",
- freeShipping: "",
- },
- dialog: false,
- }
- },
- created() {
- this.fetchData()
- },
- methods: {
- fetchData() {
- this.loading = true
- fetchTransportationList().then(response => {
- this.conversionsList = response
- setTimeout(() => {
- this.loading = false
- }, 0.5 * 1000)
- })
- },
- edit(data){
- this.editForm = {
- countryId: data.ID,
- freight: data.freight,
- freeShipping: data.free_shipping,
- }
- this.dialog = true
- },
- editSubmit(){
- setTransportation(this.editForm).then(response => {
- this.$message({
- message: response.data,
- type: 'success'
- })
- this.dialog = false
- this.fetchData()
- }).catch(error => {
- this.$message({
- message: error,
- type: 'warning'
- })
- })
- },
- }
- }
- </script>
- <style scoped>
- .app-main {
- padding: 15px;
- }
- .app-container {
- padding: 0;
- }
- .white-box {
- padding: 15px;
- }
- .form-page {
- width: 100%;
- }
- ::v-deep .el-input-number .el-input__inner {
- text-align: left;
- }
- </style>
|