|
@@ -30,7 +30,12 @@
|
|
|
<div class="title">接收人</div>
|
|
|
<SelectUser v-model="formData.receiveUserIds" />
|
|
|
<div class="blank-line"></div>
|
|
|
- <div class="send-btn-group">
|
|
|
+ <div class="send-btn-group" v-if="formData.isUpdate">
|
|
|
+ <van-button type="primary" block @click="onSubmit(false)"
|
|
|
+ >更新</van-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="send-btn-group" v-else>
|
|
|
<van-button type="success" block class="send-btn" @click="onSubmit(true)"
|
|
|
>暂存</van-button
|
|
|
>
|
|
@@ -45,7 +50,7 @@
|
|
|
* @description 周报
|
|
|
*/
|
|
|
import moment from "moment";
|
|
|
-import { reactive } from "vue";
|
|
|
+import { reactive, watch } from "vue";
|
|
|
import { showSuccessToast, showToast } from "vant";
|
|
|
import SelectUser from "@/components/UserSelect.vue";
|
|
|
import ProjectList from "../components/ProjectList.vue";
|
|
@@ -65,6 +70,7 @@ interface FormData {
|
|
|
reportYear: string | number; // 年
|
|
|
reportMonth: string | number; // 月
|
|
|
reportWeek: string | number; // 周
|
|
|
+ isUpdate?: boolean; // 是否是更新
|
|
|
}
|
|
|
const defWeek = () => {
|
|
|
if (moment().day() == 0) {
|
|
@@ -127,15 +133,27 @@ onMounted(async () => {
|
|
|
formData.receiveUserIds = receiveUser;
|
|
|
});
|
|
|
|
|
|
-// 在退出前调用一下暂存
|
|
|
-onBeforeRouteLeave((ev: any) => {
|
|
|
- // 如果是千万详情,则不做处理
|
|
|
- if (ev.name == "LogsDetail") return;
|
|
|
- // 如果日志内容不为空则触发暂存,否则直接退出
|
|
|
- if (formData.reportContent?.length > 0) {
|
|
|
- onSubmit(true, true);
|
|
|
+// 在退出前调用一下暂存(做好实时暂存后就不需要退出暂存了)
|
|
|
+// onBeforeRouteLeave((ev: any) => {
|
|
|
+// // 如果是前往详情,则不做处理
|
|
|
+// if (ev.name == "LogsDetail") return;
|
|
|
+// // 如果日志内容不为空则触发暂存,否则直接退出
|
|
|
+// if (formData.reportContent?.length > 0) {
|
|
|
+// onSubmit(true, true);
|
|
|
+// }
|
|
|
+// });
|
|
|
+
|
|
|
+// 在改动工作量的时候实时暂存
|
|
|
+watch(
|
|
|
+ () => formData.reportContent,
|
|
|
+ (newData, oldData) => {
|
|
|
+ // 如果是更新,则不进行实时暂存
|
|
|
+ if (formData.isUpdate) return;
|
|
|
+ if (newData?.length > 0 && oldData?.length > 0) {
|
|
|
+ onSubmit(true, true);
|
|
|
+ }
|
|
|
}
|
|
|
-});
|
|
|
+);
|
|
|
|
|
|
// 回填暂存数据
|
|
|
const receiveData = (weekDetail: any) => {
|
|
@@ -143,6 +161,9 @@ const receiveData = (weekDetail: any) => {
|
|
|
formData.reportYear = weekDetail.reportYear;
|
|
|
formData.reportMonth = weekDetail.reportMonth;
|
|
|
formData.reportWeek = weekDetail.reportWeek;
|
|
|
+ if (weekDetail.isUpdate) {
|
|
|
+ formData.isUpdate = weekDetail.isUpdate;
|
|
|
+ }
|
|
|
thisWeek.value = `${moment(weekDetail.reportStartDate).format(
|
|
|
"YYYY/MM/DD"
|
|
|
)} ~ ${moment(weekDetail.reportEndDate).format("YYYY/MM/DD")}`;
|