|
@@ -1,14 +1,14 @@
|
|
|
import { delProject, getProjectList } from '@/services/api/project'
|
|
|
import ProTable from '@ant-design/pro-table'
|
|
|
import type { ProColumnType, ActionType } from '@ant-design/pro-table'
|
|
|
-import { Popconfirm } from 'antd'
|
|
|
+import { Button, Popconfirm } from 'antd'
|
|
|
import consts from '@/utils/consts'
|
|
|
import { useRef, useState, useEffect } from 'react'
|
|
|
import { connect, useRequest } from 'umi'
|
|
|
import type { ConnectProps } from 'umi'
|
|
|
import type { ProjectModelState } from '../model'
|
|
|
import { DeleteOutlined } from '@ant-design/icons'
|
|
|
-import AddProject, { ModalType } from './components/AddProject'
|
|
|
+import ProjectModal, { ModalType } from './components/ProjectModal'
|
|
|
|
|
|
type ListProps = ConnectProps & {
|
|
|
pTypeList: { label: string; value: string }[]
|
|
@@ -49,7 +49,7 @@ const List: React.FC<ListProps> = ({ dispatch, pTypeList }) => {
|
|
|
title: '项目类型',
|
|
|
filters: true,
|
|
|
filterMultiple: false,
|
|
|
- render: (_, record) => <div>{record.name}</div>,
|
|
|
+ render: (_, record) => <div>{record.project_type.name}</div>,
|
|
|
valueEnum: pTypeList.reduce((prev, curr) => {
|
|
|
const items = { ...prev }
|
|
|
items[curr.value] = {
|
|
@@ -99,39 +99,47 @@ const List: React.FC<ListProps> = ({ dispatch, pTypeList }) => {
|
|
|
}
|
|
|
]
|
|
|
return (
|
|
|
- <ProTable<API.ProjectListItem>
|
|
|
- rowKey="id"
|
|
|
- params={state.params}
|
|
|
- actionRef={tRef}
|
|
|
- columns={columns}
|
|
|
- request={async (params, filter, sorter) => {
|
|
|
- const { code = -1, data: { items = [], totle = 0 } = {} } = await getProjectList({
|
|
|
- ...params,
|
|
|
- ...filter,
|
|
|
- ...sorter
|
|
|
- })
|
|
|
- return {
|
|
|
- data: items,
|
|
|
- success: code === consts.RET_CODE.SUCCESS,
|
|
|
- totle
|
|
|
- }
|
|
|
- }}
|
|
|
- toolbar={{
|
|
|
- search: {
|
|
|
- onSearch: val => setState({ ...state, params: { ...state.params, search: val } })
|
|
|
- },
|
|
|
- actions: [
|
|
|
- <AddProject
|
|
|
- type={state.currentModalType}
|
|
|
- defaultFormData={state.defaultFormData}
|
|
|
- pTypeList={pTypeList}
|
|
|
- visible={state.visible}
|
|
|
- onVisibleChange={(visible: boolean) => setState({ ...state, visible })}
|
|
|
- />
|
|
|
- ]
|
|
|
- }}
|
|
|
- search={false}
|
|
|
- />
|
|
|
+ <div>
|
|
|
+ <ProTable<API.ProjectListItem>
|
|
|
+ rowKey="id"
|
|
|
+ params={state.params}
|
|
|
+ actionRef={tRef}
|
|
|
+ columns={columns}
|
|
|
+ request={async (params, filter, sorter) => {
|
|
|
+ const { code = -1, data: { items = [], totle = 0 } = {} } = await getProjectList({
|
|
|
+ ...params,
|
|
|
+ ...filter,
|
|
|
+ ...sorter
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ data: items,
|
|
|
+ success: code === consts.RET_CODE.SUCCESS,
|
|
|
+ totle
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ toolbar={{
|
|
|
+ search: {
|
|
|
+ onSearch: val => setState({ ...state, params: { ...state.params, search: val } })
|
|
|
+ },
|
|
|
+ actions: [
|
|
|
+ <Button
|
|
|
+ onClick={() => setState({ ...state, visible: true, currentModalType: ModalType.ADD })}
|
|
|
+ >
|
|
|
+ 新建项目
|
|
|
+ </Button>
|
|
|
+ ]
|
|
|
+ }}
|
|
|
+ search={false}
|
|
|
+ />
|
|
|
+ <ProjectModal
|
|
|
+ type={state.currentModalType}
|
|
|
+ defaultFormData={state.defaultFormData}
|
|
|
+ pTypeList={pTypeList}
|
|
|
+ visible={state.visible}
|
|
|
+ reloadTable={() => tRef.current?.reload()}
|
|
|
+ setVisible={(visible: boolean) => setState({ ...state, visible })}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
)
|
|
|
}
|
|
|
|