添加修改最低工资功能
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import request from './request'
|
||||
|
||||
// 获取最低工资配置
|
||||
export function getMinimumWageConfig() {
|
||||
return request({
|
||||
url: '/config',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 更新最低工资配置
|
||||
export function updateMinimumWageConfig(data) {
|
||||
return request({
|
||||
url: '/config',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -141,6 +141,18 @@ const routerList = [
|
||||
icon: "Notebook",
|
||||
roles: [3] // 只有财务角色可以访问
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/config',
|
||||
name: 'MinimumWageConfig',
|
||||
component: () => import('../views/payroll/config/index.vue'),
|
||||
meta: {
|
||||
title: '当地最低工资查询',
|
||||
name: "当地最低工资查询",
|
||||
requiresAuth: true,
|
||||
icon: "Notebook",
|
||||
roles: [3] // 只有财务角色可以访问
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<template>
|
||||
<div class="minimum-wage-config">
|
||||
<el-card class="box-card">
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span class="title">当地最低工资配置</span>
|
||||
<el-tag type="info" size="small">仅财务人员可操作</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form :model="formData" :rules="rules" ref="formRef" label-width="120px" class="wage-form">
|
||||
<el-form-item label="最低工资标准" prop="minimumWage">
|
||||
<el-input-number v-model="formData.minimumWage" :min="0" :precision="2" :step="100"
|
||||
:controls-position="'right'" @change="handleWageChange" class="wage-input" />
|
||||
<span class="unit">元/月</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleSubmit" :loading="loading">
|
||||
保存修改
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getMinimumWageConfig, updateMinimumWageConfig } from '../../../api/payroll'
|
||||
|
||||
const formRef = ref(null)
|
||||
const loading = ref(false)
|
||||
|
||||
const formData = ref({
|
||||
minimumWage: 0
|
||||
})
|
||||
|
||||
const rules = {
|
||||
minimumWage: [
|
||||
{ required: true, message: '请输入最低工资标准', trigger: 'blur' },
|
||||
{ type: 'number', min: 0, message: '最低工资不能小于0', trigger: 'blur' }
|
||||
],
|
||||
effectiveDate: [
|
||||
{ required: true, message: '请选择生效日期', trigger: 'change' }
|
||||
]
|
||||
}
|
||||
|
||||
// 获取最低工资配置
|
||||
const fetchConfig = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
const response = await getMinimumWageConfig()
|
||||
// 处理后端返回的数据格式
|
||||
if (response && response.errcode === 0 && response.result) {
|
||||
formData.value = {
|
||||
minimumWage: Number(response.result.recordValue) || 0
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取最低工资配置失败')
|
||||
console.error('获取配置失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 提交修改
|
||||
const handleSubmit = async () => {
|
||||
if (!formRef.value) return
|
||||
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
loading.value = true
|
||||
|
||||
await ElMessageBox.confirm(
|
||||
'确定要修改最低工资标准吗?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
|
||||
// 只传递recordValue参数
|
||||
const submitData = {
|
||||
recordValue: formData.value.minimumWage.toString()
|
||||
}
|
||||
|
||||
await updateMinimumWageConfig(submitData)
|
||||
ElMessage.success('修改成功')
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
ElMessage.error('修改失败')
|
||||
console.error('修改失败:', error)
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 重置表单
|
||||
const resetForm = () => {
|
||||
if (!formRef.value) return
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
|
||||
// 工资变化时的处理
|
||||
const handleWageChange = (value) => {
|
||||
console.log('工资值变化:', value)
|
||||
}
|
||||
|
||||
// 禁用过去的日期
|
||||
const disablePastDates = (time) => {
|
||||
return time.getTime() < Date.now() - 8.64e7
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchConfig()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.minimum-wage-config {
|
||||
padding: 20px;
|
||||
background-color: #f5f7fa;
|
||||
min-height: calc(100vh - 120px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.minimum-wage-config {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.box-card {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
width: 100px !important;
|
||||
}
|
||||
|
||||
.wage-input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.card-header .title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
.wage-form {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.wage-input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.unit {
|
||||
margin-left: 10px;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.el-input-number .el-input__wrapper) {
|
||||
padding-right: 40px;
|
||||
}
|
||||
|
||||
:deep(.el-textarea__inner) {
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
:deep(.el-button) {
|
||||
padding: 12px 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.el-button + .el-button) {
|
||||
margin-left: 12px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user