添加拉取部门的等待
parent
1f73983dfb
commit
a39d3ce14a
|
@ -1,8 +1,8 @@
|
|||
import React, {useRef, useState} from "react";
|
||||
import {Button, Popover, Tabs, TabsProps, theme} from "antd";
|
||||
import {ActionType, ProColumns, ProTable} from "@ant-design/pro-components";
|
||||
import {ActionType, ProColumns, ProFormInstance, ProTable} from "@ant-design/pro-components";
|
||||
import Search from "antd/es/input/Search";
|
||||
import {statusEnum} from "../mine/MyReimbursement";
|
||||
import {preStatusFilter, statusEnum} from "../mine/MyReimbursement";
|
||||
import axiosInstance from "../../../utils/axiosInstance";
|
||||
import {ExclamationCircleOutlined} from "@ant-design/icons";
|
||||
import {openNotification} from "../mine/utils";
|
||||
|
@ -31,6 +31,7 @@ export type TableListItem = {
|
|||
|
||||
class ReimbursementTab extends React.Component<any, any> {
|
||||
tableAction = React.createRef<ActionType>();
|
||||
formRef: React.MutableRefObject<ProFormInstance> = React.createRef<ProFormInstance>() as any;
|
||||
departments = new Map<number, string>()
|
||||
columns: ProColumns<TableListItem>[] = [
|
||||
{
|
||||
|
@ -89,6 +90,7 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
onFilter: false,
|
||||
search: false,
|
||||
valueEnum: statusEnum,
|
||||
// defaultFilteredValue:preStatusFilter(),
|
||||
//render: (_) => <a>{_}</a>,
|
||||
},
|
||||
{
|
||||
|
@ -138,6 +140,7 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
mode: props.mode,
|
||||
detailedReimbursement: undefined,
|
||||
activate: props.activate,
|
||||
initialized: false,
|
||||
reload: () => {
|
||||
this.tableAction.current?.reload()
|
||||
},
|
||||
|
@ -149,6 +152,7 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
prevState.reload()
|
||||
if (nextProps.activate !== prevState.activate) {
|
||||
return {
|
||||
initialized: false,
|
||||
mode: nextProps.mode,
|
||||
activate: nextProps.activate,
|
||||
detailedReimbursement: undefined,
|
||||
|
@ -165,7 +169,7 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
axiosInstance.get('common/department').then(response => {
|
||||
this.departments.clear()
|
||||
response.data.forEach((value: any) => {
|
||||
this.departments.set(value.departmentId, value.departmentName)
|
||||
this.departments.set(value.departmentId, value.departmentName)
|
||||
}
|
||||
)
|
||||
this.tableAction.current?.reload()
|
||||
|
@ -190,7 +194,14 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
async updateRequest(current: number | undefined, pageSize: number | undefined, sort: Record<string, SortOrder>, filter: Record<string, React.ReactText[] | null>) {
|
||||
let tableListDataSource: TableListItem[] = []
|
||||
let totalRecordLength = 0
|
||||
|
||||
if(this.departments.size===0){
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
if (!this.state.initialize && this.state.mode === 0) {
|
||||
console.log({status: [statusEnum[0]]})
|
||||
this.formRef.current?.setFieldsValue({status: [statusEnum[0]]})
|
||||
this.setState({initialize: true})
|
||||
}
|
||||
current = (current === undefined ? 1 : current)
|
||||
pageSize = (pageSize === undefined ? 5 : pageSize)
|
||||
let params: any = {
|
||||
|
@ -288,6 +299,7 @@ class ReimbursementTab extends React.Component<any, any> {
|
|||
accessLevel={this.props.accessLevel}
|
||||
/>
|
||||
<ProTable<TableListItem>
|
||||
formRef={this.formRef}
|
||||
actionRef={this.tableAction}
|
||||
columns={this.columns}
|
||||
request={async (params, sorter, filter) => {
|
||||
|
|
|
@ -15,6 +15,20 @@ import ReimbursementDetail from "./ReimbursementDetail";
|
|||
import {openNotification} from "./utils";
|
||||
import {store} from "../../../models/store";
|
||||
|
||||
export function preStatusFilter(mode:number) {
|
||||
let d1 = store.getState().staff.managingDepartment
|
||||
let d2 = store.getState().staff.staffDepartments
|
||||
if (store.getState().token.staffId === "manager") {
|
||||
return ["3"]
|
||||
} else if ((d1 && d1.departmentId === 1)) {
|
||||
return ["2"]
|
||||
} else if ((d2 && d2.find((value, index, obj) => value.departmentId === 1))) {
|
||||
return ["4"]
|
||||
} else {
|
||||
return ["0"]
|
||||
}
|
||||
}
|
||||
|
||||
const valueEnum = {
|
||||
0: 'success',
|
||||
1: 'wait1',
|
||||
|
@ -277,6 +291,9 @@ class Subpage extends React.Component<any, any> {
|
|||
async updateRequest(current: number | undefined, pageSize: number | undefined, sort: Record<string, SortOrder>, filter: Record<string, React.ReactText[] | null>) {
|
||||
let tableListDataSource: TableListItem[] = []
|
||||
let totalRecordLength = 0
|
||||
if(this.departments.size === 0){
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
if (this.state.searchWord.trim() === "") {
|
||||
current = (current === undefined ? 0 : current)
|
||||
pageSize = (pageSize === undefined ? 5 : pageSize)
|
||||
|
|
Loading…
Reference in New Issue