/* * @Author: code4eat awesomedema@gmail.com * @Date: 2024-03-06 10:43:05 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2024-06-20 21:03:12 * @FilePath: /CostAccountingSys/src/pages/costLibraryManagement/projectCostManagement/chargeItemsMana/components/match.tsx * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import { KCIMTable } from "@/components/KCIMTable"; import ProgressModal from "@/components/ProgressModal"; import { createFromIconfontCN } from "@ant-design/icons"; import { ProColumns, ProFormText } from "@ant-design/pro-components"; import { Progress, message, Modal, Skeleton } from 'antd'; import { useEffect, useState } from "react"; import { getAllNeedMatchItems, getMatchCount, getReferralMatch, getSingleItem, mapItemAndStandItem, matchRequest } from "../service"; import './style.less'; const IconFont = createFromIconfontCN({ scriptUrl: '', }); interface SignalBarProps { level: number; // 信号强度级别,通常在0-4之间 } const SignalBar: React.FC = ({ level }) => { const maxLevel = 5; const signalLevel = Math.round(level * maxLevel); // 现在signalLevel是0到4之间的整数 const signalBars = []; for (let i = 0; i < maxLevel; i++) { signalBars.push(
0 ? '2px' : undefined, height: `${8 + (i * 2)}px`, // 使每个条更高一些 // 定义更多样式... }} /> ); } return
{signalBars}
; }; export const MatchPage = (props: any) => { const { record, single = true, closeDrawer, switchBatchHandle } = props; const [matchItemInfo, set_matchItemInfo] = useState(undefined); const [allNeedMatchList, set_allNeedMatchList] = useState([]); const [allStandItem, set_allStandItem] = useState([]); const [matchStandItem, set_matchStandItem] = useState([]); const [dataSource, set_dataSource] = useState([]); const [chargeItemTabledataSource, set_chargeItemTabledataSource] = useState([]); const [searchText, setSearchText] = useState(''); const [chargeItemSearchText, setChargeItemSearchText] = useState(''); const [countInfo, set_countInfo] = useState(undefined); const [currentTablePage, set_currentTablePage] = useState(1); const [openTable, set_openTable] = useState(false); const [isProgressModalVisible, set_isProgressModalVisible] = useState(false); const [loading, set_loading] = useState(true); const leftTableColumns = [ { title: '标准项目编码', dataIndex: 'code', }, { title: '标准项目名称', dataIndex: 'name', }, { title: '康程分类', dataIndex: 'kcClassName', }, { title: '操作', key: 'option', width: 80, valueType: 'option', render: (_: any, data: any) => { const { code } = data; return code != matchItemInfo?.standItemCode ? [ matchRequestHandle(data,1)} style={{ display: 'inline-block', width: 56, height: 24, cursor: 'pointer', backgroundColor: '#FAFCFF', borderRadius: 4, border: '1px solid #DAE2F2', textAlign: 'center', color: '#17181A' }}>匹配 ] : [ 当前匹配 ] }, }, ]; const chargeTableColumns: ProColumns[] = [ { title: '编号', width: 80, dataIndex: 'id', }, { title: '收费项目编码', dataIndex: 'code', }, { title: '收费项目名称', dataIndex: 'name', }, { title: '状态', dataIndex: 'match', width: 90, renderText(bool, record, index, action) { return <>{bool ? 已匹配 : 待匹配}{matchItemInfo?.code == record.code && } }, }, ] const getMatchInfo = async () => { const { code } = record; const resp = await getSingleItem(code,record.departmentCode); if (resp) { set_matchItemInfo(resp); } } const getNeedMatchList = async () => { const resp = await getAllNeedMatchItems(); if (resp) { set_allNeedMatchList(resp); } } const getReferralMatchHandle = async () => { set_loading(true); const { code,departmentCode } = matchItemInfo; const resp = await getReferralMatch(code,single?record.departmentCode:departmentCode); if (resp) { const { allStandItem: all = [], matchStandItem: match = [] } = resp; const temp = [...all]; const index = temp.findIndex((item: any) => item.code == matchItemInfo.standItemCode); if (index !== -1) { // 如果找到了符合条件的项,先将其从数组中移除 const [item] = temp.splice(index, 1); // 然后将其添加到数组的开头 temp.unshift(item); } set_allStandItem([...temp]); set_matchStandItem(match?Array.from(new Map(match.map((a: any) => [a.code, a])).values()):[]); set_dataSource([...all]); set_loading(false); } } const switchNeddMatchItem = async (flag: number) => { const currentIndex = allNeedMatchList.findIndex((a) => a.code == matchItemInfo.code); if ((currentIndex == allNeedMatchList.length - 1) && flag > 0) { message.info('已经是最后一项!'); return; } if ((currentIndex == 0) && flag < 0) { message.info('没有上一项!'); return; } let next = undefined; if (flag > 0) { for (const item of [...allNeedMatchList].splice(currentIndex + 1, allNeedMatchList.length)) { if (!item.match) { next = item break; // 满足条件后退出循环 } } } if (flag < 0) { for (const item of ([...allNeedMatchList].splice(0, currentIndex)).reverse()) { if (!item.match) { next = item break; // 满足条件后退出循环 } } } // console.log({switchNeddMatchItem,currentIndex,next}); if (next) { set_matchItemInfo(next); } else { message.info('未找到未匹配项!'); getMatchInfo(); getNeedMatchList(); } } const matchRequestHandle = async (data: any,type:number) => { try { const { code: itemCode,departmentCode } = matchItemInfo; const { code: standItemCode } = data; const resp = await matchRequest(itemCode, standItemCode,type,departmentCode); if (resp) { if (!single) { switchNeddMatchItem(1); getNeedMatchList(); } else { getMatchInfo(); getNeedMatchList(); } } } catch (error) { console.log('matchRequestHandle_error', error); } } const getRightsInfo = async () => { const resp = await getMatchCount(); if (resp) { set_countInfo(resp); } } const openTableHandle = (bool: boolean) => { if (bool) { const currentIndex = allNeedMatchList.findIndex((a) => a.code == matchItemInfo.code); set_currentTablePage(Math.ceil((currentIndex + 1) / 10)); set_chargeItemTabledataSource([...allNeedMatchList]); } set_openTable(bool); } const startBatchCalc = async () => { set_isProgressModalVisible(true); const resp = await mapItemAndStandItem(); if (resp) { set_isProgressModalVisible(false); } } const mapBtnHandle = async () => { Modal.confirm({ title: '注意', content: '对照操作只会自动匹配未对照的项目,是否继续操作?', okText: '确定', cancelText: '取消', onOk: (...args) => { startBatchCalc(); }, }) } const goMatch = () => { getReferralMatchHandle() } useEffect(() => { if (matchItemInfo) { getReferralMatchHandle(); getRightsInfo(); } }, [matchItemInfo]); useEffect(() => { const filteredData = allStandItem.filter((item) => { return item.code.includes(searchText) || item.name.includes(searchText); }); set_dataSource(filteredData); }, [searchText, allStandItem]); useEffect(() => { const filteredData = allNeedMatchList.filter((item) => { return item.code.includes(chargeItemSearchText) || item.name.includes(chargeItemSearchText); }); set_chargeItemTabledataSource(filteredData); }, [chargeItemSearchText]); useEffect(() => { if (!single) getRightsInfo(); }, [single]); useEffect(() => { if (record) { getMatchInfo(); getNeedMatchList(); } }, [record]) return (
{ getMatchInfo(); getNeedMatchList(); }} visible={isProgressModalVisible} /> { single && (
{record ? record.standItemName : '项目'}
{ closeDrawer() }} type="iconquxiao" style={{ color: '#17181A', marginRight: 8, cursor: 'pointer', fontSize: 21 }} />
) }
{ !single && (
openTableHandle(!openTable)} /> 当前项目:{matchItemInfo?.id}
{ switchBatchHandle && switchBatchHandle(false) }}>返回上一层
switchNeddMatchItem(-1)}>上一项
switchNeddMatchItem(1)}>下一项
{ openTable && (
, onChange: (e) => { if (e.target.value.length != 0) { setChargeItemSearchText(e.target.value); } else { setChargeItemSearchText(''); } } }} />
{ return { onClick: () => { set_matchItemInfo(record); set_openTable(false) } } }} tableAlertRender={false} rowClassName={(record) => record.code == matchItemInfo.code ? 'match' : ''} pagination={{ showTitle: false, showSizeChanger: true, simple: true, defaultPageSize: 10, defaultCurrent: currentTablePage }} />
) }
) }
{matchItemInfo?.code}
项目编码
{matchItemInfo?.name}
项目名称
{matchItemInfo?.type}
项目类别
{(matchItemInfo?.match) ? '已匹配' : '未匹配'}
匹配状态
手动匹配
, onChange: (e) => { if (e.target.value.length != 0) { setSearchText(e.target.value); } else { setSearchText(''); } } }} />
{ !single && (
{`${percent}%`}} percent={countInfo ? Math.floor((countInfo.trueMatch / countInfo.allCount) * 100) : 0} width={64} />
全部项目:{countInfo ? countInfo.allCount : 0}
mapBtnHandle()}> 智能匹配
匹配规则
1、逐个匹配未匹配的项目,已匹配的项目会自动跳过
2、与标准项目国家编码精准匹配的项目状态设置成已匹配
3、未精准匹配的项目会通过智能匹配算法形成推荐项,需用户逐个选择匹配项
) }
推荐匹配 switchNeddMatchItem(1)}>跳过该项
{ loading && ( ) } { !loading && matchStandItem.map((item, index) => { const { code } = item; return (
{item.name}
{item.percentDisplay}
普通门诊诊察费
康程分类:诊察费/西医诊察费
{code != matchItemInfo?.standItemCode ?
matchRequestHandle(item,2)}>匹配
:
当前匹配
}
) }) } { !loading && matchStandItem.length == 0 && (
暂无推荐项目
当前暂无推荐匹配项目,您可尝试进行对照或
goMatch()}>去匹配
) }
) }