Commit 9f22e139 authored by wanghuazhou's avatar wanghuazhou

refactor: 页面代码整理

parent 0422189d
<template>
<div>
<div class="remarks">{{ row.remarks || '' }}</div>
<div class="remarks">{{ row.remarks || $t('') }}</div>
<div><i>{{ row.updateAt }}</i> <b>{{ row.updateBy }}</b></div>
</div>
</template>
......@@ -8,13 +8,12 @@
<script>
import Vue from 'vue'
const props = {
row: Object,
}
export default Vue.extend({
props: {
row: {
type: Object,
required: true,
},
},
props,
})
</script>
......
......@@ -52,7 +52,7 @@
<el-col :span="11">
<div>
<i v-if="model.expiration && expires > 0" class="diff">{{ expires }}天后过期</i>
<i v-if="model.expiration && expires <= 0" class="diff expired">已过期{{ 0 - expires }}天</i>
<i v-if="model.expiration && expires < 0" class="diff expired">已过期{{ 0 - expires }}天</i>
</div>
</el-col>
</el-form-item>
......@@ -146,8 +146,10 @@ export default Vue.extend({
if (await this.$refs['form'].validate().catch(() => {})) {
if (this.update) {
await updateCurrencyRate(this.model.id, this.model)
} else {
await createCurrencyRate(this.model)
}
await createCurrencyRate(this.model)
this.$emit('update:model', this.model)
this.close()
}
......
......@@ -61,35 +61,19 @@ import Query from './query.vue'
import Audit from './audit.vue'
import Decimal from 'decimal.js'
const components = { FormDialog, LogsDialog, Query, Audit, }
export default Vue.extend({
components: {
FormDialog, LogsDialog, Query, Audit,
},
components,
data() {
return {
map: {
countries: {},
currencies: {},
},
dict: {
countries: [],
currencies: [],
},
form: {
rules: {},
},
map: { countries: {}, currencies: {}, },
dict: { countries: [], currencies: [], },
query: {
show: true,
loading: false,
params: {
page: 1,
rows: 10,
expiration: ['', ''],
},
result: {
list: [],
total: 0,
},
params: { page: 1, rows: 10, expiration: ['', ''], },
result: { list: [], total: 0, },
},
dialogs: {
form: { visible: false, update: false, data: {}, },
......@@ -101,7 +85,7 @@ export default Vue.extend({
async pagination() {
this.query.loading = true
try {
this.query.result = (await getCurrencyRatePage(this.query.params)).data
this.query.result = await getCurrencyRatePage(this.query.params).then(it => it.data)
} finally {
this.query.loading = false
}
......@@ -150,7 +134,7 @@ export default Vue.extend({
this.dict.currencies = await getCurrencyList().then(it => it.data)
this.map.countries = this.dict.countries.reduce((m, e) => (m[e.id] = e, m), {})
this.map.currencies = this.dict.currencies.reduce((m, e) => (m[e.id] = e, m), {})
this.pagination()
await this.pagination()
},
})
</script>
......
......@@ -41,18 +41,6 @@
</div>
</template>
</el-table-column>
<!-- <el-table-column :label="$t('修改前')" align="right" class-name="before">
<template v-slot="{ row }">
<div>{{ amount(row.sourceAmount1, row.targetAmount1) }}</div>
<div>1 : <i>{{ rate(row.sourceAmount1, row.targetAmount1) }}</i>, {{ row.sourceExpiration }}</div>
</template>
</el-table-column>
<el-table-column :label="$t('修改后')" align="right" class-name="after">
<template v-slot="{ row }">
<div>{{ amount(row.sourceAmount2, row.targetAmount2) }}</div>
<div>1 : <i>{{ rate(row.sourceAmount2, row.targetAmount2) }}</i>, {{ row.targetExpiration }}</div>
</template>
</el-table-column> -->
</el-table>
<pagination v-show="total > 0" :background="false" small layout="total,prev,pager,next,jumper" :total="total" :page.sync="page" :limit.sync="limit" @pagination="pagination"/>
</el-dialog>
......@@ -62,33 +50,25 @@
import { getCurrencyRateLogs } from '@/api/ecw/currencyRate'
import Decimal from 'decimal.js'
import Vue from 'vue'
import audit from './audit.vue'
import Audit from './audit.vue'
const components = {
Audit,
}
const props = {
id: Number,
visible: { type: Boolean, default: false, },
source: Object,
target: Object,
}
export default Vue.extend({
components: { audit },
props: {
visible: {
type: Boolean,
default: false,
},
id: Number,
source: {
},
target: {
},
},
model: {
prop: 'visible',
event: 'update',
},
components,
props,
model: { prop: 'visible', event: 'update', },
data() {
return {
loading: false,
page: 1,
limit: 10,
list: [],
total: 0,
}
return { loading: false, page: 1, limit: 10, list: [], total: 0, }
},
methods: {
close() {
......
......@@ -33,29 +33,16 @@
<script>
import Vue from 'vue'
const props = {
show: { type: Boolean, default: false, },
value: { type: Object, default: {}, },
countries: { type: Array, default: [], },
currencies: { type: Array, default: [], },
}
export default Vue.extend({
props: {
show: {
type: Boolean,
default: false,
},
value: {
type: Object,
default: {},
},
countries: {
type: Array,
default: [],
},
currencies: {
type: Array,
default: [],
},
},
model: {
prop: 'value',
event: 'update',
},
props,
model: { prop: 'value', event: 'update', },
data() {
return {
params: this.value,
......@@ -66,7 +53,6 @@ export default Vue.extend({
this.$emit('query', this.params)
},
clear() {
console.log('query', this.params)
this.$emit('update:value', this.params = {})
},
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment