pointAndGroup.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import React,{ useState,useEffect} from 'react';
  2. import {deptAndCheckPointPage,delDeptAndCheckPoint} from "@/api/checkPointManage.js";
  3. import EditableFormTable from './table';
  4. import { Input} from 'antd';
  5. const { Search } = Input;
  6. const CheckGroupManage = () => {
  7. let [arr,setarr] = useState([]);
  8. let [pages,setpages] = useState({});
  9. let [ifUpdateList,setifUpdateList]=useState(false);
  10. let [ifRender,setifRender] = useState(false);
  11. const columns = [
  12. {
  13. title: 'id',
  14. dataIndex: 'id',
  15. key: 'id',
  16. width:'10%',
  17. render: text => <a>{text}</a>,
  18. },
  19. {
  20. title: '部门ID',
  21. dataIndex: 'deptId',
  22. key: 'deptId',
  23. editable: true,
  24. },
  25. {
  26. title: '部门名称',
  27. dataIndex: 'deptName',
  28. key: 'deptName',
  29. editable: true,
  30. },
  31. {
  32. title: '查核要点ID',
  33. dataIndex: 'checkPointId',
  34. key: 'checkPointId',
  35. editable: true,
  36. },
  37. {
  38. title: '查核要点',
  39. dataIndex: 'checkPointName',
  40. key: 'checkPointName',
  41. editable: true,
  42. },
  43. ];
  44. const getData = async (pageObj)=>{
  45. let data = await deptAndCheckPointPage(pageObj);
  46. const renderData = data.data.data.list.map((item,index)=>{
  47. return {
  48. ...item,
  49. key:item['id'],
  50. // editable: true,
  51. }
  52. })
  53. setarr(renderData);
  54. setpages({
  55. 'currPage':data.data.data.currPage,
  56. 'totalPage':data.data.data.totalPage,
  57. 'totalCount':data.data.data.totalCount,
  58. });
  59. setifRender(false);
  60. setifRender(true);
  61. }
  62. const deleteCallback = (record)=>{
  63. // console.log('删除');
  64. delDeptAndCheckPoint([record.id]).then(res=>{
  65. if(res.data.msg=="success"){
  66. getData();
  67. }
  68. })
  69. }
  70. const paginationCallback = (obj)=>{
  71. const {currPage} = obj;
  72. getData({page:currPage,pageSize:10});
  73. }
  74. const onSearch = (searchKey)=>{
  75. // console.log({searchKey});
  76. getData({
  77. 'keyword':searchKey?searchKey:''
  78. });
  79. }
  80. useEffect(()=>{
  81. getData();
  82. },[]);
  83. return (
  84. <div className="app-container">
  85. <h1>要点与单位</h1>
  86. <div style={{display:'flex',flexDirection:'row',marginBottom:16}}>
  87. {/* <Button onClick={handleAdd} type="primary" style={{ marginBottom: 16,marginRight:20 }}>
  88. 新增查核项
  89. </Button> */}
  90. <Search style={{ width: 230 }} allowClear placeholder="请输入要点名/单位名" onSearch={onSearch} enterButton />
  91. </div>
  92. {
  93. ifRender&& <EditableFormTable columns={columns} pages={pages} paginationCallback={paginationCallback} data={arr} deleteCallback={deleteCallback} ifUpdateList={ifUpdateList}/>
  94. }
  95. </div>
  96. );
  97. }
  98. export default CheckGroupManage;