提交 bf461fce 作者: ZhangLingKun

优化:结算问题修复

上级 340ee2a5
import React, { useEffect, useState } from 'react';
import { Button, message, Table } from 'antd';
import { Button, message, Modal, Table } from 'antd';
import {
getOrderAmountDetailsType,
serviceOrderFormDetailsType,
......@@ -52,6 +52,8 @@ const OrderSettleView: React.FC<{ detail: DetailType; onRefresh: () => void }> =
settleAccountsProportion: 0,
subsidyFestival: 0,
trafficSubsidy: 0,
otherSubsidy: 0,
remark: undefined,
workDate: '合计',
},
];
......@@ -60,7 +62,7 @@ const OrderSettleView: React.FC<{ detail: DetailType; onRefresh: () => void }> =
// 使用 reduce () 函数计算每一列的总和
const data = keys.reduce((acc, key) => {
// 将字符串转换为数字并累加
const total = list.reduce((sum, row: any) => sum + (+row[key] ?? 0), 0);
const total = list.reduce((sum, row: any) => sum + (+row[key] || 0), 0);
// 返回累加器对象
return { ...acc, [key]: total };
}, {});
......@@ -72,6 +74,7 @@ const OrderSettleView: React.FC<{ detail: DetailType; onRefresh: () => void }> =
workDate: '合计',
id: new Date().getTime(),
settleAccountsProportion: undefined,
remark: undefined,
},
] as ListType;
};
......@@ -101,19 +104,25 @@ const OrderSettleView: React.FC<{ detail: DetailType; onRefresh: () => void }> =
// console.log('添加数据 --->', data);
};
// 提交数据
const handleSubmit = async () => {
const res = await OrderManageAPI.updateOrderAmountDetails(
tableData.slice(0, -1)?.map((i) => ({
...i,
requirementsInfoId: detail?.serviceOrderFormDetailsDTO?.id,
id: undefined,
})),
);
if (res && res.code === '200') {
message.success('操作成功');
await getTableData();
onRefresh();
}
const handleSubmit = () => {
Modal.confirm({
title: '提示',
content: '确认修改订单结算信息?',
onOk: async () => {
const res = await OrderManageAPI.updateOrderAmountDetails(
tableData.slice(0, -1)?.map((i) => ({
...i,
requirementsInfoId: detail?.serviceOrderFormDetailsDTO?.id,
id: undefined,
})),
);
if (res && res.code === '200') {
message.success('操作成功');
await getTableData();
onRefresh();
}
},
});
};
// 组件挂载
useEffect(() => {
......@@ -126,11 +135,13 @@ const OrderSettleView: React.FC<{ detail: DetailType; onRefresh: () => void }> =
{ title: '日期', dataIndex: 'workDate', align: 'center' },
{ title: '结算标准(元/天)', dataIndex: 'dailyWage', align: 'center' },
{ title: '节日补贴(元/天)', dataIndex: 'subsidyFestival', align: 'center' },
{ title: '出差租房补贴', dataIndex: 'rentalSubsidy', align: 'center' },
{ title: '交通补贴', dataIndex: 'trafficSubsidy', align: 'center' },
{ title: '高温补贴', dataIndex: 'highTemperatureSubsidy', align: 'center' },
{ title: '结算比例', dataIndex: 'settleAccountsProportion', align: 'center' },
{ title: '出差租房补贴(元)', dataIndex: 'rentalSubsidy', align: 'center' },
{ title: '交通补贴(元)', dataIndex: 'trafficSubsidy', align: 'center' },
{ title: '高温补贴(元)', dataIndex: 'highTemperatureSubsidy', align: 'center' },
{ title: '其他费用(元)', dataIndex: 'otherSubsidy', align: 'center' },
{ title: '结算比例(%)', dataIndex: 'settleAccountsProportion', align: 'center' },
{ title: '应结工资(元)', dataIndex: 'realWages', align: 'center' },
{ title: '备注', dataIndex: 'remark', align: 'center', ellipsis: true },
{
title: '操作',
dataIndex: 'action',
......
import React, { useEffect } from 'react';
import { DatePicker, Form, InputNumber, message, Modal, ModalProps } from 'antd';
import { DatePicker, Form, Input, InputNumber, message, Modal, ModalProps } from 'antd';
import { InterDataType } from '~/api/interface';
import { getOrderAmountDetailsType } from '~/api/interface/orderManageType';
import Big from 'big.js';
......@@ -29,12 +29,20 @@ const OrderSettleModal: React.FC<ModalProps & SelfProps> = ({
};
// 表单值改变事件
const handleChange = () => {
// 结算比例
const settleRatio = Big(editForm.getFieldValue('settleAccountsProportion') || 0);
// 结算标准
const dailyWage = Big(editForm.getFieldValue('dailyWage') || 0)
.mul(settleRatio)
.toNumber();
// 计算其他金额的总和
const money = Object.values({
...editForm.getFieldsValue(),
dailyWage: dailyWage,
realWages: 0,
workDate: 0,
settleAccountsProportion: 0,
remark: 0,
})?.reduce(
(a: number, b: any) =>
Big(a || 0)
......@@ -42,11 +50,7 @@ const OrderSettleModal: React.FC<ModalProps & SelfProps> = ({
.toNumber(),
0,
);
// 最后乘以结算比例
const total = Big(money || 0)
.mul(Big(editForm.getFieldValue('settleAccountsProportion') || 0))
.toNumber();
editForm?.setFieldValue('realWages', total);
editForm?.setFieldValue('realWages', money);
};
// 提交事件
const handleSubmit = async () => {
......@@ -186,6 +190,24 @@ const OrderSettleModal: React.FC<ModalProps & SelfProps> = ({
/>
</Form.Item>
<Form.Item
label='其他费用'
name='otherSubsidy'
rules={[
{ required: true, message: '请输入其他费用' },
// 最多两位小数
{ pattern: /^(\d+)?(?:\.\d{1,2})?$/, message: '最多两位小数' },
]}
initialValue={0}
>
<InputNumber
placeholder='请输入其他费用'
maxLength={25}
min={0}
max={999999999}
style={{ width: '100%' }}
/>
</Form.Item>
<Form.Item
label='结算比例'
name='settleAccountsProportion'
rules={[
......@@ -222,6 +244,9 @@ const OrderSettleModal: React.FC<ModalProps & SelfProps> = ({
disabled={true}
/>
</Form.Item>
<Form.Item label='备注' name='remark'>
<Input.TextArea placeholder={'请输入备注'} maxLength={50} showCount />
</Form.Item>
</Form>
</Modal>
);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论