| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- 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: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// 列头
- titles: [['重量 | 形状 | 款式 | 尺寸', ' 编号'],
- ['颜色 | 净度 | 对称 | 抛光 | 荧光 | 证书', '价格']],
- /// 显示的值
- values: <{}[]>[],
- /// 履约单据信息
- order: <GuangZuan.MyPerformanc>({}),
- /// 延期备注
- remark: '',
- /// 延期天数
- delaydays: '',
- /// 是否显示延期申请
- showDelay: false,
- /// 是否显示立即执行
- showExculate: false,
- /// 履约步骤信息
- steps: <GuangZuan.WrPerformancePlanStep[]>[],
- /// 步骤信息
- 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: Number(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 ( (Number(this.data.delaydays) === 0 || this.data.delaydays === ' ') && isDelay) {
- showToast('请输入延期天数!')
- return false
- }
- if (this.data.remark === '') {
- showToast('请输入备注!')
- return false
- }
- return true
- },
- /**
- * 查询履约信息
- */
- queryWrPerformancePlanStep() {
- /// loding.....
- showLoading(()=> {
- /// 发送请求
- queryWrPerformancePlanStep({
- data: {
- planid: <number><unknown>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) {
- /// 数据处理
- var obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
-
- if (obj) {
- var buyer = ''
- var seller = ''
- /// 买方信息
- if (obj.buyerinfo != '') {
- const { ContactInfo, ReceiptInfo, ReceiveInfo } = JSON.parse(obj.buyerinfo)
- if ( ContactInfo != '' ) {
- buyer += '联络信息:'+ContactInfo
- }
- if ( ReceiveInfo != '' ) {
- buyer += +' '+'收货地址:'+ReceiveInfo
- }
- if ( ReceiptInfo != '' ) {
- buyer += +' '+'发票信息:'+ReceiptInfo
- }
- }
-
- /// 卖方信息
- if (obj.sellerinfo != '') {
- const { ContactInfo, ReceiptInfo, ReceiveInfo } = JSON.parse(obj.sellerinfo)
- if ( ContactInfo != '' ) {
- seller += '联络信息:'+ContactInfo
- }
- if ( ReceiveInfo != '' ) {
- seller += +' '+'收货地址:'+ReceiveInfo
- }
- if ( ReceiptInfo != '' ) {
- seller += +' '+'发票信息:'+ReceiptInfo
- }
- }
- obj.sellerinfo = isnullstr(seller.replace('\n', ' '))
- obj.buyerinfo = isnullstr(buyer.replace('\n', ' '))
- this.setData({
- order: obj,
- values: [{up: [`${isnullstr(obj.weight.toFixed(2))} | ${isnullstr(obj.zsshapetypedisplay)} | ${isnullstr(obj.zsstyletypedisplay)} | ${isnullstr(obj.sizedisplay)}`, `${isnullstr(obj.goodsno)}`],
- dwn: [`${isnullstr(obj.zscolortype1display)} | ${isnullstr(obj.zscuttype1display)}| ${isnullstr(obj.zssymmetrytype1display)} | ${isnullstr(obj.zspolishtype1display)}| ${isnullstr(obj.zsfluorescencetype1display)} | ${isnullstr(obj.zscerttypedisplay)}`,
- obj.price.toFixed(2)]}],
- status: getPerformancestatus(obj.performancestatus),
- step: getSteptype(obj.steptypeid)
- })
- }
- /// 查询履约信息
- this.queryWrPerformancePlanStep()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|