import { tableColumnsWidObj } from "@/constant";
import { formatMoneyNumber, formatToPercentage } from "@/utils/format";
import { createFromIconfontCN } from "@ant-design/icons";
import { ProColumns } from "@ant-design/pro-components";
import { Popover } from 'antd'
import React from "react";

const IconFont = createFromIconfontCN({
    scriptUrl: '',
});


export const unitPersonnelCostCalc: ProColumns[] = [
    {
        title: '人事分类名称',
        dataIndex: 'name',
    },
    {
        title: '实际编制人数',
        dataIndex: 'empNum',
    },
    {
        title: '实际总工时',
        dataIndex: 'actualHour',
    },
    {
        title: '预计总工时',
        dataIndex: 'expectHour',
    },
    {
        title: '总成本',
        dataIndex: 'totalCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '人均成本',
        dataIndex: 'avgCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '每分钟成本',
        dataIndex: 'minuteCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
];


export const chargeItemCostCalc: ProColumns[] = [
    {
        title: '收费项目编码',
        dataIndex: 'code',
    },
    {
        title: '收费项目名称',
        dataIndex: 'name',
        width: '20%'
    },
    {
        title: '项目类别',
        dataIndex: 'itemType',
    },
    {
        title: '药品收入',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目成本',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
];


export const patientCostCalc: ProColumns[] = [
    {
        title: '住院号/门诊号',
        dataIndex: 'visitNo',
    },
    {
        title: '病人ID',
        dataIndex: 'patientNo',
    },
    {
        title: '患者姓名',
        dataIndex: 'name',
    },
    {
        title: '科室代码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        dataIndex: 'departmentName',
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        align:'right',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        align:'right',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        align:'right',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目成本',
        align:'right',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        align:'right',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        align:'right',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        align:'right',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品收入',
        align:'right',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        align:'right',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },

    },
];


export const diseaseCostCalculation: ProColumns[] = [
    {
        title: '病种代码',
        dataIndex: 'code',
    },
    {
        title: '病种名称',
        dataIndex: 'name',
    },
    {
        title: '科室代码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        dataIndex: 'departmentName',
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目成本',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品收入',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    }
];

export const DRG_DIPCostCalc: ProColumns[] = [
    {
        title: '分组代码',
        dataIndex: 'code',
    },
    {
        title: '分组名称',
        width: '18%',
        dataIndex: 'name',
    },
    {
        title: '科室代码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        dataIndex: 'departmentName',
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目成本',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品收入',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    }
];
export const clinicalPathway: ProColumns[] = [
    {
        title: '路径代码',
        dataIndex: 'code',
    },
    {
        title: '路径名称',
        width: '20%',
        dataIndex: 'name',
    },
    {
        title: '科室代码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        dataIndex: 'departmentName',
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目成本',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品收入',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    }
];

export const medicalOrderItem: ProColumns[] = [
    {
        title: '医嘱项目编码',
        dataIndex: 'code',
    },
    {
        title: '医嘱项目名称',
        dataIndex: 'name',
        width: '18%'
    },
    {
        title: '科室代码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        dataIndex: 'departmentName',
    },

    {
        title: '项目成本',
        dataIndex: 'itemCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '项目收入',
        dataIndex: 'itemIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品收入',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '人力成本',
        dataIndex: 'empCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '设备成本',
        dataIndex: 'equipmentCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '空间成本',
        dataIndex: 'spaceCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
];

export const medicalMaterialCostCalc: ProColumns[] = [
    {
        title: '责任中心代码',
        dataIndex: 'responsibilityCode',
    },
    {
        title: '责任中心名称',
        dataIndex: 'responsibilityName',
        width: '10%'
    },
    {
        title: '收费项目编码',
        dataIndex: 'code',
    },
    {
        title: '收费项目名称',
        dataIndex: 'name',
        width: '30%'
    },

    {
        title: '项目类别',
        dataIndex: 'itemType',
    },
    {
        title: '药品收入',
        align:'right',
        dataIndex: 'drugIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料收入',
        align:'right',
        dataIndex: 'materialIncome',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '药品成本',
        dataIndex: 'drugCost',
        align:'right',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '材料成本',
        align:'right',
        dataIndex: 'materialCost',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },

];
export const beforeCollectionSearch: ProColumns[] = [
    {
        title: '收入项目',
        dataIndex: 'productCodeName',
    },
    {
        title: '会计科目',
        dataIndex: 'accountCodeName',
    },
    {
        title: '金额(元)',
        dataIndex: 'amount',
        width: 130,
        align:'center',
        renderText(num, record, index, action) {
            return <div style={{paddingRight:30,textAlign:'right'}}>{formatMoneyNumber(num)}</div>
        }
    },
    {
        title: '开单科室',
        dataIndex: 'openDepartmentCodeName',

    },
    {
        title: '开单责任中心',
        dataIndex: 'openResponsibilityCodeName',
    },

    {
        title: '执行科室',
        dataIndex: 'startDepartmentCodeName',
    },
    {
        title: '执行责任中心',
        dataIndex: 'startResponsibilityCodeName',
    },
];

export const incomeCollection: ProColumns[] = [
    {
        title: '年份',
        dataIndex: 'year',
    },
    {
        title: '月份',
        dataIndex: 'month',
    },
    {
        title: '金额',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },

];
export const afterCollectionSearch: ProColumns[] = [
    {
        title: '年份',
        dataIndex: 'year',
        width: tableColumnsWidObj.year
    },
    {
        title: '月份',
        dataIndex: 'month',
        width: tableColumnsWidObj.month
    },
    {
        title: '科室编码',
        dataIndex: 'departmentCode',
    },
    {
        title: '科室名称',
        width: tableColumnsWidObj.departmentName,
        dataIndex: 'departmentName',
    },
    {
        title: '责任中心编码',
        width: tableColumnsWidObj.responsibilityCenterCode,
        dataIndex: 'responsibilityCode',
    },
    {
        title: '责任中心名称',
        width: tableColumnsWidObj.responsibilityCenter,
        dataIndex: 'responsibilityName',
    },
    {
        title: '会计科目编码',
        dataIndex: 'accountingCode',
    },
    {
        title: '会计科目名',
        dataIndex: 'accountingName',
    },
    {
        title: '成本项目编码',
        dataIndex: 'productCode',
    },
    {
        title: '成本项目名',
        dataIndex: 'productName',
    },
    {
        title: '金额',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },

];

export const beforeCostShareSearch: ProColumns[] = [
    {
        title: '成本项目',
        width: '20%',
        dataIndex: 'productName',
        renderText(num, record, index, action) {
            const { productCode, productName } = record;
            return `[${productCode}]${productName}`
        },
    },
    {
        title: '会计科目',
        width: '20%',
        dataIndex: 'accountName',
        renderText(num, record, index, action) {
            const { accountCode, accountName } = record;
            return `[${accountCode}]${accountName}`
        },
    },
    {
        title: '金额(元)',
        width: '20%',
        align:'center',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            return <div style={{textAlign:'right',paddingRight:'30%'}}>{formatMoneyNumber(num)}</div>
        },
    },
    {
        title: '科室名称',
        width: '20%',
        dataIndex: 'departName',
        renderText(num, record, index, action) {
            const { departCode, departName } = record;
            return `[${departCode}]${departName}`
        },
    },
    {
        title: '责任中心名',
        dataIndex: 'responsibilityName',
        width: '20%',
        renderText(num, record, index, action) {
            const { responsibilityCode, responsibilityName } = record;
            return `[${responsibilityCode}]${responsibilityName}`
        },
    },
];

export const costShare: ProColumns[] = [
    {
        title: '年份',
        align:'left',
        dataIndex: 'year',
    },
    {
        title: '月份',
        align:'center',
        dataIndex: 'month',
    },
    {
        title: '金额',
        align:'right',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            return <div style={{textAlign:'right'}}>{formatMoneyNumber(num)}</div>
        },
    },
    {
        title: '是否分摊',
        align:'right',
        dataIndex: 'isAllocation',
        render: bool => bool ? '已分摊' : '未分摊'
    },

];

