index.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. import { hideLoading, showLoading, showToast } from "../../../../utils/message/index";
  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 params = {
  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: JSON.stringify(params),
  65. funCodeReq: FunCode.PerformanceDelayApplyReq,
  66. funCodeRsp: FunCode.PerformanceDelayApplyReq,
  67. isEncrypted: isEncrypted()
  68. },
  69. success: (res) => {
  70. if (res.code != 0) {
  71. hideLoading(()=>{}, '操作申请失败,原因:'+res.msg, 'error')
  72. return
  73. }
  74. /// 操作成功
  75. hideLoading(()=>{
  76. /// 返回上层视图
  77. wx.navigateBack()
  78. }, '操作成功', 'success')
  79. },
  80. fail: (emsg) => {
  81. /// 操作失败
  82. hideLoading(()=>{}, '操作申请失败,原因:'+emsg, 'error')
  83. }
  84. })
  85. }, '延期申请请求中.....')
  86. },
  87. /**
  88. * 立即执行
  89. */
  90. doExculpate() {
  91. this.setData({ showDelay: false})
  92. /// 合规性校验
  93. if (!this.check(false)) { return }
  94. /// loding.....
  95. showLoading(()=>{
  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. hideLoading(()=>{}, '操作申请请求失败,原因:'+res.msg, 'error')
  114. return
  115. }
  116. /// 操作成功
  117. hideLoading(()=> {
  118. /// 返回上层视图
  119. wx.navigateBack()
  120. }, '操作成功', 'success')
  121. },
  122. fail: (emsg) => {
  123. /// 操作失败
  124. hideLoading(()=>{}, '操作申请请求失败,原因:'+emsg, 'error')
  125. }
  126. })
  127. }, '立即执行请求中.....')
  128. },
  129. onClose() {
  130. /// 关闭
  131. this.setData({
  132. showDelay: false,
  133. showExculate: false
  134. })
  135. },
  136. onShowDelay() {
  137. /// 关闭
  138. this.setData({ showDelay: true })
  139. },
  140. onShowExculate() {
  141. /// 关闭
  142. this.setData({ showExculate: true })
  143. },
  144. check(isDelay: boolean): boolean {
  145. if (this.data.delaydays === 0 && isDelay) {
  146. showToast('请输入延期天数!')
  147. return false
  148. }
  149. if (this.data.remark === '') {
  150. showToast('请输入备注!')
  151. return false
  152. }
  153. return true
  154. },
  155. /**
  156. * 查询履约信息
  157. */
  158. queryWrPerformancePlanStep() {
  159. /// loding.....
  160. showLoading(()=> {
  161. /// 发送请求
  162. queryWrPerformancePlanStep({
  163. data: {
  164. planid: <number><unknown>this.data.order.performanceplanid
  165. },
  166. success: (res) => {
  167. /// 请求失败
  168. if (res.code != 200) {
  169. /// 加载失败
  170. hideLoading(()=>{}, '请求失败,原因:'+res.msg, 'error')
  171. return
  172. }
  173. hideLoading(()=>{
  174. this.setData({
  175. steps: res.data,
  176. stepsValues: res.data.map(itm => {
  177. return { stepindex: itm.stepindex,
  178. steptypename: itm.steptypename,
  179. stepstatus: itm.stepstatus,
  180. stepstatusdisplay: getStepStatus(itm.stepstatus),
  181. starttime: formatDateString(itm.starttime, 'YYYY-MM-DD'),
  182. endtime: formatDateString(itm.endtime, 'YYYY-MM-DD'),
  183. remaindays: itm.stepstatus === 2 ? `剩余${itm.remaindays}天` : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? `${itm.stepdays}` : ''),
  184. stepdays: itm.stepdays,
  185. bgcolor: itm.stepstatus === 2 ? '#2794FF' : ((itm.stepstatus === 3 || itm.stepstatus === 6) ? '#89C5FF' : '#DDE3E8')
  186. }
  187. })
  188. })
  189. })
  190. },
  191. fail: (emsg) => {
  192. hideLoading(()=>{}, '请求失败,原因:'+emsg, 'error')
  193. }
  194. })
  195. })
  196. },
  197. /**
  198. * 生命周期函数--监听页面加载
  199. */
  200. onLoad(options: any) {
  201. const obj: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
  202. if (obj) {
  203. this.setData({
  204. order: obj,
  205. values: [{up: [`${isnullstr(obj.warehousenamedisplay)} | ${isnullstr(obj.zsshapetypedisplay)} | ${isnullstr(obj.zsstyletypedisplay)} | ${isnullstr(obj.sizedisplay)}`, `${isnullstr(obj.goodsno)}`],
  206. 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)]}],
  207. status: getPerformancestatus(obj.performancestatus),
  208. step: getSteptype(obj.steptypeid)
  209. })
  210. }
  211. /// 查询履约信息
  212. this.queryWrPerformancePlanStep()
  213. },
  214. /**
  215. * 生命周期函数--监听页面初次渲染完成
  216. */
  217. onReady() {
  218. },
  219. /**
  220. * 生命周期函数--监听页面显示
  221. */
  222. onShow() {
  223. },
  224. /**
  225. * 生命周期函数--监听页面隐藏
  226. */
  227. onHide() {
  228. },
  229. /**
  230. * 生命周期函数--监听页面卸载
  231. */
  232. onUnload() {
  233. },
  234. /**
  235. * 页面相关事件处理函数--监听用户下拉动作
  236. */
  237. onPullDownRefresh() {
  238. },
  239. /**
  240. * 页面上拉触底事件的处理函数
  241. */
  242. onReachBottom() {
  243. },
  244. /**
  245. * 用户点击右上角分享
  246. */
  247. onShareAppMessage() {
  248. }
  249. })