Files
FreeERP.Applet/miniprogram/pages/other/batchDetail/batchDetail.ts

137 lines
2.9 KiB
TypeScript
Raw 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';
const defaultParams = { curr_page: 1, page_count: 20, batch_id: '' };
Page({
/**
*
*/
data: {
params: cloneLite(defaultParams) as any,
list: [] as any[],
count: 0,
sort: [{ label: '创建日期', value: 'create_date' }],
depots: [] as any[],
depotsObj: {} as any,
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
this.getData();
},
searchChange(e: any) {
const key = getDataSet(e).key;
2026-02-06 14:49:13 +08:00
const val = searchValueFormat(e.detail.value);
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);
},
getData() {
post('ErpDepot/ajaxDepotList').then((res: any) => {
const depots = toArray(res.data).map((el) => {
this.data.depotsObj[el.depot_id] = el.depot_name;
return { label: el.depot_name, value: el.depot_id };
});
this.setData({
depots,
depotsObj: this.data.depotsObj,
});
});
},
getList(curr: number = 1) {
this.data.params.curr_page = curr;
this.setData({ params: this.data.params });
const temp = cloneLite(this.data.params);
post('GoodsBatch/getBatchLogList', temp).then((res: any) => {
const list = toArray(res.data);
if (list.length == 0 && this.data.params.curr_page > 1) {
this.getList(this.data.params.curr_page - 1);
}
this.setData({
count: toNumber(res.count),
list: list,
});
});
},
/**
* --
*/
onLoad(options) {
const { batch_id, title } = options;
this.data.params.batch_id = batch_id;
if (title) {
wx.setNavigationBarTitle({ title });
}
2026-02-06 15:30:07 +08:00
loginStatusPage(this);
},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});