xiaochan 3 weeks ago
parent
commit
565d3790c9

+ 20 - 15
src/views/settings/scheduling-class/ExportFalseExcel.vue

@@ -5,7 +5,6 @@ import dayjs from "dayjs";
 import env from "@/utils/setting";
 import XEUtils from "xe-utils";
 import { stringNotBlank } from "@/utils/blank-utils";
-import { isDev } from "@/utils/public";
 
 const props = defineProps<{
   deptList: any[];
@@ -15,16 +14,20 @@ const [TableTemplate, exportFun] = useTableToExcel({
   css: `td{text-align: center}`,
 });
 
-const store = reactive({
-  headerColSpan: 0,
-  title: "",
-  dayLength: 0,
-  month: "",
-  weekList: [],
+function init() {
+  return {
+    headerColSpan: 0,
+    title: "",
+    dayLength: 0,
+    month: "",
+    weekList: [],
+
+    keyDayMap: new Map(),
+    deptList: [],
+  };
+}
 
-  keyDayMap: new Map(),
-  deptList: [],
-});
+const store = reactive(init());
 
 const days = ["天", "一", "二", "三", "四", "五", "六"];
 
@@ -88,14 +91,16 @@ function employeeHandling(month) {
 }
 
 function renderTable(month: string, value: DataValue[]) {
-  store.keyDayMap.clear();
+  XEUtils.assign(store, init());
+  store.month = month;
+
   value.forEach(item => {
     store.keyDayMap.set(dayjs(item.schedulingDate).format("MM-DD"), item);
   });
 
   store.dayLength = dayjs(month).daysInMonth();
   store.headerColSpan = store.dayLength + 13;
-  store.title = `${dayjs(month).format("YYYY年MM月")}排班表`;
+  store.title = `${dayjs(month).format("YYYY年MM月")}考勤表`;
   store.weekList = Array.from({ length: store.dayLength }).map((_, i) => {
     let strIndex = i + 1 < 10 ? `${month}-0${i + 1}` : `${month}-${i + 1}`;
     const week = dayjs(strIndex).day();
@@ -107,7 +112,7 @@ function renderTable(month: string, value: DataValue[]) {
 defineExpose({
   exportExcel(month: string, value: DataValue[]) {
     renderTable(month, value);
-    exportFun(dayjs(month).format("YYYY年MM月") + "排班表.xlsx");
+    exportFun(dayjs(month).format("YYYY年MM月") + "考勤表");
   },
 });
 </script>
@@ -145,8 +150,8 @@ defineExpose({
         <tr>
           <td>星期</td>
           <td
-            v-for="item in store.weekList"
-            :key="item"
+            v-for="(item, index) in store.weekList"
+            :key="`${store.month}-${item}-${index}`"
             :style="['天', '六'].includes(item) ? 'background: yellow' : ''"
           >
             {{ item }}

+ 6 - 1
src/views/settings/scheduling-class/index.vue

@@ -16,6 +16,7 @@ import { useCompShallowRef } from "@/utils/useCompRef";
 import ExportFalseExcel from "@/views/settings/scheduling-class/ExportFalseExcel.vue";
 import { useUserStore } from "@/pinia/user-store";
 import SchedulingSelectClasss from "@/views/settings/scheduling-class/SchedulingSelectClasss.vue";
+import { isDev } from "@/utils/public";
 
 const store = reactive({
   codes: [],
@@ -93,7 +94,11 @@ function handleGetByMonth() {
 }
 
 function exportExcel(type: "all" | "true" | "false" = "all") {
-  const month = store.tmpCurrentCalendar;
+  let month = store.tmpCurrentCalendar;
+
+  // if (isDev) {
+  //   month = "2025-07";
+  // }
 
   getByMonth(month).then(res => {
     store.months[month] = res;