Files
FreeERP.Applet/miniprogram/pages/base/workload/workload.ts

99 lines
1.9 KiB
TypeScript
Raw Normal View History

import { loginStatusPage, post } from '@/utils/https';
import { toArray, toNumber } from '@/utils/util';
Page({
/**
*
*/
data: {
process_count: [] as any[],
seven_process_count: [] as any[],
isLogin: false,
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.getList();
},
getList() {
post('Index/index')
.then((res: any) => {
const process_count = toArray(res.process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
const arr = toArray(res.seven_process_count).filter((el) => {
el.count = toNumber(el.count);
return el.count > 0;
});
const map = new Map<string, any>();
arr.forEach((el) => {
if (!map.has(el.date)) {
map.set(el.date, []);
}
map.get(el.date).push(el);
});
// console.log([...map.values()]);
this.setData({
seven_process_count: [...map.values()],
process_count: process_count,
});
})
.finally(() => {
wx.stopPullDownRefresh();
});
},
/**
* --
*/
onLoad(_options) {},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {
loginStatusPage(this);
},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {
if (this.data.isLogin) {
this.init();
}
},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});