提交 bf461fce 作者: ZhangLingKun

优化:结算问题修复

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