index.ts 7.6 KB

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