diff --git a/src/pages/reimbursement/mine/MyReimbursement.tsx b/src/pages/reimbursement/mine/MyReimbursement.tsx index ca14c8c..9a6c4bd 100644 --- a/src/pages/reimbursement/mine/MyReimbursement.tsx +++ b/src/pages/reimbursement/mine/MyReimbursement.tsx @@ -86,7 +86,7 @@ class Subpage extends React.Component { columns: ProColumns[] = [ { title: '报销单号', - width: 70, + width: 40, dataIndex: 'id', search: false, sorter: true, @@ -123,9 +123,9 @@ class Subpage extends React.Component { dataIndex: 'amount', search: false, render: (_, item) => - <>{item.amount.toFixed(2)}元 + <>{(item.amount/100.0).toFixed(2)}元 报销金额:{item.invoiceAmount.toFixed(2)}元
补贴金额:{item.additionalAmount.toFixed(2)}元}> + content={<>报销金额:{(item.invoiceAmount/100.0).toFixed(2)}元
补贴金额:{(item.additionalAmount/100.0).toFixed(2)}元}>
@@ -143,7 +143,7 @@ class Subpage extends React.Component { }, { title: '申请部门', - width: 80, + width: 90, search: false, dataIndex: 'departmentId', valueEnum: this.departments, @@ -206,7 +206,7 @@ class Subpage extends React.Component { 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 { render() { return ( <> - actionRef={this.tableAction} columns={this.columns} @@ -368,6 +367,7 @@ class Subpage extends React.Component { // , // ]} /> + ); } } diff --git a/src/pages/reimbursement/mine/ReimbursementCreate.tsx b/src/pages/reimbursement/mine/ReimbursementCreate.tsx index 6eb1322..935b8f6 100644 --- a/src/pages/reimbursement/mine/ReimbursementCreate.tsx +++ b/src/pages/reimbursement/mine/ReimbursementCreate.tsx @@ -34,6 +34,7 @@ const openNotification = (hint: string) => { }, }); }; + class ReimbursementCreate extends React.Component { formRef = React.createRef(); invoiceSelector1 = React.createRef(); @@ -43,10 +44,11 @@ class ReimbursementCreate extends React.Component { 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 { icon: , }) }) + store.subscribe(this.handleStoreChange); console.log(store.getState().staff.staffDepartments) this.state = { loading: false, @@ -86,6 +89,37 @@ class ReimbursementCreate extends React.Component { } } + 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: , + }) + }) + 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 { 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 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 { 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 { { @@ -283,32 +309,32 @@ class ReimbursementCreate extends React.Component { + + 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, }} /> = 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: '元', }} /> diff --git a/src/pages/reimbursement/mine/component/MultiInvoiceSelector.tsx b/src/pages/reimbursement/mine/component/MultiInvoiceSelector.tsx index 391e8a9..b2ccf45 100644 --- a/src/pages/reimbursement/mine/component/MultiInvoiceSelector.tsx +++ b/src/pages/reimbursement/mine/component/MultiInvoiceSelector.tsx @@ -147,7 +147,7 @@ class MultiInvoiceSelector extends React.Component { 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 { before: props.before, occupiedInvoices: props.occupiedInvoices, } - + props.onChange(prev) return { selectedInvoice: prev, after: props.after, diff --git a/src/pages/reimbursement/mine/component/SingleInvoiceSelector.tsx b/src/pages/reimbursement/mine/component/SingleInvoiceSelector.tsx index 0c4d703..c3866b1 100644 --- a/src/pages/reimbursement/mine/component/SingleInvoiceSelector.tsx +++ b/src/pages/reimbursement/mine/component/SingleInvoiceSelector.tsx @@ -182,7 +182,7 @@ class SingleInvoiceSelector extends React.Component { pageNum: page - 1, pageSize: this.state.pageSize, invoiceUploaderId: store.getState().token.staffId, - invoiceStatus: 0, + invoiceStates: 0, sortBy: "invoiceDate", asc: true, }