index.ts 7.8 KB

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