|
@@ -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 }}
|