From b68e3db0a3f7ff2e1d559d2a5a08fd18befa89df Mon Sep 17 00:00:00 2001 From: Dawn1Ocean <1785590531@qq.com> Date: Fri, 12 Apr 2024 01:42:54 +0800 Subject: [PATCH] add conclusion page --- doc/api.md | 11 +++ mock/api.ts | 6 ++ src/pages/Conclusion/Conclusion.tsx | 115 +++++++--------------------- src/plain-text/Conclusion.ts | 16 ++++ src/plain-text/index.ts | 8 ++ src/service/conclude.ts | 40 ++++++++++ 6 files changed, 108 insertions(+), 88 deletions(-) create mode 100644 src/plain-text/Conclusion.ts create mode 100644 src/service/conclude.ts diff --git a/doc/api.md b/doc/api.md index e00bb51..82dda3a 100644 --- a/doc/api.md +++ b/doc/api.md @@ -491,4 +491,15 @@ Request "reason": "家庭原因", "substitute": "晓洋" // 未找人代班则为空 } +``` + +### 值班总结上传 `POST /member/conclusion` + +Request + +```json +{ + "token": "token_test", + "conclusion": "周四第三班,一人请假,共收两台电脑,均劝退已取回。由上一班交接两台电脑,其中一台维修成功已取回,一台仍在维修。" +} ``` \ No newline at end of file diff --git a/mock/api.ts b/mock/api.ts index a848c95..0787a8c 100644 --- a/mock/api.ts +++ b/mock/api.ts @@ -143,4 +143,10 @@ export default { 'POST /upload/pic': { success: true, }, + 'POST /member/conclusion': { + success: true, + data: { + id: 514, + }, + }, }; diff --git a/src/pages/Conclusion/Conclusion.tsx b/src/pages/Conclusion/Conclusion.tsx index 498d8fc..20f54f7 100644 --- a/src/pages/Conclusion/Conclusion.tsx +++ b/src/pages/Conclusion/Conclusion.tsx @@ -3,16 +3,15 @@ import { AtButton, AtForm, AtMessage, - AtInput, AtList, AtListItem, - AtModal, } from 'taro-ui'; -import { Component, ReactNode } from 'react'; +import React, { Component, ReactNode } from 'react'; import Taro from '@tarojs/taro'; import pt from '@/plain-text'; import { Picker, View } from '@tarojs/components'; -import { askLeave } from '@/service/askleave'; +import PicUploader from '@/components/PicUploader/PicUploader'; +import { conclude } from '@/service/conclude'; import './Conclusion.scss'; const submitInterval = 5000; @@ -21,19 +20,23 @@ export default class ConclusionPage extends Component { state = { isLoading: false, isDisable: false, - showModal: false, - range: [ - ['周一', '周二', '周三', '周四', '周五', '周六', '周日'], - ['第一班', '第二班', '第三班'], - ], + conclusion: '', + conclusionId: 0, + range: [pt.get().askLeave.shift.week, pt.get().askLeave.shift.shift], shift: [0, 0], - reason: '', - substitute: '', }; componentDidMount(): void { Taro.setNavigationBarTitle({ - title: pt.get().navBar.askLeave, + title: pt.get().navBar.conclusion, + }); + } + + uploaderRef = React.createRef(); + + handleConclusionChange(conclusion: string) { + this.setState({ + conclusion, }); } @@ -44,57 +47,11 @@ export default class ConclusionPage extends Component { console.log(event); } - onModalClose() { - this.setState({ - showModal: false, - }); - setTimeout(() => { - this.setState({ - isDisable: false, - }); - }, submitInterval); - } - - onModalCancel() { - this.setState({ - showModal: false, - }); - setTimeout(() => { - this.setState({ - isDisable: false, - }); - }, submitInterval); - } - - onModalConfirm() { - this.setState({ - showModal: false, - }); - askLeave(this); - setTimeout(() => { - this.setState({ - isDisable: false, - }); - }, submitInterval); - } - - handleReasonChange(reason: string) { - this.setState({ - reason, - }); - } - - handleSubstituteChange(substitute: string) { - this.setState({ - substitute, - }); - } - onSubmit() { this.setState({ isDisable: true, }); - if (this.state.reason == '') { + if (this.state.conclusion == '') { Taro.atMessage({ message: pt.get().button.submitText.blank, type: 'error', @@ -106,13 +63,8 @@ export default class ConclusionPage extends Component { }, submitInterval); return; } - if (this.state.substitute == '') { - this.setState({ - showModal: true, - }); - return; - } - askLeave(this); + conclude(this); + this.uploaderRef.current?.onUpload(); setTimeout(() => { this.setState({ isDisable: false, @@ -123,16 +75,6 @@ export default class ConclusionPage extends Component { return ( - - {pt.get().askLeave.reason.title} + {pt.get().conclusion.title} - - { + console.log(res.data); + that.setState({ + isLoading: false, + conclusionId: res.data.data.id, + }); + Taro.atMessage({ + message: pt.get().button.submitText.success, + type: 'success', + }); + }) + .catch((err) => { + console.log(err.errMsg); + that.setState({ + isLoading: false, + }); + Taro.atMessage({ + message: pt.get().button.submitText.error + err.errMsg, + type: 'error', + }); + }); +}