123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- /*
- * @Author: code4eat awesomedema@gmail.com
- * @Date: 2023-03-03 11:30:33
- * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2024-06-11 10:44:27
- * @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 { createFromIconfontCN } from '@ant-design/icons';
- import { ModalForm, ProFormDatePicker } from '@ant-design/pro-form';
- import FormItem from 'antd/es/form/FormItem';
- import { DatePicker, Input, message, Modal, Dropdown } from 'antd';
- import { useEffect, useRef, useState } from 'react';
- import type { MenuProps } from 'antd';
- import { getData, downloadTemplateReq, importDataPost, getIncomeCostDataImportErrList, cancelIncomeCostDataImport, rebackIncomeCostDataImport } from './service';
- import './style.less';
- import moment from 'moment';
- import 'moment/locale/zh-cn';
- import locale from 'antd/es/date-picker/locale/zh_CN';
- import KCIMPagecontainer from '@/components/KCIMPageContainer';
- import { KCIMTable } from '@/components/KCIMTable';
- import KCIMUpload from '@/components/KCIMUpload';
- import { TableDataResponse } from 'typings';
- import { ActionType, ProColumns, ProFormSelect } from '@ant-design/pro-components';
- import { importEmpCostDataPost } from '../empCostDataImport/service';
- import { importPatientInfoDataPost } from '../patientInfoImport/service';
- import { importPatientChargeItemDataPost } from '../patientChargeItemsImport/service';
- const IconFont = createFromIconfontCN({
- scriptUrl: '',
- });
- const { host } = location;
- const currentData = `${new Date().getFullYear()}-${(new Date().getMonth() + 1).toString().padStart(2, '0')}`
- let currentImportkey: any = undefined;
- const items: MenuProps['items'] = [
- {
- key: '1',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/excel/getShareParamTemplate'); currentImportkey = 1 }}>
- 成本分摊参数模板
- </a>
- ),
- },
- {
- key: '2',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/excel/getImportIncomeProductAccountTemplate'); currentImportkey = 2 }} >
- 收入数据模板
- </a>
- ),
- },
- {
- key: '3',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/excel/getImportCostProductAccountTemplate'); currentImportkey = 3 }}>
- 成本数据模板
- </a>
- ),
- },
- {
- key: '4',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/computeImport/exportEmpCostList'); currentImportkey = 4 }}>
- 人事成本数据
- </a>
- ),
- },
- {
- key: '5',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/computeImport/exportPatientInfo'); currentImportkey = 5 }}>
- 患者信息
- </a>
- ),
- },
- {
- key: '6',
- label: (
- <a target="_blank" rel="noopener noreferrer" onClick={() => { downloadTemplateReq('/gateway/costAccount/computeImport/exportPatientItem'); currentImportkey = 6 }}>
- 患者收费项目
- </a>
- ),
- },
- ];
- let _computeDate: string | undefined = undefined;
- export default function IncomeCostDataImport({ date, btnPerm }: { date: string, btnPerm: string }) {
- const [computeDate, set_computeDate] = useState(date);
- const [tableDataFilterParams, set_tableDataFilterParams] = useState<any>({ computeDate: currentData });
- const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState('');
- const tableRef = useRef<ActionType>();
- const [currentEditRow, set_currentEditRow] = useState<undefined | any>(undefined);
- const [ifShowGetBtn, set_ifShowGetBtn] = useState(false);
- const [ifShowCancelBtn, set_ifShowCancelBtn] = useState(false);
- const columns: ProColumns[] = [
- {
- title: '文件编号',
- dataIndex: 'id',
- width: '15%',
- },
- {
- title: '文件名称',
- width:'40%',
- dataIndex: 'fileName',
- renderText(text, record, index, action) {
- const {fileUrl} = record;
- const userData = localStorage.getItem('userData');
- const { token } = JSON.parse(userData as string);
- return <a key='download' href={`${fileUrl}?token=${token}`} target="_blank">{text}</a>
- },
- },
- {
- title: '导入类型',
- width: '15%',
- dataIndex: 'fileType',
- },
- {
- title: '导入人员',
- width: '15%',
- dataIndex: 'userName',
- },
- {
- title: '导入时间',
- width: '15%',
- dataIndex: 'dateTime',
- },
- {
- title: '操作',
- width: '10%',
- dataIndex: 'option',
- renderText(text, record) {
- const { errStatus, rollbackStatus } = record;
-
- return [
- <span key='act' style={{ color: '#3377FF', cursor: 'pointer' }}
- onClick={() => {
- optionBtnGrouphandle(errStatus, record)
- }}>{errStatus == 1 ? '错误详情' :rollbackStatus == 1?'复原导入':'撤销导入'}</span>
- ]
- },
- }
- ];
- const getTableData = async (params: any): Promise<TableDataResponse | any[]> => {
- const resp = await getData({ ...params, ...tableDataFilterParams });
- if (resp) {
- const { list, totalCount, pageSize, current, totalPage } = resp;
- if (totalCount == 0 && current != 1) {
- return getTableData({ ...params, current: current - 1 });
- } else {
- return {
- data: list,
- success: true,
- total: totalCount,
- pageSize: pageSize,
- totalPage: totalPage,
- };
- }
- }
- return [];
- };
- const tableDataSearchHandle = (paramName: string) => {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- [`${paramName}`]: tableDataSearchKeywords
- })
- }
- const getErrorInfo = async (id: number) => {
- const resp = await getIncomeCostDataImportErrList({ id });
- if (resp) {
- return {
- data: resp,
- success: true,
- };
- } else {
- return []
- }
- }
- const optionBtnGrouphandle = async (errStatus: number, record: any) => {
- set_currentEditRow(record);
- const { id,rollbackStatus } = record;
- if (errStatus != 1) {
- let resp = undefined
- if(rollbackStatus != 1){
- //撤销
- resp = await cancelIncomeCostDataImport(id,date);
- }
- if(rollbackStatus == 1){
- //复原
- resp = await rebackIncomeCostDataImport(id,date);
- }
-
- if (resp){
- message.success(rollbackStatus == 1?'还原成功!':'撤销成功!');
- tableRef.current?.reload();
- }
- } else {
- Modal.info({
- title: '错误详情',
- icon: '',
- content: (
- <>
- <KCIMTable
- rowKey='id'
- columns={[
- {
- title: '行数',
- width: 50,
- dataIndex: 'total',
- },
- {
- title: '错误信息',
- dataIndex: 'errMessage',
- ellipsis: true
- }
- ]}
- request={() => getErrorInfo(id)}
- />
- </>
- )
- })
- }
- }
- const importData = () => {
- return (
- <ModalForm
- width={360}
- title={`导入数据`}
- trigger={
- <a className="import" key="3">
- 导入
- </a>
- }
- initialValues={{dateTime:date}}
- submitter={{
- render: (props, defaultDoms) => {
- const needBtn = defaultDoms.filter((b) => {
- return b.key != 'rest';
- });
- return [
- // <Button
- // key="ok"
- // onClick={auditType == '0' ? () => downloadTemplate(index) : () => { }}
- // >
- // 下载模板
- // </Button>,
- ...needBtn,
- ];
- },
- }}
- onFinish={async (values) => {
- try {
- const {
- importFile: { fileList },
- fileType
- } = values;
- if (fileType <= 3) {
- let formData = new FormData();
- formData.append('file', fileList[0].originFileObj);
- formData.append('dateTime', date);
- formData.append('fileType', fileType);
- const resp = await importDataPost(formData);
- if (resp) {
- tableRef.current?.reload();
- return true;
- }
- } else {
- if (fileType == 4) {
- //人事成本
- let formData = new FormData();
- formData.append('file', fileList[0].originFileObj);
- formData.append('computeDate', date);
- const resp = await importEmpCostDataPost(formData);
- if (resp) {
- tableRef.current?.reload();
- return true;
- }
- }
- if (fileType == 5) {
- //患者信息
- let formData = new FormData();
- formData.append('file', fileList[0].originFileObj);
- formData.append('computeDate', date);
- const resp = await importPatientInfoDataPost(formData);
- if (resp) {
- tableRef.current?.reload();
- return true;
- }
- }
- if (fileType == 6) {
- //患者收费项目
- let formData = new FormData();
- formData.append('file', fileList[0].originFileObj);
- formData.append('computeDate', date);
- const resp = await importPatientChargeItemDataPost(formData);
- if (resp) {
- tableRef.current?.reload();
- return true;
- }
- }
- }
- } catch (err) {
- console.log({ err });
- }
- }}
- >
- {/* <ProFormDatePicker label='数据所属年月:' name='dateTime'
- width={328}
- fieldProps={{
- picker: 'month',
- locale: locale,
- format: 'YYYY-MM'
- }}
- disabled
- placeholder="选择年月"
- rules={[
- {
- required: true,
- message: '请选择年月',
- },
- ]}
- /> */}
- <ProFormSelect
- rules={[
- {
- required: true,
- message: '请选择数据类型',
- },
- ]}
- options={[
- {
- value: 1,
- label: '成本分摊参数值',
- },
- {
- value: 2,
- label: '收入数据',
- },
- {
- value: 3,
- label: '成本数据',
- },
- {
- value: 4,
- label: '人事成本数据',
- },
- {
- value: 5,
- label: '患者信息',
- },
- {
- value: 6,
- label: '患者收费项目',
- },
- ]}
- name="fileType"
- label="选择数据类型"
- />
- <FormItem name={'importFile'}>
- <KCIMUpload ifShowTemplateDownload={false} ifShowTip={false} />
- </FormItem>
- </ModalForm>
- );
- };
- useEffect(() => {
- if (date) {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- computeDate: date,
- });
- _computeDate = date
- }
- }, [date]);
- useEffect(() => {
- if (btnPerm) {
- const [a, b] = btnPerm.split('|');
- set_ifShowCancelBtn(b == '1');
- set_ifShowGetBtn(a == '1')
- }
- }, [btnPerm])
- useEffect(() => { }, []);
- return (
- <div className="IncomeCostDataImport" >
- <div className="toolBar">
- <div className="filter">
- {/* <div className="filterItem">
- {
- <div className="search">
- <span>核算年月:</span>
- <DatePicker
- onChange={(data, dateString) => {
- set_computeDate(dateString);
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- computeDate: dateString,
- });
- }}
- picker="month"
- locale={locale}
- defaultValue={moment(`${new Date().getFullYear()}-${(new Date().getMonth() + 1).toString().padStart(2, '0')}`, 'YYYY-MM')}
- format="YYYY-MM"
- placeholder="选择年月"
- />
- </div>
- }
- </div> */}
- <div className='filterItem' style={{ width: 205 }}>
- <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
- <Input placeholder={'文件名称'} allowClear
- suffix={
- <IconFont type="iconsousuo" style={{ color: '#99A6BF' }} onClick={() => tableDataSearchHandle('fileName')} />
- }
- onChange={(e) => {
- set_tableDataSearchKeywords(e.target.value);
- if (e.target.value.length == 0) {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- fileName: ''
- });
- }
- }}
- onPressEnter={(e) => {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- fileName: ((e.target) as HTMLInputElement).value
- });
- }}
- />
- </div>
- </div>
- <div className="btnGroup">
- <>
- <Dropdown menu={{ items }} placement="bottomLeft">
- <span className='normal'>模板下载</span>
- </Dropdown>
- {importData()}
- </>
- </div>
- </div>
- <div style={{ marginTop: 16 }}>
- <KCIMTable
- columns={columns}
- actionRef={tableRef}
- rowKey="id"
- scroll={{y:`calc(100vh - 259px)`}}
- params={tableDataFilterParams}
- request={(params) => getTableData(params)}
- />
- </div>
- </div>
- );
- }
|