Files

117 lines
2.4 KiB
TypeScript
Raw Permalink Normal View History

2026-02-06 15:30:07 +08:00
import { loginStatusPage, post } from '@/utils/https';
2026-02-06 14:49:13 +08:00
import {
cloneLite,
getAuthInfo,
getDataSet,
searchValueFormat,
toArray,
toNumber,
} from '@/utils/util';
2026-02-02 16:58:37 +08:00
const defaultParams = { curr_page: 1, page_count: 20 };
Page({
/**
*
*/
data: {
params: cloneLite(defaultParams) as any,
list: [] as any[],
count: 0,
sort: [{ label: '创建日期', value: 'create_date' }],
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
searchChange(e: any) {
const key = getDataSet(e).key;
2026-02-06 14:49:13 +08:00
const val = searchValueFormat(e.detail.value);
2026-02-02 16:58:37 +08:00
if (val) {
this.data.params[key] = val;
} else {
delete this.data.params[key];
}
this.setData({ params: this.data.params });
},
searchOk() {
this.getList(1);
},
searchReset() {
this.data.params = cloneLite(defaultParams);
this.getList(1);
},
onSort(e: any) {
this.data.params.order = e.detail.value;
this.setData({ params: this.data.params });
this.getList(1);
},
paginationChange(e: any) {
this.getList(e.detail.curr_page);
},
getList(curr: number = 1) {
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('Log/operateList', temp).then((res: any) => {
const list = toArray(res.data?.list);
if (list.length == 0 && this.data.params.curr_page > 1) {
this.getList(this.data.params.curr_page - 1);
}
this.setData({
count: toNumber(res.data?.count),
list: list,
});
});
},
/**
* --
*/
onLoad(_options) {},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {
2026-02-06 15:30:07 +08:00
loginStatusPage(this);
2026-02-02 16:58:37 +08:00
},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});