<template>
|
<div class="app-container">
|
<!--工具栏-->
|
<div class="head-container">
|
<div v-if="crud.props.searchToggle">
|
<!-- 搜索 -->
|
<el-select v-model="query.unitCurrency" filterable clearable placeholder="币种" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
|
<el-option
|
v-for="item in dict[standardUnitCurrency]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
<rrOperation :crud="crud" />
|
</div>
|
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
<crudOperation :permission="permission" />
|
<!--表单组件-->
|
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
<el-form-item label="币种" prop="unitCurrency">
|
<el-select v-model="form.unitCurrency" filterable placeholder="请选择" style="width: 370px;">
|
<el-option
|
v-for="item in dict[standardUnitCurrency]"
|
:key="item.id"
|
:label="item.label"
|
:value="item.value"
|
/>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="汇率" prop="exchangeRate">
|
<money-input :key="random" v-model="form.exchangeRate" :width="370" />
|
<div class="prompt-text">例:选择币种:美元。1美元≈6.87人民币。汇率:6.87。</div>
|
</el-form-item>
|
<el-form-item label="备注">
|
<el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 370px;" />
|
</el-form-item>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
</div>
|
</el-dialog>
|
<!--表格渲染-->
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
<el-table-column type="selection" width="55" />
|
<el-table-column :show-overflow-tooltip="true" prop="unitCurrency" label="单价币种">
|
<template slot-scope="scope">
|
{{ dict.label[standardUnitCurrency][scope.row.unitCurrency] }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="exchangeRate" label="汇率">
|
<template slot-scope="scope">
|
{{ crud.toMoney(scope.row.exchangeRate) }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" label="公式">
|
<template slot-scope="scope">
|
{{ crud.toMoney(1) }}人民币 ≈ {{ crud.toMoney(scope.row.exchangeRate) }}{{ dict.label[standardUnitCurrency][scope.row.unitCurrency] }}
|
</template>
|
</el-table-column>
|
<el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
|
<el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" />
|
<el-table-column v-if="checkPer(['admin','sysExchangeRate:edit','sysExchangeRate:del'])" label="操作" width="150px" align="center">
|
<template slot-scope="scope">
|
<udOperation
|
:data="scope.row"
|
:permission="permission"
|
/>
|
</template>
|
</el-table-column>
|
</el-table>
|
<!--分页组件-->
|
<pagination />
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import crudSysExchangeRate from '@/api/system/exchangeRate'
|
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
import rrOperation from '@crud/RR.operation'
|
import crudOperation from '@crud/CRUD.operation'
|
import udOperation from '@crud/UD.operation'
|
import pagination from '@crud/Pagination'
|
import constant from '../../../utils/constant'
|
import moneyInput from '../../assembly/moneyInput/index.vue'
|
|
const defaultForm = { id: null, unitCurrency: null, exchangeRate: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
|
export default {
|
name: 'SysExchangeRate',
|
components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
dicts: [constant.STANDARD_UNIT_CURRENCY],
|
cruds() {
|
return CRUD({ title: '汇率管理', url: 'api/sysExchangeRate', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysExchangeRate }})
|
},
|
data() {
|
// 汇率(千万内)验证
|
var rateValidate = (rule, value, callback) => {
|
if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) {
|
callback(new Error('请输入 一千万 以内的正整数或两位小数'))
|
} else {
|
callback()
|
}
|
}
|
return {
|
permission: {
|
add: ['admin', 'sysExchangeRate:add'],
|
edit: ['admin', 'sysExchangeRate:edit'],
|
del: ['admin', 'sysExchangeRate:del'],
|
download: ['admin', 'sysExchangeRate:download']
|
},
|
rules: {
|
unitCurrency: [
|
{ required: true, message: '币种不能为空', trigger: 'change' }
|
],
|
exchangeRate: [
|
{ required: true, message: '汇率不能为空', trigger: 'blur' },
|
{ validator: rateValidate, trigger: 'blur' }
|
]
|
},
|
queryTypeOptions: [
|
{ key: 'unitCurrency', display_name: '币种' }
|
],
|
// 字典:标准单价币种
|
standardUnitCurrency: constant.STANDARD_UNIT_CURRENCY,
|
// 随机数
|
random: 0
|
}
|
},
|
methods: {
|
// 钩子:在获取表格数据之前执行,false 则代表不获取数据
|
[CRUD.HOOK.beforeRefresh]() {
|
return true
|
},
|
// 钩子: 开始 "新建/编辑" - 之前
|
[CRUD.HOOK.beforeToCU]() {
|
// 随机数
|
this.random = Math.random()
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.prompt-text {
|
font-size: 10px;
|
}
|
</style>
|