|
|
@ -1,12 +1,13 @@ |
|
|
<script setup> |
|
|
<script setup> |
|
|
import { onMounted, reactive, ref } from 'vue' |
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
|
|
|
|
|
import {onMounted, reactive, ref} from 'vue' |
|
|
|
|
|
import {ElMessage, ElMessageBox} from 'element-plus' |
|
|
import request from '@/util/http' |
|
|
import request from '@/util/http' |
|
|
import { useAdminStore } from "@/store/index.js"; |
|
|
|
|
|
import { storeToRefs } from "pinia"; |
|
|
|
|
|
import { permissionMapping, hasMenuPermission } from "@/utils/menuTreePermission.js" |
|
|
|
|
|
|
|
|
import {useAdminStore} from "@/store/index.js"; |
|
|
|
|
|
import {storeToRefs} from "pinia"; |
|
|
|
|
|
import {permissionMapping, hasMenuPermission} from "@/utils/menuTreePermission.js" |
|
|
|
|
|
|
|
|
const adminStore = useAdminStore() |
|
|
const adminStore = useAdminStore() |
|
|
const { adminData, menuTree } = storeToRefs(adminStore) |
|
|
|
|
|
|
|
|
const {adminData, menuTree} = storeToRefs(adminStore) |
|
|
const regeEdit = ref(false) |
|
|
const regeEdit = ref(false) |
|
|
const editFormRef = ref(null) |
|
|
const editFormRef = ref(null) |
|
|
const tableData = ref([]) |
|
|
const tableData = ref([]) |
|
|
@ -74,7 +75,7 @@ const checkFreeGoldRadio = function (rule, value, callback) { |
|
|
} |
|
|
} |
|
|
// 定义表单验证规则 |
|
|
// 定义表单验证规则 |
|
|
const rules = reactive({ |
|
|
const rules = reactive({ |
|
|
num: [{ validator: checkFreeGoldRadio, trigger: 'blur' }], |
|
|
|
|
|
|
|
|
num: [{validator: checkFreeGoldRadio, trigger: 'blur'}], |
|
|
}) |
|
|
}) |
|
|
// 表单大小 |
|
|
// 表单大小 |
|
|
const formSize = ref('default') |
|
|
const formSize = ref('default') |
|
|
@ -109,7 +110,7 @@ const getEditData = async function (row) { |
|
|
console.log('搜索参数', getObj.value) |
|
|
console.log('搜索参数', getObj.value) |
|
|
const result = await request({ |
|
|
const result = await request({ |
|
|
url: '/rate/selectById', |
|
|
url: '/rate/selectById', |
|
|
data: { id: row.id } |
|
|
|
|
|
|
|
|
data: {id: row.id} |
|
|
}) |
|
|
}) |
|
|
console.log('根据id查 请求成功', result) |
|
|
console.log('根据id查 请求成功', result) |
|
|
rateEdit.value.id = row.id |
|
|
rateEdit.value.id = row.id |
|
|
@ -133,24 +134,24 @@ const initPermissions = () => { |
|
|
}; |
|
|
}; |
|
|
// 编辑汇率 |
|
|
// 编辑汇率 |
|
|
const editRate = async function () { |
|
|
const editRate = async function () { |
|
|
if(!hasrateEdit){ |
|
|
|
|
|
ElMessage.error('暂无权限') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
// 提交前验证 汇率是否为数字 |
|
|
|
|
|
rateEdit.value.num = parseFloat(rateEdit.value.num); |
|
|
|
|
|
try { |
|
|
|
|
|
console.log('搜索参数', rateEdit.value) |
|
|
|
|
|
const result = await request({ |
|
|
|
|
|
url: '/rate/update', |
|
|
|
|
|
data: rateEdit.value |
|
|
|
|
|
}) |
|
|
|
|
|
console.log('请求成功', result) |
|
|
|
|
|
await getAllRate() |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log('请求失败', error) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasrateEdit) { |
|
|
|
|
|
ElMessage.error('暂无权限') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
// 提交前验证 汇率是否为数字 |
|
|
|
|
|
rateEdit.value.num = parseFloat(rateEdit.value.num); |
|
|
|
|
|
try { |
|
|
|
|
|
console.log('搜索参数', rateEdit.value) |
|
|
|
|
|
const result = await request({ |
|
|
|
|
|
url: '/rate/update', |
|
|
|
|
|
data: rateEdit.value |
|
|
|
|
|
}) |
|
|
|
|
|
console.log('请求成功', result) |
|
|
|
|
|
await getAllRate() |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log('请求失败', error) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
// 添加前验证 |
|
|
// 添加前验证 |
|
|
const edit = () => { |
|
|
const edit = () => { |
|
|
@ -181,6 +182,7 @@ const handleEditDialogClose = () => { |
|
|
getAllRate() |
|
|
getAllRate() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 日期格式化 |
|
|
// 日期格式化 |
|
|
function formatDate(value) { |
|
|
function formatDate(value) { |
|
|
if (!value) return '' |
|
|
if (!value) return '' |
|
|
@ -193,6 +195,7 @@ function formatDate(value) { |
|
|
const seconds = date.getSeconds().toString().padStart(2, '0') |
|
|
const seconds = date.getSeconds().toString().padStart(2, '0') |
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` |
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 输入框过滤 |
|
|
// 输入框过滤 |
|
|
function handleInput(value) { |
|
|
function handleInput(value) { |
|
|
// 检查是否使用了中文句号 |
|
|
// 检查是否使用了中文句号 |
|
|
@ -220,10 +223,10 @@ function handleInput(value) { |
|
|
ElMessage.info('整数部分最多允许六位') |
|
|
ElMessage.info('整数部分最多允许六位') |
|
|
} |
|
|
} |
|
|
// 限制小数部分最多两位 |
|
|
// 限制小数部分最多两位 |
|
|
if (parts[1].length > 2) { |
|
|
|
|
|
parts[1] = parts[1].slice(0, 2) |
|
|
|
|
|
|
|
|
if (parts[1].length > 7) { |
|
|
|
|
|
parts[1] = parts[1].slice(0, 7) |
|
|
value = parts[0] + '.' + parts[1] |
|
|
value = parts[0] + '.' + parts[1] |
|
|
ElMessage.info('最多允许两位小数') |
|
|
|
|
|
|
|
|
ElMessage.info('最多允许七位小数') |
|
|
} else { |
|
|
} else { |
|
|
value = parts[0] + '.' + parts[1] |
|
|
value = parts[0] + '.' + parts[1] |
|
|
} |
|
|
} |
|
|
@ -245,6 +248,7 @@ function handleInput(value) { |
|
|
|
|
|
|
|
|
return value |
|
|
return value |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
onMounted(async function () { |
|
|
onMounted(async function () { |
|
|
initPermissions() |
|
|
initPermissions() |
|
|
await getAllRate() |
|
|
await getAllRate() |
|
|
@ -257,11 +261,11 @@ onMounted(async function () { |
|
|
<el-table-column type="index" label="序号" width="100px" fixed="left"> |
|
|
<el-table-column type="index" label="序号" width="100px" fixed="left"> |
|
|
<template #default="scope"> |
|
|
<template #default="scope"> |
|
|
<span>{{ |
|
|
<span>{{ |
|
|
scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize |
|
|
|
|
|
}}</span> |
|
|
|
|
|
|
|
|
scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize |
|
|
|
|
|
}}</span> |
|
|
</template> |
|
|
</template> |
|
|
</el-table-column> |
|
|
</el-table-column> |
|
|
<el-table-column prop="rateName" label="货币名称" :span="2" /> |
|
|
|
|
|
|
|
|
<el-table-column prop="rateName" label="货币名称" :span="2"/> |
|
|
<el-table-column prop="num" label="汇率" :span="2"> |
|
|
<el-table-column prop="num" label="汇率" :span="2"> |
|
|
<template #default="scope"> |
|
|
<template #default="scope"> |
|
|
<p> |
|
|
<p> |
|
|
@ -289,22 +293,22 @@ onMounted(async function () { |
|
|
<!-- 分页 --> |
|
|
<!-- 分页 --> |
|
|
<div class="pagination"> |
|
|
<div class="pagination"> |
|
|
<el-pagination background :page-size="getObj.pageSize" :page-sizes="[5, 10, 20, 50, 100]" |
|
|
<el-pagination background :page-size="getObj.pageSize" :page-sizes="[5, 10, 20, 50, 100]" |
|
|
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handlePageSizeChange" |
|
|
|
|
|
@current-change="handleCurrentChange"></el-pagination> |
|
|
|
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handlePageSizeChange" |
|
|
|
|
|
@current-change="handleCurrentChange"></el-pagination> |
|
|
</div> |
|
|
</div> |
|
|
</el-card> |
|
|
</el-card> |
|
|
|
|
|
|
|
|
<!-- 这是编辑弹窗 --> |
|
|
<!-- 这是编辑弹窗 --> |
|
|
<el-dialog align-center v-model="regeEdit" title="修改汇率" width="30vw" :close-on-click-modal="false" |
|
|
<el-dialog align-center v-model="regeEdit" title="修改汇率" width="30vw" :close-on-click-modal="false" |
|
|
@close="handleEditDialogClose"> |
|
|
|
|
|
|
|
|
@close="handleEditDialogClose"> |
|
|
<el-form ref="editFormRef" :model="rateEdit" :rules="rules" label-width="auto" class="edit-form" :size="formSize" |
|
|
<el-form ref="editFormRef" :model="rateEdit" :rules="rules" label-width="auto" class="edit-form" :size="formSize" |
|
|
status-icon> |
|
|
|
|
|
|
|
|
status-icon> |
|
|
<el-form-item prop="rateName" label="货币名称:"> |
|
|
<el-form-item prop="rateName" label="货币名称:"> |
|
|
<el-input v-model="rateEdit.rateName" disabled style="width: 10vw" /> |
|
|
|
|
|
|
|
|
<el-input v-model="rateEdit.rateName" disabled style="width: 10vw"/> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
|
|
|
|
|
|
<el-form-item prop="num" label="汇率:"> |
|
|
<el-form-item prop="num" label="汇率:"> |
|
|
<el-input v-model="rateEdit.num" @update:modelValue="handleInput" style="width: 120px" /> |
|
|
|
|
|
|
|
|
<el-input v-model="rateEdit.num" @update:modelValue="handleInput" style="width: 120px"/> |
|
|
<span class="unit">:1</span> |
|
|
<span class="unit">:1</span> |
|
|
<span class="rate-tip"> |
|
|
<span class="rate-tip"> |
|
|
(提示:当前规则每 |
|
|
(提示:当前规则每 |
|
|
@ -326,10 +330,11 @@ onMounted(async function () { |
|
|
.card1 { |
|
|
.card1 { |
|
|
background: #F3FAFE; |
|
|
background: #F3FAFE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
:deep(.el-table__header-wrapper), |
|
|
:deep(.el-table__header-wrapper), |
|
|
:deep(.el-table__body-wrapper), |
|
|
:deep(.el-table__body-wrapper), |
|
|
:deep(.el-table__cell), |
|
|
:deep(.el-table__cell), |
|
|
/* 表格 */ |
|
|
|
|
|
|
|
|
/* 表格 */ |
|
|
:deep(.el-table__body td) { |
|
|
:deep(.el-table__body td) { |
|
|
background-color: #F3FAFE !important; |
|
|
background-color: #F3FAFE !important; |
|
|
} |
|
|
} |
|
|
|