'use client' import { EllipsisOutlined, PlusOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { ProTable, TableDropdown } from '@ant-design/pro-components'; import { Button, Dropdown, Space, Tag } from 'antd'; import React, { useRef } from 'react'; import {DataType} from "@/app/lib/definitions"; import {OPERATION_BUTTON_TYPE, taskPriorityList, taskStateList, taskTreeResult} from "@/app/lib/task/project/data"; import {DetailModelForm} from "@/app/ui/task/project/DetailModelForm"; const columns: ProColumns[] = [ { title: '任务编码', dataIndex: 'code', // valueType: 'indexBorder', width: '10%', }, { title: '任务名称', dataIndex: 'name', width: '15%', copyable: true, ellipsis: true, tooltip: '标题过长会自动收缩', formItemProps: { rules: [ { required: true, message: '此项为必填项', }, ], }, }, { title: '任务描述', dataIndex: 'description', }, { disable: true, title: '任务状态', dataIndex: 'state', filters: true, onFilter: true, ellipsis: true, valueType: 'select', fieldProps:{options:taskStateList.map(item => {return {label: item.name,value: item.code}})}, }, { disable: true, title: '优先级', dataIndex: 'priority', valueType: 'select', fieldProps:{options:taskPriorityList.map(item => {return {label: item.name,value: item.code}})}, render: (_, record) => ( { item.code===record.priority?.toString())?.color} key={taskPriorityList.find(item=> item.code===record.priority?.toString())?.code}> {taskPriorityList.find(item=> item.code===record.priority?.toString())?.name} } ), }, { title: '期望开始时间', dataIndex: 'expectedStartTime', valueType: 'date', // hideInTable: true, // search: { // transform: (value) => { // return { // startTime: value, // }; // }, // }, }, { title: '期望结束时间', dataIndex: 'expectedEndTime', valueType: 'date', // hideInTable: true, // search: { // transform: (value) => { // return { // startTime: value, // }; // }, // }, }, { title: '实际开始时间', dataIndex: 'actualStartTime', valueType: 'date', // hideInTable: true, // search: { // transform: (value) => { // return { // startTime: value, // }; // }, // }, }, { title: '期望结束时间', dataIndex: 'actualEndTime', valueType: 'date', // hideInTable: true, // search: { // transform: (value) => { // return { // startTime: value, // }; // }, // }, }, // { // title: '创建时间', // dataIndex: 'created_at', // valueType: 'dateRange', // hideInTable: true, // search: { // transform: (value) => { // return { // startTime: value[0], // endTime: value[1], // }; // }, // }, // }, // { // title: '操作', // valueType: 'option', // key: 'option', // render: (text, record, _, action) => [ // { // action?.startEditable?.(record.id); // }} // > // 编辑 // , // // 查看 // , // action?.reload()} // menus={[ // { key: 'copy', name: '复制' }, // { key: 'delete', name: '删除' }, // ]} // />, // ], // }, ]; const TreeTablePro: React.FC = () => { const actionRef = useRef(); return ( columns={columns} actionRef={actionRef} cardBordered request={async (params, sort, filter) => { console.log(sort, filter); // await waitTime(2000); // return axios.post<{ // data: GithubIssueItem[]; // }>('https://proapi.azurewebsites.net/github/issues', { // params, // }); const response = await taskTreeResult() // axios.post('https://proapi.azurewebsites.net/github/issues', { // params, // }); return { data:response.data.content, success: response.status.success, } // return response.data; }} editable={{ type: 'multiple', }} columnsState={{ persistenceKey: 'pro-table-singe-demos', persistenceType: 'localStorage', defaultValue: { option: { fixed: 'right', disable: true }, }, onChange(value) { console.log('value: ', value); }, }} rowKey="id" // search={{ // labelWidth: 'auto', // }} search={false} options={{ setting: { listsHeight: 400, }, }} form={{ // 由于配置了 transform,提交的参与与定义的不同这里需要转化一下 syncToUrl: (values, type) => { if (type === 'get') { return { ...values, created_at: [values.startTime, values.endTime], }; } return values; }, }} pagination={{ pageSize: 5, onChange: (page) => console.log(page), }} dateFormatter="string" headerTitle="任务管理" toolBarRender={() => [ , // // // , ]}> ); }; export default TreeTablePro