index.ts 7.3 KB

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