index.tsx 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. /*
  2. * @Author: code4eat awesomedema@gmail.com
  3. * @Date: 2023-03-03 11:30:33
  4. * @LastEditors: code4eat awesomedema@gmail.com
  5. * @LastEditTime: 2023-07-28 11:33:30
  6. * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. import BMSPagecontainer from '@/components/BMSPageContainer';
  10. import { BMSTable } from '@/components/BMSTable';
  11. import { createFromIconfontCN, MenuOutlined } from '@ant-design/icons';
  12. import { ActionType, arrayMoveImmutable, ProFormSelect, useRefFunction } from '@ant-design/pro-components';
  13. import { ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
  14. import { ProColumns } from '@ant-design/pro-table';
  15. import { InputNumber, Dropdown, Input, MenuProps, message, Modal, Popconfirm, Space, Form, Table, Tabs } from 'antd';
  16. import { TransferItem, TransferProps } from 'antd/es/transfer';
  17. import React, { Key } from 'react';
  18. import { useEffect, useImperativeHandle, useRef, useState } from 'react';
  19. import { getMedicalGroup, getEmpTableDataFromMedicalGroup, addMedicalGroup, editMedicalGroup, delLeftReportData, addMedicalGroupEmp, updateMedicalGroupEmpInfo, delTableData, getAllUnitList, addGroupItemList, editGroupItemList } from './service';
  20. import './style.less';
  21. import '../../../../utils/zhongtaiB';
  22. import '../../../../utils/zhongtaiA'
  23. import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
  24. import { getSecondaryProjectDistriData } from '../secondaryProjectDistribute/service';
  25. const IconFont = createFromIconfontCN({
  26. scriptUrl: '',
  27. });
  28. const AddIconFont = createFromIconfontCN({
  29. scriptUrl: '',
  30. });
  31. const DragHandle = SortableHandle(() => (
  32. <MenuOutlined style={{ cursor: 'grab', color: '#999' }} />
  33. ));
  34. let _currentSelectedType: { groupCode: any; } | undefined = undefined;
  35. const SecondaryDistriGroupSet = () => {
  36. const [tableDataFilterParams, set_tableDataFilterParams] = useState<any | undefined>();
  37. const [typeList, set_typeList] = useState<any[]>([]);
  38. const [showTypeListArr, set_showTypeListArr] = useState<any[]>([]);
  39. const [currentSelectedType, set_currentSelectedType] = useState<any | undefined>(undefined);
  40. const [tableSelectedKeys, set_tableSelectedKeys] = useState<any[]>([]);
  41. const [selectedAddKeys, set_selectedAddKeys] = useState<Key[]>([]);
  42. const [ifShowModal, set_ifShowModal] = useState(false);
  43. const [currentEditLeftData, set_currentEditLeftData] = useState<any | undefined>(undefined);
  44. const [ifEditTable, set_ifEditTable] = useState(false);
  45. const [currentTabKey, set_currentTabKey] = useState('1');
  46. const tableRef = useRef<ActionType>();
  47. const [dataSource,set_dataSource] = useState<any[]>([]);
  48. const ref = React.createRef<{ save: any; getSelectedKeys: any }>();
  49. const [tableColumns,set_tableColumns] = useState<ProColumns[]>([]);
  50. const [tableDataSearchKeywords,set_tableDataSearchKeywords] = useState('');
  51. const columnOne:ProColumns[] = [
  52. {
  53. title: '核算单元名称',
  54. ellipsis: true,
  55. dataIndex: 'unitName',
  56. },
  57. {
  58. title: '核算单元代码',
  59. dataIndex: 'unitCode',
  60. },
  61. {
  62. title: '职类',
  63. dataIndex: 'unitTypeName',
  64. },
  65. {
  66. title: '操作',
  67. key: 'option',
  68. valueType: 'option',
  69. render: (_: any, record: any) => {
  70. console.log({currentSelectedType});
  71. return [
  72. <Popconfirm
  73. title="是否确认删除?"
  74. key="del"
  75. onConfirm={() => delTableDataHanfle(record)}
  76. >
  77. <a>删除</a>
  78. </Popconfirm>
  79. ]
  80. },
  81. },
  82. ];
  83. const columnTwo = [
  84. {
  85. title: '排序',
  86. dataIndex: 'sort',
  87. width: 60,
  88. className: 'drag-visible',
  89. render: () => <DragHandle />,
  90. },
  91. {
  92. title: '项目名称',
  93. ellipsis: true,
  94. dataIndex: 'itemName',
  95. },
  96. {
  97. title: '占比',
  98. dataIndex: 'weightPercent',
  99. },
  100. {
  101. title: '评价方式',
  102. dataIndex: 'evaluationName',
  103. },
  104. {
  105. title: '来源',
  106. dataIndex: 'sourceName',
  107. }
  108. ]
  109. const getTableData = async (params?:any)=>{
  110. if(!_currentSelectedType)return false;
  111. const { groupCode:secondGroupCode } = _currentSelectedType;
  112. let keywords=params?params.keywords:''
  113. if (secondGroupCode) {
  114. const resp = await getEmpTableDataFromMedicalGroup(currentTabKey == '1'?{secondGroupCode,unitName:keywords}:{secondGroupCode,itemName:keywords},currentTabKey == '1'?1:2);
  115. if (resp) {
  116. set_dataSource(resp);
  117. }
  118. }
  119. }
  120. const switchChangeHandle = async (checked: boolean, record: any, key: string) => {
  121. const result = { ...record, medicalGroupManager: checked ? 1 : 0 }
  122. const resp = await updateMedicalGroupEmpInfo(result);
  123. if (resp) {
  124. tableRef.current?.reload();
  125. }
  126. }
  127. const delTableDataHanfle = async (record?: { id: number; }) => {
  128. const resp = await delTableData(record ? [record.id] : [...tableSelectedKeys]);
  129. console.log({currentSelectedType});
  130. if (resp) {
  131. set_tableSelectedKeys([]);
  132. getTableData();
  133. }
  134. }
  135. //获取左侧数据
  136. const getPageLeftData = async () => {
  137. const resp = await getMedicalGroup();
  138. if (resp) {
  139. set_typeList(resp);
  140. set_showTypeListArr(resp);
  141. }
  142. }
  143. const updateTable = async (formVal: any, type: 'EDIT' | "ADD" | 'ADD_LEFTDATA' | 'EDIT_LEFTDATA') => {
  144. // console.log({formVal,type});
  145. if (type == 'ADD_LEFTDATA') {
  146. const resp = await addMedicalGroup({
  147. groupName: formVal.groupName,
  148. description: formVal.description,
  149. });
  150. if (resp) {
  151. getPageLeftData();
  152. }
  153. }
  154. if (type == 'EDIT_LEFTDATA') {
  155. const resp = await editMedicalGroup({
  156. id: formVal.id,
  157. groupName: formVal.groupName,
  158. description: formVal.description
  159. });
  160. if (resp) {
  161. getPageLeftData();
  162. }
  163. }
  164. return true;
  165. }
  166. const UpDataActBtn = ({ record, type }: { record: any, type: 'EDIT' | 'ADD' | 'ADD_LEFTDATA' | 'EDIT_LEFTDATA' }) => {
  167. const getTrriger = () => {
  168. if (type == 'ADD') {
  169. return <span className='add'>添加</span>
  170. }
  171. if (type == 'EDIT') {
  172. return <a key="edit" >编辑</a>
  173. }
  174. if (type == 'ADD_LEFTDATA') {
  175. return (
  176. <div className='add'>
  177. <img src={require('../../../../../static/addIcon_black.png')} alt="" />
  178. </div>
  179. )
  180. }
  181. if (type == 'EDIT_LEFTDATA') {
  182. return <a key="edit" >编辑</a>
  183. }
  184. }
  185. return (
  186. <ModalForm
  187. title={type == 'ADD_LEFTDATA' ? `新增分组` : `编辑分组`}
  188. width={352}
  189. initialValues={type == 'EDIT_LEFTDATA' ? { ...record } : {}}
  190. trigger={
  191. getTrriger()
  192. }
  193. onFinish={(val) => {
  194. return updateTable(type == 'EDIT_LEFTDATA' ? { ...record, ...val } : val, type);
  195. }}
  196. >
  197. <ProFormText
  198. label='分组名称:'
  199. name='groupName'
  200. rules={[{ required: true, message: '名称不能为空!' }]}
  201. />
  202. <ProFormTextArea
  203. label='说明:'
  204. name='description'
  205. />
  206. </ModalForm>
  207. )
  208. }
  209. interface TableSelecterProps extends TransferProps<TransferItem> {
  210. tableSelecterColumn: any[];
  211. record: any
  212. }
  213. const tableSelecterUnitColumn: any[] = [
  214. {
  215. title: '核算单元名称',
  216. dataIndex: 'unitName',
  217. },
  218. {
  219. title: '职类',
  220. dataIndex: 'unitTypeName',
  221. },
  222. ];
  223. const addGroupEmpHandle = () => {
  224. const ref = React.createRef<{ save: any; getSelectedKeys: any }>();
  225. set_ifShowModal(true);
  226. }
  227. const TableSelecter = React.forwardRef(({ tableSelecterColumn, record }: TableSelecterProps, ref) => {
  228. const [datasource, set_datasource] = useState<any[]>([]);
  229. const [selectedKeys, setSelectedKeys] = useState<React.Key[]>([]);
  230. const [showList, set_showList] = useState<any[]>([]);
  231. //获取表格数据
  232. const getFuncList = async () => {
  233. const resp = await getAllUnitList({ secondGroupCode: currentSelectedType.groupCode });
  234. if (resp) {
  235. set_datasource(resp);
  236. set_showList(resp);
  237. }
  238. }
  239. const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
  240. setSelectedKeys([...newSelectedRowKeys]);
  241. };
  242. const save = async () => {
  243. const result = {
  244. secondGroupCode: currentSelectedType.groupCode as string,
  245. unitCodeList: selectedKeys
  246. };
  247. const resp = await addMedicalGroupEmp(result);
  248. if (resp) {
  249. message.success('添加成功!');
  250. set_ifShowModal(false);
  251. getTableData();
  252. }
  253. }
  254. useEffect(() => {
  255. getFuncList();
  256. }, [])
  257. return (
  258. <div className='TableSelecter'>
  259. <Input placeholder={'请输入'} allowClear
  260. suffix={
  261. <IconFont style={{ color: '#99A6BF' }} type="iconsousuo" />
  262. }
  263. style={{ marginBottom: 8 }}
  264. onChange={(e) => {
  265. if (e.target.value.length != 0) {
  266. const result = datasource.filter(item => item.unitName.indexOf(e.target.value) != -1);
  267. set_showList(result);
  268. } else {
  269. set_showList(datasource);
  270. }
  271. }}
  272. />
  273. <BMSTable columns={tableSelecterColumn}
  274. options={{
  275. density: true,
  276. setting: {
  277. listsHeight: 100,
  278. },
  279. }}
  280. rowKey='code'
  281. // scroll={{y:300}}
  282. tableAlertRender={false}
  283. rowSelection={{
  284. // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
  285. // 注释该行则默认不显示下拉选项
  286. selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT],
  287. onChange: onSelectChange,
  288. }}
  289. pagination={{ showSizeChanger: false, pageSize:9, simple: true, showTitle: false }}
  290. dataSource={showList}
  291. />
  292. <div className='footer'>
  293. <span className='cancel' onClick={() => set_ifShowModal(false)}>取消</span>
  294. <span className='ok' onClick={() => save()}>{`确认(${selectedKeys.length > 0 && selectedKeys.length})`}</span>
  295. </div>
  296. </div>
  297. )
  298. });
  299. const moreItems: MenuProps['items'] = [
  300. {
  301. key: '1',
  302. label: <UpDataActBtn key={'act'} record={currentEditLeftData} type='EDIT_LEFTDATA' />,
  303. },
  304. {
  305. key: '2',
  306. label: (
  307. <a onClick={async (e) => {
  308. e.preventDefault();
  309. const resp = await delLeftReportData(currentEditLeftData.id);
  310. if (resp) {
  311. getPageLeftData();
  312. }
  313. }}>
  314. 删除
  315. </a>
  316. ),
  317. }
  318. ];
  319. const onTableSelectChange = (newSelectedRowKeys: React.Key[]) => {
  320. set_tableSelectedKeys([...newSelectedRowKeys]);
  321. };
  322. const updateSecondaryDistriItemSet = async (itemList:any[],type:'ADD'|'EDIT')=>{
  323. if(type == 'ADD'){
  324. const totalWeight = itemList.reduce((prev,cur)=>{
  325. console.log({'prev':prev,'cur.weight':cur.weight})
  326. return (prev)+cur.weight
  327. },0);
  328. console.log({totalWeight,itemList});
  329. if(totalWeight.toFixed(2) != 1){
  330. message.error('占比总和必须等于1!');
  331. return false
  332. }
  333. const result = {
  334. secondGroupCode:currentSelectedType.groupCode,
  335. itemList:itemList.map((a:any)=>({
  336. secondItemCode:a.secondItemCode?a.secondItemCode:a.itemCode,
  337. weight:a.weight
  338. }))
  339. }
  340. const resp = await addGroupItemList(result);
  341. if(resp){
  342. getTableData();
  343. return true;
  344. }
  345. return false
  346. }
  347. if(type == 'EDIT'){
  348. const resp = await editGroupItemList(itemList);
  349. if(resp){
  350. getTableData();
  351. }
  352. }
  353. }
  354. const AddItemComponent = () => {
  355. const [scoreList, set_scoreList] = useState<any[]>([]);
  356. const [scoreInitList, set_scoreInitList] = useState({});
  357. const addIndicator = () => {
  358. const key = Math.random();
  359. const temp = [...scoreList, { tempId: key, id: key, [`secondItemCode${key}`]: '', [`weight${key}`]: '' }];
  360. set_scoreInitList({ ...scoreInitList, [`secondItemCode${key}`]: '', [`weight${key}`]: '' });
  361. set_scoreList([...temp]);
  362. }
  363. const delGroupIndic = (data: any, index: number) => {
  364. let temp = [...scoreList];
  365. let defaultFormData: { [key: string]: any } = {};
  366. const result = temp.filter((a: any) => a.id != data.id);
  367. result.forEach((a: any) => {
  368. defaultFormData[`secondItemCode${a.id}`] = a.secondItemCode;
  369. defaultFormData[`weight${a.id}`] = a.weight;
  370. });
  371. set_scoreInitList({ ...defaultFormData });
  372. set_scoreList([...result]);
  373. }
  374. useEffect(() => {
  375. let defaultFormData: { [key: string]: any } = {};
  376. if (true) {
  377. const defaultVal = dataSource.map((a: any) => {
  378. defaultFormData[`secondItemCode${a.id}`] = a.itemCode;
  379. defaultFormData[`weight${a.id}`] = a.weight;
  380. return { ...a, tempId: Math.random() }
  381. });
  382. set_scoreInitList({ ...defaultFormData });
  383. set_scoreList([...defaultVal]);
  384. }
  385. },[]);
  386. return (
  387. <ModalForm
  388. title={`二次分配项目设置(${currentSelectedType.groupName})`}
  389. className='SecondaryDistriGroupSet-ModalForm'
  390. width={355}
  391. initialValues={{...scoreInitList}}
  392. trigger={
  393. <a className='score'>添加</a>
  394. }
  395. onFinish={(val) => {
  396. return updateSecondaryDistriItemSet(scoreList,'ADD');
  397. }}
  398. modalProps={{ destroyOnClose: true }}
  399. >
  400. {
  401. (
  402. <div>
  403. {
  404. scoreList.map((item: any, index: number) => {
  405. return (
  406. <div className='item' key={index}>
  407. <ProFormSelect label="管理指标:" width={160}
  408. name={`secondItemCode${item.id}`}
  409. request={async () => {
  410. const resp = await getSecondaryProjectDistriData({pageSize:1000,current:1});
  411. if (resp) {
  412. return resp.list.map((a: any) => ({
  413. label: a.name,
  414. value: a.code
  415. }))
  416. }
  417. return []
  418. }}
  419. fieldProps={{
  420. // labelInValue:true,
  421. onChange(value, option: any) {
  422. // console.log({value,option});
  423. const temp = [...scoreList];
  424. const newArr = temp.map((a: any) => {
  425. if (a.id == item.id) {
  426. return { ...a, secondItemCode: value, secondItemName: option.label }
  427. }
  428. return a
  429. });
  430. set_scoreList([...newArr]);
  431. },
  432. }}
  433. />
  434. <Form.Item name={`weight${item.id}`} label='占比:'>
  435. <InputNumber
  436. style={{ width: 120, height: 24, position: 'relative', top: 0 }}
  437. onChange={(value) => {
  438. //console.log({value,index,indicatorData});
  439. const temp = [...scoreList];
  440. const newArr = temp.map((a: any) => {
  441. if (a.id == item.id) {
  442. return { ...a, weight: value }
  443. }
  444. return a
  445. });
  446. set_scoreList([...newArr]);
  447. }}
  448. />
  449. </Form.Item>
  450. <span className='delIcon' onClick={() => delGroupIndic(item, index)}><IconFont type="iconshanchu" /></span>
  451. </div>
  452. )
  453. })
  454. }
  455. <div className='addBtn' onClick={() => addIndicator()}>
  456. <AddIconFont type="icon-zengjia" style={{ color: '#3376FE' }} /><span>增加一行</span>
  457. </div>
  458. </div>
  459. )
  460. }
  461. </ModalForm>
  462. )
  463. }
  464. const onTabChange = (activeKey:string) => {
  465. set_currentTabKey(activeKey);
  466. activeKey == '1'?set_tableColumns(columnOne):set_tableColumns(columnTwo);
  467. }
  468. const SortableItem = SortableElement((props: any) => <tr {...props} />);
  469. const SortContainer = SortableContainer((props: any) => <tbody {...props} />);
  470. const onSortEnd = useRefFunction(
  471. ({ oldIndex, newIndex }: { oldIndex: number; newIndex: number }) => {
  472. if (oldIndex !== newIndex) {
  473. const newData = arrayMoveImmutable({
  474. array: [...dataSource],
  475. fromIndex: oldIndex,
  476. toIndex: newIndex,
  477. }).filter((el) => !!el);
  478. const updatedSortArr = newData.map((item: any, index: number) => ({ ...item, sort: index }))
  479. set_dataSource([...updatedSortArr]);
  480. updateSecondaryDistriItemSet(updatedSortArr,'EDIT');
  481. }
  482. },
  483. );
  484. const DraggableContainer = (props: any) => (
  485. <SortContainer
  486. useDragHandle
  487. disableAutoscroll
  488. helperClass="row-dragging"
  489. onSortEnd={onSortEnd}
  490. {...props}
  491. />
  492. );
  493. const DraggableBodyRow = (props: any) => {
  494. const { className, style, ...restProps } = props;
  495. // function findIndex base on Table rowKey props and should always be a right array index
  496. const index = dataSource.findIndex(
  497. (x) => x.id === restProps['data-row-key'],
  498. );
  499. return <SortableItem index={index} {...restProps} />;
  500. };
  501. useEffect(() => {
  502. _currentSelectedType = currentSelectedType;
  503. if (currentSelectedType) {
  504. set_tableDataFilterParams({ ...tableDataFilterParams, secondGroupCode: currentSelectedType.groupCode });
  505. getTableData();
  506. }
  507. }, [currentSelectedType])
  508. useEffect(() => {
  509. if (showTypeListArr.length > 0) {
  510. set_currentSelectedType(showTypeListArr[0]);
  511. //set_tableDataFilterParams({ ...tableDataFilterParams, medicalGroupCode: showTypeListArr[0].code });
  512. }
  513. }, [showTypeListArr]);
  514. useEffect(()=>{
  515. getPageLeftData();
  516. },[currentTabKey]);
  517. useEffect(()=>{
  518. },[tableDataFilterParams])
  519. useEffect(() => {
  520. getPageLeftData();
  521. set_tableColumns(columnOne);
  522. }, [])
  523. return (
  524. <BMSPagecontainer title={false} className='SecondaryDistriGroupSet'>
  525. <ModalForm title={'新增分组核算单元'} width={400}
  526. submitter={{
  527. render: (props, defaultDoms) => []
  528. }}
  529. open={ifShowModal} modalProps={{
  530. closable: false,
  531. }}>
  532. <TableSelecter
  533. ref={ref}
  534. record={undefined}
  535. tableSelecterColumn={tableSelecterUnitColumn}
  536. ></TableSelecter>
  537. </ModalForm>
  538. <div className='left'>
  539. <div className='toolbar'>
  540. <Input placeholder={'请输入分组名称'} allowClear
  541. suffix={
  542. <IconFont style={{ color: '#99A6BF' }} type="iconsousuo" />
  543. }
  544. style={{ width: 156 }}
  545. onChange={(e) => {
  546. const result = typeList.filter(item => item.groupName.indexOf(e.target.value) != -1);
  547. set_showTypeListArr(result);
  548. }}
  549. />
  550. <UpDataActBtn key={'act'} record={undefined} type='ADD_LEFTDATA' />
  551. </div>
  552. <div className='wrap'>
  553. {
  554. showTypeListArr.map((item, index) => {
  555. return (
  556. <div className={currentSelectedType ? currentSelectedType.id == item.id ? 'type on' : 'type' : 'type'}
  557. key={index}
  558. onClick={() => {
  559. if (ifEditTable) {
  560. //编辑状态还未保存
  561. Modal.confirm({
  562. title: '当前存在编辑未保存,请保存后再操作!',
  563. okText: '放弃编辑',
  564. cancelText: '继续编辑',
  565. onOk(...args) {
  566. set_ifEditTable(false);
  567. set_currentSelectedType(item);
  568. },
  569. })
  570. } else {
  571. set_currentSelectedType(item)
  572. }
  573. }}
  574. >
  575. <div className='content'>
  576. <div className='name'>{item.groupName}</div>
  577. </div>
  578. <Dropdown menu={{ items: moreItems }} placement="bottom" onOpenChange={(bool) => { bool && set_currentEditLeftData(item) }}>
  579. <div className='more'>
  580. <img src={require('../../../../../static/more_point_gray.png')} alt="" />
  581. </div>
  582. </Dropdown>
  583. </div>
  584. )
  585. })
  586. }
  587. </div>
  588. </div>
  589. <div className='right'>
  590. <Tabs
  591. defaultActiveKey="1"
  592. onChange={onTabChange}
  593. items={[
  594. {
  595. label: `核算单元`,
  596. key: '1',
  597. },
  598. {
  599. label: `二次分配项目`,
  600. key: '2',
  601. },
  602. ]}
  603. />
  604. <div className='toolBar'>
  605. <div className='filter'>
  606. <div className='filterItem'>
  607. <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
  608. <Input placeholder={currentTabKey == '1'?'核算单元名称':'请输入项目名称'} allowClear
  609. suffix={
  610. <IconFont style={{ color: '#99A6BF' }} type="iconsousuo" onClick={() => getTableData({keywords:tableDataSearchKeywords})} />
  611. }
  612. onChange={(e) => {
  613. set_tableDataSearchKeywords(e.target.value);
  614. if (e.target.value.length == 0) {
  615. getTableData({keywords:''});
  616. }
  617. }}
  618. onPressEnter={(e) => {
  619. getTableData({keywords:tableDataSearchKeywords});
  620. }}
  621. />
  622. </div>
  623. </div>
  624. <div className='btnGroup'>
  625. {currentTabKey == '1'?<span className='manaBtn' onClick={() => addGroupEmpHandle()}>添加</span>:<AddItemComponent />}
  626. </div>
  627. </div>
  628. <div style={{ marginTop: 16 }}>
  629. {(currentSelectedType&&currentTabKey) && <BMSTable actionRef={tableRef} columns={tableColumns}
  630. rowKey='id'
  631. pagination={false}
  632. tableAlertRender={false}
  633. rowSelection={ currentTabKey == '1'?{
  634. // 自定义选择项参考: https://ant.design/components/table-cn/#components-table-demo-row-selection-custom
  635. // 注释该行则默认不显示下拉选项
  636. //selections: [Table.SELECTION_ALL, Table.SELECTION_INVERT, Table.SELECTION_NONE,],
  637. onChange: onTableSelectChange,
  638. }:false}
  639. tableAlertOptionRender={() => {
  640. return (
  641. <Space size={16}>
  642. <Popconfirm
  643. title="是否确认删除?"
  644. key="del"
  645. onConfirm={() => delTableDataHanfle()}
  646. >
  647. <a>批量删除</a>
  648. </Popconfirm>
  649. </Space>
  650. );
  651. }}
  652. params={tableDataFilterParams}
  653. dataSource={dataSource}
  654. //request={currentTabKey == '1'?(params, sort, filter) => getTableData(params, sort, filter):undefined}
  655. components={currentTabKey == '2' ? {
  656. body: {
  657. wrapper: DraggableContainer,
  658. row: DraggableBodyRow,
  659. },
  660. } : undefined}
  661. />}
  662. </div>
  663. </div>
  664. {
  665. tableSelectedKeys.length > 0 && (
  666. <div className='bottomToolbar'>
  667. <span className='leftAccount'>已选择<a>{tableSelectedKeys.length}</a>项</span>
  668. <div className='btnGroup'>
  669. <span className='cancel' onClick={() => tableRef.current?.clearSelected && tableRef.current?.clearSelected()}>取消选择</span>
  670. <Popconfirm
  671. title="是否确认删除?"
  672. key="del"
  673. onConfirm={() => delTableDataHanfle()}
  674. >
  675. <span className='batchDel'>批量删除</span>
  676. </Popconfirm>
  677. </div>
  678. </div>
  679. )
  680. }
  681. </BMSPagecontainer >
  682. )
  683. }
  684. export default SecondaryDistriGroupSet;