index.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-09-14 10:22:09
  4. * @LastEditTime: 2021-10-28 16:05:37
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /MedicalWisdomCheckSys/src/pages/GradeHospitalAccreditation/articleManagement/index.tsx
  8. */
  9. import React, { useRef, useEffect, useState } from 'react'
  10. import MccsPageContainer from '@/components/MccsPageContainer/index'
  11. import MccsProCard from '@/components/MccsProCard/index';
  12. import { useModel } from 'umi';
  13. import MccsFileTree from '@/components/MccsFileTree/index';
  14. import MccsTable from '@/components/MccsTable/index';
  15. import MccsScoreBanner from '@/components/MccsScoreBanner/index';
  16. import MccsRecordList from '@/components/MccsRecordList/index';
  17. import MccsDrawerForm from '@/components/MccsDrawerForm/index';
  18. import MccsClickableTabs from '@/components/MccsClickableTabs/index';
  19. import MccsUpload from '@/components/MccsUpload/index';
  20. import { MccsModal } from '@/components/MccsModal';
  21. import type { ProFormInstance, } from '@ant-design/pro-form';
  22. import { Form, Table, Space, Row, Col, Button, Tabs } from 'antd'
  23. import {
  24. ProFormText,
  25. ProFormSelect,
  26. ProFormDependency,
  27. } from '@ant-design/pro-form';
  28. import './index.less';
  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. const { TabPane } = Tabs;
  39. const columns = [
  40. {
  41. key: 'keyword',
  42. hideInTable: true,
  43. renderFormItem: (item: any, { type }: any, form: any) => {
  44. if (type === 'form') {
  45. return null;
  46. }
  47. return (
  48. <Form.Item name='keyword'>
  49. <ProFormText placeholder='条文/条款' />
  50. </Form.Item>
  51. )
  52. },
  53. },
  54. {
  55. title: '条款',
  56. key: 'numStr',
  57. dataIndex: 'numStr',
  58. hideInSearch: true,
  59. },
  60. {
  61. title: '条文',
  62. dataIndex: 'name',
  63. hideInSearch: true,
  64. width: '35%',
  65. ellipsis: true
  66. },
  67. {
  68. title: '负责单位',
  69. dataIndex: 'responsibilityDepartmentName',
  70. hideInSearch: true,
  71. },
  72. {
  73. title: '负责人',
  74. dataIndex: 'responsibilityUserName',
  75. hideInSearch: true,
  76. },
  77. {
  78. title: '自评',
  79. hideInSearch: true,
  80. dataIndex: 'selfEvaluation',
  81. },
  82. // {
  83. // title: '现场查核',
  84. // hideInSearch: true,
  85. // dataIndex: 'siteEvaluation',
  86. // },
  87. {
  88. title: '目标',
  89. dataIndex: 'targetEvaluation',
  90. hideInSearch: true,
  91. },
  92. {
  93. title: '系统评分',
  94. dataIndex: 'systemEvaluation',
  95. hideInSearch: true,
  96. },
  97. ]
  98. //条文管理
  99. const ArticleManagement: React.FC<ArticleManagementProps> = (props) => {
  100. const { columnsFromProps = [], headerConcig, isModeTwo } = props;
  101. const { articleManagement } = useModel('allModels');
  102. const drawerFormRef = useRef<ProFormInstance>();
  103. const {
  104. isLeaf,
  105. treeData,
  106. getTableData,
  107. currentActivedTree,
  108. setCurrentActivedTree,
  109. scoreList,
  110. getDepartmentRequest,
  111. departmentManagers,
  112. getDepartment,//获取责任单位
  113. ...restModelData
  114. } = articleManagement;
  115. const tableRef = useRef<MccsTable.MccsTableRef>();
  116. const [articleSettingFormInit, setArticleSettingFormInit] = useState<{}>({}); //条文设置表单回显默认值
  117. const [defaultOpened, setDefaultOpened] = useState<string>();
  118. const onSelectHandle = (data: MccsFileTree.childTree) => {
  119. //左侧树节点点击回调
  120. setCurrentActivedTree(data);
  121. setArticleSettingFormInit({});//清空默认值
  122. //重新获取数据
  123. tableRef?.current?.getTableRef().current?.reload();
  124. restModelData.setTabKey('1');
  125. }
  126. const batchSelfAssessment = (rowkeys: number[] | string[]) => {
  127. //批量设置
  128. restModelData.setDrawerFormType('BATCHSETTING');
  129. restModelData.setSelectedRowKeys(rowkeys);
  130. restModelData.setDrawerVisible(true);
  131. }
  132. const articleSetBtnHandle = () => {
  133. //条文设置
  134. // console.log({ articleSettingFormInit });
  135. restModelData.setDrawerFormType('ARTICLE_SET');
  136. restModelData.setDrawerVisible(true);
  137. }
  138. const onVisibleChangeHandle = (visible: boolean) => {
  139. //drawer展示控制
  140. !visible && setArticleSettingFormInit({});//清空默认值
  141. restModelData.setDrawerVisible(visible);
  142. }
  143. const onModalVisibleChange = (visible: boolean) => {
  144. //表单弹窗
  145. // console.log('uploadFormInitValue',restModelData.uploadFormInitValue);
  146. !visible && restModelData.setUploadFormInitValue(undefined);
  147. restModelData.setModalVisible(visible);
  148. }
  149. const upLoadFileHandle = (formInitData?: any) => {
  150. //因为modalForm开启了request+params获取表单默认值,
  151. //所以必须先设置默认值才能开启弹窗
  152. if (formInitData) {
  153. const { fileUrl, recordTypeName, accountType, fileName } = formInitData;
  154. // console.log({formInitData});
  155. restModelData.setUploadFormInitValue({
  156. tab: { label: accountType, value: { label: recordTypeName, value: recordTypeName } },
  157. files: [{
  158. uid: new Date().getTime(),
  159. name: fileName,
  160. status: 'done',
  161. url: fileUrl
  162. }]
  163. });
  164. } else {
  165. restModelData.setUploadFormInitValue({})
  166. }
  167. restModelData.getUploadLedgerType().then(data => {
  168. //设置上传台账类型
  169. restModelData.setUploadLedgerTypeList(data);
  170. })
  171. restModelData.setModalVisible(true);
  172. }
  173. const actionNodeFunc = (data: any) => {
  174. //渲染记录列表操作按钮
  175. // console.log({ data });
  176. const { fileUrl } = data;
  177. const reupload = () => {
  178. upLoadFileHandle(data);
  179. }
  180. return isModeTwo ? (
  181. //台账上传
  182. <a onClick={reupload}>重新上传</a>
  183. ) : (
  184. //条文管理
  185. <a href={fileUrl}>下载文件</a>
  186. )
  187. }
  188. const uploadLedgerChangeHandle = (tabData: any) => {
  189. //台账上传类型选择回调
  190. }
  191. useEffect(() => {
  192. if (restModelData.reloadRightContent) {
  193. //重新获取数据
  194. tableRef?.current?.getTableRef().current?.reload();
  195. tableRef?.current?.getTableRef().current?.clearSelected();
  196. }
  197. }, [restModelData]);
  198. useEffect(() => {
  199. if (restModelData.leafData) {
  200. const { responsibilityDepartmentId, responsibilityDepartmentName, responsibilityUserId, targetEvaluation, responsibilityUserName, accountType } = restModelData.leafData;
  201. if (responsibilityDepartmentName && responsibilityDepartmentId) {
  202. setArticleSettingFormInit({
  203. responsibilityDepartment: { label: responsibilityDepartmentName, value: responsibilityDepartmentId },
  204. responsibilityUser: { label: responsibilityUserName, value: responsibilityUserId },
  205. targetScores: { label: targetEvaluation, value: targetEvaluation },
  206. articleType: { label: accountType, value: accountType },
  207. });
  208. }
  209. }
  210. }, [restModelData.leafData]);
  211. useEffect(() => {
  212. if (isModeTwo) {
  213. //设置当前模块模式
  214. restModelData.setModuleMode(isModeTwo);
  215. } else {
  216. //设置当前模块模式
  217. restModelData.setModuleMode(false);
  218. }
  219. }, [props]);
  220. useEffect(() => {
  221. if (treeData.length > 0) {
  222. //默认展开书结构第一个结点
  223. const { id } = treeData[0];
  224. setDefaultOpened(`${id}`);
  225. }
  226. }, [treeData]);
  227. useEffect(() => {
  228. restModelData.getArticleTreeData();
  229. restModelData.getCurrentHospScore();
  230. }, [])
  231. return (
  232. <MccsPageContainer
  233. config={headerConcig ? headerConcig : {
  234. content: !isModeTwo && <div style={{ textAlign: 'right', fontSize: 12, color: '#525866' }}>{restModelData.currentHospSelfScoreAndOthers}</div>
  235. }}
  236. >
  237. {
  238. restModelData.modalVisible && (
  239. <MccsModal title='台账上传' visible={restModelData.modalVisible}
  240. onFinish={(values: any) => restModelData.uploadFile(values)}
  241. initialValues={!restModelData.uploadFormInitValue ? {} : restModelData.uploadFormInitValue}
  242. onVisibleChange={onModalVisibleChange}
  243. params={restModelData.uploadFormInitValue}
  244. request={(params: any) => {
  245. return Promise.resolve(params)
  246. }}
  247. >
  248. <div className='formItemTitle'>选择类型</div>
  249. <Form.Item name='tab' rules={[
  250. {
  251. required: true,
  252. message: '请选择类型!',
  253. },
  254. ]}>
  255. <MccsClickableTabs
  256. disabled={(restModelData.uploadFormInitValue && JSON.stringify(restModelData.uploadFormInitValue) != '{}') ? true : false}
  257. type='multi'
  258. onChange={uploadLedgerChangeHandle}
  259. data={restModelData.uploadLedgerTypeList}
  260. />
  261. </Form.Item>
  262. <ProFormDependency name={['tab']}>
  263. {
  264. ({tab})=>{
  265. return tab&&tab.value.label == '制度'&&(
  266. <ProFormSelect
  267. name="publicCateId"
  268. label="制度下类型"
  269. width='md'
  270. request={async ()=> await restModelData.getSelectableRuleChilds(tab.value.value)}
  271. placeholder="请选择"
  272. rules={[{ required: true, message: '请选择!' }]}
  273. />
  274. )
  275. }
  276. }
  277. </ProFormDependency>
  278. <Form.Item name='files' rules={[
  279. {
  280. required: true,
  281. message: '请上传文件!',
  282. },
  283. ]}>
  284. <MccsUpload maxCount={1} />
  285. </Form.Item>
  286. </MccsModal>
  287. )
  288. }
  289. {
  290. //条文设置/表格批量设置drawer弹窗
  291. restModelData.drawerVisible && (
  292. <MccsDrawerForm
  293. title={restModelData.drawerFormType == 'ARTICLE_SET' ? '条文设置' : '批量设置'}
  294. width={500}
  295. formRef={drawerFormRef}
  296. visible={restModelData.drawerVisible}
  297. initialValues={restModelData.drawerFormType == 'ARTICLE_SET' ? { ...articleSettingFormInit } : {}}
  298. onFinish={(values: any) => restModelData.drawerFormType == 'ARTICLE_SET' ? restModelData.setArticle(values) : restModelData.batchSetting(values)}
  299. onVisibleChange={onVisibleChangeHandle}
  300. >
  301. <div className='formItemTitle'>负责人及单位</div>
  302. <Row gutter={16}>
  303. <Col className="gutter-row" span={10}>
  304. <ProFormSelect
  305. name="responsibilityDepartment"
  306. width='sm'
  307. showSearch
  308. request={getDepartmentRequest}
  309. placeholder="选择单位"
  310. fieldProps={{
  311. labelInValue: true,
  312. onChange: (value, option) => {
  313. //责任单位修改时清空责任人
  314. drawerFormRef.current?.setFieldsValue({ ...articleSettingFormInit, responsibilityUser: { label: '', value: '' } });
  315. getDepartment(value, option)
  316. }
  317. }}
  318. rules={[{ required: true, message: '请选择单位!' }]}
  319. />
  320. </Col>
  321. <Col className="gutter-row" span={8}>
  322. <ProFormDependency name={['responsibilityDepartment']}>
  323. {({ responsibilityDepartment }) => {
  324. return (
  325. <ProFormSelect
  326. name="responsibilityUser"
  327. width='sm'
  328. disabled={!responsibilityDepartment || JSON.stringify(responsibilityDepartment) == '{}'}
  329. options={departmentManagers}
  330. placeholder="选择负责人"
  331. fieldProps={{
  332. labelInValue: true,
  333. // onChange:(value,option)=>getManagers(value,option)
  334. }}
  335. rules={[{ required: true, message: '请选择负责人!' }]}
  336. />
  337. )
  338. }}
  339. </ProFormDependency>
  340. </Col>
  341. </Row>
  342. <div className='formItemTitle'>目标分数</div>
  343. <Row >
  344. <Col span={24}>
  345. <Form.Item name='targetScores' rules={[
  346. {
  347. required: true,
  348. message: '请选择目标分数!',
  349. },
  350. ]}>
  351. <MccsClickableTabs
  352. data={restModelData.targetScores}
  353. />
  354. </Form.Item>
  355. </Col>
  356. </Row>
  357. {
  358. true && (
  359. <>
  360. <div className='formItemTitle'>条文组别</div>
  361. <Row>
  362. <Col span={24}>
  363. <Form.Item name='articleType' rules={[
  364. {
  365. required: true,
  366. message: '请选择条文组别!',
  367. },
  368. ]}>
  369. <MccsClickableTabs
  370. data={restModelData.ruleTypes}
  371. />
  372. </Form.Item>
  373. </Col>
  374. </Row>
  375. </>
  376. )
  377. }
  378. </MccsDrawerForm>
  379. )
  380. }
  381. <MccsProCard gutter={16} ghost direction='row'>
  382. <MccsProCard colSpan={6} style={{ height: '78vh' }} bodyStyle={{ padding: '16px' }}>
  383. {
  384. defaultOpened&&(
  385. <MccsFileTree
  386. treeData={treeData}
  387. defaultSelected={defaultOpened}
  388. onSelectHandle={onSelectHandle}
  389. // actionHandle={actionHandle}
  390. // searchHandle={searchHandle}
  391. editable={false}
  392. />
  393. )
  394. }
  395. </MccsProCard>
  396. <MccsProCard colSpan={18} style={{ minHeight: '78vh' }} bodyStyle={{ padding: '16px' }}>
  397. {
  398. !isLeaf && (
  399. <MccsTable
  400. ref={tableRef}
  401. columns={columnsFromProps.length > 0 ? columnsFromProps : columns}
  402. request={getTableData}
  403. search={{
  404. span: 6
  405. }}
  406. rowSelection={{
  407. // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
  408. // 注释该行则默认不显示下拉选项
  409. selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
  410. }}
  411. rowKey="id"
  412. tableAlertOptionRender={({ selectedRowKeys, selectedRows, onCleanSelected }: { selectedRowKeys: number[] | string[], selectedRows: SelectedRowsType[], onCleanSelected: () => void }) => {
  413. return (
  414. <Space size={16}>
  415. <Button type='primary' onClick={() => batchSelfAssessment(selectedRowKeys)}>批量设置</Button>
  416. <Button type='ghost' onClick={onCleanSelected}>取消选择</Button>
  417. </Space>
  418. );
  419. }}
  420. // searchNode={searchNode()}
  421. />
  422. )
  423. }
  424. {
  425. isLeaf && (
  426. <div className='leafContent'>
  427. <div className='leafContentTitle'>{currentActivedTree ? currentActivedTree.title : ''}</div>
  428. <div className='peopleGroup'>
  429. <span>条文组别:</span>
  430. <span>{restModelData.leafData?.accountType}</span>
  431. <span>负责单位:</span>
  432. <span>{restModelData.leafData?.responsibilityDepartmentName}</span>
  433. <span>负责人:</span>
  434. <span>{restModelData.leafData?.responsibilityUserName}</span>
  435. </div>
  436. <MccsScoreBanner list={scoreList} />
  437. {
  438. isModeTwo && (
  439. <div style={{ marginTop: 5 }}>
  440. <Tabs activeKey={`${restModelData.tabKey}`} centered size='large' onChange={(key) => restModelData.setTabKey(key)}>
  441. <TabPane tab="台账记录" key="1">
  442. <div className='articleSetBtn'>
  443. <span onClick={() => upLoadFileHandle()}>上传文件</span>
  444. </div>
  445. <MccsRecordList
  446. title='台账记录'
  447. list={restModelData.records}
  448. actionFunc={(data) => restModelData.delHistoryRecordHandle(data)}
  449. actionNode={(data) => actionNodeFunc(data)}
  450. />
  451. </TabPane>
  452. <TabPane tab="自评结果" key="2">
  453. <div className='selfEvolutionTitle'>开始自评</div>
  454. <div className='selfEvolutionArea'>
  455. <MccsClickableTabs
  456. classNames='tabWrap'
  457. onChange={(value: { label: string, value: any }) => restModelData.onSelfEvolutionTabChange(value)}
  458. data={restModelData.targetScores}
  459. value={restModelData.selectedSelfEvolution}
  460. />
  461. <Button onClick={() => restModelData.commitSelfEvolution()}>提交自评</Button>
  462. </div>
  463. <MccsRecordList
  464. title='自评记录'
  465. list={restModelData.selfEvaluationRecords}
  466. />
  467. </TabPane>
  468. </Tabs>
  469. </div>
  470. )
  471. }
  472. {
  473. !isModeTwo && (
  474. <>
  475. <div className='articleSetBtn'><span onClick={articleSetBtnHandle}>条文设置</span></div>
  476. <MccsRecordList
  477. title='台账记录'
  478. list={restModelData.records}
  479. actionFunc={(data) => { console.log({ data }) }}
  480. //restModelData.delHistoryRecordHandle(data)
  481. actionNode={(data) => actionNodeFunc(data)}
  482. />
  483. </>
  484. )
  485. }
  486. </div>
  487. )
  488. }
  489. </MccsProCard>
  490. </MccsProCard>
  491. </MccsPageContainer>
  492. )
  493. }
  494. export default ArticleManagement