index.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import { FunCode } from "../../../../constants/enum/funcode"
  2. import { sendMsgToMQ } from "../../../../services/api/common/index"
  3. import { queryGZCJJCOrder } from "../../../../services/api/trade/index"
  4. import { userid, isEncrypted, protoHeader, loginid, clientType, timetample, loginCode, getErrorMsg } 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. /// tabs
  14. tabs: [{id: 0, name: '待处理'}, {id: 1, name: '进行中'}, {id: 2, name: '已结束'}],
  15. /// tab索引
  16. active: 0,
  17. /// 列头
  18. titles: [['货物品类', '送检账户', '单据编号'],
  19. ['总重量(粒)| 总重量(ct)| 总参考值(USD)', '状态']],
  20. /// 是否空数据
  21. isEmpty: true,
  22. /// 数据信息
  23. orders: <GuangZuan.GZCJJCOrder[]>[],
  24. /// 显示的值
  25. values: [{ up: [''], dwn: [''], width: 100 }],
  26. },
  27. /**
  28. * tab触发事件
  29. */
  30. onTabChange(e: any) {
  31. /// 设置激活项
  32. this.setData({ active: e.detail.index })
  33. /// 查询出境检测单据
  34. this.queryGZCJJCOrder()
  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> <unknown>ids[1]
  41. /// 单号
  42. const { orderidstr } = this.data.orders[index]
  43. switch (id) {
  44. case 'detail': /// 详情
  45. wx.navigateTo({
  46. url: "/mHome/pages/inspection/detail/index?item="+JSON.stringify(this.data.orders[index])
  47. })
  48. break;
  49. case 'cancel': /// 撤销
  50. this.doCJJCOperator(1, orderidstr)
  51. break;
  52. case 'confirmsend': /// 确认发货
  53. this.doCJJCOperator(2, orderidstr)
  54. break;
  55. case 'confirmresult': /// 确认检测结果
  56. this.doCJJCOperator(3, orderidstr)
  57. break;
  58. case 'confirmprepayment': /// 确认预付款
  59. wx.navigateTo({
  60. url: "/mHome/pages/inspection/prepayment/index?item="+JSON.stringify(this.data.orders[index])
  61. })
  62. break;
  63. case 'confirmpayment': /// 确认付款
  64. wx.navigateTo({
  65. url: "/mHome/pages/inspection/payment/index?item="+JSON.stringify(this.data.orders[index])
  66. })
  67. break;
  68. default:
  69. break;
  70. }
  71. },
  72. /**
  73. * 返回上层视图
  74. */
  75. backToParent() {
  76. /// 返回上层视图
  77. wx.navigateBack()
  78. },
  79. /**
  80. * 查询出境检测单据
  81. */
  82. queryGZCJJCOrder() {
  83. /// loding.....
  84. showLoading(()=>{
  85. /// 发送查询
  86. queryGZCJJCOrder({
  87. data: {
  88. /// 模糊搜索
  89. userid: userid(),
  90. executestatus: this.data.active+1
  91. },
  92. /// 加载成功
  93. success: (res) => {
  94. if (res.code != 200) {
  95. /// 加载失败
  96. hideLoading(()=>{}, '加载失败,原因:'+res.msg)
  97. return
  98. }
  99. hideLoading(()=>{
  100. /// 数据赋值
  101. this.setData({
  102. orders: res.data,
  103. /// 显示的值
  104. values: res.data.map(obj => {
  105. /// 宽度设置
  106. var width = 50.0
  107. if (obj.gzcjstatus === 1 || obj.gzcjstatus === 22 || obj.gzcjstatus === 2 || obj.gzcjstatus === 8 || obj.gzcjstatus === 10 || obj.gzcjstatus === 13) {
  108. width = 100.0
  109. }
  110. return {up: [obj.gzcjcategorytypedisplay,
  111. obj.gzcjaccount,
  112. isnullstr(obj.orderno)],
  113. dwn: [obj.totalnumber.toString()+'(粒)'+' | '+
  114. obj.totalgrossweight.toString()+'(ct)'+' | '+
  115. obj.totalweightgm.toString()+'(USD)',
  116. obj.gzcjstatusdisplay],
  117. width: width }
  118. }),
  119. isEmpty: res.data.length === 0
  120. })
  121. })
  122. },
  123. fail: (emsg) => {
  124. /// 加载失败
  125. hideLoading(()=>{}, emsg)
  126. },
  127. complete: () => {
  128. /// 停止下拉刷新
  129. wx.stopPullDownRefresh()
  130. }
  131. })
  132. })
  133. },
  134. /**
  135. * 出境检测操作请求
  136. */
  137. doCJJCOperator(operator: number, orderid: string) {
  138. /// loding.....
  139. showLoading(()=>{
  140. /// 参数信息
  141. const info = JSON.stringify({
  142. UserID: userid(),
  143. OperateID: loginid(),
  144. ClientType: clientType,
  145. ClientSerialNo: timetample().toString(),
  146. OperateAccount: loginCode().toString(),
  147. OrderID: orderid.toString(),
  148. OperateType: operator,
  149. Header: protoHeader(FunCode.CJJCMemberOperateReq, 66201)
  150. })
  151. /// 发送请求
  152. sendMsgToMQ({
  153. data: {
  154. data: encryptBody(info),
  155. funCodeReq: FunCode.CJJCMemberOperateReq,
  156. funCodeRsp: FunCode.CJJCMemberOperateRsp,
  157. isEncrypted: isEncrypted()
  158. },
  159. success: (res) => {
  160. /// 解析对象
  161. const data = JSON.parse(res.data.data)
  162. if (data.RetCode != 0) {
  163. hideLoading(() => {}, getErrorMsg(data.RetCode))
  164. return
  165. }
  166. /// 操作成功
  167. hideLoading(()=>{
  168. /// 重新获取数据
  169. this.queryGZCJJCOrder()
  170. }, '操作成功', 'success')
  171. },
  172. fail: (emsg) => {
  173. /// 操作失败
  174. hideLoading(()=>{}, emsg)
  175. }
  176. })
  177. }, '操作请求中.....')
  178. },
  179. /**
  180. * 生命周期函数--监听页面加载
  181. */
  182. onLoad() {
  183. /// 查询出境检测单据
  184. this.queryGZCJJCOrder()
  185. },
  186. /**
  187. * 生命周期函数--监听页面初次渲染完成
  188. */
  189. onReady() {
  190. },
  191. /**
  192. * 生命周期函数--监听页面显示
  193. */
  194. onShow() {
  195. },
  196. /**
  197. * 生命周期函数--监听页面隐藏
  198. */
  199. onHide() {
  200. },
  201. /**
  202. * 生命周期函数--监听页面卸载
  203. */
  204. onUnload() {
  205. },
  206. /**
  207. * 页面相关事件处理函数--监听用户下拉动作
  208. */
  209. onPullDownRefresh() {
  210. },
  211. /**
  212. * 页面上拉触底事件的处理函数
  213. */
  214. onReachBottom() {
  215. },
  216. /**
  217. * 用户点击右上角分享
  218. */
  219. onShareAppMessage() {
  220. }
  221. })