This commit is contained in:
2026-07-27 17:19:36 +08:00
parent e50d1b8fda
commit 1c7532e0de
132 changed files with 7066 additions and 1241 deletions

View File

@@ -90,7 +90,7 @@
</avue-crud>
<el-dialog title="币种汇率导入" append-to-body v-model="excelBox" width="555px">
<avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
<avue-form :option="excelOption" v-model="excelForm">
<template #excelTemplate>
<el-button type="primary" @click="handleTemplate">
点击下载<i class="el-icon-download el-icon--right"></i>
@@ -106,6 +106,8 @@ import { changeStatus, getDetail, getList, submit } from '@/api/base/currency';
import { exportBlob } from '@/api/common';
import { mapGetters } from 'vuex';
import { downloadXls } from '@/utils/util';
import { openImportDialog } from '@/utils/import-excel';
import { formatUpdateUserName } from '@/utils/audit';
import { getToken } from '@/utils/auth';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
@@ -131,7 +133,7 @@ export default {
};
const validateExchangeRate = (rule, value, callback) => {
if (value === undefined || value === null || value === '') {
callback(new Error('请输入汇率'));
callback();
} else if (Number(value) <= 0) {
callback(new Error('汇率必须大于0'));
} else if (!/^\d+(\.\d{1,6})?$/.test(String(value))) {
@@ -157,10 +159,13 @@ export default {
height: 'auto',
calcHeight: 32,
dialogWidth: 860,
labelPosition: 'top',
labelPosition: 'right',
tip: false,
searchShow: true,
searchMenuSpan: 6,
searchMenuSpan: 24,
searchIcon: true,
searchIndex: 8,
searchMenuPosition: 'right',
border: true,
index: true,
indexLabel: '序号',
@@ -195,7 +200,6 @@ export default {
label: '汇率',
prop: 'exchangeRate',
type: 'number',
search: true,
minWidth: 120,
precision: 6,
rules: [{ validator: validateExchangeRate, trigger: 'blur' }],
@@ -216,7 +220,6 @@ export default {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
searchRange: true,
search: true,
hide: true,
addDisplay: false,
editDisplay: false,
@@ -239,7 +242,6 @@ export default {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
searchRange: true,
search: true,
hide: true,
addDisplay: false,
editDisplay: false,
@@ -278,6 +280,14 @@ export default {
showWordLimit: true,
rules: [{ max: 200, message: '最多 200 个字符', trigger: 'blur' }],
},
{
label: '更新人',
prop: 'updateUserName',
formatter: formatUpdateUserName,
addDisplay: false,
editDisplay: false,
minWidth: 120,
},
{
label: '更新时间',
prop: 'updateTime',
@@ -296,7 +306,6 @@ export default {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
searchRange: true,
search: true,
hide: true,
addDisplay: false,
editDisplay: false,
@@ -344,7 +353,10 @@ export default {
},
methods: {
handleCodeChange(value) {
this.form.code = String(value || '').toUpperCase().replace(/[^A-Z]/g, '').slice(0, 3);
this.form.code = String(value || '')
.toUpperCase()
.replace(/[^A-Z]/g, '')
.slice(0, 3);
const matched = this.data.find(item => item.code === this.form.code);
if (matched) {
this.form.name = matched.name;
@@ -375,6 +387,7 @@ export default {
normalizeRow(row) {
const values = { ...row };
values.code = String(values.code || '').toUpperCase();
values.exchangeRate = values.exchangeRate === '' ? null : values.exchangeRate;
values.dataSource = values.dataSource || '手工录入';
values.status = values.status || 1;
return values;
@@ -384,11 +397,21 @@ export default {
this.$message.warning('备注不能超过 200 字');
return false;
}
if (Number(row.exchangeRate) <= 0) {
if (
row.exchangeRate !== undefined &&
row.exchangeRate !== null &&
row.exchangeRate !== '' &&
Number(row.exchangeRate) <= 0
) {
this.$message.warning('汇率必须大于0');
return false;
}
if (!/^\d+(\.\d{1,6})?$/.test(String(row.exchangeRate))) {
if (
row.exchangeRate !== undefined &&
row.exchangeRate !== null &&
row.exchangeRate !== '' &&
!/^\d+(\.\d{1,6})?$/.test(String(row.exchangeRate))
) {
this.$message.warning('汇率最多保留6位小数');
return false;
}
@@ -519,12 +542,7 @@ export default {
});
},
handleImport() {
this.excelBox = true;
},
uploadAfter(res, done) {
this.excelBox = false;
this.onLoad(this.page);
done();
openImportDialog(this, '币种汇率');
},
handleExport() {
this.$confirm('是否导出币种汇率数据?', '提示', {
@@ -550,7 +568,9 @@ export default {
};
},
handleTemplate() {
exportBlob(`/blade-system/currency/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
exportBlob(
`/blade-system/currency/export-template?${this.website.tokenHeader}=${getToken()}`
).then(res => {
downloadXls(res.data, '币种汇率模板.xlsx');
});
},