2024-04-12 06:43:55 -04:00
|
|
|
'use client'
|
2024-05-30 02:32:17 -04:00
|
|
|
import React, {useContext} from 'react';
|
2024-04-23 03:38:51 -04:00
|
|
|
import {ConfigProvider, Table} from 'antd';
|
2024-04-19 05:44:44 -04:00
|
|
|
import type {TableColumnsType, TableProps} from 'antd';
|
2024-05-28 06:54:58 -04:00
|
|
|
import {taskPriorityList, taskStateList} from "@/lib/task/project/data";
|
|
|
|
import {DataType} from "@/lib/definitions";
|
2024-05-10 04:00:35 -04:00
|
|
|
import OperationButton from "@/ui/task/OperationButton";
|
|
|
|
import "@/ui/task/four/detailForm.modules.css"
|
|
|
|
import LocalContext from "@/ui/LocalContent";
|
2024-04-25 04:36:40 -04:00
|
|
|
import {useSearchParams} from "next/dist/client/components/navigation";
|
2024-05-10 04:00:35 -04:00
|
|
|
import {RequestDateType} from "@/ui/task/RequestDateType";
|
2024-04-12 06:43:55 -04:00
|
|
|
|
2024-04-25 04:36:40 -04:00
|
|
|
type TableRowSelection<T> = TableProps<T>['rowSelection'];
|
2024-04-12 06:43:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
// rowSelection objects indicates the need for row selection
|
|
|
|
const rowSelection: TableRowSelection<DataType> = {
|
|
|
|
onChange: (selectedRowKeys, selectedRows) => {
|
|
|
|
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
|
|
|
},
|
|
|
|
onSelect: (record, selected, selectedRows) => {
|
|
|
|
console.log(record, selected, selectedRows);
|
|
|
|
},
|
|
|
|
onSelectAll: (selected, selectedRows, changeRows) => {
|
|
|
|
console.log(selected, selectedRows, changeRows);
|
|
|
|
},
|
|
|
|
};
|
2024-04-16 04:11:21 -04:00
|
|
|
|
2024-04-19 05:44:44 -04:00
|
|
|
interface TableSearchType {
|
2024-04-25 04:36:40 -04:00
|
|
|
priority: string,
|
|
|
|
resultDataTypeList: DataType[],
|
2024-05-10 04:10:54 -04:00
|
|
|
refreshDate?: () => void,
|
|
|
|
loadingState:boolean
|
2024-04-19 05:44:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const TreeTable: React.FC<TableSearchType> = (props) => {
|
2024-04-25 04:36:40 -04:00
|
|
|
const dataLocalContext = useContext(LocalContext);
|
|
|
|
console.log('dataLocalContext', dataLocalContext)
|
|
|
|
const checkLocal:boolean = useSearchParams().get('pid')!=undefined;
|
|
|
|
const columns: TableColumnsType<DataType> = [
|
|
|
|
{
|
|
|
|
title: '任务编码',
|
|
|
|
dataIndex: 'code',
|
|
|
|
key: 'code',
|
|
|
|
width: '10%',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '任务名称',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
width: '20%',
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// title: '任务描述',
|
|
|
|
// dataIndex: 'description',
|
|
|
|
// // width: '30%',
|
|
|
|
// key: 'description',
|
|
|
|
// },
|
|
|
|
{
|
|
|
|
title: '任务状态',
|
|
|
|
dataIndex: 'state',
|
|
|
|
width: '10%',
|
|
|
|
key: 'state',
|
|
|
|
filtered: checkLocal&&dataLocalContext.taskState.length > 0,
|
|
|
|
defaultFilteredValue: dataLocalContext.taskState.split(','),
|
|
|
|
onFilter: (text, record) => {
|
|
|
|
// console.log('&record.priority.toString()===props.priority',record.priority,text,props.priority)
|
|
|
|
// &record.priority.toString()===props.priority 不重要紧急 0 0
|
|
|
|
if (dataLocalContext.taskState.length === 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
var dataLocalContextTaskStateList = dataLocalContext.taskState.split(",");
|
|
|
|
console.log('dataLocalContextTaskStateList', dataLocalContext.taskState.length > 0, dataLocalContextTaskStateList);
|
|
|
|
return taskStateList.filter(taskState => dataLocalContextTaskStateList.includes(taskState.code))
|
|
|
|
.find(taskState => taskState.name === record.state) != undefined;
|
2024-04-23 01:19:26 -04:00
|
|
|
}
|
2024-04-25 04:36:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '优先级',
|
|
|
|
dataIndex: 'priority',
|
|
|
|
width: '10%',
|
|
|
|
key: 'priority',
|
|
|
|
hidden: true,
|
|
|
|
filters: taskPriorityList.map(taskState => {
|
|
|
|
return {
|
|
|
|
'text': taskState.name,
|
|
|
|
'value': taskState.code
|
2024-04-23 01:19:26 -04:00
|
|
|
}
|
2024-04-25 04:36:40 -04:00
|
|
|
}),
|
|
|
|
filtered: true,
|
|
|
|
defaultFilteredValue: [props.priority],
|
|
|
|
onFilter: (text, record) => {
|
|
|
|
console.log('&record.priority.toString()===props.priority',record.priority,text,props.priority,props.priority === record.priority)
|
|
|
|
// &record.priority.toString()===props.priority 不重要紧急 0 0
|
|
|
|
return props.priority === record.priority+''
|
2024-04-16 04:11:21 -04:00
|
|
|
}
|
2024-04-25 04:36:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '期望开始时间',
|
|
|
|
dataIndex: 'expectedStartTime',
|
|
|
|
width: '10%',
|
|
|
|
key: 'expectedStartTime',
|
|
|
|
filtered: checkLocal&&dataLocalContext.expectedStartTime.length > 0,
|
|
|
|
// defaultFilteredValue: JSON.parse(dataLocalContext.expectedStartTime),
|
|
|
|
onFilter: (text, record) => {
|
|
|
|
console.log('dataLocalContext.expectedStartTime',dataLocalContext.expectedStartTime)
|
|
|
|
if (dataLocalContext.expectedStartTime.length === 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
const expectStartTimeParseResult:RequestDateType[] = JSON.parse(dataLocalContext.expectedStartTime);
|
|
|
|
console.log('expectStartTimeParseResult',expectStartTimeParseResult)
|
|
|
|
if (expectStartTimeParseResult[0]!=undefined){
|
|
|
|
let le:boolean;
|
|
|
|
if (expectStartTimeParseResult[0].operateType==='<='){
|
|
|
|
le=record.expectedStartTime!=undefined&&record.expectedStartTime<=expectStartTimeParseResult[0].value
|
|
|
|
}else {
|
|
|
|
le=record.expectedStartTime!=undefined&&record.expectedStartTime>=expectStartTimeParseResult[0].value
|
|
|
|
}
|
|
|
|
if (!le){
|
|
|
|
return le;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(expectStartTimeParseResult[1]!=undefined){
|
|
|
|
let ge:boolean = record.expectedStartTime!=undefined&&record.expectedStartTime<=expectStartTimeParseResult[1].value
|
|
|
|
if (!ge){
|
|
|
|
return ge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2024-04-12 06:43:55 -04:00
|
|
|
}
|
2024-04-25 04:36:40 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '操作',
|
|
|
|
dataIndex: 'action',
|
|
|
|
width: '10%',
|
|
|
|
key: 'action',
|
|
|
|
},
|
|
|
|
];
|
2024-04-12 06:43:55 -04:00
|
|
|
return (
|
|
|
|
<>
|
2024-04-23 03:38:51 -04:00
|
|
|
<ConfigProvider
|
|
|
|
theme={{
|
|
|
|
components: {
|
|
|
|
Table: {
|
2024-04-25 04:36:40 -04:00
|
|
|
headerBg: taskPriorityList.find((item) => item.code === props.priority)?.color
|
2024-04-23 03:38:51 -04:00
|
|
|
/* 这里是你的组件 token */
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Table
|
|
|
|
columns={columns}
|
|
|
|
// rowSelection={{ ...rowSelection, checkStrictly}}
|
2024-04-25 04:36:40 -04:00
|
|
|
dataSource={props.resultDataTypeList.filter(resultDataType=>{
|
|
|
|
resultDataType.action= <OperationButton itemId={resultDataType.id} pid={resultDataType.pid} pPid={resultDataType.pPid} refreshDate={props.refreshDate}/>
|
|
|
|
if (dataLocalContext.expectedStartTime.length === 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
const expectStartTimeParseResult:RequestDateType[] = JSON.parse(dataLocalContext.expectedStartTime);
|
|
|
|
if (expectStartTimeParseResult[0]!=undefined){
|
|
|
|
let le:boolean;
|
|
|
|
if (expectStartTimeParseResult[0].operateType==='<='){
|
|
|
|
le=resultDataType.expectedStartTime!=undefined&&resultDataType.expectedStartTime<=expectStartTimeParseResult[0].value
|
|
|
|
}else {
|
|
|
|
le=resultDataType.expectedStartTime!=undefined&&resultDataType.expectedStartTime>=expectStartTimeParseResult[0].value
|
|
|
|
}
|
|
|
|
if (!le){
|
|
|
|
return le;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(expectStartTimeParseResult[1]!=undefined){
|
|
|
|
let ge:boolean = resultDataType.expectedStartTime!=undefined&&resultDataType.expectedStartTime<=expectStartTimeParseResult[1].value
|
|
|
|
if (!ge){
|
|
|
|
return ge;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
})}
|
|
|
|
pagination={{pageSize: 5}}
|
|
|
|
scroll={{y: 280}}
|
2024-05-10 04:10:54 -04:00
|
|
|
loading={props.loadingState}
|
2024-04-23 03:38:51 -04:00
|
|
|
/>
|
|
|
|
</ConfigProvider>
|
2024-04-12 06:43:55 -04:00
|
|
|
{/*<Space align="center" style={{ marginBottom: 16 }}>*/}
|
|
|
|
{/* CheckStrictly: <Switch checked={checkStrictly} onChange={setCheckStrictly} />*/}
|
|
|
|
{/*</Space>*/}
|
2024-04-17 22:38:47 -04:00
|
|
|
{/*<ColorPicker defaultValue="#1677ff" showText/>*/}
|
2024-04-12 06:43:55 -04:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default TreeTable;
|