export const afterCostShareSearch: ProColumns[] = [
    // {
    //     title: '年份',
    //     dataIndex: 'dateYear',
    //     width: tableColumnsWidObj.year
    // },
    // {
    //     title: '月份',
    //     dataIndex: 'dateMonth',
    //     width: tableColumnsWidObj.month
    // },
    {
        width:90,
        title: '分摊层级',
        dataIndex: 'levelSort',
    },
    {
        title: '分摊层级名',
        dataIndex: 'levelName',
    },
    {
        title: '责任中心编码',
        width: tableColumnsWidObj.responsibilityCenterCode,
        dataIndex: 'responsibilityCode',
    },
    {
        title: '责任中心名',
        width: tableColumnsWidObj.responsibilityCenter,
        dataIndex: 'responsibilityName',
    },
    {
        title: '会计科目编码',
        dataIndex: 'accountingCode',
    },
    {
        title: '会计科目名',
        width:220,
        dataIndex: 'accountingName',
    },
    {
        title: '金额',
        dataIndex: 'amount',
        align:'right',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },

];

export const departmentCostCalculate: ProColumns[] = [
    {
        title: '责任中心',
        dataIndex: 'responsibilityCode',

    },
    {
        title: '年份',
        dataIndex: 'year',

    },
    {
        title: '月份',
        dataIndex: 'month',

    },
    {
        title: '报表项目编码',
        width: '10%',
        dataIndex: 'reportNum',
    },
    {
        title: '报表项目名',
        dataIndex: 'reportName',
    },
    {
        title: '责任中心名',
        dataIndex: 'responsibilityName',
    },
    {
        title: '责任中心编码',
        dataIndex: 'responsibilityCode',

    },
    {
        title: '金额',
        width: '10%',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            return formatMoneyNumber(num);
        },
    },
    {
        title: '占比',
        dataIndex: 'percentName',
    },

];
export const wholeHospCostCalculate: ProColumns[] = [
    {
        title: '报表项目',
        dataIndex: 'reportName',
        renderText(text, record, index, action) {
            const { description } = record;
            return description ? <Popover content={()=><div dangerouslySetInnerHTML={{__html:description}} />}><span style={{ cursor: 'pointer' }}>{text}</span><IconFont className="hover-icon" style={{ fontSize: 16, color: '#17181a', paddingLeft: 4, position: 'relative', top: 1 }} type={'iconshuoming'} /></Popover> : text
        },
    },
    {
        title: '金额',
        width:200,
        align:'right',
        dataIndex: 'amount',
        renderText(num, record, index, action) {
            const { children,calcType } = record;
            // 有 children 时返回 null，否则格式化金额
            return (children && children.length > 0 && calcType == '0' )? <React.Fragment></React.Fragment> : formatMoneyNumber(num);
            
        },
    },
    {
        title: '占比',
        width:100,
        align:'right',
        dataIndex: 'percent',
        renderText(num, record) {
            const { children,calcType } = record;
            // 有 children 时返回 null，否则格式化百分比
            return (children && children.length > 0 && calcType == '0') ? <React.Fragment></React.Fragment> : formatToPercentage(num);
        },
    },

    // {
    //     title: '说明',
    //     dataIndex: 'description',
    //     renderText(text,record) {
    //         const {children} = record;
    //         return (children&&children.length>0)?<React.Fragment></React.Fragment>:text;
    //     },
    // },

];

