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

@ -34,10 +34,10 @@ class DepartmentConfig extends React.Component<any, any> {
}
})
if (newRow) {
let data={
let data = {
departmentName: row.departmentName,
departmentManagerId: row.departmentManagerId,
staffIds:[]
staffIds: []
}
axiosInstance.post("management/department", data).then((res) => {
this.update()
@ -45,11 +45,11 @@ class DepartmentConfig extends React.Component<any, any> {
this.update()
})
} else {
let data={
let data = {
departmentName: row.departmentName,
departmentManagerId: row.departmentManagerId,
}
axiosInstance.put("management/department/"+row.departmentId, data).then((res) => {
axiosInstance.put("management/department/" + row.departmentId, data).then((res) => {
this.update()
}).catch((err) => {
this.update()
@ -76,15 +76,16 @@ class DepartmentConfig extends React.Component<any, any> {
return []
}
let res = []
console.log(columns)
for (let i = 0; i < columns.length; i++) {
console.log(columns[i].departmentName)
res.push({
id: columns[i].departmentId,
departmentId: columns[i].departmentId,
departmentName: columns[i].departmentName,
departmentManagerId: columns[i].departmentManager.staffId,
departmentManagerName: columns[i].departmentManager.staffName,
})
if (columns[i].deletedAt == null)
res.push({
id: columns[i].departmentId,
departmentId: columns[i].departmentId,
departmentName: columns[i].departmentName,
departmentManagerId: columns[i].departmentManager.staffId,
departmentManagerName: columns[i].departmentManager.staffName,
})
}
console.log(res);
return res

View File

@ -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) => {

View File

@ -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)