import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
import BasicCrudModal from '../../../../components/crud/BasicCrudModal';
import { Table, Card, Modal, Form, Input, Button, Row,Col, Timeline, message, Tabs,Image } from 'antd';
import {FileWordOutlined,FilePdfOutlined,FileZipOutlined,FileExcelOutlined } from '@ant-design/icons';
import { useSelector } from 'react-redux';
import ToolBar from './toolbar';
import ModalForm from './form';
import DetailModalForm from "./detailForm"
import apiurl from '../../../../service/apiurl';
import usePageTable from '../../../../components/crud/usePageTable2';
import { createCrudService } from '../../../../components/crud/_';
import {CrudOpRender_text} from '../../../../components/crud/CrudOpRender';
const url = "http://223.75.53.141:9102/test.by-lyf.tmp"
const Page = () => {
const role = useSelector(state => state.auth.role);
const editBtn = role?.rule?.find(item => item.menuName == "编辑")||true;
const viewBtn = role?.rule?.find(item => item.menuName == "查看")||true;
const delBtn = role?.rule?.find(item => item.menuName == "删除")||true;
const task = {
0: "未完成",
1: "进行中",
2: "已完成"
}
const taskType = {
0: "日常巡查",
1: "特别检查",
2: "汛前巡检"
}
const refModal = useRef();
const [searchVal, setSearchVal] = useState(false)
const [tabs, setTabsChange] = useState(0)
const columns = [
{ title: '序号', key: 'inx', dataIndex: 'inx', width: 60, align: "center" },
{
title: '任务类型', key: 'taskType', dataIndex: 'taskType', width: 200,
render: (value) => {taskType[value]}
},
{ title: '任务标题', key: 'taskTitle', dataIndex: 'taskTitle', width: 250, ellipsis: true },
{title: '任务内容', key: 'taskContent', dataIndex: 'taskContent', width: 200},
{
title: '任务状态', key: 'status', dataIndex: 'status', width: 200,
render: (value) =>
{task[value]}
},
{title: '巡查人', key: 'inspectUserName', dataIndex: 'inspectUserName', width: 100},
{title: '开始日期', key: 'startDate', dataIndex: 'startDate', width: 200},
{title: '结束日期', key: 'endDate', dataIndex: 'endDate', width: 200},
{title: '问题数量', key: 'problemNum', dataIndex: 'problemNum', width: 100,align: 'center'},
{ title: '待处理', key: 'handleNum ', dataIndex: 'handleNum ', width: 100,align: 'center'},
{ title: '创建时间', key: 'createTime', dataIndex: 'createTime', width: 200 },
{ title: '创建人', key: 'createUserName', dataIndex: 'createUserName', width: 150 },
{
title: '操作', key: 'operation', width: 200, fixed: 'right',align: 'center',
render: (value, row, index) => (
() => command(cmd)(row)} />)
},
];
const [modeBtn, setModeBtn] = useState('')
const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]);
const command = (type) => (params) => {
setModeBtn(type)
if (type === 'save') {
refModal.current.showSave();
} else if (type === 'edit') {
refModal.current.showEdit({ ...params });
} else if (type === 'view') {
refModal.current.showView(params);
} else if (type === 'del') {
refModal.current.onDeleteGet(apiurl.rcgl.xcxj.xjrw.delete + `/${params.id}`);
}
}
const { tableProps, search, refresh } = usePageTable(createCrudService(apiurl.rcgl.xcxj.xjrw.page).find_noCode);
const { tableProps:tableProps0, search:search0 } = usePageTable(createCrudService(apiurl.rcgl.xcxj.xjrw.page).find_noCode);
const { tableProps:tableProps1, search:search1 } = usePageTable(createCrudService(apiurl.rcgl.xcxj.xjrw.page).find_noCode);
const { tableProps:tableProps2, search:search2 } = usePageTable(createCrudService(apiurl.rcgl.xcxj.xjrw.page).find_noCode);
/**
* @description 处理成功的回调
*/
const successCallback = () => {
refresh()
setTabsChange(0)
}
useEffect(() => {
const userId = localStorage.getItem('userId')
if (searchVal) {
const params = {
search: {
...searchVal,
status: Number(tabs),
createUserId:userId
}
};
search(params)
}
}, [searchVal, tabs])
useEffect(() => {
const userId = localStorage.getItem('userId')
if (searchVal) {
const params = {
search: {
...searchVal,
status: 0,
createUserId:userId
}
};
search0(params)
}
}, [searchVal])
useEffect(() => {
const userId = localStorage.getItem('userId')
if (searchVal) {
const params = {
search: {
...searchVal,
status: 1,
createUserId:userId
}
};
search1(params)
}
}, [searchVal])
useEffect(() => {
const userId = localStorage.getItem('userId')
if (searchVal) {
const params = {
search: {
...searchVal,
status: 2,
createUserId:userId
}
};
search2(params)
}
}, [searchVal])
return (
<>
setTabsChange(e)}
activeKey={tabs}
items={[
{
label: `未完成(${tableProps0?.pagination?.total})`,
key: 0,
children:
},
{
label: `进行中(${tableProps1?.pagination?.total})`,
key: 1,
children:
},
{
label: `已完成(${tableProps2?.pagination?.total})`,
key: 2,
children:
}
]}
>
{refresh({addvcd:localStorage.getItem('ADCD6')})}}
/>
>
);
}
export default Page;