2025-10-21 21:51:51 +08:00
|
|
|
|
// 员工模块 - 处理所有员工(管理员和货运人员)的通用功能
|
|
|
|
|
|
import { DataModule } from './dataModule';
|
|
|
|
|
|
import employeeService from '../../../services/employeeService';
|
2025-10-26 13:15:04 +08:00
|
|
|
|
import { API_BASE_URL } from '../../../services/apiService';
|
2025-10-21 21:51:51 +08:00
|
|
|
|
|
|
|
|
|
|
export class EmployeeModule {
|
2025-10-26 13:15:04 +08:00
|
|
|
|
|
2025-10-21 21:51:51 +08:00
|
|
|
|
private dataModule: DataModule;
|
|
|
|
|
|
|
2025-10-26 13:15:04 +08:00
|
|
|
|
constructor(_pageContext: any, dataModule: DataModule) {
|
2025-10-21 21:51:51 +08:00
|
|
|
|
this.dataModule = dataModule;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理员工标记点点击 - 通用处理逻辑
|
|
|
|
|
|
*/
|
2025-10-26 13:15:04 +08:00
|
|
|
|
onEmployeeMarkerClick(employee: any, _position: { x: number, y: number }): void {
|
2025-10-21 21:51:51 +08:00
|
|
|
|
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();
|
2025-10-26 13:15:04 +08:00
|
|
|
|
console.log('员工数据加载完成,共', employees.length, '名员工');
|
|
|
|
|
|
|
|
|
|
|
|
// 打印每个员工的基本信息
|
|
|
|
|
|
console.log('=== 员工列表详细信息 ===');
|
|
|
|
|
|
employees.forEach((employee, index) => {
|
|
|
|
|
|
console.log(`员工 ${index + 1}:`);
|
|
|
|
|
|
console.log(` - ID: ${employee.id}`);
|
|
|
|
|
|
console.log(` - 姓名: ${employee.name || '未设置'}`);
|
|
|
|
|
|
console.log(` - 电话: ${employee.phone || '未设置'}`);
|
|
|
|
|
|
console.log(` - 角色: ${employee.role || '未设置'}`);
|
|
|
|
|
|
|
|
|
|
|
|
// 处理头像路径:使用avatarPath转换为完整URL
|
|
|
|
|
|
let avatarFullUrl = '未设置';
|
|
|
|
|
|
if (employee.avatarPath) {
|
|
|
|
|
|
avatarFullUrl = `${API_BASE_URL}${employee.avatarPath}`;
|
|
|
|
|
|
console.log(` - 头像路径: ${employee.avatarPath}`);
|
|
|
|
|
|
console.log(` - 完整头像URL: ${avatarFullUrl}`);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.log(` - 头像URL: 未设置`);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log(` - 头像缩略图: ${employee.avatarThumbnail || '未设置'}`);
|
|
|
|
|
|
console.log('---');
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log('=== 员工列表打印完成 ===');
|
2025-10-21 21:51:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 这里可以添加员工数据处理逻辑,比如更新到dataModule
|
|
|
|
|
|
// this.dataModule.updateEmployees(employees);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('加载员工数据失败:', error);
|
|
|
|
|
|
throw error; // 重新抛出错误,让调用方处理
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 清理资源
|
|
|
|
|
|
*/
|
|
|
|
|
|
cleanup(): void {
|
|
|
|
|
|
console.log('清理员工模块资源');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|