|
|
@@ -111,37 +111,52 @@
|
|
|
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
import { useAuthGuard } from "@/hooks/useAuthGuard";
|
|
|
-import { onboardings, onboardStatus, resignings, resignStatus } from "@/data/mock";
|
|
|
+import { onboardings, resignings, resignStatus } from "@/data/mock";
|
|
|
import { mergeOnboardings } from "@/utils/storage";
|
|
|
+import { getServerConfig } from "@/utils/auth";
|
|
|
+import {
|
|
|
+ adaptOnboardingRecord,
|
|
|
+ getOnboardingRecords,
|
|
|
+ mapOnboardingForList,
|
|
|
+} from "@/api/onboarding";
|
|
|
import { go } from "@/utils/router";
|
|
|
const type = ref("recruit");
|
|
|
useAuthGuard();
|
|
|
const keyword = ref("");
|
|
|
const statusFilter = ref("全部状态");
|
|
|
+
|
|
|
+// 入职记录原始数据(mock 或 API VO 经 adaptOnboardingRecord 归一后的形状)。
|
|
|
+// 服务器模式按 getOnboardingRecords 拉取;演示模式合并本地 mock + storage。
|
|
|
+const onboardRecords = ref([]);
|
|
|
+async function loadOnboardList() {
|
|
|
+ try {
|
|
|
+ if (getServerConfig().mode === "server") {
|
|
|
+ const records = await getOnboardingRecords();
|
|
|
+ onboardRecords.value = records
|
|
|
+ .map((vo) => adaptOnboardingRecord(vo) || vo)
|
|
|
+ .filter(Boolean);
|
|
|
+ } else {
|
|
|
+ onboardRecords.value = mergeOnboardings(onboardings);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.warn("[manage/onboard] 入职列表加载失败:", e?.message || e);
|
|
|
+ uni.showToast({ title: "入职列表加载失败", icon: "none" });
|
|
|
+ onboardRecords.value = mergeOnboardings(onboardings);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const onboardItems = computed(() =>
|
|
|
- mergeOnboardings(onboardings)
|
|
|
+ onboardRecords.value
|
|
|
.slice()
|
|
|
- .sort((a, b) => a.expectedEntryDate.localeCompare(b.expectedEntryDate))
|
|
|
- .map((o) => {
|
|
|
- const total = Object.keys(o.materials).length;
|
|
|
- const done = Object.values(o.materials).filter(Boolean).length;
|
|
|
- const statusInfo = onboardStatus[o.status] || onboardStatus.pending;
|
|
|
- return {
|
|
|
- id: o.id,
|
|
|
- avatar: o.avatar,
|
|
|
- name: o.name,
|
|
|
- sub: `${o.department} · ${o.position}`,
|
|
|
- status: statusInfo.label,
|
|
|
- statusClass: statusInfo.class,
|
|
|
- label1: o.entryDate ? "入职日期" : "预计入职",
|
|
|
- value1: o.entryDate || o.expectedEntryDate,
|
|
|
- label2: o.entryDate ? "员工编号" : "资料进度",
|
|
|
- value2: o.entryDate ? o.id : `${done}/${total}`,
|
|
|
- };
|
|
|
- }),
|
|
|
+ .sort((a, b) =>
|
|
|
+ (a.hireDate || a.entryDate || a.expectedEntryDate || "").localeCompare(
|
|
|
+ b.hireDate || b.entryDate || b.expectedEntryDate || "",
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ .map(mapOnboardingForList),
|
|
|
);
|
|
|
const pendingOnboardCount = computed(
|
|
|
- () => mergeOnboardings(onboardings).filter((o) => o.status !== "done").length,
|
|
|
+ () => onboardRecords.value.filter((o) => o.status !== "done").length,
|
|
|
);
|
|
|
const resignItems = computed(() =>
|
|
|
resignings
|
|
|
@@ -347,6 +362,7 @@ onLoad(syncType);
|
|
|
onShow(() => {
|
|
|
const pages = getCurrentPages();
|
|
|
syncType(pages[pages.length - 1]?.options || {});
|
|
|
+ loadOnboardList();
|
|
|
});
|
|
|
function syncHash() {
|
|
|
if (typeof location === "undefined") return;
|
|
|
@@ -381,7 +397,7 @@ function onCreateOnboarding() {
|
|
|
go("/pages/manage/onboard-create");
|
|
|
}
|
|
|
function chooseStatus() {
|
|
|
- const items = ["全部状态", "待审批", "进行中", "已离职", "已逾期", "已撤回"];
|
|
|
+ const items = ["全部状态", "待入职", "入职中", "已入职", "已逾期"];
|
|
|
uni.showActionSheet({
|
|
|
itemList: items,
|
|
|
success: (r) => (statusFilter.value = items[r.tapIndex]),
|