/* * @Author: code4eat awesomedema@gmail.com * @Date: 2023-03-03 11:30:33 * @LastEditors: code4eat awesomedema@gmail.com * @LastEditTime: 2024-08-16 10:34:01 * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ import KCIMPagecontainer from '@/components/KCIMPageContainer'; import { KCIMTable } from '@/components/KCIMTable'; import { formatMoneyNumber } from '@/utils/format'; import { createFromIconfontCN } from '@ant-design/icons'; import FormItem from 'antd/es/form/FormItem'; import { ActionType, DrawerForm, ProFormInstance, ProFormText, ProTable, TableDropdown } from '@ant-design/pro-components'; import { ModalForm, ProFormDigit, ProFormSelect, ProFormSwitch } from '@ant-design/pro-form' import { ProColumns } from '@ant-design/pro-table'; import type { MenuProps } from 'antd'; import { Input, message, Dropdown, Modal, Popconfirm, Drawer, Breadcrumb } from 'antd'; import { useEffect, useRef, useState } from 'react'; import 'moment/locale/zh-cn'; import locale from 'antd/es/date-picker/locale/zh_CN'; import { addData, delData, editData, getAllNeedMatchItems, getDepartmentListsReq, getTableDataReq, importDataPost, mapItemAndStandItem } from './service'; import './style.less'; import KCIMUpload from '@/components/KCIMUpload'; import { downloadTemplateReq } from '@/utils/tooljs'; import { getStandItemList } from '../standardProjectMana/service'; import { getDicDataBySysId } from '@/services/getDic'; import { KcimCenterSysId } from '@/constant'; import { Setting } from './components/setting'; import KCIMDrawerForm from '@/components/KCIMDrawerForm'; import { MatchPage } from './components/match'; const IconFont = createFromIconfontCN({ scriptUrl: '', }); let currentRow: any = undefined; export const fetchAllDepartments = async (params:any) => { const {keyWords} = params; let currentPage = 1; const pageSize = 500; let allDepartments: any[] = []; let hasMore = true; do { const resp = await getDepartmentListsReq({ current: currentPage, pageSize,departName:keyWords }); if (resp) { const { list = [] } = resp; allDepartments = [...allDepartments, ...list]; if (list.length < pageSize) { hasMore = false; // 如果返回的数据少于每页数量,说明已经是最后一页 } else { currentPage++; // 否则继续请求下一页 } } else { hasMore = false; // 如果请求失败,终止循环 } } while (hasMore); return allDepartments.map((a: any) => ({ label:`${a.name}(${a.code})`, value: a.code })); }; export default function ChargeItemsMana() { const [tableDataFilterParams, set_tableDataFilterParams] = useState(); const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState(''); const tableRef = useRef(); const formRef = useRef(); const [stopStat, set_stopStat] = useState(0); const [drawerVisible, set_drawerVisible] = useState(false); const [drawerType, set_drawerType] = useState(1); const [currentSelectRow, set_currentSelectRow] = useState(undefined); const [ifBatchMatch, set_ifBatchMatch] = useState(false); const columns: ProColumns[] = [ { title: '科室', dataIndex: 'departmentName', width: 160, renderText(text, record, index, action) { return `[${record.departmentCode}]${record.departmentName}` }, }, { title: '收费项目编码', dataIndex: 'code', width: 100 }, { title: '收费项目名称', dataIndex: 'name', width: 260 }, { title: '国家编码', dataIndex: 'nationalCode', width: 100 }, { title: '项目类别', dataIndex: 'type', width: 100 }, { title: '项目分类', dataIndex: 'itemTypeName', width: 100 }, { title: '康程分类', dataIndex: 'kcCodeName', width: 280 }, { title: '标准项目编码', dataIndex: 'standItemCode', width: 100 }, { title: '标准项目名称', dataIndex: 'standItemName', width: 260 }, { title: '参与人员', dataIndex: 'empMaps', width: 260, renderText(arr, record, index, action) { if (arr) return arr.reduce((prev: any, cur: any) => `${prev.length > 0 ? prev + '|' : prev}${cur.empTypeCodeName + '*' + cur.num + '*' + cur.executeTime}`, '') }, }, { title: '使用设备', dataIndex: 'equipmentMaps', width: 260, renderText(arr, record, index, action) { if (arr) return arr.reduce((prev: any, cur: any) => `${prev.length > 0 ? prev + '|' : prev}${cur.equipmentCodeName + '*' + cur.num + '*' + cur.executeTime}`, '') }, }, { title: '使用空间', dataIndex: 'spaceMaps', width: 260, renderText(arr, record, index, action) { if (arr) return arr.reduce((prev: any, cur: any) => `${prev.length > 0 ? prev + '|' : prev}${cur.spaceCodeName + '*' + cur.num + '*' + cur.executeTime}`, '') }, }, { title: '计价药材', dataIndex: 'valuation', width: 260, renderText(arr) { if (arr) return arr.reduce((prev: any, cur: any) => `${prev.length > 0 ? prev + '|' : prev}${cur.code + '*' + cur.name + '*' + cur.num}`, '') }, }, { title: '不计价药材成本', dataIndex: 'noValuation', width: 260, renderText(arr, record, index, action) { if (arr) return arr.reduce((prev: any, cur: any) => `${prev.length > 0 ? prev + '|' : prev}${cur.code + '*' + cur.name + '*' + cur.num}`, '') }, }, { title: '单价', dataIndex: 'price', width: 90 }, { title: '操作', key: 'option', width: 120, fixed: 'right', valueType: 'option', render: (_: any, record: any) => { const items: MenuProps['items'] = [ { key: '1', label: ( ), }, // { // key: '2', // label: ( // // 同步设置 // // ), // }, { key: '3', label: ( delTableData(record)} > 删除 ), }, ]; return [ // , // delTableData(record)} // > // 删除 // { set_currentSelectRow(record); currentRow = record; set_drawerType(2); set_drawerVisible(true) }}>匹配, { currentRow = record; set_drawerType(1); set_currentSelectRow(record);set_drawerVisible(true); }}>设置, ] }, }, ] const getTableData = async (params: any) => { const resp = await getTableDataReq({ ...params, type: stopStat }); if (resp) { return { data: resp.list, success: true, total: resp.totalCount, pageSize: resp.pageSize, totalPage: resp.totalPage, } } return [] } const delTableData = async (record: any) => { const resp = await delData(record.id); if (resp) { message.success('操作成功!'); tableRef.current?.reload(); // message.success('操作成功!'); } } const updateTable = async (formVal: any, type: 'EDIT' | "ADD") => { const result = { ...formVal, standItemCode: formVal.standItem ? formVal.standItem.label : undefined, standItemName: formVal.standItem ? formVal.standItem.label : undefined, departmentCode: formVal.department ? formVal.department.value : undefined, departmentName: formVal.department ? formVal.department.label : undefined, department:null } if (type == 'ADD') { const resp = await addData(result); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } if (type == 'EDIT') { const resp = await editData({ ...result }); if (resp) { tableRef.current?.reload(); message.success('操作成功!'); } } return true; } const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' }) => { return ( 编辑 : 新增 } onFinish={(val) => { return updateTable(type == 'EDIT' ? { ...record, ...val } : { ...val }, type); }} modalProps={{ destroyOnClose: true }} colProps={{ span: 24 }} grid > { const resp = await getDicDataBySysId(KcimCenterSysId, 'MED_SERVICE_ITEM_TYPE'); if (resp) { const { dataVoList = [] } = resp; return dataVoList.map((a: any) => ({ label: a.name, value: a.code })) } return [] }} rules={[{ required: false, message: '项目分类不能为空!' }]} /> { const resp = await getStandItemList({ name: keyWords, pageSize: 100, current: 1 }); if (resp) { return resp.list.map((a: any) => ({ label: a.name, value: a.code })) } else { return [] } }} /> ) } const tableDataSearchHandle = (paramName: string) => { set_tableDataFilterParams({ ...tableDataFilterParams, [`${paramName}`]: tableDataSearchKeywords }) } const downloadTemplate = async () => { await downloadTemplateReq('/costAccount/setting/exportItem'); }; const closeDrawer = () => { set_drawerVisible(false); } const switchBatchHandle = (bool:boolean)=>{ set_ifBatchMatch(bool); } const importData = () => { return ( 导入 } submitter={{ render: (props, defaultDoms) => { const needBtn = defaultDoms.filter((b) => { return b.key != 'rest'; }); return [ ...needBtn, ]; }, }} onFinish={async (values) => { const { importFile: { fileList }, } = values; let formData = new FormData(); formData.append('file', fileList[0].originFileObj); const resp = await importDataPost(formData); if (resp) { tableRef.current?.reload(); return true; } }} > downloadTemplate()} /> ); }; const batchMatchInit = async () => { const resp = await getAllNeedMatchItems(); if (resp) { let needItem = undefined; for (const item of resp) { if (!item.match) { set_currentSelectRow(item); needItem = item; break; // 满足条件后退出循环 } } if(!needItem){ set_currentSelectRow(resp[0]); } } } useEffect(() => { if (ifBatchMatch) { batchMatchInit(); } }, [ifBatchMatch]); return ( <>
收费项目设置 {ifBatchMatch ? set_ifBatchMatch(false)}>收费项目管理 : '收费项目管理'} {ifBatchMatch && 项目匹配}
{ set_drawerVisible(bool); if (!bool){ set_currentSelectRow(undefined); tableRef.current?.reload(); } }} headerStyle={{ height: 0, padding: 0, overflow: 'hidden' }} bodyStyle={{ padding: 0 }} destroyOnClose={true} > {drawerType == 1 && set_drawerVisible(bool)} />} {drawerType == 2 && set_drawerVisible(bool)} />} { !ifBatchMatch ? ( <>
检索: tableDataSearchHandle('name')} /> } onChange={(e) => { set_tableDataSearchKeywords(e.target.value); if (e.target.value.length == 0) { set_tableDataFilterParams({ ...tableDataFilterParams, name: '' }); } }} onPressEnter={(e) => { set_tableDataFilterParams({ ...tableDataFilterParams, name: (e.target as HTMLInputElement).value }); }} />
{ set_stopStat(bool ? 1 : 0); tableRef.current?.reload(); } }} />只显示未对照项目 {/* mapBtnHandle()}>对照 */} set_ifBatchMatch(true)}>批量匹配 {importData()}
getTableData(params)} // expandable={{ expandedRowRender }} />
):( currentSelectRow&& set_drawerVisible(bool)} /> ) }
) }