index.tsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-09-14 10:22:09
  4. * @LastEditors: Please set LastEditors
  5. * @Description: In User Settings Edit
  6. * @FilePath: /MedicalWisdomCheckSys/src/pages/GradeHospitalAccreditation/articleManagement/index.tsx
  7. */
  8. import React, { useRef, useEffect, useState } from 'react'
  9. import MccsPageContainer from '@/components/MccsPageContainer/index'
  10. // import MccsProCard from '@/components/MccsProCard/index';
  11. import { useModel } from 'umi';
  12. import MccsFileTree from '@/components/MccsFileTree/index';
  13. import MccsTable from '@/components/MccsTable/index';
  14. import MccsClickableTabs from '@/components/MccsClickableTabs/index';
  15. import MccsUpload from '@/components/MccsUpload/index';
  16. import { MccsModal } from '@/components/MccsModal';
  17. import { getDepartmentList } from './server';
  18. import { getScoreLevelData } from '@/pages/PlatformMana/generalSetting/serve';
  19. import { Form, Table, Space, Button, Switch, Select } from 'antd'
  20. import {
  21. ProFormText,
  22. ProFormSelect,
  23. ProFormDependency,
  24. } from '@ant-design/pro-form';
  25. import './index.less';
  26. import ArticleDetail from './components/articleDetailModule';
  27. import MccsDrawerForm from '@/components/MccsDrawerForm/index';
  28. const { Option } = Select;
  29. type ArticleManagementProps = {
  30. //组件配置信息
  31. columnsFromProps?: {}[],
  32. headerConcig?: { [key: string]: any }, //配置参考ProPageContainer
  33. isModeTwo?: boolean
  34. }
  35. type SelectedRowsType = {
  36. [propsName: string]: any
  37. }
  38. export enum ActType {
  39. 'NOACT', //不操作
  40. 'ADD',
  41. 'EDIT',
  42. 'DEL'
  43. };
  44. //条文管理
  45. const ArticleManagement: React.FC<ArticleManagementProps> = (props) => {
  46. const { columnsFromProps = [], headerConcig, isModeTwo } = props;
  47. const { articleManagement } = useModel('allModels');
  48. const {
  49. isLeaf,
  50. treeData,
  51. getTableData,
  52. currentActivedTree,
  53. setCurrentActivedTree,
  54. scoreList,
  55. getDepartmentRequest,
  56. departmentManagers,
  57. getDepartment,//获取责任单位
  58. currentSelectedActObj,
  59. setdetailDrawerVisible,
  60. detailDrawerVisible,
  61. ...restModelData
  62. } = articleManagement;
  63. const tableRef = useRef<MccsTable.MccsTableRef>();
  64. const [defaultOpened, setDefaultOpened] = useState<string>();
  65. const [departments, setdepartments] = useState<{ label: string; value: string }[]>([]);
  66. const columns = [
  67. {
  68. key: 'keyword',
  69. hideInTable: true,
  70. renderFormItem: (item: any, { type }: any, form: any) => {
  71. if (type === 'form') {
  72. return null;
  73. }
  74. return (
  75. <Form.Item name='keyword'>
  76. <ProFormText placeholder='条文/条款' />
  77. </Form.Item>
  78. )
  79. },
  80. },
  81. {
  82. key: 'department',
  83. hideInTable: true,
  84. renderFormItem: (item: any, { type }: any, form: any) => {
  85. if (type === 'form') {
  86. return null;
  87. }
  88. return (
  89. <Form.Item name='department'>
  90. <Select
  91. showSearch
  92. placeholder="请选择单位"
  93. >
  94. {
  95. departments.map((item, index) => {
  96. return (
  97. <Option value={item.value} key={index}>{item.label}</Option>
  98. )
  99. })
  100. }
  101. </Select>
  102. </Form.Item>
  103. )
  104. },
  105. },
  106. {
  107. key: 'name',
  108. hideInTable: true,
  109. renderFormItem: (item: any, { type }: any, form: any) => {
  110. if (type === 'form') {
  111. return null;
  112. }
  113. return (
  114. <Form.Item name='name'>
  115. <ProFormText placeholder='负责人' />
  116. </Form.Item>
  117. )
  118. },
  119. },
  120. {
  121. key: 'selfEvaluation',
  122. hideInTable: true,
  123. renderFormItem: (item: any, { type }: any, form: any) => {
  124. if (type === 'form') {
  125. return null;
  126. }
  127. return (
  128. <ProFormSelect
  129. name="selfEvaluation"
  130. request={async () => {
  131. const data = await getScoreLevelData();
  132. if (!data) return [];
  133. return data.map(item => ({ label: item.levelNumber, value: item.levelNumber }))
  134. }}
  135. placeholder="选择自评"
  136. rules={[{ required: false }]}
  137. />
  138. )
  139. },
  140. },
  141. {
  142. key: 'targetEvaluation',
  143. hideInTable: true,
  144. renderFormItem: (item: any, { type }: any, form: any) => {
  145. if (type === 'form') {
  146. return null;
  147. }
  148. return (
  149. <ProFormSelect
  150. name="targetEvaluation"
  151. request={async () => {
  152. const data = await getScoreLevelData();
  153. if (!data) return [];
  154. return data.map(item => ({ label: item.levelNumber, value: item.levelNumber }))
  155. }}
  156. placeholder="选择目标"
  157. rules={[{ required: false }]}
  158. />
  159. )
  160. },
  161. },
  162. {
  163. title: '条款',
  164. key: 'numStr',
  165. dataIndex: 'numStr',
  166. hideInSearch: true,
  167. },
  168. {
  169. title: '条文',
  170. dataIndex: 'name',
  171. hideInSearch: true,
  172. width: '35%',
  173. ellipsis: true
  174. },
  175. {
  176. title: '负责单位',
  177. dataIndex: 'responsibilityDepartmentName',
  178. hideInSearch: true,
  179. },
  180. {
  181. title: '负责人',
  182. dataIndex: 'responsibilityUserName',
  183. hideInSearch: true,
  184. },
  185. {
  186. title: '自评',
  187. hideInSearch: true,
  188. dataIndex: 'selfEvaluation',
  189. },
  190. // {
  191. // title: '现场查核',
  192. // hideInSearch: true,
  193. // dataIndex: 'siteEvaluation',
  194. // },
  195. {
  196. title: '目标',
  197. dataIndex: 'targetEvaluation',
  198. hideInSearch: true,
  199. },
  200. {
  201. title: '系统评分',
  202. dataIndex: 'systemEvaluation',
  203. hideInSearch: true,
  204. },
  205. {
  206. title: '操作',
  207. width: 100,
  208. valueType: 'option',
  209. render: (_: any, record: any) => {
  210. return [<a key="1" onClick={() => openDetailInDrawer(record)}>详情</a>]
  211. },
  212. },
  213. ]
  214. //左侧树搜索回调
  215. const searchHandle = (val: any) => {
  216. restModelData.getArticleTreeData(val);
  217. }
  218. const onSelectHandle = (data: MccsFileTree.childTree) => {
  219. //左侧树节点点击回调
  220. setCurrentActivedTree(data);
  221. restModelData.setCurrentSelectedActObj(data);
  222. articleManagement.setArticleSettingFormInit({});//清空默认值
  223. //重新获取数据
  224. tableRef?.current?.getTableRef().current?.reload();
  225. }
  226. const batchSelfAssessment = (rowkeys: number[] | string[]) => {
  227. //批量设置
  228. restModelData.setDrawerFormType('BATCHSETTING');
  229. restModelData.setSelectedRowKeys(rowkeys);
  230. restModelData.setDrawerVisible(true);
  231. }
  232. const onModalVisibleChange = (visible: boolean) => {
  233. //表单弹窗
  234. // console.log('uploadFormInitValue',restModelData.uploadFormInitValue);
  235. !visible && restModelData.setUploadFormInitValue(undefined);
  236. restModelData.setModalVisible(visible);
  237. }
  238. const uploadLedgerChangeHandle = (tabData: any) => {
  239. //台账上传类型选择回调
  240. }
  241. const openDetailInDrawer = (record: any) => {
  242. // restModelData.setRecords(record)
  243. setdetailDrawerVisible(true);
  244. restModelData.setCurrentSelectedActObj(record);
  245. getTableData({ id: record.id});
  246. }
  247. const taizhangImplementationCommit = () => {
  248. //台账执行情况编辑结果提交
  249. restModelData.commitTaizhangImplementationHandle();
  250. }
  251. const getDepartments = async () => {
  252. const resp = await getDepartmentList();
  253. if (resp) {
  254. const { list = [] } = resp;
  255. setdepartments(list.map(t => ({ label: t.name, value: t.name })));
  256. }
  257. }
  258. useEffect(() => {
  259. if (restModelData.reloadRightContent) {
  260. //重新获取数据
  261. tableRef?.current?.getTableRef().current?.reload();
  262. tableRef?.current?.getTableRef().current?.clearSelected();
  263. }
  264. }, [restModelData]);
  265. useEffect(() => {
  266. //点击叶子结点时回调
  267. if (restModelData.leafData) {
  268. const { responsibilityDepartmentId, responsibilityDepartmentName, responsibilityUserId, targetEvaluation, responsibilityUserName, accountType } = restModelData.leafData.reviewArticle;
  269. if (responsibilityDepartmentName && responsibilityDepartmentId) {
  270. articleManagement.setArticleSettingFormInit({
  271. responsibilityDepartment: { label: responsibilityDepartmentName, value: responsibilityDepartmentId },
  272. responsibilityUser: { label: responsibilityUserName, value: responsibilityUserId },
  273. targetScores: { label: targetEvaluation, value: targetEvaluation },
  274. articleType: { label: accountType, value: accountType },
  275. });
  276. }
  277. restModelData.getGradeOptions(); //获取可选档次
  278. restModelData.getAccoutTypeOptions(); //可选类型
  279. }
  280. }, [restModelData.leafData]);
  281. useEffect(() => {
  282. if (isModeTwo) {
  283. //设置当前模块模式,台账上传共用时
  284. restModelData.setModuleMode(isModeTwo);
  285. } else {
  286. //设置当前模块模式
  287. restModelData.setModuleMode(false);
  288. }
  289. }, [props]);
  290. useEffect(() => {
  291. if (treeData.length > 0) {
  292. //默认展开书结构第一个结点
  293. //树结构组件会默认执行一遍onSelectHandle,将选中结点信息传出来
  294. const { id } = treeData[0];
  295. setDefaultOpened(`${id}`);
  296. }
  297. }, [treeData]);
  298. useEffect(() => {
  299. //页面加载完
  300. //获取左侧输结构
  301. restModelData.getArticleTreeData();
  302. //获取当前评分
  303. restModelData.getCurrentHospScore();
  304. getDepartments();
  305. }, [])
  306. return (
  307. <div className='ArticleManagement'>
  308. <MccsDrawerForm
  309. width={1000}
  310. visible={detailDrawerVisible}
  311. onVisibleChange={(bool: boolean) => setdetailDrawerVisible(bool)}
  312. submitter={false}
  313. >
  314. <ArticleDetail />
  315. </MccsDrawerForm>
  316. <MccsPageContainer
  317. config={headerConcig ? headerConcig : {
  318. content: !isModeTwo && <div style={{ textAlign: 'right', fontSize: 12, color: '#525866' }}>{restModelData.currentHospSelfScoreAndOthers}</div>,
  319. footer: restModelData.editMode ? [
  320. <Button key="3" onClick={() => restModelData.setEditMode(false)}>取消</Button>,
  321. <Button key="2" type="primary" onClick={() => taizhangImplementationCommit()}>
  322. 保存
  323. </Button>,
  324. ] : null
  325. }}
  326. >
  327. {
  328. restModelData.modalVisible && (
  329. //台账上传弹窗
  330. <MccsModal title='台账上传' visible={restModelData.modalVisible}
  331. onFinish={(values: any) => restModelData.uploadFile(values)}
  332. initialValues={!restModelData.uploadFormInitValue ? {} : restModelData.uploadFormInitValue}
  333. onVisibleChange={onModalVisibleChange}
  334. params={restModelData.uploadFormInitValue}
  335. request={(params: any) => {
  336. return Promise.resolve(params)
  337. }}
  338. >
  339. <div className='formItemTitle'>选择类型</div>
  340. <Form.Item name='tab' rules={[
  341. {
  342. required: true,
  343. message: '请选择类型!',
  344. },
  345. ]}>
  346. <MccsClickableTabs
  347. //重新上传不允许更改类型
  348. disabled={(restModelData.uploadFormInitValue && JSON.stringify(restModelData.uploadFormInitValue) != '{}') ? true : false}
  349. type='multi'
  350. onChange={uploadLedgerChangeHandle}
  351. data={restModelData.uploadLedgerTypeList}
  352. />
  353. </Form.Item>
  354. <ProFormDependency name={['tab']}>
  355. {
  356. ({ tab }) => {
  357. //制度特殊处理
  358. return tab && tab.value.label == '制度' && (
  359. <ProFormSelect
  360. name="publicCateId"
  361. label="制度下类型"
  362. width='md'
  363. request={async () => await restModelData.getSelectableRuleChilds(tab.value.value)}
  364. placeholder="请选择"
  365. rules={[{ required: true, message: '请选择!' }]}
  366. />
  367. )
  368. }
  369. }
  370. </ProFormDependency>
  371. <Form.Item name='files' rules={[
  372. {
  373. required: true,
  374. message: '请上传文件!',
  375. },
  376. ]}>
  377. <MccsUpload maxCount={10} />
  378. </Form.Item>
  379. </MccsModal>
  380. )
  381. }
  382. <div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', width: '100%' }}>
  383. <div style={{ height: '85vh', width: restModelData.editMode ? 0 : '25%', transition: 'width 0.2s ease-in', padding: '16px', backgroundColor: '#fff', marginRight: '16px', boxSizing: 'border-box' }} >
  384. {
  385. defaultOpened && (
  386. <MccsFileTree
  387. treeData={treeData}
  388. defaultSelected={defaultOpened}
  389. onSelectHandle={onSelectHandle}
  390. searchHandle={searchHandle}
  391. renderFilter={() => {
  392. //只在台账上传时展示
  393. return isModeTwo ? (
  394. <div className='onlyMyselfFilter'>
  395. <span>只看我的</span>
  396. <Switch size='small' onChange={(checked) => restModelData.setIsShowMineOnly(checked)} />
  397. </div>
  398. ) : null
  399. }}
  400. editable={false}
  401. />
  402. )
  403. }
  404. </div>
  405. <div style={{ padding: 0, width: restModelData.editMode ? '100%' : '75%', transition: 'width 0.2s ease-in' }}>
  406. <div className='card' style={{ display: currentActivedTree?.isLeaf ? 'none' : 'block' }}>
  407. <MccsTable
  408. ref={tableRef}
  409. columns={columnsFromProps.length > 0 ? columnsFromProps : columns}
  410. request={getTableData}
  411. search={{
  412. span: 6
  413. }}
  414. rowSelection={isModeTwo ? false : {
  415. // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
  416. // 注释该行则默认不显示下拉选项
  417. selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
  418. }}
  419. rowKey="id"
  420. tableAlertOptionRender={({ selectedRowKeys, selectedRows, onCleanSelected }: { selectedRowKeys: number[] | string[], selectedRows: SelectedRowsType[], onCleanSelected: () => void }) => {
  421. return (
  422. <Space size={16}>
  423. <Button type='primary' onClick={() => batchSelfAssessment(selectedRowKeys)}>批量设置</Button>
  424. <Button type='ghost' onClick={onCleanSelected}>取消选择</Button>
  425. </Space>
  426. );
  427. }}
  428. // searchNode={searchNode()}
  429. />
  430. </div>
  431. <div style={{ display: currentActivedTree?.isLeaf ? 'block' : 'none' }}>
  432. <ArticleDetail isModeTwo={isModeTwo} />
  433. </div>
  434. </div>
  435. </div>
  436. </MccsPageContainer>
  437. </div>
  438. )
  439. }
  440. export default ArticleManagement