index.tsx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. /*
  2. * @Author: your name
  3. * @Date: 2022-01-13 15:22:48
  4. * @LastEditTime: 2023-03-24 12:20:28
  5. * @LastEditors: code4eat awesomedema@gmail.com
  6. * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  7. * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/hospManage/index.tsx
  8. */
  9. import { FC, Key, useEffect, useMemo, useState } from 'react';
  10. import { hospManageModelState, ConnectProps, Loading, connect } from 'umi';
  11. import { Button, Checkbox, Divider, Drawer, Dropdown, Input, Popconfirm, Switch, Table, Tree, TreeProps } from 'antd';
  12. import KCTable from '@/components/kcTable';
  13. import type { ProColumns } from '@ant-design/pro-table';
  14. import { getAllHosp, getHospOwnSys, getHospYoushuAccounts, getMenuRelaPerm, hospInit, saveHospMenuApiPerm, setReadOnly } from '@/service/hospList';
  15. import { TableRequestParamsType } from '@/typings';
  16. import ActModal from './modals/modal';
  17. import './style.less';
  18. import { TableListItem } from './typings';
  19. import { getSpacifyHospMenu } from '@/service/menu';
  20. import { KCInput } from '@/components/KCInput';
  21. import { createFromIconfontCN, DownOutlined } from '@ant-design/icons';
  22. import { DrawerForm } from '@ant-design/pro-form';
  23. import { DataNode } from 'antd/es/tree';
  24. import { getTreeDataRespType } from '../systemNavMana/service';
  25. import expandedIcon from '../../../../../public/images/treenode_open.png';
  26. import closeIcon from '../../../../../public/images/treenode_collapse.png';
  27. import { getDeepestTreeData, uniqueFunc } from '@/utils';
  28. import { CheckboxValueType } from 'antd/lib/checkbox/Group';
  29. export enum TableActType {
  30. NOACT,
  31. ADD,
  32. DEL,
  33. EDIT,
  34. EDITMENU,
  35. BINDACCOUNT, //绑定有数账号
  36. }
  37. const { DirectoryTree } = Tree;
  38. const SearchIcon = createFromIconfontCN({
  39. scriptUrl: '//at.alicdn.com/t/c/font_1927152_g1njmm1kh7b.js',
  40. });
  41. interface PageProps extends ConnectProps {
  42. hospManageModel: hospManageModelState;
  43. loading: boolean;
  44. }
  45. const HospManage: FC<PageProps> = ({ hospManageModel: state, dispatch }) => {
  46. const { reloadTable } = state;
  47. const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
  48. const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState<string>('');
  49. const [drawerVisible, set_drawerVisible] = useState(false);
  50. const columns: ProColumns<TableListItem>[] = [
  51. {
  52. title: 'ID',
  53. dataIndex: 'id',
  54. hideInTable: true,
  55. },
  56. {
  57. title: '院区名称',
  58. dataIndex: 'hospName',
  59. hideInSearch: false,
  60. },
  61. // {
  62. // title: '是否主院',
  63. // dataIndex: 'isHospital',
  64. // render: (text) => {
  65. // return text == 0 ? '是' : '否';
  66. // },
  67. // },
  68. {
  69. title: '医院标识',
  70. dataIndex: 'hospSign',
  71. },
  72. // {
  73. // title: '简称',
  74. // dataIndex: 'hospAbbreviation',
  75. // },
  76. {
  77. title: '主院名称',
  78. dataIndex: 'mainHospName',
  79. },
  80. {
  81. title: '医院等级',
  82. dataIndex: 'hospitalLevelName',
  83. },
  84. // {
  85. // title: '医院类型',
  86. // dataIndex: 'hospitalType',
  87. // },
  88. {
  89. title: '医院性质',
  90. dataIndex: 'hospitalNature',
  91. },
  92. // {
  93. // title: '医院编码',
  94. // dataIndex: 'hospitalCode',
  95. // },
  96. {
  97. title: '系统名称',
  98. dataIndex: 'systemName',
  99. },
  100. {
  101. title: '互通',
  102. dataIndex: 'dataShare',
  103. },
  104. // {
  105. // title: '变更日期',
  106. // dataIndex: 'updateTime',
  107. // },
  108. {
  109. title: '操作',
  110. width: 230,
  111. key: 'option',
  112. valueType: 'option',
  113. render: (text, record) => [
  114. <a key="link" onClick={() => editHandle(record)}>
  115. 编辑
  116. </a>,
  117. <Divider key="1" type="vertical" style={{ margin: '0 1px' }} />,
  118. <Popconfirm
  119. title="是否确定删除?"
  120. onConfirm={() => delHandle(record)}
  121. // onCancel={cancel}
  122. okText="确定"
  123. cancelText="取消"
  124. key="link2"
  125. >
  126. <a>删除</a>
  127. </Popconfirm>,
  128. <Divider key="2" type="vertical" style={{ margin: '0 1px' }} />,
  129. <a key="link3" onClick={() => editMenuBind(record)}>
  130. 菜单
  131. </a>,
  132. <Divider key="3" type="vertical" style={{ margin: '0 1px' }} />,
  133. <Dropdown key='4' menu={{
  134. items: [
  135. { key: '1', label: <a key="link4" onClick={() => youshuAccountBind(record)}>报告</a> },
  136. { key: '2', label: <DrawerActBtn record={record} /> },
  137. { key: '3', label: <a key="link5" onClick={() => initHospData(record)}>初始化</a> },
  138. { key: '4', label: <a key="link6" onClick={() => setOnlyRead(record)}>初始化只读</a> },
  139. ]
  140. }}>
  141. <a>
  142. 更多 <DownOutlined />
  143. </a>
  144. </Dropdown>,
  145. ],
  146. },
  147. ];
  148. const DrawerActBtn = ({ record }: { record: any }) => {
  149. const [treeData, set_treeData] = useState<getTreeDataRespType[]>([]);
  150. const [currentSelectedTreeNode, set_currentSelectedTreeNode] = useState<any | undefined>(undefined);
  151. const [drawerTablereload, set_drawerTablereload] = useState(false);
  152. const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
  153. const [searchValue, setSearchValue] = useState('');
  154. const [autoExpandParent, setAutoExpandParent] = useState(true);
  155. const [drawerTableDataFilterParams, set_drawerTableDataFilterParams] = useState<any | undefined>();
  156. const [checkBoxCodes, set_checkBoxCodes] = useState<any[]>([]); //勾选的菜单
  157. const [drawerTableDataSearchKeywords, set_drawerTableDataSearchKeywords] = useState<string>('');
  158. const [checkedTableMenuIds, set_checkedTableMenuIds] = useState<any[]>([]);
  159. const [oldSelectedMenuIds, set_oldSelectedMenuIds] = useState<any[]>([]);
  160. const columnsData: ProColumns<TableListItem>[] = [
  161. {
  162. title: '名称',
  163. dataIndex: 'name',
  164. width: 300,
  165. ellipsis: true
  166. },
  167. {
  168. title: '类型',
  169. width: 50,
  170. dataIndex: 'contentType',
  171. key: 'contentType',
  172. render: (_: any, record: any) => {
  173. //console.log({ record });
  174. switch (record.type) {
  175. case 0:
  176. return '目录'
  177. case 1:
  178. return '菜单'
  179. case 2:
  180. return 'api'
  181. case 3:
  182. return '系统'
  183. case 4:
  184. return '有数bi'
  185. case 5:
  186. return '体系'
  187. case 6:
  188. return '中心层'
  189. case 7:
  190. return '平台层'
  191. default:
  192. break;
  193. }
  194. },
  195. },
  196. {
  197. title: '功能',
  198. dataIndex: 'deptName',
  199. key: 'deptName',
  200. render: (_: any, record: any) => {
  201. if (record.functionList) {
  202. const options = record.functionList.map((item: any, index: number) => ({ label: item.name, value: item.code }))
  203. const needItem = checkBoxCodes.filter(a => a.menuId == record.menuId);
  204. const codes = needItem && needItem.length > 0 ? needItem[0].function.map((a: any) => a.code) : [];
  205. const onCheckGroupChange = (checkedValue: CheckboxValueType[]) => {
  206. if (checkedValue.length > 0) {
  207. const _temp = checkBoxCodes;
  208. const index = checkBoxCodes.findIndex((item) => item.menuId == record.menuId);
  209. const needed = options.filter((item: any) => checkedValue.includes(item.value));
  210. const transfered = needed.map((item: any) => ({ name: item.label, code: item.value }));
  211. if (index >= 0) {
  212. //先去除旧的的对象
  213. _temp.splice(index, 1);
  214. }
  215. _temp.push({
  216. menuId: record.menuId,
  217. function: transfered
  218. });
  219. const menuIdsArr = _temp.map((item: any) => item.menuId);
  220. set_checkedTableMenuIds([...menuIdsArr])
  221. set_checkBoxCodes([..._temp]);
  222. } else {
  223. //取消选择
  224. const _temp = checkBoxCodes;
  225. const index = checkBoxCodes.findIndex((item) => item.menuId == record.menuId);
  226. _temp.splice(index, 1);
  227. const menuIdsArr = _temp.map((item: any) => item.menuId);
  228. set_checkedTableMenuIds([...menuIdsArr])
  229. set_checkBoxCodes([..._temp]);
  230. }
  231. }
  232. return (
  233. <Checkbox.Group
  234. options={options}
  235. value={codes}
  236. onChange={checkedValue => onCheckGroupChange(checkedValue)}
  237. />
  238. )
  239. }
  240. return '-'
  241. }
  242. },
  243. ];
  244. const getTreeReqFunc = async (hospId: string) => {
  245. if(hospId){
  246. const resp = await getHospOwnSys(hospId);
  247. set_treeData(resp);
  248. }
  249. }
  250. const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
  251. //console.log('selected', selectedKeys, info);
  252. const { node } = info;
  253. set_currentSelectedTreeNode(node);
  254. };
  255. const dataList: any[] = [];
  256. const getParentKey = (key: React.Key, tree: any[]): React.Key => {
  257. let parentKey: React.Key;
  258. for (let i = 0; i < tree.length; i++) {
  259. const node = tree[i];
  260. if (node.children) {
  261. if (node.children.some((item: { code: React.Key; }) => item.code === key)) {
  262. parentKey = node.code;
  263. } else if (getParentKey(key, node.children)) {
  264. parentKey = getParentKey(key, node.children);
  265. }
  266. }
  267. }
  268. return parentKey!;
  269. };
  270. const onTreeSearchKeyChange = (e: React.ChangeEvent<HTMLInputElement>) => {
  271. const { value } = e.target;
  272. const newExpandedKeys = dataList
  273. .map((item) => {
  274. if (item.name.indexOf(value) > -1) {
  275. return getParentKey(item.code, treeData);
  276. }
  277. return null;
  278. });
  279. const b = newExpandedKeys.filter((item, i, self) => item && self.indexOf(item) === i);
  280. setExpandedKeys(newExpandedKeys as React.Key[]);
  281. setSearchValue(value);
  282. setAutoExpandParent(true);
  283. }
  284. const onExpand = (newExpandedKeys: React.Key[]) => {
  285. setExpandedKeys(newExpandedKeys);
  286. setAutoExpandParent(false);
  287. };
  288. const generateList = (data: getTreeDataRespType[]) => {
  289. for (let i = 0; i < data.length; i++) {
  290. const node = data[i];
  291. const { code, name } = node;
  292. dataList.push({ code, name: name });
  293. if (node.children) {
  294. generateList(node.children);
  295. }
  296. }
  297. };
  298. generateList(treeData as any);
  299. const getTableData = async (params: any, sort: any, filter: any) => {
  300. set_drawerTablereload(false);
  301. if (currentSelectedTreeNode) {
  302. const resp = await getMenuRelaPerm({ ...params, hospId: record.id });
  303. if (resp) {
  304. let temp: { menuId: any; function: any; }[] = [];
  305. const setTreeRecursion = (data: any) => {
  306. data.map((item: any, index: number) => {
  307. if (item.type == 1 && item.functionCheckList) {
  308. //菜单
  309. temp.push({
  310. menuId: item.menuId,
  311. function: item.functionCheckList
  312. });
  313. }
  314. if (item.children && item.children.length != 0) {
  315. setTreeRecursion(item.children);
  316. }
  317. });
  318. }
  319. setTreeRecursion(resp);
  320. set_checkBoxCodes(temp);
  321. set_checkedTableMenuIds(temp.map((a: any) => a.menuId));
  322. set_oldSelectedMenuIds(temp.map((a: any) => a.menuId));
  323. return {
  324. data: resp,
  325. success: true,
  326. }
  327. }
  328. return {
  329. data: [],
  330. success: true
  331. }
  332. }
  333. return []
  334. }
  335. const saveResult = async () => {
  336. let old = oldSelectedMenuIds;
  337. const result = checkBoxCodes.map((item: any) => {
  338. old.splice(old.findIndex(a=>a == item.menuId),1);
  339. return { ...item, hospId: record.id, systemId: currentSelectedTreeNode.code }
  340. });
  341. const needCancelMenus = old.map(a => ({ hospId: record.id, systemId: currentSelectedTreeNode.code, function: [], menuId: a }));
  342. const data = [...result, ...needCancelMenus];
  343. const resp = await saveHospMenuApiPerm(result.length == 0 ? [{ hospId: record.id, systemId: currentSelectedTreeNode.code }] : data);
  344. if (resp) {
  345. set_drawerTablereload(true);
  346. set_checkBoxCodes([]);
  347. set_checkedTableMenuIds([]);
  348. }
  349. }
  350. const onCancel = () => {
  351. set_drawerVisible(false);
  352. }
  353. const drawerTableDataSearchHandle = (paramName: string) => {
  354. set_drawerTableDataFilterParams({
  355. ...drawerTableDataFilterParams,
  356. [`${paramName}`]: drawerTableDataSearchKeywords
  357. })
  358. }
  359. // const oneKeySetReadOnly = (bool: boolean) => {
  360. // if (bool) {
  361. // const _temp = checkBoxCodes.map((item: any) => {
  362. // const needed = item.function.filter((a: any) => a.code == 'search');
  363. // return { ...item, function: needed }
  364. // })
  365. // set_checkBoxCodes([..._temp]);
  366. // }
  367. // }
  368. useEffect(() => {
  369. if (currentSelectedTreeNode) {
  370. set_drawerTableDataFilterParams({ ...drawerTableDataFilterParams, systemId: currentSelectedTreeNode.code })
  371. }
  372. //切换系统清空数据
  373. set_checkBoxCodes([]);
  374. set_checkedTableMenuIds([]);
  375. }, [currentSelectedTreeNode]);
  376. useEffect(() => {
  377. //初始化左侧树结构数据后
  378. if (treeData?.length > 0) {
  379. if (treeData[0].children && treeData[0].children.length > 0) {
  380. const [node, nodeParent] = getDeepestTreeData(treeData[0], 'children');
  381. set_currentSelectedTreeNode(node);
  382. setExpandedKeys([nodeParent.code]);
  383. }
  384. }
  385. }, [treeData]);
  386. useEffect(() => {
  387. getTreeReqFunc(record.id);
  388. }, []);
  389. return (
  390. <DrawerForm
  391. trigger={
  392. <a key="link3" onClick={(e) => { set_drawerVisible(true); }}>功能</a>
  393. }
  394. width={908}
  395. // visible={drawerVisible}
  396. drawerProps={{
  397. open: drawerVisible,
  398. closable: false,
  399. destroyOnClose: true,
  400. extra: <div>anniu</div>,
  401. }}
  402. submitter={false}
  403. >
  404. <div className='setApiPermDrawer'>
  405. <div className='topbar'>
  406. <div className='title'>{`院区功能权限设置(${record.hospName})`}</div>
  407. <div className='btnGroup'>
  408. <span className='cancel' onClick={() => onCancel()}>取消</span>
  409. <span className='save' onClick={() => saveResult()}>保存</span>
  410. </div>
  411. </div>
  412. <div className='content'>
  413. <div className='leftTree'>
  414. <div className='search'>
  415. <Input
  416. className='searchInput'
  417. placeholder="请输入"
  418. size='small'
  419. allowClear
  420. style={{ marginBottom: 16 }}
  421. onChange={onTreeSearchKeyChange}
  422. suffix={
  423. <SearchIcon type='iconsousuo' />
  424. }
  425. />
  426. </div>
  427. {
  428. treeData && treeData.length > 0 && (
  429. <DirectoryTree
  430. fieldNames={{ title: 'name', key: 'code' }}
  431. rootStyle={{ height: '100%', paddingBottom: 50, overflowY: 'scroll', overflowX: 'hidden' }}
  432. onSelect={onSelect}
  433. onExpand={onExpand}
  434. expandedKeys={expandedKeys}
  435. autoExpandParent={autoExpandParent}
  436. selectedKeys={currentSelectedTreeNode ? [currentSelectedTreeNode.code] : []}
  437. blockNode={true}
  438. icon={() => null}
  439. titleRender={
  440. (nodeData: any) => {
  441. const strTitle = nodeData.name as string;
  442. const index = strTitle.indexOf(searchValue);
  443. const beforeStr = strTitle.substring(0, index);
  444. const afterStr = strTitle.slice(index + searchValue.length);
  445. const title =
  446. index > -1 ? (
  447. <span>
  448. {beforeStr}
  449. <span className="site-tree-search-value" style={{ color: 'red', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{searchValue}</span>
  450. {afterStr}
  451. </span>
  452. ) : (
  453. <span className='strTitle'>{strTitle}</span>
  454. );
  455. return <div style={{
  456. display: 'flex', flexDirection: 'row',
  457. width: '100%',
  458. justifyContent: 'flex-start', alignItems: 'center', height: 32,
  459. borderRadius: '4px',
  460. overflow: 'hidden',
  461. color: '#17181A',
  462. textOverflow: 'ellipsis',
  463. whiteSpace: 'nowrap'
  464. }}>{title}</div>
  465. }
  466. }
  467. defaultSelectedKeys={[treeData[0].children[0].code]}
  468. treeData={treeData as unknown as DataNode[]}
  469. switcherIcon={(props: any) => {
  470. const { expanded } = props;
  471. //return <button className='site-table-row-expand-icon site-table-row-expand-icon-expanded'></button>
  472. return !expanded ? <img style={{ width: 20, height: 20, position: 'relative', top: 5 }} src={expandedIcon} /> : <img style={{ width: 20, height: 20, position: 'relative', top: 5 }} src={closeIcon} />
  473. }}
  474. />
  475. )
  476. }
  477. </div>
  478. {/* <div style={{width:16,height:'92vh',background:'#F5F7FA'}}></div> */}
  479. <div className='rightContent'>
  480. <div className='tableToolbar'>
  481. <div className='filter'>
  482. <div className='filterItem'>
  483. <span className='label'>检索:</span>
  484. <KCInput placeholder={'请输入'} style={{ width: 160 }} search allowClear
  485. onChange={(e) => {
  486. set_drawerTableDataSearchKeywords(e.target.value);
  487. if (e.target.value.length == 0) {
  488. set_drawerTableDataFilterParams({
  489. ...drawerTableDataFilterParams,
  490. name: ''
  491. });
  492. }
  493. }}
  494. onSearch={() => drawerTableDataSearchHandle('name')}
  495. />
  496. </div>
  497. </div>
  498. <div className={'btnGroup'}>
  499. {/* <a style={{color: '#17181A'}}><Switch style={{position:'relative',marginRight:4}} size='small' onChange={(bool)=>oneKeySetReadOnly(bool)} />只读</a> */}
  500. {/* <UpDataActBtn key={'act'} record={undefined} type='ADD' /> */}
  501. </div>
  502. </div>
  503. {currentSelectedTreeNode && <KCTable
  504. rowSelection={{
  505. // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
  506. // 注释该行则默认不显示下拉选项
  507. checkStrictly: false,
  508. onChange(selectedRowKeys, selectedRows, info) {
  509. //console.log({selectedRowKeys, selectedRows, info});
  510. if (selectedRowKeys.length == 0) {
  511. set_checkedTableMenuIds([]);
  512. }
  513. if (selectedRows.length == 0) {
  514. set_checkBoxCodes([]);
  515. }
  516. },
  517. selectedRowKeys: checkedTableMenuIds,
  518. selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
  519. onSelect: (record, selected, selectedRows, nativeEvent) => {
  520. //console.log({ record, selected, selectedRows, nativeEvent });
  521. let checkedData = checkBoxCodes;
  522. if (selected) {
  523. //选中
  524. selectedRows.forEach(a => {
  525. if (a.functionList) {
  526. checkedData.push({
  527. menuId: a.menuId,
  528. function: a.functionList
  529. });
  530. }
  531. });
  532. //更新表格row选中状态
  533. if (record.type == 0) {
  534. //选中的是目录
  535. const ids = record.children.map((item: any) => item.menuId);
  536. const totalData = Array.from(new Set([...checkedTableMenuIds, ...ids]));
  537. set_checkedTableMenuIds([...totalData]);
  538. }
  539. if (record.type == 1) {
  540. //菜单
  541. set_checkedTableMenuIds([...checkedTableMenuIds, record.menuId]);
  542. }
  543. set_checkBoxCodes([...uniqueFunc(checkedData,'menuId')]);
  544. } else {
  545. let _tempCheckedCodes = checkBoxCodes;
  546. const leftCheckedMenuIds = selectedRows.map(a => a.menuId);
  547. const filtedCheckCodes = _tempCheckedCodes.filter(a => (leftCheckedMenuIds.includes(a.menuId)));
  548. set_checkedTableMenuIds([...leftCheckedMenuIds]);
  549. set_checkBoxCodes([...uniqueFunc(filtedCheckCodes, 'menuId')]);
  550. }
  551. }
  552. }}
  553. pagination={false} reload={drawerTablereload} newVer params={drawerTableDataFilterParams} rowKey='menuId' columns={columnsData as ProColumns[]} request={(params: any, sort: any, filter: any) => getTableData(params, sort, filter)} />}
  554. </div>
  555. </div>
  556. </div>
  557. </DrawerForm>
  558. )
  559. }
  560. const getHospData = async (params: TableRequestParamsType) => {
  561. const { current = 1, pageSize = 10, hospName: hospitalName } = params;
  562. const resp = await getAllHosp({
  563. current,
  564. pageSize,
  565. hospitalName: hospitalName ? hospitalName : null,
  566. });
  567. if (resp) {
  568. const { list = [], totalCount = 0 } = resp;
  569. //获取万最新数据取消重置reload
  570. dispatch &&
  571. dispatch({
  572. type: 'hospManageModel/reloadTable',
  573. payload: false,
  574. });
  575. return {
  576. data: list,
  577. success: true,
  578. total: resp.totalCount,
  579. };
  580. } else {
  581. return {
  582. data: [],
  583. success: false,
  584. total: 0,
  585. };
  586. }
  587. };
  588. const addHandle = () => {
  589. dispatch &&
  590. dispatch({
  591. type: 'hospManageModel/add',
  592. payload: {
  593. tableAct: TableActType.ADD,
  594. isShowModal: true,
  595. },
  596. });
  597. };
  598. const editHandle = (record: TableListItem) => {
  599. dispatch &&
  600. dispatch({
  601. type: 'hospManageModel/edit',
  602. payload: {
  603. data: record,
  604. act: TableActType.EDIT,
  605. isShowModal: true,
  606. },
  607. });
  608. };
  609. const delHandle = (record: TableListItem) => {
  610. dispatch &&
  611. dispatch({
  612. type: 'hospManageModel/delRequest',
  613. payload: [record.id],
  614. });
  615. };
  616. const editMenuBind = async (record: TableListItem) => {
  617. //编辑菜单绑定关系
  618. const { selectedMenuIds } = await getSpacifyHospMenu({ hospId: record.id });
  619. dispatch &&
  620. dispatch({
  621. type: 'hospManageModel/edit',
  622. payload: {
  623. data: { ...record, bindMenuIds: selectedMenuIds },
  624. act: TableActType.EDITMENU,
  625. isShowModal: true,
  626. },
  627. });
  628. };
  629. const youshuAccountBind = async (record: TableListItem) => {
  630. const { id } = record;
  631. const resp = await getHospYoushuAccounts({ hospId: id });
  632. if (resp) {
  633. const { reportId, reportUrl, youshuUsers } = resp;
  634. dispatch &&
  635. dispatch({
  636. type: 'hospManageModel/edit',
  637. payload: {
  638. data: { ...record, reportId, reportUrl, youshuUsers },
  639. act: TableActType.BINDACCOUNT,
  640. isShowModal: true,
  641. },
  642. });
  643. }
  644. };
  645. const setOnlyRead = async (record: any) => {
  646. const resp = await setReadOnly(record.id);
  647. if (resp) {
  648. dispatch &&
  649. dispatch({
  650. type: 'hospManageModel/reloadTable',
  651. });
  652. }
  653. }
  654. const initHospData = async (record: TableListItem) => {
  655. const resp = await hospInit(record.id);
  656. }
  657. const tableDataSearchHandle = (paramName: string) => {
  658. set_tableDataFilterParams({
  659. ...tableDataFilterParams,
  660. [`${paramName}`]: tableDataSearchKeywords
  661. })
  662. }
  663. return (
  664. <div className="HospManage">
  665. <ActModal {...state} dispatch={dispatch} />
  666. <div className='toolBar'>
  667. <div className='filter'>
  668. <div className='filterItem'>
  669. <span className='label'>检索:</span>
  670. <KCInput placeholder={'请输入院区名称'} style={{ width: 160 }} search allowClear
  671. onChange={(e) => {
  672. set_tableDataSearchKeywords(e.target.value);
  673. if (e.target.value.length == 0) {
  674. set_tableDataFilterParams({
  675. ...tableDataFilterParams,
  676. hospName: ''
  677. });
  678. }
  679. }}
  680. onSearch={() => tableDataSearchHandle('hospName')}
  681. />
  682. </div>
  683. </div>
  684. <div className='btnGroup'>
  685. <span className='add' onClick={addHandle}>新增</span>
  686. </div>
  687. </div>
  688. <KCTable
  689. newVer
  690. rowKey="id"
  691. columns={columns}
  692. reload={reloadTable}
  693. options={false}
  694. params={tableDataFilterParams}
  695. request={(params) => getHospData(params)}
  696. />
  697. </div>
  698. );
  699. };
  700. export default connect(
  701. ({ hospManageModel, loading }: { hospManageModel: hospManageModelState; loading: Loading }) => {
  702. // console.log({userManageModel});
  703. return {
  704. hospManageModel,
  705. loading: loading.models.hospManageModel,
  706. };
  707. },
  708. )(HospManage);