import React, { useRef } from "react"; import type { CurrentUser } from "umi"; import { connect } from "umi"; import numeral from 'numeral'; import type { ConnectState } from "@/models/connect"; import { useState } from "react"; import ProCard from "@ant-design/pro-card"; import { MenuFoldOutlined } from "@ant-design/icons"; import type { FormInstance } from "antd"; import { Modal, Popconfirm } from "antd"; import { Button, Drawer, message, Spin, Tree, Typography, Tooltip } from "antd"; import { getMoney, getServerpartTree, handleFormatNumber } from "@/services/options"; import useRequest from "@ahooksjs/use-request"; import ReactHTMLTableToExcel from "react-html-table-to-excel"; import moment from "moment"; import type { ActionType } from "@ant-design/pro-table"; import ProTable from "@ant-design/pro-table"; import { contractType } from "@/pages/contract/emun"; import session from "@/utils/session"; import { handleGetTableRevenueRecognition, handleGetTableRevenueRecognitionOtherData } from "@/pages/reports/ShopExpenseDetail/service"; import ProjectDetail from "@/pages/BussinessProject/detail"; import type { BusinessProjectModel } from "@/pages/BussinessProject/data"; import RevenueSecondList from "./components/RevenueSecondList"; import './style.less' import { getProjectDetail } from "@/pages/reports/accountTable/service"; import RevenueList from "@/pages/BussinessProject/components/RevenueList"; import CompareList from "@/pages/reports/revenueConfirmation/components/compareList"; import { handleGetProjectPeriodIncome, handleStorageMonthProjectAccount } from "./components/service"; import { wrapTreeNode } from "@/utils/format"; import { handleGetSERVERPARTCRTList } from "@/pages/basicManage/costing/service"; import { handleHighPrecision } from "@/utils/utils"; import LeftSelectTree from "../settlementAccount/component/leftSelectTree"; const revenueConfirmation: React.FC<{ currentUser: CurrentUser }> = (props) => { const { currentUser } = props const actionRef = useRef(); const formRef = useRef(); const downloadBtnRef = useRef() const { confirm } = Modal; const [reqDetailList, setReqDetailList] = useState(); // 合计项数据源 const [printOut, setPrintOut] = useState(); // 打印数据的内容 // 树相关的属性和方法 // 选择的服务区 const [selectedId, setSelectedId] = useState() // 选择的片区 const [selectedAreaId, setSelectAreaId] = useState() const [collapsible, setCollapsible] = useState(false) const [treeView, setTreeView] = useState() // 是否显示打印的表格 const [showExportTable, setShowExportTable] = useState(false) // 统计月份 const [searchMonth, setSearchMonth] = useState() const [exportDate, setExportDate] = useState() const [currentRow, setCurrentRow] = useState(undefined) // 选中的当前行 const [showDetail, setShowDetail] = useState(false) // 是否显示详情 const [showMonthDetail, setShowMonthDetail] = useState(false) // 是否显示详情 const [showMonthSecondDetail, setShowMonthSecondDetail] = useState(false) // 查询表格接口的时间 const [monthTime, setMonthTime] = useState() // 累计应确认收入 累计已确认收入 本月应确认 点击进入表格带上的时间 const [drawerSearchTime, setDrawerSearchTime] = useState() // 加载服务区树 const { loading: treeLoading, data: treeViews } = useRequest(async () => { const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) setTreeView(data) return data }) // 最近固化时间 const [otherData, setOtherData] = useState() const [columnsStateMap, setColumnsStateMap] = useState({ CurMonthRevenue: { show: false } }) // 导出的加载效果 const [showLoading, setShowLoading] = useState(false) const SETTLEMENT_MODESList = session.get('SETTLEMENT_MODESList') const SETTLEMENT_MODESObj = session.get('SETTLEMENT_MODESObj') const BUSINESSTYPEObj = session.get('BUSINESSTYPEObj') // 导出表格的数据 const [exportTableData, setExportTableData] = useState() // 累计营业额和自然日报表对比的抽屉数据 const [compareCurrent, setCompareCurrent] = useState() // 累计营业额和自然日报表的抽屉是否显示 const [showCompareDrawer, setShowCompareDrawer] = useState(false) // 搜索参数 const [searchParams, setSearchParams] = useState() // 拿到列表最初始的数据 用户固化数据 const [defaultTableData, setDefaultTableData] = useState() // 判断是否有不一样的税率 const [differentRate, setDifferentRate] = useState() const columns: any = [ // { // title:
{'序号'}
, // hideInSearch: true, // dataIndex: 'index', // width: 90, // fixed:'left', // align:'center', // render:(_,record)=>{ // return record.index?record.index:'' // } // }, { title:
{'门店名称'}
, dataIndex: 'Name', hideInSearch: true, width: 280, ellipsis: true, fixed: 'left', align: 'left', render: (_, record) => { return { if (record?.BUSINESSPROJECT_ID) { setCurrentRow(record) setShowDetail(true) } }}>{record.Name} } }, { title: '统计时间', dataIndex: 'search_months', valueType: 'date', initialValue: moment().subtract(1, 'months').format('YYYY-MM'), search: { transform: (value) => { return { MonthDate: moment(value).startOf("month").format('YYYY-MM'), }; }, }, hideInTable: true, fieldProps: { picker: "month", format: 'YYYY-MM', } }, { title: '结算模式', dataIndex: 'SettlementModes', hideInTable: true, hideInDescriptions: true, valueType: 'select', fieldProps: { mode: 'multiple' }, valueEnum: SETTLEMENT_MODESObj // request: ()=>{ // return SETTLEMENT_MODESList // } }, { title:
{'经营商户'}
, dataIndex: 'MERCHANTS_NAME', align: 'left', width: 200, ellipsis: true, }, { title: "历史项目", dataIndex: 'ShowHisProject', valueType: "select", valueEnum: { "true": "包含", "false": "不含", }, initialValue: 'false', hideInTable: true }, { title:
{'合同起止日期'}
, dataIndex: 'COMPACT_DATE', align: 'left', width: 200, hideInSearch: true, ellipsis: true, render: (_, record) => { return `${record?.COMPACT_STARTDATE ? moment(record?.COMPACT_STARTDATE).format('YYYY/MM/DD') : ''}${record?.COMPACT_ENDDATE ? `-${moment(record?.COMPACT_ENDDATE).format('YYYY/MM/DD')}` : ''}` } }, // { // title:
{'租金类别'}
, // dataIndex: 'BusinessType', // align:'left', // hideInSearch: true, // valueType: 'select', // width: 90, // valueEnum: BUSINESSTYPEObj // }, { title:
{'结算模式'}
, dataIndex: 'SettlementModes', align: 'left', hideInSearch: true, valueType: 'select', width: 90, valueEnum: SETTLEMENT_MODESObj }, { title:
切换日期
, dataIndex: 'SwitchDate', width: 110, align: 'center', hideInSearch: true, render: (_, record) => { return record?.SwitchDate ? moment(record?.SwitchDate).format('YYYY-MM-DD') : '-' } }, { title: '当年基础信息', dataIndex: '', hideInSearch: true, children: [ { title:
{'期数'}
, dataIndex: 'IndexStr', width: 90, align: 'left', hideInSearch: true, }, { title:
{'履约保证金'}
, dataIndex: 'SECURITYDEPOSIT', width: 90, align: 'right', hideInSearch: true, render: (_, record) => { return record?.SECURITYDEPOSIT ? numeral(record?.SECURITYDEPOSIT).format('0,0') : '-' } }, { title:
{'期限'}
, dataIndex: 'IndexDesc', align: 'left', width: 200, hideInSearch: true, }, { title:
{'装修期'}
, dataIndex: 'DecorateDesc', align: 'left', width: 180, hideInSearch: true, }, { title:
{'保底/固定租金'}
, dataIndex: 'RENTFEE', valueType: 'digit', align: 'right', width: 120, hideInSearch: true, }, { title:
{'提成比例'}
, dataIndex: 'GUARANTEERATIO', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { return record.GUARANTEERATIO ? `${record.GUARANTEERATIO}%` : '-' } }, ] }, { title: '保底租金应确认收入', dataIndex: '', hideInSearch: true, children: [ { title:
{'税率'}
, dataIndex: 'TaxRate', align: 'right', width: 100, hideInSearch: true, render: (_, record) => { const rightTaxRate = record?.errorTaxRate ? `${record?.errorTaxRate}%` : '' return
{ record?.isErrorTaxRate ? : '' } {record?.TaxRate ? `${record?.TaxRate}%` : '-'}
} }, { title:
{'期收入'}
, dataIndex: 'MINTURNOVER', align: 'right', hideInSearch: true, width: 110, valueType: 'digit', render: (_, record) => { const title: string = record?.RENTFEE ? `${record?.RENTFEE}(保底租金) /(1 ${record?.TaxRate ? `+${record?.TaxRate}%(税率)` : ''})` : '' return record?.MINTURNOVER ? {numeral(record?.MINTURNOVER).format('0,0.00')} : '-' } }, { title:
{'月收入'}
, dataIndex: 'MonthlyIncome', align: 'right', width: 100, valueType: 'digit', hideInSearch: true, render: (_, record) => { // const title: string = `${record?.MINTURNOVER}(期收入) /12/(1 ${record?.TaxRate?`+${record?.TaxRate}%(税率)`:''})` const title: string = `${record?.MINTURNOVER}(期收入) /12` return record?.MonthlyIncome ? {numeral(record?.MonthlyIncome).format('0,0.00')} : '-' } }, { title:
{'累计月数'}
, dataIndex: 'MonthlyCount', align: 'right', width: 100, hideInSearch: true, }, { title:
{'累计应确认收入(保底租金)'}
, dataIndex: 'MonthlyTotalIncome', align: 'right', width: 200, valueType: 'digit', hideInSearch: true, render: (_, record) => { // const title: string = `${record?.MonthlyIncome}(月收入) * ${record?.MonthlyCount}(累计月数)` const title: string = `${record?.Remark}` return record?.MonthlyTotalIncome && record?.BUSINESSPROJECT_ID ? {record?.MonthlyTotalIncome ? numeral(record?.MonthlyTotalIncome).format('0,0.00') : '-'} : record?.MonthlyTotalIncome ? numeral(record?.MonthlyTotalIncome).format('0,0.00') : '-' } }, ] }, { title: '浮动提成应确认收入', dataIndex: '', hideInSearch: true, children: [ { title:
{'当月分润营业额'}
, dataIndex: 'CurMonthRevenue', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, }, { title:
{'累计营业额'}
, dataIndex: 'REVENUEDAILY_AMOUNTTotal', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return record?.REVENUEDAILY_AMOUNTTotal ? record?.BUSINESSPROJECT_ID ? { const obj: any = { ...record, BUSINESSAPPROVAL_ID: record?.BusinessApprovalId } let [monthStartTime, monthEndTime] = record?.IndexDesc.split('-') monthStartTime = moment(monthStartTime).format('YYYY-MM-DD') monthEndTime = moment(monthEndTime).format('YYYY-MM-DD') const startDate: any = moment(monthTime).startOf('months').format('YYYY-MM-DD') const endDate: any = moment(monthTime).endOf('months').format('YYYY-MM-DD') obj.startTime = monthStartTime if (new Date(monthEndTime).getTime() < new Date(endDate).getTime()) { obj.endTime = monthEndTime } else { obj.endTime = endDate } console.log('obj', obj) setCompareCurrent(obj) setShowCompareDrawer(true) }}>{numeral(record?.REVENUEDAILY_AMOUNTTotal).format('0,0.00')} : {numeral(record?.REVENUEDAILY_AMOUNTTotal).format('0,0.00')} : '-' } }, { title:
{'自然日营收'}
, dataIndex: 'DailyRevenueAmount', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return numeral(record?.DailyRevenueAmount).format('0,0.00') } }, { title:
{'营收差额'}
, dataIndex: 'DiffRevenueAmount', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return numeral(record?.DiffRevenueAmount).format('0,0.00') } }, { title:
{'提成金额'}
, dataIndex: 'GUARANTEERATIOAMOUNT', width: 120, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { const title: string = `分润营业额(${record.REVENUEDAILY_AMOUNTTotal}) * 提成比例(${record.GUARANTEERATIO ? `${record.GUARANTEERATIO}%` : ''})` return record.GUARANTEERATIO ? {numeral(record?.GUARANTEERATIOAMOUNT).format('0,0.00')} : {numeral(record?.GUARANTEERATIOAMOUNT).format('0,0.00')} } }, { title:
{'提成收入'}
, dataIndex: 'GUARANTEERATIOINCOME', width: 120, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { const title: string = `提成金额(${record.GUARANTEERATIOAMOUNT}) / 税(1 + ${numeral(record.TaxRate / 100).format('0.00')})` return record.TaxRate ? {numeral(record?.GUARANTEERATIOINCOME).format('0,0.00')} : {numeral(record?.GUARANTEERATIOINCOME).format('0,0.00')} } }, ] }, { title: '本月确认收入', dataIndex: '', fixed: 'right', hideInSearch: true, children: [ { title:
{'累计应确认收入'}
, dataIndex: 'ROYALTYTHEORYMUST', width: 130, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { const title: string = record?.GUARANTEERATIOINCOME > record?.MonthlyTotalIncome ? `${record?.GUARANTEERATIOINCOME}(提成收入)>${record?.MonthlyTotalIncome}(累计应确认收入)=${record?.GUARANTEERATIOINCOME}(提成收入)` : `${record?.MonthlyTotalIncome}(累计应确认收入)>${record?.GUARANTEERATIOINCOME}(提成收入)=${record?.MonthlyTotalIncome}(累计应确认收入)` return record?.ROYALTYTHEORYMUST && record?.BUSINESSPROJECT_ID ? { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const obj: any = { ...record, endTime: moment(monthTime).endOf('month').format('YYYY-MM-DD'), startTime: '', ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).format('YYYYMM')) // setShowMonthDetail(true); setShowMonthSecondDetail(true); } }}>{record?.ROYALTYTHEORYMUST ? numeral(record?.ROYALTYTHEORYMUST).format('0,0.00') : '-'} : record?.ROYALTYTHEORYMUST ? numeral(record?.ROYALTYTHEORYMUST).format('0,0.00') : '-' } }, { title:
{'累计已确认收入'}
, dataIndex: 'ROYALTYTHEORYOK', width: 130, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { return { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const nowDay: any = moment(monthTime).endOf('month').format('YYYY-MM-DD') const obj: any = { ...record, endTime: moment(nowDay).subtract(1, 'months').endOf('month').format('YYYY-MM-DD'), startTime: '', ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).subtract(1, 'months').format('YYYYMM')) setShowMonthSecondDetail(true); } }}>{record?.ROYALTYTHEORYOK ? numeral(record?.ROYALTYTHEORYOK).format('0,0.00') : '-'} } }, { title:
{'本月应确认'}
, dataIndex: 'ROYALTYTHEORYMONTHLYMUST', width: 110, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { const title: string = `累计应确认收入(${record.ROYALTYTHEORYMUST}) - 累计已确认收入(${numeral(record?.ROYALTYTHEORYOK).format('0.00')})` return { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const obj: any = { ...record, endTime: moment(monthTime).endOf('month').format('YYYY-MM-DD'), startTime: moment(monthTime).startOf('month').format('YYYY-MM-DD'), ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).format('YYYYMM')) // setShowMonthDetail(true); setShowMonthSecondDetail(true); } }}>{record?.ROYALTYTHEORYMONTHLYMUST ? numeral(record?.ROYALTYTHEORYMONTHLYMUST).format('0,0.00') : '-'} } }, ] }, ] // 导出表格的columns const exportColumns: any = [ { title:
{'序号'}
, hideInSearch: true, dataIndex: 'index', width: 90, fixed: 'left', align: 'center', render: (_, record) => { return record.index ? record.index : '' } }, { title: '管理中心', dataIndex: 'SPRegionType_Name', hideInSearch: true, align: 'center', // render: (text, record, index) => { // const obj = { // children: text !== null ? text : '', // props: {}, // }; // if (undefined !== text && '' !== text && text === '合计') { // obj.props.colSpan = 8; // } // return obj; // }, }, { title: '服务区', align: 'center', dataIndex: 'Serverpart_Name', hideInSearch: true, }, { title: '门店名称', dataIndex: 'Name', align: 'center', hideInSearch: true, render: (_, record) => { return record?.Name || record?.someName || '-' } }, { title:
{'经营商户'}
, dataIndex: 'MERCHANTS_NAME', align: 'left', width: 200, ellipsis: true, render: (_, record) => { return record?.MERCHANTS_NAME || record?.sameMERCHANTS_NAME || '-' } }, { title:
{'合同起止日期'}
, dataIndex: 'COMPACT_DATE', align: 'center', width: 200, hideInSearch: true, ellipsis: true, render: (_, record) => { return `${record?.COMPACT_STARTDATE ? moment(record?.COMPACT_STARTDATE).format('YYYY/MM/DD') : ''}${record?.COMPACT_ENDDATE ? `-${moment(record?.COMPACT_ENDDATE).format('YYYY/MM/DD')}` : ''}` } }, { title:
{'结算模式'}
, dataIndex: 'SettlementModes', align: 'center', hideInSearch: true, valueType: 'select', width: 90, valueEnum: SETTLEMENT_MODESObj }, { title:
切换日期
, dataIndex: 'SwitchDate', width: 110, align: 'center', hideInSearch: true, render: (_, record) => { return record?.SwitchDate ? moment(record?.SwitchDate).format('YYYY-MM-DD') : '-' } }, { title: '当年基础信息', dataIndex: '', hideInSearch: true, children: [ { title:
{'期数'}
, dataIndex: 'IndexStr', width: 90, align: 'center', hideInSearch: true, }, { title:
{'履约保证金'}
, dataIndex: 'SECURITYDEPOSIT', width: 90, align: 'right', hideInSearch: true, render: (_, record) => { // return record?.SECURITYDEPOSIT ? numeral(record?.SECURITYDEPOSIT).format('0,0') : '0' return record?.SECURITYDEPOSIT ? handleFormatNumber(record?.SECURITYDEPOSIT) : '0.00' } }, { title:
{'期限'}
, dataIndex: 'IndexDesc', align: 'center', width: 200, hideInSearch: true, }, { title:
{'装修期'}
, dataIndex: 'DecorateDesc', align: 'center', width: 180, hideInSearch: true, }, { title:
{'保底/固定租金'}
, dataIndex: 'RENTFEE', valueType: 'digit', align: 'right', width: 120, hideInSearch: true, render: (_, record) => { return record?.RENTFEE ? handleFormatNumber(record?.RENTFEE) : '0.00' } }, { title:
{'提成比例'}
, dataIndex: 'GUARANTEERATIO', align: 'center', width: 100, hideInSearch: true, render: (_, record) => { return record.GUARANTEERATIO ? `${record.GUARANTEERATIO}%` : '0' } }, ] }, { title: '保底租金应确认收入', dataIndex: '', hideInSearch: true, children: [ { title:
{'税率'}
, dataIndex: 'TaxRate', align: 'center', width: 100, hideInSearch: true, render: (_, record) => { return {record?.TaxRate ? `${record?.TaxRate}%` : '-'} } }, { title:
{'期收入'}
, dataIndex: 'MINTURNOVER', align: 'right', hideInSearch: true, width: 110, valueType: 'digit', render: (_, record) => { return record?.MINTURNOVER ? handleFormatNumber(record?.MINTURNOVER) : '0.00' } }, { title:
{'月收入'}
, dataIndex: 'MonthlyIncome', align: 'right', width: 100, valueType: 'digit', hideInSearch: true, render: (_, record) => { // const title: string = `${record?.MINTURNOVER}(期收入) /12/(1 ${record?.TaxRate?`+${record?.TaxRate}%(税率)`:''})` const title: string = `${record?.MINTURNOVER}(期收入) /12` return record?.MonthlyIncome ? {/* {numeral(record?.MonthlyIncome).format('0,0.00')} */} {record?.MonthlyIncome ? handleFormatNumber(record?.MonthlyIncome) : '0.00'} : '0' } }, { title:
{'累计月数'}
, dataIndex: 'MonthlyCount', align: 'right', width: 100, hideInSearch: true, }, { title:
{'累计应确认收入(保底租金)'}
, dataIndex: 'MonthlyTotalIncome', align: 'right', width: 200, valueType: 'digit', hideInSearch: true, render: (_, record) => { // const title: string = `${record?.MonthlyIncome}(月收入) * ${record?.MonthlyCount}(累计月数)` const title: string = `${record?.Remark}` return record?.MonthlyTotalIncome && record?.BUSINESSPROJECT_ID ? {/* {numeral(record?.MonthlyTotalIncome).format('0,0.00')} */} {record?.MonthlyTotalIncome ? handleFormatNumber(record?.MonthlyTotalIncome) : '0.00'} : record?.MonthlyTotalIncome ? {record?.MonthlyTotalIncome ? handleFormatNumber(record?.MonthlyTotalIncome) : '0.00'} : '0' } }, ] }, { title: '浮动提成应确认收入', dataIndex: '', hideInSearch: true, children: [ { title:
{'当月分润营业额'}
, dataIndex: 'CurMonthRevenue', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return record?.CurMonthRevenue ? handleFormatNumber(record?.CurMonthRevenue) : '0.00' } }, { title:
{'累计营业额'}
, dataIndex: 'REVENUEDAILY_AMOUNTTotal', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return record?.REVENUEDAILY_AMOUNTTotal ? handleFormatNumber(record?.REVENUEDAILY_AMOUNTTotal) : '0.00' } }, { title:
{'自然日营收'}
, dataIndex: 'DailyRevenueAmount', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return record?.DailyRevenueAmount ? handleFormatNumber(record?.DailyRevenueAmount) : '0.00' } }, { title:
{'营收差额'}
, dataIndex: 'DiffRevenueAmount', width: 130, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { return record?.DiffRevenueAmount ? handleFormatNumber(record?.DiffRevenueAmount) : '0.00' } }, { title:
{'提成金额'}
, dataIndex: 'GUARANTEERATIOAMOUNT', width: 120, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { const title: string = `分润营业额(${record.REVENUEDAILY_AMOUNTTotal}) * 提成比例(${record.GUARANTEERATIO ? `${record.GUARANTEERATIO}%` : ''})` return record.GUARANTEERATIO ? {/* {numeral(record?.GUARANTEERATIOAMOUNT).format('0,0.00')} */} {record?.GUARANTEERATIOAMOUNT ? handleFormatNumber(record?.GUARANTEERATIOAMOUNT) : '0.00'} : {/* {numeral(record?.GUARANTEERATIOAMOUNT).format('0,0.00')} */} {record?.GUARANTEERATIOAMOUNT ? handleFormatNumber(record?.GUARANTEERATIOAMOUNT) : '0.00'} } }, { title:
{'提成收入'}
, dataIndex: 'GUARANTEERATIOINCOME', width: 120, valueType: 'digit', align: 'right', hideInSearch: true, render: (_, record) => { const title: string = `提成金额(${record.GUARANTEERATIOAMOUNT}) / 税(1 + ${numeral(record.TaxRate / 100).format('0.00')})` return record.TaxRate ? {/* {numeral(record?.GUARANTEERATIOINCOME).format('0,0.00')} */} {record?.GUARANTEERATIOINCOME ? handleFormatNumber(record?.GUARANTEERATIOINCOME) : '0.00'} : {/* {numeral(record?.GUARANTEERATIOINCOME).format('0,0.00')} */} {record?.GUARANTEERATIOINCOME ? handleFormatNumber(record?.GUARANTEERATIOINCOME) : '0.00'} } }, ] }, { title: '本月确认收入', dataIndex: '', fixed: 'right', hideInSearch: true, children: [ { title:
{'累计应确认收入'}
, dataIndex: 'ROYALTYTHEORYMUST', width: 130, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { const title: string = record?.GUARANTEERATIOINCOME > record?.MonthlyTotalIncome ? `${record?.GUARANTEERATIOINCOME}(提成收入)>${record?.MonthlyTotalIncome}(累计应确认收入)=${record?.GUARANTEERATIOINCOME}(提成收入)` : `${record?.MonthlyTotalIncome}(累计应确认收入)>${record?.GUARANTEERATIOINCOME}(提成收入)=${record?.MonthlyTotalIncome}(累计应确认收入)` return record?.ROYALTYTHEORYMUST && record?.BUSINESSPROJECT_ID ? { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const obj: any = { ...record, endTime: moment(monthTime).endOf('month').format('YYYY-MM-DD'), startTime: '', ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).format('YYYYMM')) // setShowMonthDetail(true); setShowMonthSecondDetail(true); } }}> {/* {record?.ROYALTYTHEORYMUST ? numeral(record?.ROYALTYTHEORYMUST).format('0,0.00') : '0'} */} {record?.ROYALTYTHEORYMUST ? handleFormatNumber(record?.ROYALTYTHEORYMUST) : '0.00'} : record?.ROYALTYTHEORYMUST ? handleFormatNumber(record?.ROYALTYTHEORYMUST) : '0.00' } }, { title:
{'累计已确认收入'}
, dataIndex: 'ROYALTYTHEORYOK', width: 130, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { return { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const nowDay: any = moment(monthTime).endOf('month').format('YYYY-MM-DD') const obj: any = { ...record, endTime: moment(nowDay).subtract(1, 'months').endOf('month').format('YYYY-MM-DD'), startTime: '', ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).subtract(1, 'months').format('YYYYMM')) setShowMonthSecondDetail(true); } }}> {/* {record?.ROYALTYTHEORYOK ? numeral(record?.ROYALTYTHEORYOK).format('0,0.00') : '0'} */} {record?.ROYALTYTHEORYOK ? handleFormatNumber(record?.ROYALTYTHEORYOK) : '0.00'} } }, { title:
{'本月应确认'}
, dataIndex: 'ROYALTYTHEORYMONTHLYMUST', width: 110, valueType: 'digit', align: 'right', fixed: 'right', hideInSearch: true, render: (_, record) => { const title: string = `累计应确认收入(${record.ROYALTYTHEORYMUST}) - 累计已确认收入(${numeral(record?.ROYALTYTHEORYOK).format('0.00')})` return { if (record?.BUSINESSPROJECT_ID) { const req = { BusinessProjectId: record?.BUSINESSPROJECT_ID } const data = await getProjectDetail(req) const obj: any = { ...record, endTime: moment(monthTime).endOf('month').format('YYYY-MM-DD'), startTime: moment(monthTime).startOf('month').format('YYYY-MM-DD'), ...data } setCurrentRow(obj); setDrawerSearchTime(moment(monthTime).format('YYYYMM')) // setShowMonthDetail(true); setShowMonthSecondDetail(true); } }}> {/* {record?.ROYALTYTHEORYMONTHLYMUST ? numeral(record?.ROYALTYTHEORYMONTHLYMUST).format('0,0.00') : '0'} */} {record?.ROYALTYTHEORYMONTHLYMUST ? handleFormatNumber(record?.ROYALTYTHEORYMONTHLYMUST) : '0.00'} } }, ] }, ] // 导出excel方法 const exportTable = (e) => { e.stopPropagation(); // 防止Collapse组件收起 const main = document.getElementsByClassName('revenueConfirmHideBox')[0] const thead = main.querySelector('thead').cloneNode(true); // 深克隆DOM节点 const tbody = main.querySelector('tbody').cloneNode(true); // 深克隆DOM节点 const container = document.querySelector('#hiddenBox'); // 加个标题 const tableTop = document.createElement('div') tableTop.innerText = `${searchParams?.MonthDate ? moment(searchParams?.MonthDate).format('YYYY年MM月') : ''}收入确认表` tableTop.setAttribute('style', 'font-size:20px;font-weight:600;display:flex;width:100%;justify-content: center;text-align: center;'); const tempTable = document.createElement('table'); tempTable.appendChild(tableTop) tempTable.appendChild(thead); tempTable.appendChild(tbody); tempTable.setAttribute('id', 'table-to-xls-revenueConfirm'); // 给table添加id,值与按钮上的table字段对应 container.appendChild(tempTable); // 把创建的节点添加到页面容器中 setShowLoading(false) console.log('downloadBtnRef', downloadBtnRef); downloadBtnRef.current.handleDownload(); setShowExportTable(false) tempTable.remove() // 防止重复打印一个内容 } // 重新刷新调用表格数据 const handleGetRefreshTableData = () => { actionRef.current?.reload() } // compareList组件跳转月份的方法 const handleGetNewMonth = async (obj: any, time: any) => { setShowCompareDrawer(false) console.log('obj', obj); console.log('time', time); const req = { BusinessProjectId: obj?.BUSINESSPROJECT_ID, StatisticsMonth: moment(time).format('YYYYMM'), ShopRoyaltyId: obj?.ShopRoyaltyId, } const data = await handleGetProjectPeriodIncome(req) console.log('data', data); if (data && data.length > 0) { let obj: any = {} data.forEach((item: any) => { if (item.SHOPROYALTY_ID === obj?.ShopRoyaltyId) { obj = item } }) let [monthStartTime, monthEndTime] = obj?.IndexDesc.split('-') monthStartTime = moment(monthStartTime).format('YYYY-MM-DD') monthEndTime = moment(monthEndTime).format('YYYY-MM-DD') const startDate: any = moment(monthTime).startOf('months').format('YYYY-MM-DD') const endDate: any = moment(monthTime).endOf('months').format('YYYY-MM-DD') obj.startTime = monthStartTime obj.STATISTICS_MONTH = time if (new Date(monthEndTime).getTime() < new Date(endDate).getTime()) { obj.endTime = monthEndTime } else { obj.endTime = endDate } setCompareCurrent(obj) } setShowCompareDrawer(true) } return (
{ // 打印报表 if (!reqDetailList || reqDetailList.length === 0) return; setPrintOut(el); }}> { showLoading ?
数据加载中...
: '' }
{ showExportTable && exportTableData && exportTableData.length > 0 ? : '' }
{/* { setCollapsible(!collapsible) }} />} colSpan={!collapsible ? "300px" : "60px"} title={!collapsible ? "请选择服务区" : ""} headerBordered collapsed={collapsible} > {treeView && treeView.length > 0 ? { const selectedIds = info.checkedNodes.filter(n => n?.type === 1) const selectedAreaIds = info.checkedNodes.filter(n => n?.type === 0) setSelectedId(selectedIds.map(n => n?.value)?.toString() || '') console.log('selectedAreaIds', selectedAreaIds.map(n => n?.value)?.toString() || ''); setSelectAreaId(selectedAreaIds.map(n => n?.value)?.toString() || '') // actionRef?.current?.reload() // getData(selectedIds.map(n => n?.value)?.toString() || '') }} // switcherIcon={} /> : ''} */} { const selectedIds = info.checkedNodes.filter(n => n?.type === 1) const selectedAreaIds = info.checkedNodes.filter(n => n?.type === 0) setSelectedId(selectedIds.map(n => n?.value)?.toString() || '') setSelectAreaId(selectedAreaIds.map(n => n?.value)?.toString() || '') }} />
record?.Name + record?.Id + record?.IndexStr + record?.IndexDesc} search={{ span: 6 }} pagination={false} scroll={{ x: 'max-content', y: 'calc(100vh - 470px)' }} request={async (params: any) => { if (!selectedId) { setReqDetailList([]) return [] } if (params.MonthDate) { const date = new Date(params.MonthDate) const y = date.getFullYear() const m = date.getMonth() + 1 setSearchMonth(m) setExportDate(`${y}年${m < 10 ? `0${m}` : m}月`) setMonthTime(params.MonthDate) } console.log('params', params); setSearchParams(params) // let SETTLEMENT_MODESSTR: string = '' // if (params.SETTLEMENT_MODES && params.SETTLEMENT_MODES.length > 0) { // params.SETTLEMENT_MODES.forEach((item: any) => { // if (SETTLEMENT_MODESSTR) { // SETTLEMENT_MODESSTR += `,${item}` // } else { // SETTLEMENT_MODESSTR = item // } // }) // } // 是否只选择了一个服务区 let isOneServerPart: boolean = false // 是否只选择了一个片区 let isOneArea: boolean = false if (selectedId.indexOf(',') === -1) { isOneServerPart = true } console.log('selectedAreaId', selectedAreaId); if (selectedAreaId && selectedAreaId.indexOf(',') === -1) { isOneArea = true } const req = { ServerpartIds: selectedId, SETTLEMENT_MODES: params?.SettlementModes && params?.SettlementModes.length > 0 ? params?.SettlementModes.toString() : "", startDate: params.MonthDate ? moment(params.MonthDate).format('YYYYMM') : '', endDate: params.MonthDate ? moment(params.MonthDate).format('YYYYMM') : '', keyword: params.MERCHANTS_NAME, SolidType: true, ShowHisProject: params?.ShowHisProject === 'true' ? true : params?.ShowHisProject === 'false' ? false : '' } const res = await handleGetTableRevenueRecognitionOtherData(req) console.log('res', res) setOtherData(res.OtherData) const data = res.List setDefaultTableData(data) if (data && data.length > 0) { // 拿到所有服务区的税率 const taxRate: any = await handleGetSERVERPARTCRTList({ SearchParameter: { }, PageIndex: 1, PageSize: 999999 }) console.log('taxRate', taxRate); const taxRateObj: any = {} if (taxRate && taxRate.length > 0) { taxRate.forEach((item: any) => { taxRateObj[item.SERVERPART_ID] = item.ACCOUNTTAX }) } const list: any = JSON.parse(JSON.stringify(wrapTreeNode(data))) console.log('list', list); console.log('taxRateObj', taxRateObj); // 下面处理的各种东西太多了 把判断税率是否正确 放在上面 多遍历一遍 list.forEach((item: any) => { if (item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { if (subItem.children && subItem.children.length > 0) { subItem.children.forEach((thirdItem: any) => { if (taxRateObj[Number(thirdItem.SERVERPART_ID)]) { // 正确的税率值 const right: any = taxRateObj[Number(thirdItem.SERVERPART_ID)] thirdItem.isErrorTaxRate = Number(thirdItem.TaxRate) !== Number(right) thirdItem.errorTaxRate = Number(right) if (thirdItem.isErrorTaxRate) { item.isErrorTaxRate = true subItem.isErrorTaxRate = true setDifferentRate(true) } subItem.TaxRate = Number(right) } }) } }) } }) // 当一行数据和上一行的数据 是同一个项目时 省略不显示重复的数据 list.forEach((item: any) => { if (item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { if (subItem.children && subItem.children.length > 0) { // 当一行数据和上一行的数据 是同一个项目时 省略不显示重复的数据 for (let i = 0; i <= subItem.children.length; i++) { if (i >= 1) { if (subItem.children[i] && subItem.children[i - 1]) { if (subItem.children[i].BUSINESSPROJECT_ID === subItem.children[i - 1].BUSINESSPROJECT_ID) { subItem.children[i].someName = subItem.children[i].Name subItem.children[i].Name = '' subItem.children[i].sameMERCHANTS_NAME = subItem.children[i].MERCHANTS_NAME subItem.children[i].MERCHANTS_NAME = '' subItem.children[i].BusinessType = '' subItem.children[i].indexFlag = true if (subItem.children[i].SECURITYDEPOSIT === subItem.children[i - 1].SECURITYDEPOSIT) { subItem.children[i].SECURITYDEPOSIT = '' } if (subItem.children[i].RENTFEE === subItem.children[i - 1].RENTFEE) { subItem.children[i].RENTFEE = '' } } } } } let index: number = 1 // 加序号 同一个项目算一个 subItem.children.forEach((thirdItem: any) => { if (!thirdItem.indexFlag) { thirdItem.SERVERPART_ID = subItem.Id thirdItem.index = index++ } }) } }) } }) setReqDetailList(list) const exportList: any = [] if (list && list.length > 0) { let index: number = 1 list.forEach((item: any) => { if (item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { if (subItem.children && subItem.children.length > 0) { subItem.children.forEach((thirdItem: any) => { thirdItem.SPRegionType_Name = item.Name thirdItem.Serverpart_Name = subItem.Name thirdItem.index = index exportList.push(thirdItem) index++ }) } }) } }) } console.log('exportList', exportList); if (exportList && exportList.length > 0) { const exportRes: any = JSON.parse(JSON.stringify(exportList)) // 期收入 let MINTURNOVERSUM: number = 0 // 月收入 let MonthlyIncomeSum: number = 0 // 累计应确认收入(保底租金) let MonthlyTotalIncomeSUM: number = 0 // 累计营业额 let REVENUEDAILY_AMOUNTTotalSUM: number = 0 // 提成金额 let GUARANTEERATIOAMOUNTSUM: number = 0 // 提成收入 let GUARANTEERATIOINCOMESUM: number = 0 // 累计应确认收入 let ROYALTYTHEORYMUSTSUM: number = 0 // 累计已确认收入 let ROYALTYTHEORYOKSUM: number = 0 // 本月应确认 let ROYALTYTHEORYMONTHLYMUSTSUM: number = 0 // 自然日营收合计 let DailyRevenueAmountSum: number = 0 // 营收差额合计 let DiffRevenueAmountSum: number = 0 exportList.forEach((item: any) => { MINTURNOVERSUM += item.MINTURNOVER * 100 MonthlyTotalIncomeSUM += item.MonthlyTotalIncome * 100 REVENUEDAILY_AMOUNTTotalSUM += item.REVENUEDAILY_AMOUNTTotal * 100 GUARANTEERATIOAMOUNTSUM += item.GUARANTEERATIOAMOUNT * 100 GUARANTEERATIOINCOMESUM += item.GUARANTEERATIOINCOME * 100 ROYALTYTHEORYMUSTSUM += item.ROYALTYTHEORYMUST * 100 ROYALTYTHEORYOKSUM += item.ROYALTYTHEORYOK * 100 ROYALTYTHEORYMONTHLYMUSTSUM += item.ROYALTYTHEORYMONTHLYMUST * 100 DailyRevenueAmountSum += item.DailyRevenueAmount * 100 DiffRevenueAmountSum += item.DiffRevenueAmount * 100 MonthlyIncomeSum += item.MonthlyIncome * 100 }) exportRes.forEach((item: any) => { item.SPRegionType_Name = item.SPRegionType_Name.split('管理中心')[0] item.Serverpart_Name = item.Serverpart_Name.split('服务区')[0] }) exportRes.push({ SPRegionType_Name: '合计', MINTURNOVER: handleHighPrecision(MINTURNOVERSUM), MonthlyTotalIncome: handleHighPrecision(MonthlyTotalIncomeSUM), REVENUEDAILY_AMOUNTTotal: handleHighPrecision(REVENUEDAILY_AMOUNTTotalSUM), GUARANTEERATIOAMOUNT: handleHighPrecision(GUARANTEERATIOAMOUNTSUM), GUARANTEERATIOINCOME: handleHighPrecision(GUARANTEERATIOINCOMESUM), ROYALTYTHEORYMUST: handleHighPrecision(ROYALTYTHEORYMUSTSUM), ROYALTYTHEORYOK: handleHighPrecision(ROYALTYTHEORYOKSUM), ROYALTYTHEORYMONTHLYMUST: handleHighPrecision(ROYALTYTHEORYMONTHLYMUSTSUM), DailyRevenueAmount: handleHighPrecision(DailyRevenueAmountSum), DiffRevenueAmount: handleHighPrecision(DiffRevenueAmountSum), MonthlyIncome: handleHighPrecision(MonthlyIncomeSum) }) console.log('exportRes', exportRes); setExportTableData(exportRes) } else { setExportTableData([]) } console.log('isOneServerPart', isOneServerPart); console.log('isOneArea', isOneArea); const res: any = [] if (isOneServerPart) { list.forEach((item: any) => { if (item.children && item.children.length > 0) { item.children.forEach((subItem: any) => { res.push(subItem) }) } }) console.log('setExportTableData1', res); return { data: res, success: true } } if (!isOneArea) { console.log('list', list); if (list && list.length > 0) { // 期收入 let MINTURNOVERSUM: number = 0 // 累计应确认收入(保底租金) let MonthlyTotalIncomeSUM: number = 0 // 累计营业额 let REVENUEDAILY_AMOUNTTotalSUM: number = 0 // 提成金额 let GUARANTEERATIOAMOUNTSUM: number = 0 // 提成收入 let GUARANTEERATIOINCOMESUM: number = 0 // 累计应确认收入 let ROYALTYTHEORYMUSTSUM: number = 0 // 累计已确认收入 let ROYALTYTHEORYOKSUM: number = 0 // 本月应确认 let ROYALTYTHEORYMONTHLYMUSTSUM: number = 0 // 自然日营收合计 let DailyRevenueAmountSum: number = 0 // 营收差额合计 let DiffRevenueAmountSum: number = 0 list.forEach((item: any) => { MINTURNOVERSUM += item.MINTURNOVER * 100 MonthlyTotalIncomeSUM += item.MonthlyTotalIncome * 100 REVENUEDAILY_AMOUNTTotalSUM += item.REVENUEDAILY_AMOUNTTotal * 100 GUARANTEERATIOAMOUNTSUM += item.GUARANTEERATIOAMOUNT * 100 GUARANTEERATIOINCOMESUM += item.GUARANTEERATIOINCOME * 100 ROYALTYTHEORYMUSTSUM += item.ROYALTYTHEORYMUST * 100 ROYALTYTHEORYOKSUM += item.ROYALTYTHEORYOK * 100 ROYALTYTHEORYMONTHLYMUSTSUM += item.ROYALTYTHEORYMONTHLYMUST * 100 DailyRevenueAmountSum += item.DailyRevenueAmount * 100 DiffRevenueAmountSum += item.DiffRevenueAmount * 100 }) list.unshift({ Name: '合计', MINTURNOVER: handleHighPrecision(MINTURNOVERSUM), MonthlyTotalIncome: handleHighPrecision(MonthlyTotalIncomeSUM), REVENUEDAILY_AMOUNTTotal: handleHighPrecision(REVENUEDAILY_AMOUNTTotalSUM), GUARANTEERATIOAMOUNT: handleHighPrecision(GUARANTEERATIOAMOUNTSUM), GUARANTEERATIOINCOME: handleHighPrecision(GUARANTEERATIOINCOMESUM), ROYALTYTHEORYMUST: handleHighPrecision(ROYALTYTHEORYMUSTSUM), ROYALTYTHEORYOK: handleHighPrecision(ROYALTYTHEORYOKSUM), ROYALTYTHEORYMONTHLYMUST: handleHighPrecision(ROYALTYTHEORYMONTHLYMUSTSUM), DailyRevenueAmount: handleHighPrecision(DailyRevenueAmountSum), DiffRevenueAmount: handleHighPrecision(DiffRevenueAmountSum) }) console.log('setExportTableData2', list); return { data: list, success: true } } } console.log('setExportTableData3', list); return { data: list, success: true } } // 都没数据 那导出也没数据 setExportTableData([]) return { data: [], success: true } }} headerTitle={{`分账收银收入确认表(${searchMonth || '-'}月)`}} // 列表表头 columnsState={{ value: columnsStateMap, onChange: setColumnsStateMap, }} toolbar={{ actions: [ , 单位:元, <> { otherData ? 固化时间:{moment(otherData).format('YYYY-MM-DD')} : '' } , <> {/* 只八月显示 */} { moment(searchParams?.MonthDate || '').format('YYYYMM') === moment().subtract(1, 'day').subtract(1, 'm').format('YYYYMM') ? { if (differentRate) { confirm({ width: 500, content: '请检查税率是否一致', onOk: async () => { if (defaultTableData && defaultTableData.length > 0) { const req: any = defaultTableData setShowLoading(true) const data = await handleStorageMonthProjectAccount(req) if (data.Result_Code == 100) { message.success(data.Result_Desc) } else { message.error(data.Result_Desc) } setShowLoading(false) } else { message.error('请先查询数据需要固化的数据!') } } }) } else { if (defaultTableData && defaultTableData.length > 0) { const req: any = defaultTableData setShowLoading(true) const data = await handleStorageMonthProjectAccount(req) if (data.Result_Code == 100) { message.success(data.Result_Desc) } else { message.error(data.Result_Desc) } setShowLoading(false) } else { message.error('请先查询数据需要固化的数据!') } } }}> : '' } , ] }} >
{/* 查看项目详情 右侧弹出的抽屉 */} < Drawer width="80%" className="project-drawer" visible={showDetail} // 抽屉弹框是否显示状态 onClose={() => { // 关闭抽屉 则在清空选中行数据 并 设置抽屉状态为关闭 setCurrentRow(undefined); setShowDetail(false); }} bodyStyle={{ backgroundColor: "#f9f9f9", padding: 0 }} closable={false} > {/* 抽屉打开时 加载项目详情组件 */} {showDetail && } {/* 月度信息抽屉 */} < Drawer width="80%" className="project-drawer" visible={showMonthDetail} // 抽屉弹框是否显示状态 onClose={() => { // 关闭抽屉 则在清空选中行数据 并 设置抽屉状态为关闭 setCurrentRow(undefined); setShowMonthDetail(false); }} bodyStyle={{ backgroundColor: "#f9f9f9", padding: 0 }} closable={false} > {/* 抽屉打开时 加载项目详情组件 */} { showMonthDetail && } {/* 月度信息抽屉 */} < Drawer width="80%" className="project-drawer" visible={showMonthSecondDetail} // 抽屉弹框是否显示状态 onClose={() => { // 关闭抽屉 则在清空选中行数据 并 设置抽屉状态为关闭 setCurrentRow(undefined); setDrawerSearchTime(undefined) setShowMonthSecondDetail(false); }} bodyStyle={{ backgroundColor: "#f9f9f9", padding: 0 }} closable={false} > {/* 抽屉打开时 加载项目详情组件 */} { showMonthSecondDetail && } {/* 营业额和自然日报表的对比抽屉 */} < Drawer width="80%" className="project-drawer" visible={showCompareDrawer} // 抽屉弹框是否显示状态 onClose={() => { // 关闭抽屉 则在清空选中行数据 并 设置抽屉状态为关闭 setCompareCurrent(undefined) setShowCompareDrawer(false); }} bodyStyle={{ backgroundColor: "#f9f9f9", padding: 0 }} closable={false} > {showCompareDrawer && 0} monthTime={monthTime} handleGetRefreshTableData={handleGetRefreshTableData} />}
) } export default connect(({ user }: ConnectState) => ({ currentUser: user.currentUser }))(revenueConfirmation);