Files
FreeERP.Applet/miniprogram/pages/produce/processManageDetail/processManageDetail.ts

152 lines
3.6 KiB
TypeScript
Raw Normal View History

2026-01-21 17:05:30 +08:00
import { loginStatus, post } from '@/utils/https';
import { getAuthInfo, getDataSet, toArray, toastSuccess, toNumber } from '@/utils/util';
Page({
/**
*
*/
data: {
2026-01-21 17:05:30 +08:00
params: { curr_page: 1, page_count: 20, state: '1', process_id: '' } as any,
list: [] as any[],
count: 0,
dialog: {
visible: false,
content: '',
item: {} as any,
action: '' as 'end' | 'back',
},
},
handleLogin(e: any) {
this.setData({ isLogin: e.detail });
if (e.detail) {
this.init();
}
},
init() {
this.setData({ authInfo: getAuthInfo() });
this.getList();
},
searchChange(e: any) {
this.data.params.order_no = e.detail.value;
},
searchChange2(e: any) {
const key = getDataSet(e).key;
const val = `${e.detail.value || ''}`.trim();
console.log(e);
if (val) {
this.data.params[key] = val;
} else {
delete this.data.params[key];
}
},
searchOk() {
this.getList(1);
},
tabChange(e: any) {
const state = getDataSet(e).key;
this.data.params.state = state;
2026-01-21 17:05:30 +08:00
this.getList();
},
2026-01-21 17:05:30 +08:00
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 });
2026-01-21 17:05:30 +08:00
post('CompanyProcessV2/processOrd', this.data.params).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,
});
});
},
confirmDialog() {
post('ProduceOrder/setProcessV2', {
info_process_id: JSON.stringify([this.data.dialog.item.info_process_id]),
action: this.data.dialog.action,
}).then(() => {
this.closeDialog();
toastSuccess(this.data.dialog.action == 'end' ? '订单工序完成成功' : '订单工序撤回成功');
setTimeout(() => {
this.getList(this.data.params.curr_page);
}, 1500);
});
},
closeDialog() {
this.data.dialog.visible = false;
this.setData({ dialog: this.data.dialog });
},
onEndOrBack(e: any) {
const data = getDataSet(e);
const index = data.index;
const item = this.data.list[index];
this.setData({
dialog: {
visible: true,
content: `确认${data.action == 'end' ? '完成' : '撤回'} ${item.order_no} ?`,
action: data.action,
item,
},
});
},
/**
* --
*/
onLoad(options) {
// console.log(options);
wx.setNavigationBarTitle({
2026-01-21 17:05:30 +08:00
title: decodeURIComponent(options.title || ''),
});
2026-01-21 17:05:30 +08:00
this.data.params.process_id = `${options.process_id || ''}`;
this.setData({ loading: true });
loginStatus()
.then(() => {
this.setData({ isLogin: true, loading: false });
this.init();
})
.catch((err) => {
this.setData({ isLogin: false, loading: false });
console.log('调用登录状态请求失败', err);
});
},
/**
* --
*/
onReady() {},
/**
* --
*/
onShow() {},
/**
* --
*/
onHide() {},
/**
* --
*/
onUnload() {},
/**
* --
*/
onPullDownRefresh() {},
/**
*
*/
onReachBottom() {},
/**
*
*/
onShareAppMessage() {},
});