import { connect } from "umi"; import type { ConnectState } from "@/models/connect"; import { PageContainer } from "@ant-design/pro-layout"; import type { FormInstance } from "antd"; import { message } from "antd"; import { Button, Col, Descriptions, Row, Tooltip } from "antd"; import moment from 'moment' import { contractType } from "@/pages/contract/emun"; import session from "@/utils/session"; import ProTable from "@ant-design/pro-table"; import numeral from 'numeral' import { useImperativeHandle, useRef, useState } from "react"; import CorrectTable from "./correctTable"; import { handleGetPeriodSupplementList } from "../service"; import ProForm, { ProFormDigit, ProFormSelect, ProFormTextArea, ProFormUploadButton } from "@ant-design/pro-form"; import { handleGetAPPROVALROUTEDetail, handleGetProjectPeriodAccount } from "../../ShopExpenseDetail/service"; import ReviewProcess from "../../revenueConfirmation/components/ReviewProcess"; import { getMoney } from "@/services/options"; import { wrapTreeNode } from "@/utils/format"; import { handleGetBUSINESSAPPROVALDetail } from "@/pages/examine/monthSettlement/service"; import HistoricalProjects from "./HistoricalProjects"; type DetailProps = { parentRow: any dataRef: any // 可以通过这个拿到选中的数据 onShow: boolean // 组件是否显示 setIsFinishCalibration?: any onRef: any currentUser?: any readonly: boolean // 判断是否显示按钮和 精算表单 } const AfterSettlement = ({ parentRow, dataRef, onShow, setIsFinishCalibration, onRef, currentUser, readonly }: DetailProps) => { const SETTLEMENTMODESOBJ: any = session.get('SETTLEMENT_MODESObj') const settlementRef = useRef(); const HistoricalProjectsRef = useRef() // 表格数据 const [tableData, setTableData] = useState() // 表格的加载效果 const [tableLoading, setTableLoading] = useState(false) // 日结冲正信息表的表格数据 const [correctTableData, setCorrectTableData] = useState() // 校验表单的加载效果 const [proFormLoading, setProFormLoading] = useState(false) // 附件 const [fileList, setFileList] = useState() // 当前是否为指定重新申请 const [currentREJECTTYPE, setCurrentREJECT_TYPE] = useState(false) // 指定的下一个状态 const [nextState, setNextState] = useState() const columns: any = [ { title:
期限
, dataIndex: 'PeriodDesc', align: 'left', width: 300, fixed: 'left', hideInSearch: true, render: (_, record) => { return record?.PeriodDesc === '合计' ? 合计 : record?.level === 1 ? {`${record?.PeriodDesc}`} : <> {`${record?.PeriodDesc}`} { record?.EarlySettlement ? 【提前结算】 : '' } } }, { title: '租金信息', dataIndex: '', hideInSearch: true, children: [ { title:
保底/固定租金
, dataIndex: 'MinturnOver', valueType: 'digit', align: 'right', width: 130, hideInSearch: true, }, { title:
提成比率
, dataIndex: 'GuaranteeRatio', hideInSearch: true, align: 'right', width: 100, render: (_, record) => { return record?.GuaranteeRatio ? `${record?.GuaranteeRatio}%` : '' } } ] }, { title: '营业额', dataIndex: '', hideInSearch: true, children: [ { title:
现金
, dataIndex: 'CashAmount', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, }, { title:
微支付
, dataIndex: 'MobilePayAmount', valueType: 'digit', align: 'right', width: 100, hideInSearch: true, }, { title:
小计
, dataIndex: 'RevenueAmount', valueType: 'digit', align: 'right', width: 150, hideInSearch: true, render: (_, record) => { return {record?.RevenueAmount ? `${numeral(getMoney(record?.RevenueAmount)).format('0,0.00')}${record?.addRevenueMoney ? `(${record?.addRevenueMoney > 0 ? '+' : record?.addRevenueMoney < 0 ? '' : ''}${record?.addRevenueMoney})` : '' }` : '0'} } } ] }, { title:
业主收款
, dataIndex: 'RoyaltyAmount', valueType: 'digit', width: 100, align: 'right', hideInSearch: true, }, { title: '应收费用', dataIndex: '', hideInSearch: true, children: [ { title:
合计
, dataIndex: 'ReceivableAmount', valueType: 'digit', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { const str: string = `租金(${numeral(record?.GuaranteeFee).format('0.00')}) + 物业费(${numeral(record?.PropertyFee).format('0.00')}) + 房租(${numeral(record?.HouseRent).format('0.00')}) + 罚款(${numeral(record?.BreachPenalty).format('0.00')}) + 电费(${numeral(record?.ElectricityCharge).format('0.00')}) + 水费(${numeral(record?.WaterCharge).format('0.00')}) + 其他(${numeral(record?.OtherFee).format('0.00')})` return record?.ReceivableAmount ? {numeral(record?.ReceivableAmount).format('0,0.00')} : '' } }, { title:
租金
, dataIndex: 'GuaranteeFee', valueType: 'digit', align: 'right', width: 120, hideInSearch: true, render: (_, record) => { const str: string = `租金(${numeral(record?.MinturnOver).format('0.00')}) ${record?.MinturnOver > (record?.RevenueAmount * (record?.GuaranteeRatio) / 100) ? '>' : '<'} 营业额(${record?.RevenueAmount || 0}) * 提成比率(${record?.GuaranteeRatio ? `${record?.GuaranteeRatio}%` : ''})` return record?.GuaranteeFee ? {numeral(record?.GuaranteeFee).format('0,0.00')} : '' } }, { title:
物业费
, dataIndex: 'PropertyFee', valueType: 'digit', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { return record?.PropertyFee ? numeral(record?.PropertyFee).format('0,0.00') : record?.PropertyFee === 0 ? 0 : '' } }, { title:
房租
, dataIndex: 'HouseRent', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, }, { title:
罚款
, dataIndex: 'BreachPenalty', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, }, { title:
电费
, dataIndex: 'ElectricityCharge', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, render: (_, record) => { return record?.ElectricityCharge ? numeral(record?.ElectricityCharge).format('0,0.00') : record?.ElectricityCharge === 0 ? 0 : '' } }, { title:
水费
, dataIndex: 'WaterCharge', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, render: (_, record) => { return record?.WaterCharge ? numeral(record?.WaterCharge).format('0,0.00') : record?.WaterCharge === 0 ? 0 : '' } }, { title:
其他
, dataIndex: 'OtherFee', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, } ] }, { title: '已缴费用', dataIndex: '', align: 'center', hideInSearch: true, children: [ { title:
合计
, dataIndex: 'PaidFee', valueType: 'digit', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { const str: string = `水费(${numeral(record?.SHOPEXPENSE_AMOUNT_1000).format('0.00')}) + 电费(${numeral(record?.SHOPEXPENSE_AMOUNT_2000).format('0.00')}) + 房租(${numeral(record?.SHOPEXPENSE_AMOUNT_3000).format('0.00')}) + 物业费(${numeral(record?.SHOPEXPENSE_AMOUNT_5000).format('0.00')})` return record?.PaidFee ? {numeral(record?.PaidFee).format('0,0.00')} : '' } }, { title:
水费
, dataIndex: 'SHOPEXPENSE_AMOUNT_1000', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, render: (_, record) => { return record?.SHOPEXPENSE_AMOUNT_1000 ? numeral(record?.SHOPEXPENSE_AMOUNT_1000).format('0,0.00') : record?.SHOPEXPENSE_AMOUNT_1000 === 0 ? 0 : '' } }, { title:
电费
, dataIndex: 'SHOPEXPENSE_AMOUNT_2000', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, render: (_, record) => { return record?.SHOPEXPENSE_AMOUNT_2000 ? numeral(record?.SHOPEXPENSE_AMOUNT_2000).format('0,0.00') : record?.SHOPEXPENSE_AMOUNT_2000 === 0 ? 0 : '' } }, { title:
房租
, dataIndex: 'SHOPEXPENSE_AMOUNT_3000', valueType: 'digit', align: 'right', width: 80, hideInSearch: true, }, { title:
物业费
, dataIndex: 'SHOPEXPENSE_AMOUNT_5000', valueType: 'digit', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { return record?.SHOPEXPENSE_AMOUNT_5000 ? numeral(record?.SHOPEXPENSE_AMOUNT_5000).format('0,0.00') : record?.SHOPEXPENSE_AMOUNT_5000 === 0 ? 0 : '' } } ] }, { title:
退补款
, dataIndex: 'RefundSupplement', valueType: 'digit', align: 'right', fixed: 'right', width: 100, hideInSearch: true, render: (_, record) => { const str: string = `业主收款(${record?.RoyaltyAmount || 0}) - 应收费用(${record?.ReceivableAmount || 0}) + 已缴费用(${record?.PaidFee || 0})` return record?.RefundSupplement ? {numeral(record?.RefundSupplement).format('0,0.00')} : '' } }, ] const descirption = () => { return <> {parentRow?.STARTDATE ? moment(parentRow?.STARTDATE).format('YYYY-MM-DD') : ''} {parentRow?.ENDDATE ? moment(parentRow?.ENDDATE).format('YYYY-MM-DD') : ''} {parentRow?.MERCHANTS_NAME} {parentRow?.BUSINESS_TYPE ? contractType[parentRow?.BUSINESS_TYPE] : '-'} {parentRow?.SETTLEMENT_MODES ? SETTLEMENTMODESOBJ[parentRow?.SETTLEMENT_MODES] : '-'} {/* {} */} {parentRow?.SERVERPARTSHOP_NAME} {/* */} {/* */} } // 重新校准 const handleRecalibrate = (money?: any) => { if (tableData && tableData.length > 0) { // 避免重复添加重新精算的数据 把原本重新精算的数据 先给筛选掉 const newReqList: any = [] tableData.forEach((item: any) => { if (item.PeriodDesc !== '精算数据' && item.PeriodDesc !== '合计') { newReqList.push(item) } if (item.PeriodDesc === '合计' && item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { newReqList.push(subItem) }) } }) console.log('tableData', tableData); // 最近的一条数据 const newObj: any = JSON.parse(JSON.stringify(newReqList[newReqList.length - 1])) // 重新校准点击拿到的值 const res = settlementRef.current?.getFieldsValue() newObj.RevenueAmount += (res?.CORRECT_AMOUNT || money || 0) newObj.addRevenueMoney = (res?.CORRECT_AMOUNT || money || 0) let isBig: boolean = false // 判断现在新的小计乘以提升比率 是否大于租金 if ((newObj.RevenueAmount * (newObj.GuaranteeRatio / 100)) > newObj.GuaranteeFee) { isBig = true } // 如果新小计大于租金 那么租金就变成小计乘以比率 反之就是原本的值 newObj.GuaranteeFee = isBig ? getMoney(newObj.RevenueAmount * (newObj.GuaranteeRatio / 100)) : newObj.GuaranteeFee if (isBig) { // 算出合计 newObj.ReceivableAmount = newObj.GuaranteeFee + newObj.PropertyFee + newObj.HouseRent + newObj.BreachPenalty + newObj.ElectricityCharge + newObj.WaterCharge + newObj.OtherFee // 算出退补款 newObj.RefundSupplement = newObj.RoyaltyAmount - newObj.ReceivableAmount + newObj?.PaidFee } const list = JSON.parse(JSON.stringify(newReqList)) newObj.PeriodDesc = '精算数据' newObj.children = null // 根据新要求 冲正了多少钱应该显示在第二条记录里面 即精算数据的上面一行 精算数据 直接显示结果既可 list.forEach((item: any, index: number) => { if (index === list.length - 1) { item.addRevenueMoney = newObj.addRevenueMoney } }) newObj.addRevenueMoney = null list.push(newObj) console.log('list', list); setTableData(list) } } useImperativeHandle(onRef, () => ({ settlementRef, tableData, fileList, nextState, HistoricalProjectsRef })); return (
<> <> {descirption()} <> { return `${record?.ShopRoyalty_Id}-${record?.PeriodIndexStr}-${record?.PeriodDesc}` }} columns={columns} bordered search={false} pagination={false} scroll={{ x: 'max-content' }} loading={tableLoading} request={async () => { setTableLoading(true) console.log('dataRef', dataRef); const res: any = dataRef.current?.YearExamineDetailTableRef?.current?.selectDetailList setTableData(res) console.log('res', res); // 拿最小的开始 最大的结束 let startTime: string = '' let endTime: string = '' let ShopRoyaltyIdStr: string = '' if (res && res.length > 0) { res.forEach((item: any, index: number) => { if (item.PeriodDesc !== '合计') { if (ShopRoyaltyIdStr) { ShopRoyaltyIdStr += `,${item.ShopRoyalty_Id}` } else { ShopRoyaltyIdStr = `${item.ShopRoyalty_Id}` } if (startTime) { if (new Date(moment(item.StartDate).format('YYYY-MM-DD')).getTime() < new Date(startTime).getTime()) { startTime = moment(item.StartDate).format('YYYY-MM-DD') } } else { startTime = moment(item.StartDate).format('YYYY-MM-DD') } if (endTime) { if (new Date(moment(item.EndDate).format('YYYY-MM-DD')).getTime() > new Date(endTime).getTime()) { endTime = moment(item.EndDate).format('YYYY-MM-DD') } } else { endTime = moment(item.EndDate).format('YYYY-MM-DD') } } else { if (item.children && item.children.length > 0) { item.children.forEach((subItem) => { if (ShopRoyaltyIdStr) { ShopRoyaltyIdStr += `,${subItem.ShopRoyalty_Id}` } else { ShopRoyaltyIdStr = `${subItem.ShopRoyalty_Id}` } if (startTime) { if (new Date(moment(subItem.StartDate).format('YYYY-MM-DD')).getTime() < new Date(startTime).getTime()) { startTime = moment(subItem.StartDate).format('YYYY-MM-DD') } } else { startTime = moment(subItem.StartDate).format('YYYY-MM-DD') } if (endTime) { if (new Date(moment(subItem.EndDate).format('YYYY-MM-DD')).getTime() > new Date(endTime).getTime()) { endTime = moment(subItem.EndDate).format('YYYY-MM-DD') } } else { endTime = moment(subItem.EndDate).format('YYYY-MM-DD') } }) } } }) } console.log('parentRow', parentRow); // 调新接口 拿数据 const newReq: any = { BusinessProjectId: parentRow?.BUSINESSPROJECT_ID, ShopRoyaltyId: ShopRoyaltyIdStr, ServerpartShopId: parentRow?.SERVERPARTSHOP_ID, StartDate: startTime, EndDate: endTime, } const newData = await handleGetPeriodSupplementList(newReq) console.log('newDatanewDatanewDatanewData', newData); setCorrectTableData(newData) if (!(parentRow?.APPLY_PROCCESS && parentRow?.BUSINESSAPPROVAL_ID)) { settlementRef.current?.setFieldsValue({ CORRECT_AMOUNT: newData && newData.length > 0 ? newData[0].CorrectAmount : '' }) } setTableLoading(false) // 如果是重新申请的话 再调用这个接口 if (parentRow?.APPLY_PROCCESS && parentRow?.BUSINESSAPPROVAL_ID) { const req: any = { BUSINESSPROJECT_ID: parentRow?.BUSINESSPROJECT_ID, SHOPROYALTY_ID: parentRow?.SHOPROYALTY_ID, BUSINESSAPPROVAL_ID: parentRow?.BUSINESSAPPROVAL_ID } const data = await handleGetProjectPeriodAccount(req) if (data.ProjectPeriodList && data.ProjectPeriodList.length > 0) { const list: any = wrapTreeNode(data.ProjectPeriodList) console.log('dskdjaskldjas', list); if (list && list.length > 0) { list.forEach((item: any) => { if (item.PeriodIndex > 0) { settlementRef.current?.setFieldsValue({ CORRECT_AMOUNT: item.CorrectAmount }) } }) } } } }} dataSource={tableData} /> {/* */} <> { tableLoading ? '' : } { readonly ? '' :
{ return [] } }} // loading={proFormLoading ? { // spinning: proFormLoading, // tip: '正在为您查询结算年度内,服务区管理员校验冲正数据...' // } : false} // request={() => { // setProFormLoading(true) // if (correctTableData && correctTableData.length > 0) { // const obj: any = correctTableData[0] // setProFormLoading(false) // return { CORRECT_AMOUNT: obj?.CorrectAmount || 0 } // } // setProFormLoading(false) // return {} // }} > { console.log('currentRow请选择审批人', parentRow); const req = { OperationType: 11, CurState: 1000, IsValid: 1, ShowApprovalUser: true, ServerpartIds: parentRow?.SERVERPART_ID || '', ShopIds: parentRow?.SERVERPARTSHOP_ID || '' } const data = await handleGetAPPROVALROUTEDetail(req) const detailReq: any = { BUSINESSAPPROVALId: parentRow?.BUSINESSAPPROVAL_ID } console.log('req', req); let detailData: any = [] if (parentRow?.BUSINESSAPPROVAL_ID) { detailData = await handleGetBUSINESSAPPROVALDetail(detailReq) } const list: any = [] if (detailData.REJECT_TYPE === 2) { const nowPersonList: any = detailData.approveList[detailData.approveList.length - 1] const list: any = [{ label: nowPersonList.REJECT_STAFF, value: `${nowPersonList.REJECT_STAFF}-${nowPersonList.REJECT_ID}` }] settlementRef.current?.setFieldsValue({ APPROVALSTAFF_ID: `${nowPersonList.REJECT_STAFF}-${nowPersonList.REJECT_ID}` }) setNextState(nowPersonList?.REJECT_TYPE) setCurrentREJECT_TYPE(true) return list } setCurrentREJECT_TYPE(false) setNextState(undefined) if (data.UserList && data.UserList.length > 0) { data.UserList.forEach((item: any) => { list.push({ label: item.USER_NAME, value: `${item.USER_NAME}-${item.USER_ID}` }) }) } if (list && list.length > 0 && list.length === 1) { settlementRef.current?.setFieldsValue({ APPROVALSTAFF_ID: list[0].value }) } if (currentUser?.ID === 2785) { list.push({ label: '严琅杰', value: `严琅杰-2785` }) } return list }} /> false, onChange: async (info: any) => { console.log('info', info); // setFileList(info.fileList) const { fileList: newFileList } = info; // 过滤出有效的图片文件 const validFileList = newFileList.filter(file => { if (file.type.startsWith('image/')) { return true; } message.error(`${file.name} 不是图片文件,已被移除.`); return false; }); // 更新文件列表 setFileList(validFileList); // console.log('parentRow', parentRow); // const formData = new FormData(); // info.fileList.forEach((item: any) => { // if (item.status !== "done") { // console.log('item', item); // formData.append('files[]', item.originFileObj); // formData.append('ImageName', item.name); // } // }) // formData.append('TableType', '1130'); // formData.append('TableId', ); } }} buttonProps={{ children: '上传年度结算单' }} />
} { readonly ? '' :
}
) } export default connect(({ user, }: ConnectState) => ({ currentUser: user.currentUser, }))(AfterSettlement);