index.ts 8.7 KB

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