纸板小程序:订单/送货单:列表与详情功能
This commit is contained in:
@@ -0,0 +1,279 @@
|
||||
// utils/app.ts.ts
|
||||
import { getMonthDay } from '../../utils/util'
|
||||
import { getCardBoardOrderList } from '../../api/index'
|
||||
import { getAppInstance } from '../../utils/app';
|
||||
const app = getAppInstance();
|
||||
|
||||
// const userInfo = wx.getStorageSync('userInfo');
|
||||
// const devicecode = wx.getStorageSync('devicecode');
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
date_field: '',
|
||||
s_date: '',
|
||||
e_date: '',
|
||||
search_input_focus: false,
|
||||
status: '全状态',
|
||||
customerId: 0,
|
||||
searchTxt: '',
|
||||
statusOptions: [
|
||||
{
|
||||
label: '全状态',
|
||||
value: '全状态'
|
||||
},
|
||||
{
|
||||
label: '未复核',
|
||||
value: '未复核'
|
||||
},
|
||||
{
|
||||
label: '已复核',
|
||||
value: '已复核'
|
||||
},
|
||||
{
|
||||
label: '审核中',
|
||||
value: '审核中'
|
||||
},
|
||||
{
|
||||
label: '已终审',
|
||||
value: '已终审'
|
||||
},
|
||||
{
|
||||
label: '已排程',
|
||||
value: '已排程'
|
||||
},
|
||||
{
|
||||
label: '已生产',
|
||||
value: '已生产'
|
||||
},
|
||||
{
|
||||
label: '已入库',
|
||||
value: '已入库'
|
||||
},
|
||||
{
|
||||
label: '已发货',
|
||||
value: '已发货'
|
||||
},
|
||||
{
|
||||
label: '已作废',
|
||||
value: '已作废'
|
||||
},
|
||||
],
|
||||
statusColorMap: {
|
||||
},
|
||||
sDateVisible: false,
|
||||
startDate: '',
|
||||
list: [],
|
||||
showCount: true,
|
||||
totalData: {},
|
||||
customerList: [],
|
||||
pageNumber: 1, // 当前页码
|
||||
pageSize: 20, // 每页数量
|
||||
hasMore: true, // 是否还有更多数据
|
||||
loading: false, // 是否正在加载(防止重复请求)
|
||||
isCust: false //是否为客户账号,限制仅可查看本身的订单
|
||||
},
|
||||
hideCount() {
|
||||
this.setData({
|
||||
showCount: false
|
||||
})
|
||||
},
|
||||
showCount() {
|
||||
this.setData({
|
||||
showCount: true
|
||||
})
|
||||
},
|
||||
// 触底事件
|
||||
onScrollToLower() {
|
||||
// 防止重复加载 & 无更多数据
|
||||
if (this.data.loading || !this.data.hasMore) return
|
||||
|
||||
this.setData({ loading: true,pageNumber: this.data.pageNumber + 1 })
|
||||
wx.nextTick(() => {
|
||||
this.getOrderList(true);
|
||||
})
|
||||
},
|
||||
// 跳转订单详情
|
||||
toOrderDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/cardBoardOrderDetail/cardBoardOrderDetail?id=${id}`
|
||||
})
|
||||
},
|
||||
// 日期相关
|
||||
showPicker(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
this.setData({ sDateVisible: true, date_field: field });
|
||||
},
|
||||
onCancel() {
|
||||
this.setData({ sDateVisible: false });
|
||||
},
|
||||
// 选择日期
|
||||
onConfirm(e) {
|
||||
const { value } = e.detail;
|
||||
this.setData({ [this.data.date_field]: value,sDateVisible: false });
|
||||
},
|
||||
// 关键词搜索
|
||||
handleSearchTxtChange(e) {
|
||||
const { value } = e.detail;
|
||||
this.setData({ searchTxt: value });
|
||||
},
|
||||
// 切换状态
|
||||
onChange(e) {
|
||||
this.setData({
|
||||
status: e.detail.value,
|
||||
});
|
||||
this.getOrderList(false);
|
||||
},
|
||||
// 切换客户
|
||||
onCustChange(e) {
|
||||
this.setData({
|
||||
customerId: e.detail.value,
|
||||
});
|
||||
this.getOrderList(false);
|
||||
},
|
||||
// 搜索输入框焦点事件
|
||||
inputFocus() {
|
||||
this.setData({
|
||||
search_input_focus: true
|
||||
})
|
||||
},
|
||||
inputBlur() {
|
||||
this.setData({
|
||||
search_input_focus: false
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {
|
||||
const days = getMonthDay();
|
||||
const userInfo = wx.getStorageSync('userInfo');
|
||||
this.setData({
|
||||
s_date: days[0],
|
||||
e_date: days[1],
|
||||
customerId: userInfo.custid?userInfo.custid:0,
|
||||
customerList: app.globalData.customerList,
|
||||
date_field: 's_date',
|
||||
isCust: userInfo.custid?true:false,
|
||||
statusColorMap: app.globalData.statusColorMap
|
||||
})
|
||||
this.getOrderList(false);
|
||||
|
||||
},
|
||||
|
||||
async getOrderList(isLoadMore: Boolean) {
|
||||
try {
|
||||
wx.showLoading({ title: '加载中' });
|
||||
const { searchTxt, pageNumber, pageSize, s_date, e_date, status, customerId }= this.data;
|
||||
const filterStr = {};
|
||||
if (s_date || e_date) {
|
||||
filterStr.createtime = [(s_date?'#>=#' + s_date:''),(e_date?'#<=#' + e_date:'')]
|
||||
}
|
||||
if (customerId) {
|
||||
filterStr.customerid = '#IN#' + customerId;
|
||||
}
|
||||
if (status && status != '全状态') {
|
||||
filterStr.productionstatus = '#IN#' + status;
|
||||
}
|
||||
const params = {
|
||||
pageNumber,
|
||||
pageSize,
|
||||
searchTxt,
|
||||
screenStr: JSON.stringify(filterStr)
|
||||
};
|
||||
const res = await getCardBoardOrderList(params).catch( () => {});
|
||||
console.log(res);
|
||||
// const res = await new Promise((resolve, reject) => {
|
||||
// wx.request({
|
||||
// url: 'https://yueyingkeji.twaycloud.com/api/WxAppCardBoardOrder',
|
||||
// method: 'GET',
|
||||
// header: {
|
||||
// Authorization: `${userInfo.id},${userInfo.accesstoken}`,
|
||||
// devicecode: devicecode
|
||||
// },
|
||||
// data: ,
|
||||
// success: resolve,
|
||||
// fail: reject
|
||||
// });
|
||||
// });
|
||||
if (res.statusCode === 200) {
|
||||
const dataList = res.data.list.map( item => {
|
||||
item.createtime = item.createtime.replace('T', ' ')
|
||||
return item;
|
||||
})
|
||||
let totalData = res.data.totalData;
|
||||
for (const key in totalData) {
|
||||
const val = totalData[key];
|
||||
// 是数字 且 不是整数(有小数点)
|
||||
if (typeof val === 'number' && !Number.isInteger(val)) {
|
||||
totalData[key] = val.toFixed(2); // 字符串类型,如 "3.14"
|
||||
}
|
||||
}
|
||||
this.setData({
|
||||
hasMore: this.data.list.length + this.data.pageSize >= res.data.searchListResourceParamaters.total?false:true,
|
||||
loading: false,
|
||||
list: isLoadMore == true?[...this.data.list,...dataList]: dataList,
|
||||
totalData: res.data.totalData || {}
|
||||
});
|
||||
} else {
|
||||
wx.showToast({ title: '数据加载失败', icon: 'none' });
|
||||
}
|
||||
} catch (err) {
|
||||
wx.showToast({ title: '系统错误', icon: 'none' });
|
||||
} finally {
|
||||
wx.hideLoading();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user