Merge remote-tracking branch 'origin/main' into main

main
wuyize 2023-01-07 12:45:22 +08:00
commit 433d79de81
3 changed files with 46 additions and 16 deletions

View File

@ -76,8 +76,9 @@ class DepartmentConfig extends React.Component<any, any> {
return [] return []
} }
let res = [] let res = []
console.log(columns)
for (let i = 0; i < columns.length; i++) { for (let i = 0; i < columns.length; i++) {
console.log(columns[i].departmentName) if (columns[i].deletedAt == null)
res.push({ res.push({
id: columns[i].departmentId, id: columns[i].departmentId,
departmentId: columns[i].departmentId, departmentId: columns[i].departmentId,

View File

@ -1,8 +1,8 @@
import React, {useRef, useState} from "react"; import React, {useRef, useState} from "react";
import {Button, Popover, Tabs, TabsProps, theme} from "antd"; 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 Search from "antd/es/input/Search";
import {statusEnum} from "../mine/MyReimbursement"; import {preStatusFilter, statusEnum} from "../mine/MyReimbursement";
import axiosInstance from "../../../utils/axiosInstance"; import axiosInstance from "../../../utils/axiosInstance";
import {ExclamationCircleOutlined} from "@ant-design/icons"; import {ExclamationCircleOutlined} from "@ant-design/icons";
import {openNotification} from "../mine/utils"; import {openNotification} from "../mine/utils";
@ -31,6 +31,7 @@ export type TableListItem = {
class ReimbursementTab extends React.Component<any, any> { class ReimbursementTab extends React.Component<any, any> {
tableAction = React.createRef<ActionType>(); tableAction = React.createRef<ActionType>();
formRef: React.MutableRefObject<ProFormInstance> = React.createRef<ProFormInstance>() as any;
departments = new Map<number, string>() departments = new Map<number, string>()
columns: ProColumns<TableListItem>[] = [ columns: ProColumns<TableListItem>[] = [
{ {
@ -89,6 +90,7 @@ class ReimbursementTab extends React.Component<any, any> {
onFilter: false, onFilter: false,
search: false, search: false,
valueEnum: statusEnum, valueEnum: statusEnum,
// defaultFilteredValue:preStatusFilter(),
//render: (_) => <a>{_}</a>, //render: (_) => <a>{_}</a>,
}, },
{ {
@ -138,6 +140,7 @@ class ReimbursementTab extends React.Component<any, any> {
mode: props.mode, mode: props.mode,
detailedReimbursement: undefined, detailedReimbursement: undefined,
activate: props.activate, activate: props.activate,
initialized: false,
reload: () => { reload: () => {
this.tableAction.current?.reload() this.tableAction.current?.reload()
}, },
@ -149,6 +152,7 @@ class ReimbursementTab extends React.Component<any, any> {
prevState.reload() prevState.reload()
if (nextProps.activate !== prevState.activate) { if (nextProps.activate !== prevState.activate) {
return { return {
initialized: false,
mode: nextProps.mode, mode: nextProps.mode,
activate: nextProps.activate, activate: nextProps.activate,
detailedReimbursement: undefined, detailedReimbursement: undefined,
@ -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>) { async updateRequest(current: number | undefined, pageSize: number | undefined, sort: Record<string, SortOrder>, filter: Record<string, React.ReactText[] | null>) {
let tableListDataSource: TableListItem[] = [] let tableListDataSource: TableListItem[] = []
let totalRecordLength = 0 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) current = (current === undefined ? 1 : current)
pageSize = (pageSize === undefined ? 5 : pageSize) pageSize = (pageSize === undefined ? 5 : pageSize)
let params: any = { let params: any = {
@ -288,6 +299,7 @@ class ReimbursementTab extends React.Component<any, any> {
accessLevel={this.props.accessLevel} accessLevel={this.props.accessLevel}
/> />
<ProTable<TableListItem> <ProTable<TableListItem>
formRef={this.formRef}
actionRef={this.tableAction} actionRef={this.tableAction}
columns={this.columns} columns={this.columns}
request={async (params, sorter, filter) => { request={async (params, sorter, filter) => {

View File

@ -15,6 +15,20 @@ import ReimbursementDetail from "./ReimbursementDetail";
import {openNotification} from "./utils"; import {openNotification} from "./utils";
import {store} from "../../../models/store"; 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 = { const valueEnum = {
0: 'success', 0: 'success',
1: 'wait1', 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>) { async updateRequest(current: number | undefined, pageSize: number | undefined, sort: Record<string, SortOrder>, filter: Record<string, React.ReactText[] | null>) {
let tableListDataSource: TableListItem[] = [] let tableListDataSource: TableListItem[] = []
let totalRecordLength = 0 let totalRecordLength = 0
if(this.departments.size === 0){
await new Promise(resolve => setTimeout(resolve, 100));
}
if (this.state.searchWord.trim() === "") { if (this.state.searchWord.trim() === "") {
current = (current === undefined ? 0 : current) current = (current === undefined ? 0 : current)
pageSize = (pageSize === undefined ? 5 : pageSize) pageSize = (pageSize === undefined ? 5 : pageSize)