满足了开开的一个愿望

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>[] = [
{
title: '报销单号',
width: 70,
width: 40,
dataIndex: 'id',
search: false,
sorter: true,
@ -123,9 +123,9 @@ class Subpage extends React.Component<any, any> {
dataIndex: 'amount',
search: false,
render: (_, item) =>
<>{item.amount.toFixed(2)}
<>{(item.amount/100.0).toFixed(2)}
<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}}/>
</Popover>
</>
@ -143,7 +143,7 @@ class Subpage extends React.Component<any, any> {
},
{
title: '申请部门',
width: 80,
width: 90,
search: false,
dataIndex: 'departmentId',
valueEnum: this.departments,
@ -206,7 +206,7 @@ class Subpage extends React.Component<any, any> {
let result: TableListItem[] = []
for (let i = 0; i < value.length; i++) {
result.push({
id: value[i].reimbursementSubmitDepartment.departmentId,
id: value[i].reimbursementId,
beginDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate),
endDate: Date.parse(value[i].reimbursementDepartureInvoice.invoiceDate) + value[i].reimbursementTripDuration * 24 * 60 * 60 * 1000,
duration: value[i].reimbursementTripDuration,
@ -304,7 +304,6 @@ class Subpage extends React.Component<any, any> {
render() {
return (
<>
<ReimbursementCreate ref={this.createRef} open={this.state.onCreated} wrapClassName="Subpage"/>
<ProTable<TableListItem>
actionRef={this.tableAction}
columns={this.columns}
@ -368,6 +367,7 @@ class Subpage extends React.Component<any, any> {
// </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> {
formRef = React.createRef<FormInstance>();
invoiceSelector1 = React.createRef<SingleInvoiceSelector>();
@ -43,10 +44,11 @@ class ReimbursementCreate extends React.Component<any, any> {
constructor(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({
departmentId: store.getState().staff.managingDepartment.departmentId,
departmentName: store.getState().staff.managingDepartment.departmentName,
departmentId: managingDepartment.departmentId,
departmentName: managingDepartment.departmentName,
})
}
console.log(store.getState().staff.staffDepartments)
@ -64,6 +66,7 @@ class ReimbursementCreate extends React.Component<any, any> {
icon: <UserOutlined/>,
})
})
store.subscribe(this.handleStoreChange);
console.log(store.getState().staff.staffDepartments)
this.state = {
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) => {
this.setState({
selectedDepartment: {
@ -99,47 +133,39 @@ class ReimbursementCreate extends React.Component<any, any> {
submitCheck = () => {
return {ok:true,msg:""}
return {ok: true, msg: ""}
}
submit = () => {
let checkResult = this.submitCheck()
if(!checkResult.ok){
if (!checkResult.ok) {
openNotification(checkResult.msg)
return
}
let otherInvoices = null
if(this.state.otherInvoices?.length>0){
otherInvoices = ""
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:"",
let params = {
submitDepartmentId: this.state.selectedDepartment.id,
reimbursementNote: this.state.note ? this.state.note : "",
reimbursementDepartureInvoiceId: this.state.departureInvoice.invoiceId,
reimbursementDestinationInvoiceId: this.state.destinationInvoice?.invoiceId,
reimbursementOtherInvoiceIds: otherInvoices,
reimbursementOtherInvoiceIds: this.state.otherInvoices?.map((item: Invoice) => item.invoiceId),
reimbursementDepartureName: this.state.departureName,
reimbursementDestinationName: this.state.destinationName,
reimbursementDuration: this.state.duration,
reimbursementTripDuration: this.state.duration,
}
axiosInstance.post("common/reimbursement", params).then(response => {
openNotification("提交成功")
this.setState({open: false})
this.props.tableAction.current?.reload()
}).catch(error => {
console.log(error)
openNotification("提交失败")
openNotification(error.response.data?.msg !== "" ? error.response.data.msg : "提交失败")
})
}
cancel = () => {
this.setState({open: false})
}
changeDuration = (value: number | null) => {
return
if (value === null)
value = 0
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
if (state["duration"] < 0)
state["duration"] = 0
this.formRef.current?.setFieldsValue({duration: state["duration"]})
} else {
state['back'] = false
state["duration"] = 0
state["duration"] = allValues["duration"]
}
this.formRef.current?.setFieldsValue({duration: state["duration"]})
state['departureInvoice'] = allValues.departureInvoice
state["destinationInvoice"] = allValues.destinationInvoice
state["otherInvoices"] = allValues.otherInvoices
@ -239,7 +265,7 @@ class ReimbursementCreate extends React.Component<any, any> {
<Col span={12}>
<Form.Item label="返程票据" name="destinationInvoice" rules={[{required: 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}
before={0} occupiedInvoices={this.getOccupiedInvoices(2)}
pickerTitle={"返程票据"} ref={this.invoiceSelector2}
@ -270,8 +296,8 @@ class ReimbursementCreate extends React.Component<any, any> {
</Row>
<Form.Item label="附加票据" name="otherInvoices" rules={[{required: false}]}>
<MultiInvoiceSelector pickerOpen={false}
after={0}
//after={this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? Number(Date.parse(this.state.departureInvoice.invoiceDate)) : 0}
//after={0}
after={this.state.departureInvoice !== null && this.state.departureInvoice !== undefined ? Number(Date.parse(this.state.departureInvoice.invoiceDate)) : 0}
before={0} occupiedInvoices={this.getOccupiedInvoices(3)}
pickerTitle={"附加票据"} ref={this.invoiceSelector3}
/>
@ -283,32 +309,32 @@ class ReimbursementCreate extends React.Component<any, any> {
<StatisticCard
statistic={{
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>
<StatisticCard
statistic={{
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>
<StatisticCard
statistic={{
title: '附加票据金额',
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,
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,
}}
/>
<Operation>=</Operation>
<StatisticCard
statistic={{
title: '票据总金额',
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.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) ,
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.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),
suffix: '元',
}}
/>

View File

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

View File

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