From c770c86eafdcac858bba36804f2206718bc38906 Mon Sep 17 00:00:00 2001 From: wuyize Date: Fri, 6 Jan 2023 12:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E5=AE=8C=E6=88=90=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/UserConfigModels.ts | 2 +- src/pages/Invoice/InvoiceListView.tsx | 2 +- .../configuration/subpage/UserConfig.tsx | 251 ++++++++++++++---- 3 files changed, 203 insertions(+), 52 deletions(-) diff --git a/src/models/UserConfigModels.ts b/src/models/UserConfigModels.ts index f48cc91..a8be198 100644 --- a/src/models/UserConfigModels.ts +++ b/src/models/UserConfigModels.ts @@ -1,4 +1,4 @@ -export interface StaffList { +export interface StaffListResponse { records: Staff[]; /** * 总条数 diff --git a/src/pages/Invoice/InvoiceListView.tsx b/src/pages/Invoice/InvoiceListView.tsx index d73b00d..47fdb1e 100644 --- a/src/pages/Invoice/InvoiceListView.tsx +++ b/src/pages/Invoice/InvoiceListView.tsx @@ -368,7 +368,7 @@ function InvoiceListView(props: { isManagement: boolean }) { console.log(error) }) } - const onChange = (pageCurrentNum: Number, pageCurrentSize: Number) => { + const onChange = (pageCurrentNum: number, pageCurrentSize: number) => { console.log(pageCurrentNum, pageCurrentSize) navigate('?currentPage=' + pageCurrentNum + '&pageSize=' + pageCurrentSize) } diff --git a/src/pages/configuration/subpage/UserConfig.tsx b/src/pages/configuration/subpage/UserConfig.tsx index 64d6ddc..c73a8c2 100644 --- a/src/pages/configuration/subpage/UserConfig.tsx +++ b/src/pages/configuration/subpage/UserConfig.tsx @@ -1,22 +1,28 @@ import React, {useEffect, useState} from "react"; -import {Button, Space, Table, Tag, Typography} from 'antd'; +import {Button, Form, Input, Modal, Select, Space, Switch, Table, Tag, Typography} from 'antd'; import type {ColumnsType} from 'antd/es/table'; -import {Staff} from "../../../models/UserConfigModels"; +import {Staff, StaffListResponse} from "../../../models/UserConfigModels"; import axiosInstance from "../../../utils/axiosInstance"; import {Department} from "../../../models/Staff"; +import TextArea from "antd/es/input/TextArea"; +import {invoiceTypeNameMap} from "../../../models/Invoice"; const {Text, Link} = Typography; function UserConfig(props: any) { - const [departmentMap, setDepartmentMap] = useState(new Map()) - + const [staffList, setStaffList] = useState([]) + const [totalNum, setTotalNum] = useState(0) + const [createStaffModalOpen, setCreateStaffModalOpen] = useState(false) + const [createStaffLoading, setCreateStaffLoading] = useState(false) + const [placeOptions, setPlaceOptions] = useState<{ value: string; label: string; }[]>([]) + const [form] = Form.useForm() const departmentToString = (staff: Staff) => { if (staff.staffId === 'manager') return '总经理' - let result = !staff.managingDepartment ? '' : departmentMap.get(staff.managingDepartment.departmentId) + '主管' + let result = !staff.managingDepartment ? '' : departmentMap.get(staff.managingDepartment.departmentId) + '主管' if (staff.staffDepartments) for (const department of staff.staffDepartments) { result += '\xa0\xa0' + departmentMap.get(department.departmentId) @@ -36,54 +42,98 @@ function UserConfig(props: any) { key: 'staffName', }, { - title: '部门', + title: '基地', + dataIndex: 'staffBase', + key: 'staffBase', + }, + { + title: '部门 / 职务', dataIndex: 'managingDepartment', key: 'department', render: (value, record, index) => {departmentToString(record)}, }, { title: '', + dataIndex: 'banned', key: 'action', - render: (_, record) => ( + align: 'right', + width: 230, + render: (value, record) => ( - 重置密码 - 移除 + + ), }, ]; - const data: Staff[] = [ - { - staffId: 'sb123007', - staffName: 'John Brown', - managingDepartment: { - departmentId: 1 - }, - staffDepartments: [{ - departmentId: 1 - }] - }, - { - staffId: 'sb123008', - staffName: 'John Brown', - managingDepartment: { - departmentId: 1 - }, - staffDepartments: [{ - departmentId: 1 - }] - }, - { - staffId: 'sb123009', - staffName: 'John Brown', - managingDepartment: { - departmentId: 1 - }, - staffDepartments: [{ - departmentId: 1 - }] - }, - ] + + const getStaffList = (pageCurrentNum: number, pageCurrentSize: number) => { + axiosInstance({ + url: 'management/staff', + method: 'get', + params: { + pageNum: (pageCurrentNum-1), + pageSize: pageCurrentSize + } + }).then(response => { + const data: StaffListResponse = response.data + setTotalNum(data.total) + setStaffList(data.records) + + }).catch(function (error) { + console.log(error) + }) + } + + const onChange = (pageCurrentNum: number, pageCurrentSize: number) => { + getStaffList(pageCurrentNum, pageCurrentSize) + } + + const onCreateStaffClick = () => { + form.resetFields() + setCreateStaffModalOpen(true) + } + + const onCreateStaff = () => { + form.validateFields().then((values) => { + setCreateStaffLoading(true) + axiosInstance({ + url: 'management/staff', + method: 'post', + data: { + staffId: values.staffId, + staffPassword: values.staffPassword, + staffName: values.staffName, + staffBase: values.staffBase, + } + }).then(response => { + setCreateStaffLoading(false) + setCreateStaffModalOpen(false) + }).catch(function (error) { + console.log(error) + setCreateStaffLoading(false) + }) + }) + } + + const getPlaces = () => { + axiosInstance({ + url: 'common/place', + method: 'get' + }).then(response => { + const data:{placeName: string, subsidyPerDay: number}[] = response.data + setPlaceOptions(data.map((value, index, array) => { + return { + value: value.placeName, + label: value.placeName + } + })) + }).catch(function (error) { + console.log(error) + }) + } useEffect(() => { axiosInstance({ @@ -95,22 +145,123 @@ function UserConfig(props: any) { for (const department of departments) map.set(department.departmentId, department.departmentName) setDepartmentMap(map) + getStaffList(1, 10) }).catch(function (error) { console.log(error) }) - + getPlaces() }, []); return ( -
- -
- - - - - +
+
`共 ${total} 项`, + total:totalNum, + onChange:onChange + }}/> +
+ + + +
+ setCreateStaffModalOpen(false)} + confirmLoading={createStaffLoading} + > +
+ + + + + + + +