|
@@ -30,9 +30,14 @@
|
|
|
<div class="title">接收人</div>
|
|
|
<SelectUser v-model="formData.receiveUserIds" />
|
|
|
<div class="blank-line"></div>
|
|
|
- <van-button round type="primary" block class="send-btn" @click="onSubmit"
|
|
|
- >发送</van-button
|
|
|
- >
|
|
|
+ <div class="send-btn-group">
|
|
|
+ <van-button type="success" block class="send-btn" @click="onSubmit(true)"
|
|
|
+ >暂存</van-button
|
|
|
+ >
|
|
|
+ <van-button type="primary" block class="send-btn" @click="onSubmit(false)"
|
|
|
+ >发送</van-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
@@ -92,8 +97,14 @@ const formData = reactive<FormData>({
|
|
|
|
|
|
const route = useRoute();
|
|
|
onMounted(async () => {
|
|
|
- // 查看有没有传日期进来
|
|
|
const query: any = route.query;
|
|
|
+ // 查一下有没有传id进来,有的话就是数据回填
|
|
|
+ if (query.id && query.detail) {
|
|
|
+ const weekDetail = JSON.parse(route.query.detail as string);
|
|
|
+ receiveData(weekDetail);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查看有没有传日期进来
|
|
|
if (query.startDate && query.endDate) {
|
|
|
thisWeek.value = `${moment(query.startDate).format(
|
|
|
"YYYY/MM/DD"
|
|
@@ -115,48 +126,28 @@ onMounted(async () => {
|
|
|
formData.receiveUserIds = receiveUser;
|
|
|
});
|
|
|
|
|
|
-// 判断一下本周是否已经填了,如果是填了的就跳转到详情页
|
|
|
-// const isFillLog = async () => {
|
|
|
-// const date = thisWeek.value.split(" ~ ");
|
|
|
-// let searchList = await http.getMonthLogList(
|
|
|
-// "weekly",
|
|
|
-// moment(date[1]).format("YYYY"),
|
|
|
-// moment(date[1]).format("M")
|
|
|
-// );
|
|
|
-// // 以防万一
|
|
|
-// if (searchList.length == 0) {
|
|
|
-// searchList = await http.getMonthLogList(
|
|
|
-// "weekly",
|
|
|
-// moment(date[0]).format("YYYY"),
|
|
|
-// moment(date[0]).format("M")
|
|
|
-// );
|
|
|
-// }
|
|
|
-// const searchLog = searchList.find(
|
|
|
-// (item: any) =>
|
|
|
-// moment(item.reportEndDate).format("YYYY-MM-DD") ==
|
|
|
-// moment(date[1]).format("YYYY-MM-DD")
|
|
|
-// );
|
|
|
-
|
|
|
-// if (searchLog) {
|
|
|
-// push(`/logsDetail?id=${searchLog.id}`);
|
|
|
-// }
|
|
|
-// };
|
|
|
+// 回填暂存数据
|
|
|
+const receiveData = (weekDetail: any) => {
|
|
|
+ formData.reportContent = weekDetail.reportContent;
|
|
|
+ formData.reportYear = weekDetail.reportYear;
|
|
|
+ formData.reportMonth = weekDetail.reportMonth;
|
|
|
+ formData.reportWeek = weekDetail.reportWeek;
|
|
|
+ thisWeek.value = `${moment(weekDetail.reportStartDate).format(
|
|
|
+ "YYYY/MM/DD"
|
|
|
+ )} ~ ${moment(weekDetail.reportEndDate).format("YYYY/MM/DD")}`;
|
|
|
+ // 加个定时器回填接收人和工时
|
|
|
+ const timer = setTimeout(() => {
|
|
|
+ formData.receiveUserIds = weekDetail.receiveIds;
|
|
|
+ formData.weeklyWorkloadList = weekDetail.workload.map((work: any) => ({
|
|
|
+ projectId: work.projectId,
|
|
|
+ workTime: work.workTime,
|
|
|
+ }));
|
|
|
+ clearTimeout(timer);
|
|
|
+ }, 1000);
|
|
|
+};
|
|
|
|
|
|
// 日历
|
|
|
const calendarShow = ref(false);
|
|
|
-// const onConfirm = async (values: any) => {
|
|
|
-// const [start, end] = values;
|
|
|
-// thisWeek.value = `${moment(start).format("YYYY/MM/DD")} ~ ${moment(
|
|
|
-// end
|
|
|
-// ).format("YYYY/MM/DD")}`;
|
|
|
-// calendarShow.value = false;
|
|
|
-// // 获取当日详情
|
|
|
-// await getIsWorkDays();
|
|
|
-// };
|
|
|
-
|
|
|
-// 可选择的最小日期,一个月之前,最大日期:今天
|
|
|
-// const minDate = moment().subtract(2, "months").toDate();
|
|
|
-// const maxDate = moment().toDate();
|
|
|
|
|
|
// 工作量改变
|
|
|
const projectChange = (data: any) => {
|
|
@@ -166,7 +157,7 @@ const projectChange = (data: any) => {
|
|
|
|
|
|
// 提交
|
|
|
const { push, replace } = useRouter();
|
|
|
-const onSubmit = async () => {
|
|
|
+const onSubmit = async (isTemp: boolean) => {
|
|
|
const date = thisWeek.value.split(" ~ ");
|
|
|
const userInfo = getUserInfo();
|
|
|
const params: IReport = {
|
|
@@ -176,7 +167,7 @@ const onSubmit = async () => {
|
|
|
deptId: userInfo.deptId ?? "",
|
|
|
reportStartDate: moment(date[0]).valueOf(),
|
|
|
reportEndDate: moment(date[1]).valueOf(),
|
|
|
- isTemp: false,
|
|
|
+ isTemp,
|
|
|
};
|
|
|
const submitCheck = onSubmitCheck(params);
|
|
|
if (!submitCheck.success) {
|
|
@@ -252,17 +243,23 @@ const thisWeekLog = async () => {
|
|
|
log.reportMonth == formData.reportMonth
|
|
|
);
|
|
|
if (thisWeekLogs.length > 0) {
|
|
|
- // push(`/logsDetail?id=${thisWeekLogs[0].id}`);
|
|
|
- replace({
|
|
|
- path: "/logsDetail",
|
|
|
- query: {
|
|
|
- id: thisWeekLogs[0].id,
|
|
|
- detail: JSON.stringify({
|
|
|
- ...thisWeekLogs[0],
|
|
|
- comments: [], // 就不传那么多东西过去了,反正详情页面也会查询评论
|
|
|
- }),
|
|
|
- },
|
|
|
- });
|
|
|
+ // 如何获取到的是暂存数据
|
|
|
+ if (thisWeekLogs[0].isTemp) {
|
|
|
+ receiveData(thisWeekLogs[0]);
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ // 否则跳到详情页
|
|
|
+ replace({
|
|
|
+ path: "/logsDetail",
|
|
|
+ query: {
|
|
|
+ id: thisWeekLogs[0].id,
|
|
|
+ detail: JSON.stringify({
|
|
|
+ ...thisWeekLogs[0],
|
|
|
+ comments: [], // 就不传那么多东西过去了,反正详情页面也会查询评论
|
|
|
+ }),
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|