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

main
wuyize 2023-01-02 21:03:16 +08:00
commit 3f64451add
2 changed files with 116 additions and 28 deletions

View File

@ -25,6 +25,7 @@ export type Department = {
departmentName: string; departmentName: string;
} }
export type TableListItem = { export type TableListItem = {
key:number;
id: number; id: number;
beginDate: number; beginDate: number;
duration: number; duration: number;
@ -43,6 +44,7 @@ export type TableListItem = {
let fakeData: TableListItem[] = []; let fakeData: TableListItem[] = [];
for (let i = 0; i < 94; i++) { for (let i = 0; i < 94; i++) {
fakeData.push({ fakeData.push({
key:i,
id: i + 1, id: i + 1,
beginDate: Date.UTC(2022, i % 11 + 1, i % 28 + 1), beginDate: Date.UTC(2022, i % 11 + 1, i % 28 + 1),
endDate: Date.UTC(2022, i % 11 + 1, i % 28 + 1) + 1000 * 60 * 60 * 24 * i + 1, endDate: Date.UTC(2022, i % 11 + 1, i % 28 + 1) + 1000 * 60 * 60 * 24 * i + 1,
@ -72,7 +74,7 @@ class Subpage extends React.Component<any, any> {
tableAction = React.createRef<ActionType>(); tableAction = React.createRef<ActionType>();
departments = new Map<number, string>() departments = new Map<number, string>()
constructor(props: {}) { constructor(props: any) {
super(props); super(props);
this.state = { this.state = {
searchWord: "", searchWord: "",
@ -182,11 +184,8 @@ class Subpage extends React.Component<any, any> {
search(value: string, form: FormProps['form'], dom: ReactNode[]) { search(value: string, form: FormProps['form'], dom: ReactNode[]) {
this.setState({searchWord: value}); this.setState({searchWord: value});
if (value === "") { // @ts-ignore
// @ts-ignore this.tableAction.current.reloadAndRest()
this.tableAction.current.reloadAndRest()
}
this.tableAction.current?.reload()
} }
create() { create() {
@ -199,13 +198,33 @@ class Subpage extends React.Component<any, any> {
} }
async converter(value: Reimbursement[] | undefined, pageSize: number | undefined) { async converter(value: Reimbursement[] | undefined | Reimbursement, pageSize: number | undefined) {
if (value === undefined) { if (value === undefined) {
return [] return []
} }
let result: TableListItem[] = [] let result: TableListItem[] = []
if("reimbursementAdditionalAmount" in value){
result.push({
key:1,
id: value.reimbursementId,
beginDate: Date.parse(value.reimbursementDepartureInvoice.invoiceDate),
endDate: Date.parse(value.reimbursementDepartureInvoice.invoiceDate) + value.reimbursementTripDuration * 24 * 60 * 60 * 1000,
duration: value.reimbursementTripDuration,
OD: [value.reimbursementDepartureName, value.reimbursementDestinationName],
amount: value.reimbursementInvoiceAmount + value.reimbursementAdditionalAmount,
invoiceAmount: value.reimbursementInvoiceAmount,
additionalAmount: value.reimbursementAdditionalAmount,
status: value.reimbursementStatus % 6,
departmentId: value.reimbursementSubmitDepartment.departmentId,
submitDateTime: Date.parse(value.reimbursementSubmitTime),
detail: "查看详情",
back: value.reimbursementDestinationInvoice !== undefined,
})
return result
}
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
result.push({ result.push({
key:i,
id: value[i].reimbursementId, id: value[i].reimbursementId,
beginDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate), beginDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate),
endDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate) + value[i].reimbursementTripDuration * 24 * 60 * 60 * 1000, endDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate) + value[i].reimbursementTripDuration * 24 * 60 * 60 * 1000,
@ -246,7 +265,7 @@ class Subpage extends React.Component<any, any> {
current = (current === undefined ? 0 : current) current = (current === undefined ? 0 : current)
pageSize = (pageSize === undefined ? 5 : pageSize) pageSize = (pageSize === undefined ? 5 : pageSize)
let params: any = { let params: any = {
current: current, pageNum: current - 1,
pageSize: pageSize, pageSize: pageSize,
} }
if (filter.status !== undefined && filter.status !== null && filter.status.length !== 0) { if (filter.status !== undefined && filter.status !== null && filter.status.length !== 0) {
@ -281,15 +300,21 @@ class Subpage extends React.Component<any, any> {
params['sortBy'] = "reimbursementDepartureDate" params['sortBy'] = "reimbursementDepartureDate"
params['asc'] = (sort.beginDate === "ascend") params['asc'] = (sort.beginDate === "ascend")
} }
console.log(params)
let response = await axiosInstance.get('common/reimbursement', {params: params}) let response = await axiosInstance.get('common/reimbursement', {params: params})
tableListDataSource = await this.converter(response.data.records, pageSize) tableListDataSource = await this.converter(response.data.records, pageSize)
console.log(response.data.records)
totalRecordLength = response.data.total totalRecordLength = response.data.total
} else { } else {
let response = await axiosInstance.get('common/reimbursement/' + this.state.searchWord.trim(), {}) let response = await axiosInstance.get('common/reimbursement/' + Number(this.state.searchWord.trim()), {}).catch(error => {
tableListDataSource = await this.converter(response.data.records, pageSize) tableListDataSource = []
totalRecordLength = 0
return Promise.resolve({
data: tableListDataSource,
success: false,
total: totalRecordLength,
});
})
tableListDataSource = await this.converter(response.data, pageSize)
totalRecordLength = tableListDataSource.length totalRecordLength = tableListDataSource.length
} }
@ -375,7 +400,7 @@ class Subpage extends React.Component<any, any> {
function MyReimbursement() { function MyReimbursement() {
return ( return (
<> <>
<Subpage/> <Subpage key={12}/>
</> </>
) )
} }

View File

@ -6,8 +6,8 @@ import {
Form, Form,
Input, Input,
InputNumber, InputNumber,
Modal, notification, Modal, notification, Popover,
Row Row, Select, Tag
} from "antd"; } from "antd";
import {FormInstance} from "antd/es/form"; import {FormInstance} from "antd/es/form";
import {Invoice} from "../../../models/Reimbursement"; import {Invoice} from "../../../models/Reimbursement";
@ -21,7 +21,7 @@ import {FieldData} from "rc-field-form/lib/interface";
import {invoiceTypeNameMap} from "../../../models/Invoice"; import {invoiceTypeNameMap} from "../../../models/Invoice";
import SingleInvoiceSelector from "./component/SingleInvoiceSelector"; import SingleInvoiceSelector from "./component/SingleInvoiceSelector";
import MultiInvoiceSelector from "./component/MultiInvoiceSelector"; import MultiInvoiceSelector from "./component/MultiInvoiceSelector";
import {StatisticCard} from "@ant-design/pro-components"; import {ActionType, StatisticCard} from "@ant-design/pro-components";
const {Operation} = StatisticCard; const {Operation} = StatisticCard;
@ -37,11 +37,14 @@ const openNotification = (hint: string) => {
class ReimbursementCreate extends React.Component<any, any> { class ReimbursementCreate extends React.Component<any, any> {
formRef = React.createRef<FormInstance>(); formRef = React.createRef<FormInstance>();
actionRef = React.createRef<ActionType>();
invoiceSelector1 = React.createRef<SingleInvoiceSelector>(); invoiceSelector1 = React.createRef<SingleInvoiceSelector>();
invoiceSelector2 = React.createRef<SingleInvoiceSelector>(); invoiceSelector2 = React.createRef<SingleInvoiceSelector>();
invoiceSelector3 = React.createRef<MultiInvoiceSelector>(); invoiceSelector3 = React.createRef<MultiInvoiceSelector>();
departments: { departmentId: number, departmentName: string }[] = []; departments: { departmentId: number, departmentName: string }[] = [];
place: { placeName: string, subsidyPerDay: number }[] = []
constructor(props: {}) { constructor(props: {}) {
super(props); super(props);
let managingDepartment = store.getState().staff.managingDepartment let managingDepartment = store.getState().staff.managingDepartment
@ -66,8 +69,12 @@ class ReimbursementCreate extends React.Component<any, any> {
icon: <UserOutlined/>, icon: <UserOutlined/>,
}) })
}) })
axiosInstance.get("common/place").then((res) => {
this.place = res.data
this.formRef.current?.setFieldsValue({departureName: "", destinationName: ""})
this.formRef.current?.resetFields(["departureName", "destinationName"])
})
store.subscribe(this.handleStoreChange); store.subscribe(this.handleStoreChange);
console.log(store.getState().staff.staffDepartments)
this.state = { this.state = {
loading: false, loading: false,
open: this.props.open, open: this.props.open,
@ -90,7 +97,7 @@ class ReimbursementCreate extends React.Component<any, any> {
} }
handleStoreChange = () => { handleStoreChange = () => {
this.departments=[] this.departments = []
let managingDepartment = store.getState().staff.managingDepartment let managingDepartment = store.getState().staff.managingDepartment
if (managingDepartment !== null && managingDepartment !== undefined) { if (managingDepartment !== null && managingDepartment !== undefined) {
this.departments.push({ this.departments.push({
@ -154,7 +161,7 @@ class ReimbursementCreate extends React.Component<any, any> {
axiosInstance.post("common/reimbursement", params).then(response => { axiosInstance.post("common/reimbursement", params).then(response => {
openNotification("提交成功") openNotification("提交成功")
this.setState({open: false}) this.cancel()
this.props.tableAction.current?.reload() this.props.tableAction.current?.reload()
}).catch(error => { }).catch(error => {
console.log(error) console.log(error)
@ -162,7 +169,22 @@ class ReimbursementCreate extends React.Component<any, any> {
}) })
} }
cancel = () => { cancel = () => {
this.setState({open: false}) this.formRef.current?.resetFields()
this.setState({
loading: false,
open: false,
invoices: [],
selectedDepartment: {id: this.departments[0].departmentId, name: this.departments[0].departmentName},
back: false,
duration: 0,
departureInvoice: null,
destinationInvoice: null,
otherInvoices: [],
departureName: "",
destinationName: "",
note: "",
departmentId: -1,
})
} }
changeDuration = (value: number | null) => { changeDuration = (value: number | null) => {
return return
@ -215,7 +237,19 @@ class ReimbursementCreate extends React.Component<any, any> {
} }
return res return res
} }
calculateAddition = () => {
if(store.getState().staff.staffBase===this.formRef.current?.getFieldValue("destinationName"))
return {value:0,hint:"出差地点与基地相同,无补贴"}
let addition = 0
this.place.map((item)=>{
if(addition===this.formRef.current?.getFieldValue("destinationName"))
addition=item.subsidyPerDay
})
let days=0
if(this.state.duration!==undefined)
days=this.state.duration
return {value:addition*days,hint:"每日补贴"+addition+"元,共"+days+"天"}
}
render() { render() {
return ( return (
<Modal <Modal
@ -240,20 +274,40 @@ class ReimbursementCreate extends React.Component<any, any> {
duration: 0 duration: 0
}}> }}>
<Row gutter={18}> <Row gutter={18} key={1}>
<Col span={12}> <Col span={12}>
<Form.Item label="出发地" name="departureName" rules={[{required: true}]}> <Form.Item label="出发地" name="departureName" rules={[{required: true}]}>
<Input/> <Select
showSearch
placeholder="请选择出发地"
optionFilterProp="children"
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={this.place.map((item) => {
return {label: item.placeName, value: item.placeName}
})}
/>
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={12}> <Col span={12}>
<Form.Item label="目的地" name="destinationName" rules={[{required: true}]}> <Form.Item label="目的地" name="destinationName" rules={[{required: true}]}>
<Input/> <Select
showSearch
placeholder="请选择目的地"
optionFilterProp="children"
filterOption={(input, option) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
options={this.place.map((item) => {
return {label: item.placeName, value: item.placeName}
})}
/>
</Form.Item> </Form.Item>
</Col> </Col>
</Row> </Row>
<Row gutter={18}> <Row gutter={18} key={2}>
<Col span={12}> <Col span={12}>
<Form.Item help="" label="出发票据" name="departureInvoice" rules={[{required: true}]}> <Form.Item help="" label="出发票据" name="departureInvoice" rules={[{required: true}]}>
<SingleInvoiceSelector pickerOpen={false} after={0} <SingleInvoiceSelector pickerOpen={false} after={0}
@ -274,7 +328,7 @@ class ReimbursementCreate extends React.Component<any, any> {
</Col> </Col>
</Row> </Row>
<Row gutter={18}> <Row gutter={18} key={3}>
<Col span={12}> <Col span={12}>
<Form.Item label="出差时长" name={"duration"} rules={[{required: true}]}> <Form.Item label="出差时长" name={"duration"} rules={[{required: true}]}>
<InputNumber addonAfter={"天"} min={0} max={1000} disabled={this.state.back} <InputNumber addonAfter={"天"} min={0} max={1000} disabled={this.state.back}
@ -294,10 +348,19 @@ class ReimbursementCreate extends React.Component<any, any> {
</Form.Item> </Form.Item>
</Col> </Col>
</Row> </Row>
<Row style={{fontSize: 15, marginBottom: 5}} key={4}>
<Popover content={this.calculateAddition().hint} title="出差补贴" trigger="hover">
<Tag color={store.getState().staff.staffBase===this.formRef.current?.getFieldValue("destinationName")?
"red":"green"}>
{this.calculateAddition().value}
</Tag>
</Popover>
</Row>
<Form.Item label="附加票据" name="otherInvoices" rules={[{required: false}]}> <Form.Item label="附加票据" name="otherInvoices" rules={[{required: false}]}>
<MultiInvoiceSelector pickerOpen={false} <MultiInvoiceSelector pickerOpen={false}
//after={0} //after={0}
after={this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? Number(Date.parse(this.state.departureInvoice.invoiceDate)) : 0} after={this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? Number(Date.parse(this.state.departureInvoice.invoiceDate)) : 0}
before={0} occupiedInvoices={this.getOccupiedInvoices(3)} before={0} occupiedInvoices={this.getOccupiedInvoices(3)}
pickerTitle={"附加票据"} ref={this.invoiceSelector3} pickerTitle={"附加票据"} ref={this.invoiceSelector3}
/> />