187 lines
3.6 KiB
TypeScript
187 lines
3.6 KiB
TypeScript
// 管理员界面 - 全屏管理面板
|
|
import { UserInfo } from '../../types';
|
|
|
|
Page({
|
|
data: {
|
|
userInfo: null as UserInfo | null,
|
|
// Grid布局的功能菜单
|
|
menuItems: [
|
|
{
|
|
id: 'employee',
|
|
name: '员工管理',
|
|
icon: '👥',
|
|
color: '#3498db',
|
|
description: '管理员工信息'
|
|
},
|
|
{
|
|
id: 'order',
|
|
name: '订单管理',
|
|
icon: '📦',
|
|
color: '#e74c3c',
|
|
description: '处理订单分配'
|
|
},
|
|
{
|
|
id: 'warehouse',
|
|
name: '仓库管理',
|
|
icon: '🏭',
|
|
color: '#f39c12',
|
|
description: '管理库存信息'
|
|
},
|
|
{
|
|
id: 'statistics',
|
|
name: '数据统计',
|
|
icon: '📊',
|
|
color: '#9b59b6',
|
|
description: '查看业务数据'
|
|
},
|
|
{
|
|
id: 'settings',
|
|
name: '系统设置',
|
|
icon: '⚙️',
|
|
color: '#34495e',
|
|
description: '系统配置管理'
|
|
},
|
|
{
|
|
id: 'map',
|
|
name: '地图监控',
|
|
icon: '🗺️',
|
|
color: '#27ae60',
|
|
description: '实时位置监控'
|
|
}
|
|
],
|
|
// 统计数据
|
|
stats: {
|
|
employeeCount: 0,
|
|
orderCount: 0,
|
|
warehouseCount: 0
|
|
},
|
|
// 当前时间
|
|
currentTime: ''
|
|
},
|
|
|
|
onLoad() {
|
|
this.getUserInfo();
|
|
this.loadStatistics();
|
|
this.updateCurrentTime();
|
|
// 每秒更新一次时间
|
|
setInterval(() => {
|
|
this.updateCurrentTime();
|
|
}, 1000);
|
|
},
|
|
|
|
onShow() {
|
|
this.loadStatistics();
|
|
this.updateCurrentTime();
|
|
},
|
|
|
|
/**
|
|
* 获取用户信息
|
|
*/
|
|
getUserInfo() {
|
|
const app = getApp<any>();
|
|
if (app.globalData.userInfo) {
|
|
const userInfo = app.globalData.userInfo;
|
|
this.setData({ userInfo });
|
|
|
|
// 验证是否为管理员
|
|
if (userInfo.role !== 'ADMIN') {
|
|
wx.showToast({
|
|
title: '无权限访问',
|
|
icon: 'none'
|
|
});
|
|
wx.navigateBack();
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 加载统计数据
|
|
*/
|
|
loadStatistics() {
|
|
// 模拟加载统计数据
|
|
this.setData({
|
|
stats: {
|
|
employeeCount: 25,
|
|
orderCount: 156,
|
|
warehouseCount: 8
|
|
}
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 菜单项点击事件
|
|
*/
|
|
onMenuItemTap(e: any) {
|
|
const itemId = e.currentTarget.dataset.id;
|
|
|
|
switch (itemId) {
|
|
case 'employee':
|
|
wx.navigateTo({
|
|
url: '/pages/staff/employee-management'
|
|
});
|
|
break;
|
|
case 'order':
|
|
wx.navigateTo({
|
|
url: '/pages/staff/order-management'
|
|
});
|
|
break;
|
|
case 'warehouse':
|
|
wx.navigateTo({
|
|
url: '/pages/staff/warehouse-management'
|
|
});
|
|
break;
|
|
case 'statistics':
|
|
wx.navigateTo({
|
|
url: '/pages/staff/statistics'
|
|
});
|
|
break;
|
|
case 'settings':
|
|
wx.navigateTo({
|
|
url: '/pages/staff/settings'
|
|
});
|
|
break;
|
|
case 'map':
|
|
wx.navigateTo({
|
|
url: '/pages/map/map'
|
|
});
|
|
break;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 返回首页
|
|
*/
|
|
goBack() {
|
|
wx.navigateBack();
|
|
},
|
|
|
|
/**
|
|
* 刷新数据
|
|
*/
|
|
onRefresh() {
|
|
this.loadStatistics();
|
|
this.updateCurrentTime();
|
|
wx.showToast({
|
|
title: '数据已刷新',
|
|
icon: 'success'
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 更新当前时间
|
|
*/
|
|
updateCurrentTime() {
|
|
const now = new Date();
|
|
const timeString = now.toLocaleString('zh-CN', {
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit'
|
|
});
|
|
this.setData({
|
|
currentTime: timeString
|
|
});
|
|
}
|
|
}); |