优化代码

This commit is contained in:
orangebabu
2025-06-11 15:16:44 +08:00
parent 3d08a777b5
commit 012273d1c7
4 changed files with 82 additions and 23 deletions

View File

@ -2213,9 +2213,13 @@ const distData: DistData = {
value: "companyCosts"
},
{
label: "发工资",
label: "发工资",
value: "salaryPayable"
},
{
label: "实发工资",
value: "actualSalary"
},
{
label: "个人所得税",
value: "personalIncomeTax"
@ -2237,6 +2241,20 @@ const distData: DistData = {
value: "providentFundPaidByEnterprises"
}
],
"labor_fee_values": [
{
label: "劳务费总额",
value: "companyCosts"
},
{
label: "实发劳务费",
value: "actualSalary"
},
{
label: "代扣个人所得税",
value: "personalIncomeTax"
}
],
"salary_directions": [
{
label: "借",

View File

@ -8,7 +8,7 @@
<div class="queryForm">
<el-form :model="form" ref="formRef" :inline="true" label-width="68px">
<el-form-item label="凭证类型">
<el-select v-model="form.voucherType" style="width: 200px">
<el-select v-model="form.voucherType" style="width: 200px" @change="handleChangeType">
<el-option v-for="item in voucherTypes" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
@ -47,7 +47,7 @@
:show-overflow-tooltip="true">
<template #default="scope">
<el-select v-model="scope.row.selectedValue" style="width: 100%">
<el-option v-for="item in salary_values" :label="item.label" :value="item.value"/>
<el-option v-for="item in salaryValuesList" :label="item.label" :value="item.value"/>
</el-select>
</template>
</el-table-column>
@ -89,10 +89,17 @@ import modal from "@/plugins/modal";
const {t} = useI18n()
const {proxy} = getCurrentInstance()!;
const {salary_values, salary_directions}
= proxy?.useDict( "salary_values", "salary_directions");
const {salary_values, salary_directions, labor_fee_values}
= proxy?.useDict( "salary_values", "salary_directions", "labor_fee_values");
const emit: any = defineEmits(['dialogOfClosedMethods'])
const formRef = ref<InstanceType<typeof ElForm> | null>(null);
interface SalaryValueItem {
label: string
value: string | number
}
const salaryValuesList = ref<SalaryValueItem[]>([])
const props: any = defineProps({
title: {
type: String,
@ -185,35 +192,67 @@ function reset(): any {
form.value = {
voucherType: 0,
wordHead: '记'
};
}
const summaryTemplate = typeTextMap[form.value.voucherType] || "";
// 先根据 voucherType 给 salaryValuesList 赋值
if (form.value.voucherType === 0 || form.value.voucherType === 1) {
salaryValuesList.value = salary_values.value
} else {
salaryValuesList.value = labor_fee_values.value
}
dataList.value = [{
id: null,
summary: summaryTemplate,
direction: "1",
subjectCode: props.deptOptions?.[0]?.code || null,
selectedValue: salary_values.value[0].value,
}]
// 取第一个值
const selectedValue = salaryValuesList.value.length > 0 ? salaryValuesList.value[0].value : null
formRef?.value?.resetFields();
// 设置 dataList
const summaryTemplate = typeTextMap[form.value.voucherType] || ""
dataList.value = [
{
id: null,
summary: summaryTemplate,
direction: "1",
subjectCode: props.deptOptions?.[0]?.code || null,
selectedValue: selectedValue,
}
]
formRef?.value?.resetFields()
}
function addRecord() {
function addRecord() {
const summaryTemplate = typeTextMap[form.value.voucherType] || "";
// 根据 voucherType 先切换数据源
if (form.value.voucherType === 0 || form.value.voucherType === 1) {
salaryValuesList.value = salary_values.value;
} else {
salaryValuesList.value = labor_fee_values.value;
}
// 如果 salaryValuesList 为空,安全处理(防止访问 undefined
const selectedValue = salaryValuesList.value.length > 0 ? salaryValuesList.value[0].value : null;
// 新增一条记录
dataList.value.push({
id: null,
summary: summaryTemplate,
direction: "1",
subjectCode: props.deptOptions?.[0]?.code || null,
selectedValue: salary_values.value[0].value,
selectedValue: selectedValue,
});
}
function handleChangeType() {
// 根据 voucherType 先切换数据源
if (form.value.voucherType === 0 || form.value.voucherType === 1) {
salaryValuesList.value = salary_values.value;
} else {
salaryValuesList.value = labor_fee_values.value;
}
}
function dialogOfClosedMethods(val: any): any {
dialogStatus.value = false;

View File

@ -1,12 +1,12 @@
/*
* Copyright [2025] [JinBooks of copyright http://www.jinbooks.com]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -14,7 +14,7 @@
* limitations under the License.
*
*/
package com.jinbooks.enums;
@ -29,7 +29,8 @@ import lombok.Getter;
@Getter
public enum SalaryVoucherTemplateEnum {
COMPANY_COSTS("companyCosts", "公司成本"),
SALARY_PAYABLE("salaryPayable", "发工资"),
SALARY_PAYABLE("salaryPayable", "发工资"),
ACTUAL_SALARY("actualSalary", "实发工资"),
PERSONAL_INCOME_TAX("personalIncomeTax", "个人所得税"),
PERSONAL_WITHHOLDING_SOCIAL_SECURITY("personalWithholdingOfSocialSecurity", "个人代扣社保"),
PERSONAL_WITHHOLDING_PROVIDENT_FUND("personalWithholdingOfProvidentFund", "个人代扣公积金"),

View File

@ -173,7 +173,8 @@ public class EmployeeSalarySummaryServiceImpl extends ServiceImpl<EmployeeSalary
BigDecimal amount = switch (matchedEnum) {
case COMPANY_COSTS -> summary.getBusinessExpenditureCosts();
case SALARY_PAYABLE -> summary.getTotalAmount();
case SALARY_PAYABLE -> summary.getTotalAmount().add(summary.getTotalSocialInsurance()).add(summary.getProvidentFund()).add(summary.getPersonalTax());
case ACTUAL_SALARY -> summary.getTotalAmount();
case PERSONAL_INCOME_TAX -> summary.getPersonalTax();
case PERSONAL_WITHHOLDING_SOCIAL_SECURITY -> summary.getTotalSocialInsurance();
case PERSONAL_WITHHOLDING_PROVIDENT_FUND -> summary.getProvidentFund();