import { sendMsgToMQ } from "../../../../services/api/common/index" import Toast from "../../../../miniprogram_npm/@vant/weapp/toast/toast"; import { FunCode } from "../../../../constants/enum/funcode" import { accountid, getPerformancestatus, getStepStatus, getSteptype, isEncrypted, protoHeader, userid } from "../../../../services/utils"; import { queryWrPerformancePlanStep } from "../../../../services/api/orders/index"; import { formatDateString, isnullstr } from "../../../../utils/util"; Page({ /** * 页面的初始数据 */ data: { /// 列头 titles: [['重量 | 形状 | 款式 | 尺寸', ' 编号'], ['颜色 | 净度 | 对称 | 抛光 | 荧光 | 证书', '价格']], /// 显示的值 values: [{ up: [''], dwn: [''] }], /// 履约单据信息 order: ({}), /// 延期备注 remark: '', /// 延期天数 delaydays: 0, /// 是否显示延期申请 showDelay: false, /// 是否显示立即执行 showExculate: false, /// 履约步骤信息 steps: [], /// 步骤信息 stepsValues:[{}], /// 状态 status: '', /// 当前执行步骤 step: '' }, /** * 返回上层视图 */ backToParent() { /// 返回上层视图 wx.navigateBack() }, /** * 延期申请 */ doDelay() { this.setData({ showDelay: false}) /// 合规性校验 if (!this.check(true)) { return } /// loding..... Toast.loading({ message: '延期申请请求中.....'}) /// 参数信息 const params = { PerformancePlanStepID: this.data.order.curstepid, delaydays: this.data.delaydays, applyremark: this.data.remark, applicant: userid(), Header: protoHeader(FunCode.PerformanceDelayApplyReq) } /// 发送请求 sendMsgToMQ({ data: { data: JSON.stringify(params), funCodeReq: FunCode.PerformanceDelayApplyReq, funCodeRsp: FunCode.PerformanceDelayApplyReq, isEncrypted: isEncrypted() }, success: (res) => { if (res.code != 0) { Toast.fail({message: '操作申请失败, 原因:'+res.msg}) return } /// 操作成功 Toast.success('操作成功') /// 返回上层视图 wx.navigateBack() }, fail: (emsg) => { /// 操作失败 Toast.fail('操作失败,原因:'+emsg) }, complete: () => { /// hideLoading Toast.clear() } }) }, /** * 立即执行 */ doExculpate() { this.setData({ showDelay: false}) /// 合规性校验 if (!this.check(false)) { return } /// loding..... Toast.loading({ message: '立即执行请求中.....'}) /// 参数信息 const params = { PerformancePlanStepID: this.data.order.curstepid, PerformanceExecuteSide: this.data.order.buyaccountid === accountid() ? 1 : 2, StepRemark: this.data.remark, Header: protoHeader(FunCode.PerformanceManualConfirmReq) } /// 发送请求 sendMsgToMQ({ data: { data: JSON.stringify(params), funCodeReq: FunCode.PerformanceManualConfirmReq, funCodeRsp: FunCode.PerformanceManualConfirmRsp, isEncrypted: isEncrypted() }, success: (res) => { if (res.code != 0) { Toast.fail({message: '操作申请失败, 原因:'+res.msg}) return } /// 操作成功 Toast.success('操作成功') /// 返回上层视图 wx.navigateBack() }, fail: (emsg) => { /// 操作失败 Toast.fail('操作失败,原因:'+emsg) }, complete: () => { /// hideLoading Toast.clear() } }) }, onClose() { /// 关闭 this.setData({ showDelay: false, showExculate: false }) }, onShowDelay() { /// 关闭 this.setData({ showDelay: true }) }, onShowExculate() { /// 关闭 this.setData({ showExculate: true }) }, check(isDelay: boolean): boolean { if (this.data.delaydays === 0 && isDelay) { Toast.fail({message: '请输入延期天数!'}) return false } if (this.data.remark === '') { Toast.fail({message: '请输入备注!'}) return false } return true }, /** * 查询履约信息 */ queryWrPerformancePlanStep() { /// loding..... wx.showLoading({title: '加载中.....'}) /// 发送请求 queryWrPerformancePlanStep({ data: { planid: this.data.order.performanceplanid }, success: (res) => { this.setData({ steps: res.data, stepsValues: res.data.map(itm => { return { stepindex: itm.stepindex, steptypename: itm.steptypename, stepstatus: itm.stepstatus, stepstatusdisplay: getStepStatus(itm.stepstatus), starttime: formatDateString(itm.starttime, 'YYYY-MM-DD'), endtime: formatDateString(itm.endtime, 'YYYY-MM-DD'), remaindays: itm.stepstatus === 2 ? `剩余${itm.remaindays}天` : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? `${itm.stepdays}` : ''), stepdays: itm.stepdays, bgcolor: itm.stepstatus === 2 ? '#2794FF' : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? '#89C5FF' : '#DDE3E8') } }) }) }, fail: (emsg) => { Toast.fail({message: '数据请求失败,原因:'+emsg}) }, complete: () => { /// 清除Toast wx.hideLoading() } }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options: any) { const obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '') if (obj) { this.setData({ order: obj, values: [{up: [`${isnullstr(obj.warehousenamedisplay)} | ${isnullstr(obj.zsshapetypedisplay)} | ${isnullstr(obj.zsstyletypedisplay)} | ${isnullstr(obj.sizedisplay)}`, `${isnullstr(obj.goodsno)}`], dwn: [`${isnullstr(obj.zscolortype1display)}~${isnullstr(obj.zscolortype2display)} | ${isnullstr(obj.zscuttype1display)}~${isnullstr(obj.zscuttype2display)} | ${isnullstr(obj.zssymmetrytype1display)}~${isnullstr(obj.zssymmetrytype2display)} | ${isnullstr(obj.zspolishtype1display)}~${isnullstr(obj.zspolishtype2display)} | ${isnullstr(obj.zsfluorescencetype1display)}~${isnullstr(obj.zsfluorescencetype2display)} | ${isnullstr(obj.zscerttypedisplay)}`, obj.price.toFixed(2)]}], status: getPerformancestatus(obj.performancestatus), step: getSteptype(obj.steptypeid) }) } /// 查询履约信息 this.queryWrPerformancePlanStep() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })