/*
* @Author: your name
* @Date: 2021-09-14 10:22:09
* @LastEditTime: 2021-10-28 16:05:37
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /MedicalWisdomCheckSys/src/pages/GradeHospitalAccreditation/articleManagement/index.tsx
*/
import React, { useRef, useEffect, useState } from 'react'
import MccsPageContainer from '@/components/MccsPageContainer/index'
import MccsProCard from '@/components/MccsProCard/index';
import { useModel } from 'umi';
import MccsFileTree from '@/components/MccsFileTree/index';
import MccsTable from '@/components/MccsTable/index';
import MccsScoreBanner from '@/components/MccsScoreBanner/index';
import MccsRecordList from '@/components/MccsRecordList/index';
import MccsDrawerForm from '@/components/MccsDrawerForm/index';
import MccsClickableTabs from '@/components/MccsClickableTabs/index';
import MccsUpload from '@/components/MccsUpload/index';
import { MccsModal } from '@/components/MccsModal';
import type { ProFormInstance, } from '@ant-design/pro-form';
import { Form, Table, Space, Row, Col, Button, Tabs } from 'antd'
import {
ProFormText,
ProFormSelect,
ProFormDependency,
} from '@ant-design/pro-form';
import './index.less';
type ArticleManagementProps = {
//组件配置信息
columnsFromProps?: {}[],
headerConcig?: { [key: string]: any }, //配置参考ProPageContainer
isModeTwo?: boolean
}
type SelectedRowsType = {
[propsName: string]: any
}
const { TabPane } = Tabs;
const columns = [
{
key: 'keyword',
hideInTable: true,
renderFormItem: (item: any, { type }: any, form: any) => {
if (type === 'form') {
return null;
}
return (
)
},
},
{
title: '条款',
key: 'numStr',
dataIndex: 'numStr',
hideInSearch: true,
},
{
title: '条文',
dataIndex: 'name',
hideInSearch: true,
width: '35%',
ellipsis: true
},
{
title: '负责单位',
dataIndex: 'responsibilityDepartmentName',
hideInSearch: true,
},
{
title: '负责人',
dataIndex: 'responsibilityUserName',
hideInSearch: true,
},
{
title: '自评',
hideInSearch: true,
dataIndex: 'selfEvaluation',
},
// {
// title: '现场查核',
// hideInSearch: true,
// dataIndex: 'siteEvaluation',
// },
{
title: '目标',
dataIndex: 'targetEvaluation',
hideInSearch: true,
},
{
title: '系统评分',
dataIndex: 'systemEvaluation',
hideInSearch: true,
},
]
//条文管理
const ArticleManagement: React.FC = (props) => {
const { columnsFromProps = [], headerConcig, isModeTwo } = props;
const { articleManagement } = useModel('allModels');
const drawerFormRef = useRef();
const {
isLeaf,
treeData,
getTableData,
currentActivedTree,
setCurrentActivedTree,
scoreList,
getDepartmentRequest,
departmentManagers,
getDepartment,//获取责任单位
...restModelData
} = articleManagement;
const tableRef = useRef();
const [articleSettingFormInit, setArticleSettingFormInit] = useState<{}>({}); //条文设置表单回显默认值
const [defaultOpened, setDefaultOpened] = useState();
const onSelectHandle = (data: MccsFileTree.childTree) => {
//左侧树节点点击回调
setCurrentActivedTree(data);
setArticleSettingFormInit({});//清空默认值
//重新获取数据
tableRef?.current?.getTableRef().current?.reload();
restModelData.setTabKey('1');
}
const batchSelfAssessment = (rowkeys: number[] | string[]) => {
//批量设置
restModelData.setDrawerFormType('BATCHSETTING');
restModelData.setSelectedRowKeys(rowkeys);
restModelData.setDrawerVisible(true);
}
const articleSetBtnHandle = () => {
//条文设置
// console.log({ articleSettingFormInit });
restModelData.setDrawerFormType('ARTICLE_SET');
restModelData.setDrawerVisible(true);
}
const onVisibleChangeHandle = (visible: boolean) => {
//drawer展示控制
!visible && setArticleSettingFormInit({});//清空默认值
restModelData.setDrawerVisible(visible);
}
const onModalVisibleChange = (visible: boolean) => {
//表单弹窗
// console.log('uploadFormInitValue',restModelData.uploadFormInitValue);
!visible && restModelData.setUploadFormInitValue(undefined);
restModelData.setModalVisible(visible);
}
const upLoadFileHandle = (formInitData?: any) => {
//因为modalForm开启了request+params获取表单默认值,
//所以必须先设置默认值才能开启弹窗
if (formInitData) {
const { fileUrl, recordTypeName, accountType, fileName } = formInitData;
// console.log({formInitData});
restModelData.setUploadFormInitValue({
tab: { label: accountType, value: { label: recordTypeName, value: recordTypeName } },
files: [{
uid: new Date().getTime(),
name: fileName,
status: 'done',
url: fileUrl
}]
});
} else {
restModelData.setUploadFormInitValue({})
}
restModelData.getUploadLedgerType().then(data => {
//设置上传台账类型
restModelData.setUploadLedgerTypeList(data);
})
restModelData.setModalVisible(true);
}
const actionNodeFunc = (data: any) => {
//渲染记录列表操作按钮
// console.log({ data });
const { fileUrl } = data;
const reupload = () => {
upLoadFileHandle(data);
}
return isModeTwo ? (
//台账上传
重新上传
) : (
//条文管理
下载文件
)
}
const uploadLedgerChangeHandle = (tabData: any) => {
//台账上传类型选择回调
}
useEffect(() => {
if (restModelData.reloadRightContent) {
//重新获取数据
tableRef?.current?.getTableRef().current?.reload();
tableRef?.current?.getTableRef().current?.clearSelected();
}
}, [restModelData]);
useEffect(() => {
if (restModelData.leafData) {
const { responsibilityDepartmentId, responsibilityDepartmentName, responsibilityUserId, targetEvaluation, responsibilityUserName, accountType } = restModelData.leafData;
if (responsibilityDepartmentName && responsibilityDepartmentId) {
setArticleSettingFormInit({
responsibilityDepartment: { label: responsibilityDepartmentName, value: responsibilityDepartmentId },
responsibilityUser: { label: responsibilityUserName, value: responsibilityUserId },
targetScores: { label: targetEvaluation, value: targetEvaluation },
articleType: { label: accountType, value: accountType },
});
}
}
}, [restModelData.leafData]);
useEffect(() => {
if (isModeTwo) {
//设置当前模块模式
restModelData.setModuleMode(isModeTwo);
} else {
//设置当前模块模式
restModelData.setModuleMode(false);
}
}, [props]);
useEffect(() => {
if (treeData.length > 0) {
//默认展开书结构第一个结点
const { id } = treeData[0];
setDefaultOpened(`${id}`);
}
}, [treeData]);
useEffect(() => {
restModelData.getArticleTreeData();
restModelData.getCurrentHospScore();
}, [])
return (
{restModelData.currentHospSelfScoreAndOthers}
}}
>
{
restModelData.modalVisible && (
restModelData.uploadFile(values)}
initialValues={!restModelData.uploadFormInitValue ? {} : restModelData.uploadFormInitValue}
onVisibleChange={onModalVisibleChange}
params={restModelData.uploadFormInitValue}
request={(params: any) => {
return Promise.resolve(params)
}}
>
选择类型
{
({tab})=>{
return tab&&tab.value.label == '制度'&&(
await restModelData.getSelectableRuleChilds(tab.value.value)}
placeholder="请选择"
rules={[{ required: true, message: '请选择!' }]}
/>
)
}
}
)
}
{
//条文设置/表格批量设置drawer弹窗
restModelData.drawerVisible && (
restModelData.drawerFormType == 'ARTICLE_SET' ? restModelData.setArticle(values) : restModelData.batchSetting(values)}
onVisibleChange={onVisibleChangeHandle}
>
负责人及单位
{
//责任单位修改时清空责任人
drawerFormRef.current?.setFieldsValue({ ...articleSettingFormInit, responsibilityUser: { label: '', value: '' } });
getDepartment(value, option)
}
}}
rules={[{ required: true, message: '请选择单位!' }]}
/>
{({ responsibilityDepartment }) => {
return (
getManagers(value,option)
}}
rules={[{ required: true, message: '请选择负责人!' }]}
/>
)
}}
目标分数
{
true && (
<>
条文组别
>
)
}
)
}
{
defaultOpened&&(
)
}
{
!isLeaf && (
0 ? columnsFromProps : columns}
request={getTableData}
search={{
span: 6
}}
rowSelection={{
// 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
// 注释该行则默认不显示下拉选项
selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
}}
rowKey="id"
tableAlertOptionRender={({ selectedRowKeys, selectedRows, onCleanSelected }: { selectedRowKeys: number[] | string[], selectedRows: SelectedRowsType[], onCleanSelected: () => void }) => {
return (
);
}}
// searchNode={searchNode()}
/>
)
}
{
isLeaf && (
{currentActivedTree ? currentActivedTree.title : ''}
条文组别:
{restModelData.leafData?.accountType}
负责单位:
{restModelData.leafData?.responsibilityDepartmentName}
负责人:
{restModelData.leafData?.responsibilityUserName}
{
isModeTwo && (
restModelData.setTabKey(key)}>
upLoadFileHandle()}>上传文件
restModelData.delHistoryRecordHandle(data)}
actionNode={(data) => actionNodeFunc(data)}
/>
开始自评
restModelData.onSelfEvolutionTabChange(value)}
data={restModelData.targetScores}
value={restModelData.selectedSelfEvolution}
/>
)
}
{
!isModeTwo && (
<>
条文设置
{ console.log({ data }) }}
//restModelData.delHistoryRecordHandle(data)
actionNode={(data) => actionNodeFunc(data)}
/>
>
)
}
)
}
)
}
export default ArticleManagement