满足了开开的一个愿望

main
白封羽 2023-01-02 14:28:51 +08:00
parent 83f000fe47
commit 0fc89f7c50
4 changed files with 69 additions and 43 deletions

View File

@ -86,7 +86,7 @@ class Subpage extends React.Component<any, any> {
columns: ProColumns<TableListItem>[] = [ columns: ProColumns<TableListItem>[] = [
{ {
title: '报销单号', title: '报销单号',
width: 70, width: 40,
dataIndex: 'id', dataIndex: 'id',
search: false, search: false,
sorter: true, sorter: true,
@ -123,9 +123,9 @@ class Subpage extends React.Component<any, any> {
dataIndex: 'amount', dataIndex: 'amount',
search: false, search: false,
render: (_, item) => render: (_, item) =>
<>{item.amount.toFixed(2)} <>{(item.amount/100.0).toFixed(2)}
<Popover <Popover
content={<>{item.invoiceAmount.toFixed(2)}<br/>{item.additionalAmount.toFixed(2)}</>}> content={<>{(item.invoiceAmount/100.0).toFixed(2)}<br/>{(item.additionalAmount/100.0).toFixed(2)}</>}>
<ExclamationCircleOutlined style={{marginLeft: 5}}/> <ExclamationCircleOutlined style={{marginLeft: 5}}/>
</Popover> </Popover>
</> </>
@ -143,7 +143,7 @@ class Subpage extends React.Component<any, any> {
}, },
{ {
title: '申请部门', title: '申请部门',
width: 80, width: 90,
search: false, search: false,
dataIndex: 'departmentId', dataIndex: 'departmentId',
valueEnum: this.departments, valueEnum: this.departments,
@ -206,7 +206,7 @@ class Subpage extends React.Component<any, any> {
let result: TableListItem[] = [] let result: TableListItem[] = []
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
result.push({ result.push({
id: value[i].reimbursementSubmitDepartment.departmentId, 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,
duration: value[i].reimbursementTripDuration, duration: value[i].reimbursementTripDuration,
@ -304,7 +304,6 @@ class Subpage extends React.Component<any, any> {
render() { render() {
return ( return (
<> <>
<ReimbursementCreate ref={this.createRef} open={this.state.onCreated} wrapClassName="Subpage"/>
<ProTable<TableListItem> <ProTable<TableListItem>
actionRef={this.tableAction} actionRef={this.tableAction}
columns={this.columns} columns={this.columns}
@ -368,6 +367,7 @@ class Subpage extends React.Component<any, any> {
// </Button>, // </Button>,
// ]} // ]}
/> />
<ReimbursementCreate tableAction={this.tableAction} ref={this.createRef} open={this.state.onCreated} wrapClassName="Subpage"/>
</>); </>);
} }
} }

View File

@ -34,6 +34,7 @@ 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>();
invoiceSelector1 = React.createRef<SingleInvoiceSelector>(); invoiceSelector1 = React.createRef<SingleInvoiceSelector>();
@ -43,10 +44,11 @@ class ReimbursementCreate extends React.Component<any, any> {
constructor(props: {}) { constructor(props: {}) {
super(props); super(props);
if (store.getState().staff.managingDepartment != null && store.getState().staff.managingDepartment !== undefined) { let managingDepartment = store.getState().staff.managingDepartment
if (managingDepartment !== null && managingDepartment !== undefined) {
this.departments.push({ this.departments.push({
departmentId: store.getState().staff.managingDepartment.departmentId, departmentId: managingDepartment.departmentId,
departmentName: store.getState().staff.managingDepartment.departmentName, departmentName: managingDepartment.departmentName,
}) })
} }
console.log(store.getState().staff.staffDepartments) console.log(store.getState().staff.staffDepartments)
@ -64,6 +66,7 @@ class ReimbursementCreate extends React.Component<any, any> {
icon: <UserOutlined/>, icon: <UserOutlined/>,
}) })
}) })
store.subscribe(this.handleStoreChange);
console.log(store.getState().staff.staffDepartments) console.log(store.getState().staff.staffDepartments)
this.state = { this.state = {
loading: false, loading: false,
@ -86,6 +89,37 @@ class ReimbursementCreate extends React.Component<any, any> {
} }
} }
handleStoreChange = () => {
this.departments=[]
let managingDepartment = store.getState().staff.managingDepartment
if (managingDepartment !== null && managingDepartment !== undefined) {
this.departments.push({
departmentId: managingDepartment.departmentId,
departmentName: managingDepartment.departmentName,
})
}
store.getState().staff.staffDepartments?.forEach((item) => {
this.departments.push({
departmentId: item.departmentId,
departmentName: item.departmentName,
})
})
let departmentsPropItems: any[] = [];
this.departments.map((item) => {
departmentsPropItems.push({
label: item.departmentName,
key: item.departmentId,
icon: <UserOutlined/>,
})
})
this.setState({
selectedDepartment: {id: this.departments[0].departmentId, name: this.departments[0].departmentName},
departmentsProps: {
items: departmentsPropItems,
onClick: this.handleMenuClick,
}
})
}
handleMenuClick: MenuProps['onClick'] = (e) => { handleMenuClick: MenuProps['onClick'] = (e) => {
this.setState({ this.setState({
selectedDepartment: { selectedDepartment: {
@ -99,47 +133,39 @@ class ReimbursementCreate extends React.Component<any, any> {
submitCheck = () => { submitCheck = () => {
return {ok:true,msg:""} return {ok: true, msg: ""}
} }
submit = () => { submit = () => {
let checkResult = this.submitCheck() let checkResult = this.submitCheck()
if(!checkResult.ok){ if (!checkResult.ok) {
openNotification(checkResult.msg) openNotification(checkResult.msg)
return return
} }
let otherInvoices = null let params = {
if(this.state.otherInvoices?.length>0){ submitDepartmentId: this.state.selectedDepartment.id,
otherInvoices = "" reimbursementNote: this.state.note ? this.state.note : "",
for(let i=0;i<this.state.otherInvoices.length;i++){
if(i!==0){
otherInvoices += ","
}
otherInvoices += this.state.otherInvoices[i].invoiceId.toString()
}
}
let params={
submitDepartmentId:this.state.selectedDepartment.id,
reimbursementNote:this.state.note?this.state.note:"",
reimbursementDepartureInvoiceId: this.state.departureInvoice.invoiceId, reimbursementDepartureInvoiceId: this.state.departureInvoice.invoiceId,
reimbursementDestinationInvoiceId: this.state.destinationInvoice?.invoiceId, reimbursementDestinationInvoiceId: this.state.destinationInvoice?.invoiceId,
reimbursementOtherInvoiceIds: otherInvoices, reimbursementOtherInvoiceIds: this.state.otherInvoices?.map((item: Invoice) => item.invoiceId),
reimbursementDepartureName: this.state.departureName, reimbursementDepartureName: this.state.departureName,
reimbursementDestinationName: this.state.destinationName, reimbursementDestinationName: this.state.destinationName,
reimbursementDuration: this.state.duration, reimbursementTripDuration: this.state.duration,
} }
axiosInstance.post("common/reimbursement", params).then(response => { axiosInstance.post("common/reimbursement", params).then(response => {
openNotification("提交成功") openNotification("提交成功")
this.setState({open: false}) this.setState({open: false})
this.props.tableAction.current?.reload()
}).catch(error => { }).catch(error => {
console.log(error) console.log(error)
openNotification("提交失败") openNotification(error.response.data?.msg !== "" ? error.response.data.msg : "提交失败")
}) })
} }
cancel = () => { cancel = () => {
this.setState({open: false}) this.setState({open: false})
} }
changeDuration = (value: number | null) => { changeDuration = (value: number | null) => {
return
if (value === null) if (value === null)
value = 0 value = 0
this.setState({duration: value}) this.setState({duration: value})
@ -152,11 +178,11 @@ class ReimbursementCreate extends React.Component<any, any> {
state["duration"] = (Number(Date.parse(allValues.destinationInvoice.invoiceDate)) - Number(Date.parse(allValues.departureInvoice.invoiceDate))) / 1000 / 60 / 60 / 24 + 1 state["duration"] = (Number(Date.parse(allValues.destinationInvoice.invoiceDate)) - Number(Date.parse(allValues.departureInvoice.invoiceDate))) / 1000 / 60 / 60 / 24 + 1
if (state["duration"] < 0) if (state["duration"] < 0)
state["duration"] = 0 state["duration"] = 0
this.formRef.current?.setFieldsValue({duration: state["duration"]})
} else { } else {
state['back'] = false state['back'] = false
state["duration"] = 0 state["duration"] = allValues["duration"]
} }
this.formRef.current?.setFieldsValue({duration: state["duration"]})
state['departureInvoice'] = allValues.departureInvoice state['departureInvoice'] = allValues.departureInvoice
state["destinationInvoice"] = allValues.destinationInvoice state["destinationInvoice"] = allValues.destinationInvoice
state["otherInvoices"] = allValues.otherInvoices state["otherInvoices"] = allValues.otherInvoices
@ -239,7 +265,7 @@ class ReimbursementCreate extends React.Component<any, any> {
<Col span={12}> <Col span={12}>
<Form.Item label="返程票据" name="destinationInvoice" rules={[{required: false}]}> <Form.Item label="返程票据" name="destinationInvoice" rules={[{required: false}]}>
<SingleInvoiceSelector pickerOpen={false} <SingleInvoiceSelector pickerOpen={false}
//disabled={this.state.departureInvoice === null || this.state.departureInvoice === undefined} //disabled={this.state.departureInvoice === null || this.state.departureInvoice === undefined}
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(2)} before={0} occupiedInvoices={this.getOccupiedInvoices(2)}
pickerTitle={"返程票据"} ref={this.invoiceSelector2} pickerTitle={"返程票据"} ref={this.invoiceSelector2}
@ -270,8 +296,8 @@ class ReimbursementCreate extends React.Component<any, any> {
</Row> </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}
/> />
@ -283,32 +309,32 @@ class ReimbursementCreate extends React.Component<any, any> {
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '出发票据金额', title: '出发票据金额',
value: this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? (this.state.departureInvoice.invoiceAmount/100.0).toFixed(2): 0, value: this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? (this.state.departureInvoice.invoiceAmount / 100.0).toFixed(2) : 0,
}} }}
/> />
<Operation>+</Operation> <Operation>+</Operation>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '返程票据金额', title: '返程票据金额',
value: this.state.destinationInvoice !== null && this.state.destinationInvoice !== undefined ? (this.state.destinationInvoice.invoiceAmount/100.0).toFixed(2) : 0, value: this.state.destinationInvoice !== null && this.state.destinationInvoice !== undefined ? (this.state.destinationInvoice.invoiceAmount / 100.0).toFixed(2) : 0,
}} }}
/> />
<Operation>+</Operation> <Operation>+</Operation>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '附加票据金额', title: '附加票据金额',
value: this.state.otherInvoices!==null&&this.state.otherInvoices!==undefined&&this.state.otherInvoices.length > 0 ? value: this.state.otherInvoices !== null && this.state.otherInvoices !== undefined && this.state.otherInvoices.length > 0 ?
(this.state.otherInvoices.map((item:Invoice) => item.invoiceAmount).reduce((a:number, b:number) => a + b)/100.0).toFixed(2) : 0, (this.state.otherInvoices.map((item: Invoice) => item.invoiceAmount).reduce((a: number, b: number) => a + b) / 100.0).toFixed(2) : 0,
}} }}
/> />
<Operation>=</Operation> <Operation>=</Operation>
<StatisticCard <StatisticCard
statistic={{ statistic={{
title: '票据总金额', title: '票据总金额',
value: (((this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? this.state.departureInvoice.invoiceAmount: 0) value: (((this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? this.state.departureInvoice.invoiceAmount : 0)
+(this.state.destinationInvoice !== null && this.state.destinationInvoice !== undefined ? this.state.destinationInvoice.invoiceAmount : 0) + (this.state.destinationInvoice !== null && this.state.destinationInvoice !== undefined ? this.state.destinationInvoice.invoiceAmount : 0)
+(this.state.otherInvoices!==null&&this.state.otherInvoices!==undefined&&this.state.otherInvoices.length > 0 ? + (this.state.otherInvoices !== null && this.state.otherInvoices !== undefined && this.state.otherInvoices.length > 0 ?
this.state.otherInvoices.map((item:Invoice) => item.invoiceAmount).reduce((a:number, b:number) => a + b) : 0))/100.0).toFixed(2) , this.state.otherInvoices.map((item: Invoice) => item.invoiceAmount).reduce((a: number, b: number) => a + b) : 0)) / 100.0).toFixed(2),
suffix: '元', suffix: '元',
}} }}
/> />

View File

@ -147,7 +147,7 @@ class MultiInvoiceSelector extends React.Component<any, any> {
pageNum: page - 1, pageNum: page - 1,
pageSize: this.state.pageSize, pageSize: this.state.pageSize,
invoiceUploaderId: store.getState().token.staffId, invoiceUploaderId: store.getState().token.staffId,
invoiceStatus: 0, invoiceStates: 0,
sortBy: "invoiceDate", sortBy: "invoiceDate",
asc: true, asc: true,
} }
@ -199,7 +199,7 @@ class MultiInvoiceSelector extends React.Component<any, any> {
before: props.before, before: props.before,
occupiedInvoices: props.occupiedInvoices, occupiedInvoices: props.occupiedInvoices,
} }
props.onChange(prev)
return { return {
selectedInvoice: prev, selectedInvoice: prev,
after: props.after, after: props.after,

View File

@ -182,7 +182,7 @@ class SingleInvoiceSelector extends React.Component<any, any> {
pageNum: page - 1, pageNum: page - 1,
pageSize: this.state.pageSize, pageSize: this.state.pageSize,
invoiceUploaderId: store.getState().token.staffId, invoiceUploaderId: store.getState().token.staffId,
invoiceStatus: 0, invoiceStates: 0,
sortBy: "invoiceDate", sortBy: "invoiceDate",
asc: true, asc: true,
} }