index.ts 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. import { sendMsgToMQ } from "../../../../services/api/common/index"
  2. import { FunCode } from "../../../../constants/enum/funcode"
  3. import { accountid, getErrorMsg, getPerformancestatus, getStepStatus, getSteptype, isEncrypted, protoHeader, userid } from "../../../../services/utils";
  4. import { queryWrPerformancePlanStep } from "../../../../services/api/orders/index";
  5. import { formatDateString, isnullstr } from "../../../../utils/util";
  6. import { hideLoading, showLoading, showToast } from "../../../../utils/message/index";
  7. import { encryptBody } from "../../../../utils/websocket/crypto";
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. /// 底部安全区域
  14. safeBottom: getApp().globalData.safeBottom,
  15. /// 列头
  16. titles: [['重量 | 形状 | 款式 | 尺寸', ' 编号'],
  17. ['颜色 | 净度 | 对称 | 抛光 | 荧光 | 证书', '价格']],
  18. /// 显示的值
  19. values: <{}[]>[],
  20. /// 履约单据信息
  21. order: <GuangZuan.MyPerformanc>({}),
  22. /// 延期备注
  23. remark: '',
  24. /// 延期天数
  25. delaydays: '',
  26. /// 是否显示延期申请
  27. showDelay: false,
  28. /// 是否显示立即执行
  29. showExculate: false,
  30. /// 履约步骤信息
  31. steps: <GuangZuan.WrPerformancePlanStep[]>[],
  32. /// 步骤信息
  33. stepsValues:[{}],
  34. /// 状态
  35. status: '',
  36. /// 当前执行步骤
  37. step: ''
  38. },
  39. /**
  40. * 返回上层视图
  41. */
  42. backToParent() {
  43. /// 返回上层视图
  44. wx.navigateBack()
  45. },
  46. /**
  47. * 延期申请
  48. */
  49. doDelay() {
  50. this.setData({ showDelay: false})
  51. /// 合规性校验
  52. if (!this.check(true)) { return }
  53. /// loding.....
  54. showLoading(()=>{
  55. /// 参数信息
  56. const info = JSON.stringify({
  57. PerformancePlanStepID: this.data.order.curstepid,
  58. delaydays: Number(this.data.delaydays),
  59. applyremark: this.data.remark,
  60. applicant: userid(),
  61. Header: protoHeader(FunCode.PerformanceDelayApplyReq)
  62. })
  63. /// 发送请求
  64. sendMsgToMQ({
  65. data: {
  66. data: encryptBody(info),
  67. funCodeReq: FunCode.PerformanceDelayApplyReq,
  68. funCodeRsp: FunCode.PerformanceDelayApplyReq,
  69. isEncrypted: isEncrypted()
  70. },
  71. success: (res) => {
  72. /// 解析对象
  73. const data = JSON.parse(res.data.data)
  74. if (data.RetCode != 0) {
  75. hideLoading(() => {}, getErrorMsg(data.RetCode))
  76. return
  77. }
  78. /// 操作成功
  79. hideLoading(()=>{
  80. /// 返回上层视图
  81. wx.navigateBack()
  82. }, '操作成功', 'success')
  83. },
  84. fail: (emsg) => {
  85. /// 操作失败
  86. hideLoading(()=>{}, emsg)
  87. }
  88. })
  89. }, '延期申请请求中.....')
  90. },
  91. /**
  92. * 立即执行
  93. */
  94. doExculpate() {
  95. this.setData({ showDelay: false})
  96. /// 合规性校验
  97. if (!this.check(false)) { return }
  98. /// loding.....
  99. showLoading(()=>{
  100. /// 参数信息
  101. const info = JSON.stringify({
  102. PerformancePlanStepID: this.data.order.curstepid,
  103. PerformanceExecuteSide: this.data.order.buyaccountid === accountid() ? 1 : 2,
  104. StepRemark: this.data.remark,
  105. Header: protoHeader(FunCode.PerformanceManualConfirmReq)
  106. })
  107. /// 发送请求
  108. sendMsgToMQ({
  109. data: {
  110. data: encryptBody(info),
  111. funCodeReq: FunCode.PerformanceManualConfirmReq,
  112. funCodeRsp: FunCode.PerformanceManualConfirmRsp,
  113. isEncrypted: isEncrypted()
  114. },
  115. success: (res) => {
  116. /// 解析对象
  117. const data = JSON.parse(res.data.data)
  118. if (data.RetCode != 0) {
  119. hideLoading(() => {}, getErrorMsg(data.RetCode))
  120. return
  121. }
  122. /// 操作成功
  123. hideLoading(()=> {
  124. /// 返回上层视图
  125. wx.navigateBack()
  126. }, '操作成功', 'success')
  127. },
  128. fail: (emsg) => {
  129. /// 操作失败
  130. hideLoading(()=>{}, emsg)
  131. }
  132. })
  133. }, '立即执行请求中.....')
  134. },
  135. onClose() {
  136. /// 关闭
  137. this.setData({
  138. showDelay: false,
  139. showExculate: false
  140. })
  141. },
  142. onShowDelay() {
  143. /// 关闭
  144. this.setData({ showDelay: true })
  145. },
  146. onShowExculate() {
  147. /// 关闭
  148. this.setData({ showExculate: true })
  149. },
  150. check(isDelay: boolean): boolean {
  151. if ( (Number(this.data.delaydays) === 0 || this.data.delaydays === ' ') && isDelay) {
  152. showToast('请输入延期天数!')
  153. return false
  154. }
  155. if (this.data.remark === '') {
  156. showToast('请输入备注!')
  157. return false
  158. }
  159. return true
  160. },
  161. /**
  162. * 查询履约信息
  163. */
  164. queryWrPerformancePlanStep() {
  165. /// loding.....
  166. showLoading(()=> {
  167. /// 发送请求
  168. queryWrPerformancePlanStep({
  169. data: {
  170. planid: <number><unknown>this.data.order.performanceplanid
  171. },
  172. success: (res) => {
  173. /// 请求失败
  174. if (res.code != 200) {
  175. /// 加载失败
  176. hideLoading(()=>{}, '请求失败,原因:'+res.msg)
  177. return
  178. }
  179. hideLoading(()=>{
  180. this.setData({
  181. steps: res.data,
  182. stepsValues: res.data.map(itm => {
  183. return { stepindex: itm.stepindex,
  184. steptypename: itm.steptypename,
  185. stepstatus: itm.stepstatus,
  186. stepstatusdisplay: getStepStatus(itm.stepstatus),
  187. starttime: formatDateString(itm.starttime, 'YYYY-MM-DD'),
  188. endtime: formatDateString(itm.endtime, 'YYYY-MM-DD'),
  189. remaindays: itm.stepstatus === 2 ? `剩余${itm.remaindays}天` : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? `${itm.stepdays}` : ''),
  190. stepdays: itm.stepdays,
  191. bgcolor: itm.stepstatus === 2 ? '#2794FF' : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? '#89C5FF' : '#DDE3E8')
  192. }
  193. })
  194. })
  195. })
  196. },
  197. fail: (emsg) => {
  198. hideLoading(()=>{}, emsg)
  199. }
  200. })
  201. })
  202. },
  203. /**
  204. * 生命周期函数--监听页面加载
  205. */
  206. onLoad(options: any) {
  207. /// 数据处理
  208. var obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
  209. if (obj) {
  210. var buyer = ''
  211. var seller = ''
  212. /// 买方信息
  213. if (obj.buyerinfo != '') {
  214. const { ContactInfo, ReceiptInfo, ReceiveInfo } = JSON.parse(obj.buyerinfo)
  215. if ( ContactInfo != '' ) {
  216. buyer += '联络信息:'+ContactInfo
  217. }
  218. if ( ReceiveInfo != '' ) {
  219. buyer += +' '+'收货地址:'+ReceiveInfo
  220. }
  221. if ( ReceiptInfo != '' ) {
  222. buyer += +' '+'发票信息:'+ReceiptInfo
  223. }
  224. }
  225. /// 卖方信息
  226. if (obj.sellerinfo != '') {
  227. const { ContactInfo, ReceiptInfo, ReceiveInfo } = JSON.parse(obj.sellerinfo)
  228. if ( ContactInfo != '' ) {
  229. seller += '联络信息:'+ContactInfo
  230. }
  231. if ( ReceiveInfo != '' ) {
  232. seller += +' '+'收货地址:'+ReceiveInfo
  233. }
  234. if ( ReceiptInfo != '' ) {
  235. seller += +' '+'发票信息:'+ReceiptInfo
  236. }
  237. }
  238. obj.sellerinfo = isnullstr(seller.replace('\n', ' '))
  239. obj.buyerinfo = isnullstr(buyer.replace('\n', ' '))
  240. this.setData({
  241. order: obj,
  242. values: [{up: [`${isnullstr(obj.weight.toFixed(2))} | ${isnullstr(obj.zsshapetypedisplay)} | ${isnullstr(obj.zsstyletypedisplay)} | ${isnullstr(obj.sizedisplay)}`, `${isnullstr(obj.goodsno)}`],
  243. dwn: [`${isnullstr(obj.zscolortype1display)} | ${isnullstr(obj.zscuttype1display)}| ${isnullstr(obj.zssymmetrytype1display)} | ${isnullstr(obj.zspolishtype1display)}| ${isnullstr(obj.zsfluorescencetype1display)} | ${isnullstr(obj.zscerttypedisplay)}`,
  244. obj.price.toFixed(2)]}],
  245. status: getPerformancestatus(obj.performancestatus),
  246. step: getSteptype(obj.steptypeid)
  247. })
  248. }
  249. /// 查询履约信息
  250. this.queryWrPerformancePlanStep()
  251. },
  252. /**
  253. * 生命周期函数--监听页面初次渲染完成
  254. */
  255. onReady() {
  256. },
  257. /**
  258. * 生命周期函数--监听页面显示
  259. */
  260. onShow() {
  261. },
  262. /**
  263. * 生命周期函数--监听页面隐藏
  264. */
  265. onHide() {
  266. },
  267. /**
  268. * 生命周期函数--监听页面卸载
  269. */
  270. onUnload() {
  271. },
  272. /**
  273. * 页面相关事件处理函数--监听用户下拉动作
  274. */
  275. onPullDownRefresh() {
  276. },
  277. /**
  278. * 页面上拉触底事件的处理函数
  279. */
  280. onReachBottom() {
  281. },
  282. /**
  283. * 用户点击右上角分享
  284. */
  285. onShareAppMessage() {
  286. }
  287. })