index.ts 5.6 KB

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