123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import React,{ useState,useEffect} from 'react';
- import {deptAndCheckPointPage,delDeptAndCheckPoint} from "@/api/checkPointManage.js";
- import EditableFormTable from './table';
- import { Input} from 'antd';
- const { Search } = Input;
- const CheckGroupManage = () => {
- let [arr,setarr] = useState([]);
- let [pages,setpages] = useState({});
- let [ifUpdateList,setifUpdateList]=useState(false);
- let [ifRender,setifRender] = useState(false);
-
- const columns = [
- {
- title: 'id',
- dataIndex: 'id',
- key: 'id',
- width:'10%',
- render: text => <a>{text}</a>,
- },
- {
- title: '部门ID',
- dataIndex: 'deptId',
- key: 'deptId',
- editable: true,
- },
- {
- title: '部门名称',
- dataIndex: 'deptName',
- key: 'deptName',
- editable: true,
- },
- {
- title: '查核要点ID',
- dataIndex: 'checkPointId',
- key: 'checkPointId',
- editable: true,
- },
- {
- title: '查核要点',
- dataIndex: 'checkPointName',
- key: 'checkPointName',
- editable: true,
- },
- ];
- const getData = async (pageObj)=>{
- let data = await deptAndCheckPointPage(pageObj);
-
- const renderData = data.data.data.list.map((item,index)=>{
- return {
- ...item,
- key:item['id'],
- // editable: true,
- }
- })
- setarr(renderData);
- setpages({
- 'currPage':data.data.data.currPage,
- 'totalPage':data.data.data.totalPage,
- 'totalCount':data.data.data.totalCount,
- });
- setifRender(false);
- setifRender(true);
- }
- const deleteCallback = (record)=>{
- // console.log('删除');
- delDeptAndCheckPoint([record.id]).then(res=>{
- if(res.data.msg=="success"){
- getData();
- }
- })
- }
- const paginationCallback = (obj)=>{
- const {currPage} = obj;
- getData({page:currPage,pageSize:10});
- }
- const onSearch = (searchKey)=>{
- // console.log({searchKey});
- getData({
- 'keyword':searchKey?searchKey:''
- });
- }
-
- useEffect(()=>{
- getData();
- },[]);
- return (
- <div className="app-container">
- <h1>要点与单位</h1>
- <div style={{display:'flex',flexDirection:'row',marginBottom:16}}>
- {/* <Button onClick={handleAdd} type="primary" style={{ marginBottom: 16,marginRight:20 }}>
- 新增查核项
- </Button> */}
- <Search style={{ width: 230 }} allowClear placeholder="请输入要点名/单位名" onSearch={onSearch} enterButton />
- </div>
- {
- ifRender&& <EditableFormTable columns={columns} pages={pages} paginationCallback={paginationCallback} data={arr} deleteCallback={deleteCallback} ifUpdateList={ifUpdateList}/>
- }
- </div>
- );
- }
-
- export default CheckGroupManage;
|