index.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { sendMsgToMQ } from "../../../../services/api/common/index"
  3. import { queryGZBSFWOrder } from "../../../../services/api/trade/index"
  4. import { clientType, getErrorMsg, isEncrypted, loginCode, loginid, protoHeader, timetample, userid } from "../../../../services/utils"
  5. import { hideLoading, showLoading } from "../../../../utils/message/index"
  6. import { isnullstr } from "../../../../utils/util"
  7. import { encryptBody } from "../../../../utils/websocket/crypto"
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. /// 底部安全区域
  14. safeBottom: getApp().globalData.safeBottom,
  15. /// tabs
  16. tabs: [{id: 0, name: '待处理'}, {id: 1, name: '进行中'}, {id: 2, name: '已结束'}],
  17. /// tab索引
  18. active: 0,
  19. /// 列头
  20. titles: [['总净重(ct)| 总净重(g)| 总毛重(g)', '单据编号'],
  21. ['总值(USD)| 单价(USD/ct)', '状态'], ['内容 | 备注']],
  22. /// 是否空数据
  23. isEmpty: true,
  24. /// 数据信息
  25. bonds: <GuangZuan.GZBSFWOrder[]>[],
  26. /// 显示的值
  27. values: <{}[]>[]
  28. },
  29. /**
  30. * 返回上层视图
  31. */
  32. backToParent() {
  33. /// 返回上层视图
  34. wx.navigateBack()
  35. },
  36. onButtonPressed(e: any) {
  37. /// 获取对应的id
  38. const ids = String(e.target.id).split(' ')
  39. let id = String(e.target.id).split(' ')[0]
  40. const index = Number(ids[1])
  41. /// 传参
  42. const { orderid, gzbsstatusdisplay, gzbsstatus, orderno } = this.data.bonds[index]
  43. switch (id) {
  44. case 'detail': /// 详情
  45. wx.navigateTo({ url: "/mHome/pages/bond/detail/index?orderid="+orderid+'&status='+gzbsstatusdisplay+'&orderno='+orderno })
  46. break;
  47. case 'confirmprepayment': /// 确认预付款
  48. wx.navigateTo({ url: '/mHome/pages/bond/prepayment/index?orderid='+orderid+'&statusdisplay='+gzbsstatusdisplay+'&status='+gzbsstatus+'&orderno='+orderno })
  49. break;
  50. case 'confirmpayment': /// 确认付款
  51. wx.navigateTo({ url: '/mHome/pages/bond/payment/index?orderid='+orderid+'&statusdisplay='+gzbsstatusdisplay+'&status='+gzbsstatus+'&orderno='+orderno })
  52. break;
  53. default:
  54. break;
  55. }
  56. },
  57. /**
  58. * tab触发事件
  59. */
  60. onTabChange(e: any) {
  61. /// 设置激活项
  62. this.setData({ active: e.detail.index })
  63. /// 查询保税服务单据
  64. this.queryGZBSFWOrder()
  65. },
  66. /**
  67. * 查询保税服务单据
  68. */
  69. queryGZBSFWOrder() {
  70. /// loding.....
  71. showLoading(() => {
  72. /// 发送查询
  73. queryGZBSFWOrder({
  74. data: {
  75. /// 模糊搜索
  76. userid: userid(),
  77. executestatus: this.data.active+1
  78. },
  79. /// 加载成功
  80. success: (res) => {
  81. if (res.code != 200) {
  82. /// 加载失败
  83. hideLoading(()=>{}, '加载失败...')
  84. return
  85. }
  86. hideLoading(() => {
  87. /// 数据赋值
  88. this.setData({
  89. bonds: res.data,
  90. /// 显示的值
  91. values: res.data.map(obj => {
  92. /// 宽度设置
  93. var width = 50.0
  94. if (obj.gzbsstatus === 5 || obj.gzbsstatus === 11) {
  95. width = 100.0
  96. }
  97. return { up: [obj.totalnetweigthct.toString()+' | '+
  98. obj.totalnetweightgm.toString()+' | '+
  99. obj.totalgrossweightgm.toString(),
  100. isnullstr(obj.orderno)],
  101. mid:[obj.totalamount.toString(),
  102. obj.priceper.toString(),
  103. obj.gzbsstatusdisplay],
  104. dwn: [isnullstr(obj.contentrange.toString())+' | '+ '--',
  105. ''],
  106. width: width}
  107. }),
  108. isEmpty: res.data.length === 0
  109. })
  110. })
  111. },
  112. fail: (emsg) => {
  113. hideLoading(()=>{}, '加载失败...'+emsg)
  114. },
  115. complete: () => {
  116. /// 停止下拉刷新
  117. wx.stopPullDownRefresh()
  118. }
  119. })
  120. })
  121. },
  122. /**
  123. * 保税服务操作
  124. */
  125. doBSFWOperator(operator: number, orderid: number) {
  126. /// loding.....
  127. showLoading(()=>{
  128. /// 参数信息
  129. const info = JSON.stringify({
  130. UserID: userid(),
  131. OperateID: loginid(),
  132. ClientType: clientType,
  133. ClientSerialNo: timetample().toString,
  134. OperateAccount: loginCode(),
  135. OrderID: orderid,
  136. OperateType: operator,
  137. Header: protoHeader(FunCode.BSFWMemberOperateReq, 66201)
  138. })
  139. /// 发送请求
  140. sendMsgToMQ({
  141. data: {
  142. data: encryptBody(info),
  143. funCodeReq: FunCode.BSFWMemberOperateReq,
  144. funCodeRsp: FunCode.BSFWMemberOperateRsp,
  145. isEncrypted: isEncrypted()
  146. },
  147. success: (res) => {
  148. /// 解析对象
  149. const data = JSON.parse(res.data.data)
  150. if (data.RetCode != 0) {
  151. hideLoading(() => {}, getErrorMsg(data.RetCode))
  152. return
  153. }
  154. /// 操作成功
  155. hideLoading(()=>{
  156. /// 重新获取数据
  157. this.queryGZBSFWOrder()
  158. })
  159. },
  160. fail: (emsg) => {
  161. /// 操作失败
  162. hideLoading(()=>{}, emsg)
  163. }
  164. })
  165. }, '操作请求中.....')
  166. },
  167. /**
  168. * 生命周期函数--监听页面加载
  169. */
  170. onLoad() {
  171. /// 查询保税服务单据
  172. this.queryGZBSFWOrder()
  173. },
  174. /**
  175. * 生命周期函数--监听页面初次渲染完成
  176. */
  177. onReady() {
  178. },
  179. /**
  180. * 生命周期函数--监听页面显示
  181. */
  182. onShow() {
  183. },
  184. /**
  185. * 生命周期函数--监听页面隐藏
  186. */
  187. onHide() {
  188. },
  189. /**
  190. * 生命周期函数--监听页面卸载
  191. */
  192. onUnload() {
  193. },
  194. /**
  195. * 页面相关事件处理函数--监听用户下拉动作
  196. */
  197. onPullDownRefresh() {
  198. /// 查询保税服务单据
  199. this.queryGZBSFWOrder()
  200. },
  201. /**
  202. * 页面上拉触底事件的处理函数
  203. */
  204. onReachBottom() {
  205. },
  206. /**
  207. * 用户点击右上角分享
  208. */
  209. onShareAppMessage() {
  210. }
  211. })