export const costShareReportTable: ProColumns[] = [
    {
        title: '年份',
        dataIndex: 'year',
    },
    {
        title: '月份',
        dataIndex: 'month',
    },
    {
        title: '分摊报表名称',
        dataIndex: 'shareReportName',
    },
    {
        title: '分摊层级',
        dataIndex: 'shareLevel',
    },
    {
        title: '分摊时间',
        dataIndex: 'shareTime',
    },
];

export const departmentOperatingReport: ProColumns[] = [
    {
        title: '年份',
        width: 100,
        dataIndex: 'dateYear',
    },
    {
        title: '月份',
        width: 100,
        dataIndex: 'dateMonth',
    },
    {
        title: '报表类型',
        width: 100,
        dataIndex: 'fileType',
    },
    {
        title: '报表名称',
        dataIndex: 'fileName',
    },
    {
        title: '更新时间',
        width: 180,
        dataIndex: 'updateTime',
    },
];
export const wholeHospOperatingReport: ProColumns[] = [
    {
        title: '年份',
        width: 100,
        dataIndex: 'dateYear',
    },
    {
        title: '月份',
        width: 100,
        dataIndex: 'dateMonth',
    },
    {
        title: '报表类型',
        width: 120,
        dataIndex: 'fileType',
    },
    {
        title: '报表名称',
        dataIndex: 'fileName',
    }
];

export const projectShareParamsCalc: ProColumns[] = [];
// export const projectCostCalc: ProColumns[] = [
//     {
//         title: '责任中心编码',
//         dataIndex: 'responsibilityCode',
//         width:tableColumnsWidObj.responsibilityCenterCode
//     },
//     {
//         title: '责任中心名称',
//         dataIndex: 'responsibilityName',
//         width:tableColumnsWidObj.responsibilityCenter
//     },
//     {
//         title: '收费项目编码',
//         dataIndex: 'code',
//     },
//     {
//         title: '收费项目名称',
//         dataIndex: 'name',
//     },
//     {
//         title: '项目分类',
//         dataIndex: 'itemTypeName',
//     },
//     {
//         title: '项目成本',
//         dataIndex: 'itemCost',
//     },
//     {
//         title: '人事成本',
//         dataIndex: 'empCost',
//     },
//     {
//         title: '设备成本',
//         dataIndex: 'equipmentCost',
//     },
//     {
//         title: '空间成本',
//         dataIndex: 'spaceCost',
//     },
//     {
//         title: '公共费用分摊',
//         dataIndex: 'publicShareCost',
//     },
//     {
//         title: '管理费用分摊',
//         dataIndex: 'managerShareCost',
//     }
// ];