Files
WXProgram/miniprogram/pages/index/modules/employeeModule.ts
2025-10-21 21:51:51 +08:00

92 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 员工模块 - 处理所有员工(管理员和货运人员)的通用功能
import { showToast } from '../../../utils/helpers';
import { DataModule } from './dataModule';
import employeeService from '../../../services/employeeService';
export class EmployeeModule {
private pageContext: any;
private dataModule: DataModule;
constructor(pageContext: any, dataModule: DataModule) {
this.pageContext = pageContext;
this.dataModule = dataModule;
}
/**
* 处理员工标记点点击 - 通用处理逻辑
*/
onEmployeeMarkerClick(employee: any, position: { x: number, y: number }): void {
console.log('员工被点击:', employee);
// 设置当前员工
this.dataModule.setCurrentDeliveryPerson(employee);
// 显示面板
this.dataModule.toggleDeliveryPersonModal(true, 'bottom');
}
/**
* 隐藏员工详情面板
*/
hideEmployeePanel(): void {
this.dataModule.toggleDeliveryPersonModal(false);
this.dataModule.setCurrentDeliveryPerson(null);
}
/**
* 展开员工详情面板
*/
expandEmployeePanel(): void {
this.dataModule.toggleDeliveryPersonModal(true, 'full');
}
/**
* 收起员工详情面板
*/
collapseEmployeePanel(): void {
this.dataModule.toggleDeliveryPersonModal(true, 'bottom');
}
/**
* 获取员工信息摘要
*/
getEmployeeSummary(employee: any): string {
return `${employee.name || '员工'} - ${employee.role || '未知角色'}`;
}
/**
* 获取员工状态文本
*/
getEmployeeStatusText(status: string): string {
const statusMap: Record<string, string> = {
'idle': '空闲',
'busy': '忙碌',
'offline': '离线'
};
return statusMap[status] || status;
}
/**
* 加载所有员工数据
*/
async loadAllEmployees(): Promise<void> {
try {
console.log('开始加载所有员工数据');
const employees = await employeeService.getEmployees();
console.log('员工数据加载完成:', employees);
// 这里可以添加员工数据处理逻辑比如更新到dataModule
// this.dataModule.updateEmployees(employees);
} catch (error) {
console.error('加载员工数据失败:', error);
throw error; // 重新抛出错误,让调用方处理
}
}
/**
* 清理资源
*/
cleanup(): void {
console.log('清理员工模块资源');
}
}