93 lines
2.1 KiB
JavaScript
93 lines
2.1 KiB
JavaScript
// pages/warning/list/list.js
|
|
Page({
|
|
data: {
|
|
activeTab: 'all',
|
|
allCount: 15,
|
|
sevenDaysCount: 5,
|
|
fifteenDaysCount: 8,
|
|
expiredCount: 2,
|
|
warningList: [],
|
|
allWarningList: []
|
|
},
|
|
|
|
onLoad() {
|
|
this.loadWarningList();
|
|
},
|
|
|
|
loadWarningList() {
|
|
// TODO: 加载预警数据
|
|
const mockData = [
|
|
{
|
|
id: '1',
|
|
deviceId: '1',
|
|
deviceName: '绝缘手套',
|
|
deviceCode: 'SB-2023-001',
|
|
useUnit: '施工一队',
|
|
nextInspectionDate: '2024-06-01',
|
|
daysLeft: 5,
|
|
level: 'urgent',
|
|
levelText: '紧急',
|
|
tagTheme: 'danger'
|
|
},
|
|
{
|
|
id: '2',
|
|
deviceId: '2',
|
|
deviceName: '安全帽',
|
|
deviceCode: 'SB-2023-015',
|
|
useUnit: '施工二队',
|
|
nextInspectionDate: '2024-06-10',
|
|
daysLeft: 14,
|
|
level: 'warning',
|
|
levelText: '预警',
|
|
tagTheme: 'warning'
|
|
},
|
|
{
|
|
id: '3',
|
|
deviceId: '3',
|
|
deviceName: '安全带',
|
|
deviceCode: 'SB-2023-028',
|
|
useUnit: '施工三队',
|
|
nextInspectionDate: '2024-05-20',
|
|
daysLeft: -7,
|
|
level: 'expired',
|
|
levelText: '已到期',
|
|
tagTheme: 'danger'
|
|
}
|
|
];
|
|
|
|
this.setData({
|
|
allWarningList: mockData,
|
|
warningList: mockData
|
|
});
|
|
},
|
|
|
|
onTabChange(e) {
|
|
const tab = e.detail.value;
|
|
this.setData({ activeTab: tab });
|
|
this.filterWarningList(tab);
|
|
},
|
|
|
|
filterWarningList(tab) {
|
|
const { allWarningList } = this.data;
|
|
let filtered = allWarningList;
|
|
|
|
if (tab === '7days') {
|
|
filtered = allWarningList.filter(item => item.daysLeft > 0 && item.daysLeft <= 7);
|
|
} else if (tab === '15days') {
|
|
filtered = allWarningList.filter(item => item.daysLeft > 0 && item.daysLeft <= 15);
|
|
} else if (tab === 'expired') {
|
|
filtered = allWarningList.filter(item => item.daysLeft < 0);
|
|
}
|
|
|
|
this.setData({ warningList: filtered });
|
|
},
|
|
|
|
goToDetail(e) {
|
|
const id = e.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: `/pages/device/detail/detail?id=${id}`
|
|
});
|
|
}
|
|
});
|
|
|