index.ts 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { FunCode } from "../../../constants/enum/funcode";
  2. import { sendMsgToMQ } from "../../../services/api/common/index";
  3. import { queryMyWRPosition } from "../../../services/api/orders/index";
  4. import { accountid, clientType, isEncrypted, marketid, protoHeader, timetample, userid } from "../../../services/utils";
  5. import { hideLoading, showLoading, showModel } from "../../../utils/message/index";
  6. import { isnullstr } from "../../../utils/util";
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. /// 单据信息
  13. order: <GuangZuan.BuyOrder>({}),
  14. /// 我的库存
  15. objs: <GuangZuan.MyWRPosition[]>[],
  16. /// 选中的仓单
  17. wrPositon: <GuangZuan.MyWRPosition>({}),
  18. /// 备注信息
  19. remark: '',
  20. /// 申请价格
  21. applyPrice: 0.0,
  22. /// 列头
  23. titles: [['重量', '形状', '尺寸', '编号'],
  24. ['颜色 | 净度 | 切工 | 对称 | 抛光 | 荧光 | 证书', '价格']],
  25. // 显示的值
  26. values: [{ up: [''], dwn: [''], isChecked: false }],
  27. /// 数据是否为空
  28. isEmpty: false,
  29. /// 单据显示
  30. orderValue: { up: [''], dwn: ['']},
  31. },
  32. /**
  33. * 返回上层视图
  34. */
  35. backToParent() {
  36. /// 返回上层视图
  37. wx.navigateBack()
  38. },
  39. /**
  40. * 每行选中触发事件
  41. */
  42. onSelectItem(e: any) {
  43. var objs = this.data.values
  44. objs.forEach(obj => {
  45. obj.isChecked = false
  46. })
  47. objs[e.currentTarget.id].isChecked = true
  48. /// 数据赋值
  49. this.setData({
  50. values: objs,
  51. wrPositon: this.data.objs[e.currentTarget.id]
  52. })
  53. },
  54. /// 摘买
  55. doDelistingBuy() {
  56. /// showModel
  57. showModel(() => {
  58. /// showLoading
  59. showLoading(() => {
  60. /// 参数信息
  61. const params = {
  62. Header: protoHeader(FunCode.ZSSellOrderDestingApplyReq),
  63. UserID: userid(),
  64. AccountID: accountid(),
  65. BuyWRTradeOrderID: '',
  66. WRStandardID: '',
  67. WRFactorTypeID: 0,
  68. ApplyQty: 0,
  69. ApplyPrice: this.data.applyPrice,
  70. LadingBillID: '',
  71. SubNum: 0,
  72. ApplyRemark: this.data.remark,
  73. ClientType: clientType(),
  74. ClientSerialNo: timetample(),
  75. MarketID: marketid()
  76. }
  77. /// 发送请求
  78. sendMsgToMQ({
  79. data: {
  80. data: JSON.stringify(params),
  81. funCodeRsp: FunCode.ZSSellOrderDestingApplyRsp,
  82. funCodeReq: FunCode.ZSSellOrderDestingApplyReq,
  83. isEncrypted: isEncrypted()
  84. },
  85. success: (res) => {
  86. /// 请求失败
  87. if (res.code != 0) {
  88. hideLoading(()=>{}, '摘牌请失败,原因:'+res.msg, 'error')
  89. return
  90. }
  91. /// 求购发布请求成功
  92. hideLoading(() => {
  93. wx.navigateBack()
  94. }, '摘牌请成功', 'success')
  95. },
  96. fail: (emsg) => {
  97. hideLoading(()=>{}, '摘牌请求失败,原因:'+emsg, 'error')
  98. }
  99. })
  100. }, '摘牌请求中.....')
  101. }, '提示', '确认要摘牌吗?')
  102. },
  103. /// 查询我的库存
  104. queryMyWRPosition() {
  105. /// showLoading
  106. showLoading(() => {
  107. /// 发送查询请求
  108. queryMyWRPosition({
  109. data: {
  110. wruserid: userid(),
  111. zscategorys: this.data.order.zscategory.toString(),
  112. marketflag: 1
  113. },
  114. success: (res) => {
  115. /// hideLoading
  116. hideLoading(() => {
  117. this.setData({
  118. objs: res.data,
  119. isEmpty: res.data.length === 0,
  120. /// 显示的值
  121. values: res.data.map(obj => {
  122. return {up: [obj.weight+'ct',
  123. isnullstr(obj.zsshapetypedisplay),
  124. isnullstr(obj.size1),
  125. isnullstr(obj.goodsno)],
  126. dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+
  127. isnullstr(obj.zsclaritytype1display)+' | '+
  128. isnullstr(obj.zscuttype1display)+' | '+
  129. isnullstr(obj.zssymmetrytype1display)+' | '+
  130. isnullstr(obj.zspolishtype1display)+' | '+
  131. isnullstr(obj.zsfluorescencetype1display)+' | '+
  132. isnullstr(obj.zscerttypedisplay),
  133. obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
  134. isChecked: false}
  135. })
  136. })
  137. })
  138. },
  139. fail: (emsg) => {
  140. hideLoading(() => {}, '库存请求失败,原因:'+emsg, 'error')
  141. }
  142. })
  143. })
  144. },
  145. /**
  146. * 生命周期函数--监听页面加载
  147. */
  148. onLoad(options: any) {
  149. /// 数据显示
  150. try {
  151. const item = JSON.parse(options.item)
  152. if (item) {
  153. this.setData({
  154. order: item,
  155. orderValue: {
  156. up: [isnullstr(item.zsshapetypedisplay),
  157. isnullstr(item.zssize),
  158. isnullstr(item.zscategorydisplay)],
  159. dwn: [isnullstr(item.zscolortypedisplay)+' | '+
  160. isnullstr(item.zsclaritytypedisplay)+' | '+
  161. isnullstr(item.zscuttypedisplay)+' | '+
  162. isnullstr(item.zssymmetrytypedisplay)+' | '+
  163. isnullstr(item.zspolishtypedisplay)+' | '+
  164. isnullstr(item.zsfluorescencetypedisplay)+' | '+
  165. isnullstr(item.zscerttypedisplay)]
  166. }
  167. })
  168. }
  169. /// 查询我的库存
  170. this.queryMyWRPosition()
  171. } catch (error) {
  172. console.log(error)
  173. }
  174. },
  175. /**
  176. * 生命周期函数--监听页面初次渲染完成
  177. */
  178. onReady() {
  179. },
  180. /**
  181. * 生命周期函数--监听页面显示
  182. */
  183. onShow() {
  184. },
  185. /**
  186. * 生命周期函数--监听页面隐藏
  187. */
  188. onHide() {
  189. },
  190. /**
  191. * 生命周期函数--监听页面卸载
  192. */
  193. onUnload() {
  194. },
  195. /**
  196. * 页面相关事件处理函数--监听用户下拉动作
  197. */
  198. onPullDownRefresh() {
  199. },
  200. /**
  201. * 页面上拉触底事件的处理函数
  202. */
  203. onReachBottom() {
  204. },
  205. /**
  206. * 用户点击右上角分享
  207. */
  208. onShareAppMessage() {
  209. }
  210. })