index.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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']
  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. data: {
  69. marketid: marketid()
  70. },
  71. success: (res) => {
  72. /// 获取数据
  73. this.setData({
  74. tmps: res.data,
  75. tmp: res.data[0],
  76. actions: res.data.map(obj => { return obj.templatename })
  77. })
  78. },
  79. complete: () => {
  80. /// hideLoading
  81. hideLoading()
  82. }
  83. })
  84. })
  85. },
  86. /// 摘买
  87. doDelistingBuy() {
  88. if (!this.check()) { return }
  89. /// showModel
  90. showModel(() => {
  91. /// showLoading
  92. showLoading(() => {
  93. /// 参数信息
  94. const info = JSON.stringify({
  95. Header: protoHeader(FunCode.ZSSellOrderDestingApplyReq),
  96. UserID: userid(),
  97. AccountID: accountid(),
  98. BuyWRTradeOrderID: this.data.order.wrtradeorderid,
  99. WRStandardID: this.data.wrPositon.wrstandardid,
  100. WRFactorTypeID: 0,
  101. ApplyQty: this.data.wrPositon.ftotalqty,
  102. ApplyPrice: this.data.applyPrice,
  103. LadingBillID: this.data.wrPositon.ladingbillid,
  104. SubNum: this.data.wrPositon.subnum,
  105. ApplyRemark: this.data.remark,
  106. ClientType: clientType(),
  107. ClientSerialNo: timetample().toString(),
  108. MarketID: marketid()
  109. })
  110. /// 发送请求
  111. sendMsgToMQ({
  112. data: {
  113. data: encryptBody(info),
  114. funCodeRsp: FunCode.ZSSellOrderDestingApplyRsp,
  115. funCodeReq: FunCode.ZSSellOrderDestingApplyReq,
  116. isEncrypted: isEncrypted()
  117. },
  118. success: (res) => {
  119. /// 解析对象
  120. const data = JSON.parse(res.data.data)
  121. if (data.RetCode != 0) {
  122. hideLoading(() => {}, getErrorMsg(data.RetCode))
  123. return
  124. }
  125. /// 求购发布请求成功
  126. hideLoading(() => {
  127. wx.navigateBack()
  128. }, '摘牌请成功', 'success')
  129. },
  130. fail: (emsg) => {
  131. hideLoading(()=>{}, emsg)
  132. }
  133. })
  134. }, '摘牌请求中.....')
  135. }, '提示', '确认要摘牌吗?')
  136. },
  137. check(): boolean {
  138. /// 请选择仓单数据
  139. if (this.data.wrPositon.ladingbillid === "" ) {
  140. showToast('请选择仓单数据!')
  141. return false
  142. }
  143. /// 请输入价格
  144. if (this.data.applyPrice === 0) {
  145. showToast('请输入价格!')
  146. return false
  147. }
  148. return true
  149. },
  150. /// 查询我的库存
  151. queryMyWRPosition() {
  152. /// showLoading
  153. showLoading(() => {
  154. /// 发送查询请求
  155. queryMyWRPosition({
  156. data: {
  157. wruserid: userid(),
  158. zscategorys: this.data.order.zscategory.toString(),
  159. marketflag: 1
  160. },
  161. success: (res) => {
  162. /// hideLoading
  163. hideLoading(() => {
  164. this.setData({
  165. objs: res.data,
  166. isEmpty: res.data.length === 0,
  167. /// 显示的值
  168. values: res.data.map(obj => {
  169. return {up: [obj.weight+'ct',
  170. isnullstr(obj.zsshapetypedisplay),
  171. isnullstr(obj.sizedisplay),
  172. isnullstr(obj.goodsno)],
  173. dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+
  174. isnullstr(obj.zsclaritytype1display)+' | '+
  175. isnullstr(obj.zscuttype1display)+' | '+
  176. isnullstr(obj.zspolishtype1display)+' | '+
  177. isnullstr(obj.zssymmetrytype1display)+' | '+
  178. isnullstr(obj.zsfluorescencetype1display)+' | '+
  179. isnullstr(obj.zscerttypedisplay),
  180. obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
  181. isChecked: false}
  182. })
  183. })
  184. })
  185. },
  186. fail: (emsg) => {
  187. hideLoading(() => {}, emsg)
  188. }
  189. })
  190. })
  191. },
  192. /**
  193. * 生命周期函数--监听页面加载
  194. */
  195. onLoad(options: any) {
  196. /// 数据显示
  197. try {
  198. const item = JSON.parse(options.item)
  199. if (item) {
  200. this.setData({
  201. order: item,
  202. orderValue: {
  203. up: [isnullstr(item.zsshapetypedisplay),
  204. isnullstr(item.zssize),
  205. isnullstr(item.zscategorydisplay)],
  206. dwn: [isnullstr(item.zscolortypedisplay)+' | '+
  207. isnullstr(item.zsclaritytypedisplay)+' | '+
  208. isnullstr(item.zscuttypedisplay)+' | '+
  209. isnullstr(item.zssymmetrytypedisplay)+' | '+
  210. isnullstr(item.zspolishtypedisplay)+' | '+
  211. isnullstr(item.zsfluorescencetypedisplay)]
  212. }
  213. })
  214. }
  215. /// 查询我的库存
  216. this.queryMyWRPosition()
  217. /// 查询履约模板信息
  218. this.queryPermancePlanTmp()
  219. } catch (error) {
  220. console.log(error)
  221. }
  222. },
  223. /**
  224. * 生命周期函数--监听页面初次渲染完成
  225. */
  226. onReady() {
  227. },
  228. /**
  229. * 生命周期函数--监听页面显示
  230. */
  231. onShow() {
  232. },
  233. /**
  234. * 生命周期函数--监听页面隐藏
  235. */
  236. onHide() {
  237. },
  238. /**
  239. * 生命周期函数--监听页面卸载
  240. */
  241. onUnload() {
  242. },
  243. /**
  244. * 页面相关事件处理函数--监听用户下拉动作
  245. */
  246. onPullDownRefresh() {
  247. },
  248. /**
  249. * 页面上拉触底事件的处理函数
  250. */
  251. onReachBottom() {
  252. },
  253. /**
  254. * 用户点击右上角分享
  255. */
  256. onShareAppMessage() {
  257. }
  258. })