import { FunCode } from "../../../../constants/enum/funcode" import { sendMsgToMQ } from "../../../../services/api/common/index" import { queryGZCJJCOrder } from "../../../../services/api/trade/index" import { userid, getExecutestatus, isEncrypted, protoHeader, loginid, clientType, timetample, loginCode } from "../../../../services/utils" import { hideLoading, showLoading } from "../../../../utils/message/index" import { isnullstr } from "../../../../utils/util" Page({ /** * 页面的初始数据 */ data: { /// tabs tabs: [{id: 0, name: '待处理'}, {id: 1, name: '进行中'}, {id: 2, name: '已结束'}], /// tab索引 active: 0, /// 列头 titles: [['货物品类', '送检账户', '单据编号'], ['总重量(粒)| 总重量(ct)| 总参考值(USD)', '状态']], /// 是否空数据 isEmpty: true, /// 数据信息 orders: [], /// 显示的值 values: [{ up: [''], dwn: [''] }], /// 左滑宽度 width: 100, }, /** * tab触发事件 */ onTabChange(e: any) { /// 设置激活项 this.setData({ active: e.detail.index }) /// 查询出境检测单据 this.queryGZCJJCOrder() }, onButtonPressed(e: any) { /// 获取对应的id const ids = ( e.target.id).split(' ') let id = ( e.target.id).split(' ')[0] const index = ids[1] /// 单号 const orderid = this.data.orders[index].orderid switch (id) { case 'detail': /// 详情 wx.navigateTo({ url: "/mHome/pages/inspection/detail/index?item="+JSON.stringify(this.data.orders[index]) }) break; case 'cancel': /// 撤销 this.doCJJCOperator(1, orderid) break; case 'confirmsend': /// 确认发货 this.doCJJCOperator(2, orderid) break; case 'confirmresult': /// 确认检测结果 this.doCJJCOperator(3, orderid) break; case 'confirmprepayment': /// 确认预付款 wx.navigateTo({ url: "/mHome/pages/inspection/prepayment/index?item="+JSON.stringify(this.data.orders[index]) }) break; case 'confirmpayment': /// 确认付款 wx.navigateTo({ url: "/mHome/pages/inspection/payment/index?item="+JSON.stringify(this.data.orders[index]) }) break; default: break; } }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 查询出境检测单据 */ queryGZCJJCOrder() { /// loding..... showLoading(()=>{ /// 发送查询 queryGZCJJCOrder({ data: { /// 模糊搜索 userid: userid(), executestatus: this.data.active+1 }, /// 加载成功 success: (res) => { if (res.code != 200) { /// 加载失败 hideLoading(()=>{}, '加载失败,原因:'+res.msg, 'error') return } hideLoading(()=>{ /// 数据赋值 this.setData({ orders: res.data, /// 显示的值 values: res.data.map(obj => { return {up: [obj.gzcjcategorytypedisplay, obj.gzcjaccount, isnullstr(obj.orderno)], dwn: [obj.totalnumber.toString()+'(粒)'+' | '+ obj.totalgrossweight.toString()+'(ct)'+' | '+ obj.totalweightgm.toString()+'(USD)', getExecutestatus(obj.executestatus)]} }), isEmpty: res.data.length === 0 }) }) }, fail: (emsg) => { /// 加载失败 hideLoading(()=>{}, '加载失败,原因:'+emsg, 'error') }, complete: () => { /// 停止下拉刷新 wx.stopPullDownRefresh() } }) }) }, /** * 出境检测操作请求 */ doCJJCOperator(operator: number, orderid: number) { /// loding..... showLoading(()=>{ /// 参数信息 const params = { UserID: userid(), OperateID: loginid(), ClientType: clientType, ClientSerialNo: timetample().toString(), OperateAccount: loginCode().toString(), OrderID: orderid.toString(), OperateType: operator, Header: protoHeader(FunCode.CJJCMemberOperateReq, 66201) } /// 发送请求 sendMsgToMQ({ data: { data: JSON.stringify(params), funCodeReq: FunCode.CJJCMemberOperateReq, funCodeRsp: FunCode.CJJCMemberOperateRsp, isEncrypted: isEncrypted() }, success: (res) => { if (res.code != 0) { hideLoading(()=>{}, '操作申请失败, 原因:'+res.msg, 'error') return } /// 操作成功 hideLoading(()=>{ /// 重新获取数据 this.queryGZCJJCOrder() }, '操作成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, '操作申请失败, 原因:'+emsg, 'error') } }) }, '操作请求中.....') }, /** * 生命周期函数--监听页面加载 */ onLoad() { /// 查询出境检测单据 this.queryGZCJJCOrder() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })