index.ts 7.5 KB

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