import { sendMsgToMQ } from "../../../../services/api/common/index" import { FunCode } from "../../../../constants/enum/funcode" import { accountid, getErrorMsg, getPerformancestatus, getStepStatus, getSteptype, isEncrypted, protoHeader, userid } from "../../../../services/utils"; import { queryWrPerformancePlanStep } from "../../../../services/api/orders/index"; import { formatDateString, isnullstr } from "../../../../utils/util"; import { hideLoading, showLoading, showToast } from "../../../../utils/message/index"; import { encryptBody } from "../../../../utils/websocket/crypto"; 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..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ PerformancePlanStepID: this.data.order.curstepid, delaydays: this.data.delaydays, applyremark: this.data.remark, applicant: userid(), Header: protoHeader(FunCode.PerformanceDelayApplyReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.PerformanceDelayApplyReq, funCodeRsp: FunCode.PerformanceDelayApplyReq, isEncrypted: isEncrypted() }, success: (res) => { /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 操作成功 hideLoading(()=>{ /// 返回上层视图 wx.navigateBack() }, '操作成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, emsg) } }) }, '延期申请请求中.....') }, /** * 立即执行 */ doExculpate() { this.setData({ showDelay: false}) /// 合规性校验 if (!this.check(false)) { return } /// loding..... showLoading(()=>{ /// 参数信息 const info = JSON.stringify({ PerformancePlanStepID: this.data.order.curstepid, PerformanceExecuteSide: this.data.order.buyaccountid === accountid() ? 1 : 2, StepRemark: this.data.remark, Header: protoHeader(FunCode.PerformanceManualConfirmReq) }) /// 发送请求 sendMsgToMQ({ data: { data: encryptBody(info), funCodeReq: FunCode.PerformanceManualConfirmReq, funCodeRsp: FunCode.PerformanceManualConfirmRsp, isEncrypted: isEncrypted() }, success: (res) => { /// 解析对象 const data = JSON.parse(res.data.data) if (data.RetCode != 0) { hideLoading(() => {}, getErrorMsg(data.RetCode)) return } /// 操作成功 hideLoading(()=> { /// 返回上层视图 wx.navigateBack() }, '操作成功', 'success') }, fail: (emsg) => { /// 操作失败 hideLoading(()=>{}, emsg) } }) }, '立即执行请求中.....') }, 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) { showToast('请输入延期天数!') return false } if (this.data.remark === '') { showToast('请输入备注!') return false } return true }, /** * 查询履约信息 */ queryWrPerformancePlanStep() { /// loding..... showLoading(()=> { /// 发送请求 queryWrPerformancePlanStep({ data: { planid: this.data.order.performanceplanid }, success: (res) => { /// 请求失败 if (res.code != 200) { /// 加载失败 hideLoading(()=>{}, '请求失败,原因:'+res.msg) return } hideLoading(()=>{ 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) => { hideLoading(()=>{}, emsg) } }) }) }, /** * 生命周期函数--监听页面加载 */ 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() { } })