| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- import { FunCode } from "../../../constants/enum/funcode";
- import { sendMsgToMQ } from "../../../services/api/common/index";
- import { queryMyWRPosition, queryPermancePlanTmp } from "../../../services/api/orders/index";
- import { accountid, clientType, getErrorMsg, isEncrypted, loginQuery, marketid, protoHeader, timetample, userid } from "../../../services/utils";
- import { hideLoading, showLoading, showModel, showToast } from "../../../utils/message/index";
- import { isnullstr } from "../../../utils/util";
- import { encryptBody } from "../../../utils/websocket/crypto";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 底部安全区域
- safeBottom: getApp().globalData.safeBottom,
- /// 单据信息
- order: <GuangZuan.BuyOrder>({}),
- /// 我的库存
- objs: <GuangZuan.MyWRPosition[]>[],
- /// 选中的仓单
- wrPositon: <GuangZuan.MyWRPosition>({}),
- /// 备注信息
- remark: '',
- /// 申请价格
- applyPrice: 0.0,
- /// 汇率
- rate: loginQuery().exchangeRateConfigs[0].exchangerate,
- /// 列头
- titles: [['重量', '形状', '尺寸', '编号'],
- ['颜色 | 净度 | 切工 | 抛光 | 对称 | 荧光 | 证书', '价格']],
- // 显示的值
- values: [{ up: [''], dwn: [''], isChecked: false }],
- /// 选中履约模板
- tmp: <GuangZuan.PermancePlanTmp>({}),
- /// 数据是否为空
- isEmpty: false,
- /// 单据显示
- orderValue: { up: [''], dwn: ['']},
- /// 颜色
- colors: ['rebeccapurple', 'green', 'hotpink', 'orange', 'darkgoldenrod', 'firebrick']
- },
- /**
- * 返回上层视图
- */
- backToParent() {
- /// 返回上层视图
- wx.navigateBack()
- },
- /**
- * 每行选中触发事件
- */
- onSelectItem(e: any) {
- var objs = this.data.values
- objs.forEach(obj => {
- obj.isChecked = false
- })
- objs[e.currentTarget.id].isChecked = true
- /// 数据赋值
- this.setData({
- values: objs,
- wrPositon: this.data.objs[e.currentTarget.id]
- })
- },
- /// 获取履约模板信息
- queryPermancePlanTmp() {
- /// showLoading
- showLoading(() => {
- queryPermancePlanTmp({
- success: (res) => {
- /// 获取数据
- this.setData({
- tmps: res.data,
- tmp: res.data[0],
- actions: res.data.map(obj => { return obj.templatename })
- })
- },
- complete: () => {
- /// hideLoading
- hideLoading()
- }
- })
- })
- },
- /// 摘买
- doDelistingBuy() {
- if (!this.check()) { return }
- /// showModel
- showModel(() => {
- /// showLoading
- showLoading(() => {
- /// 参数信息
- const info = JSON.stringify({
- Header: protoHeader(FunCode.ZSSellOrderDestingApplyReq),
- UserID: userid(),
- AccountID: accountid(),
- BuyWRTradeOrderID: this.data.order.wrtradeorderid,
- WRStandardID: this.data.wrPositon.wrstandardid,
- WRFactorTypeID: 0,
- ApplyQty: this.data.wrPositon.ftotalqty,
- ApplyPrice: this.data.applyPrice,
- LadingBillID: this.data.wrPositon.ladingbillid,
- SubNum: this.data.wrPositon.subnum,
- ApplyRemark: this.data.remark,
- ClientType: clientType(),
- ClientSerialNo: timetample().toString(),
- MarketID: marketid()
- })
-
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: encryptBody(info),
- funCodeRsp: FunCode.ZSSellOrderDestingApplyRsp,
- funCodeReq: FunCode.ZSSellOrderDestingApplyReq,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- /// 解析对象
- const data = JSON.parse(res.data.data)
- if (data.RetCode != 0) {
- hideLoading(() => {}, getErrorMsg(data.RetCode))
- return
- }
- /// 求购发布请求成功
- hideLoading(() => {
- wx.navigateBack()
- }, '摘牌请成功', 'success')
- },
- fail: (emsg) => {
- hideLoading(()=>{}, emsg)
- }
- })
- }, '摘牌请求中.....')
- }, '提示', '确认要摘牌吗?')
- },
- check(): boolean {
- /// 请选择仓单数据
- if (this.data.wrPositon.ladingbillid === "" ) {
- showToast('请选择仓单数据!')
- return false
- }
- /// 请输入价格
- if (this.data.applyPrice === 0) {
- showToast('请输入价格!')
- return false
- }
- return true
- },
- /// 查询我的库存
- queryMyWRPosition() {
- /// showLoading
- showLoading(() => {
- /// 发送查询请求
- queryMyWRPosition({
- data: {
- wruserid: userid(),
- zscategorys: this.data.order.zscategory.toString(),
- marketflag: 1
- },
- success: (res) => {
- /// hideLoading
- hideLoading(() => {
- this.setData({
- objs: res.data,
- isEmpty: res.data.length === 0,
- /// 显示的值
- values: res.data.map(obj => {
- return {up: [obj.weight+'ct',
- isnullstr(obj.zsshapetypedisplay),
- isnullstr(obj.sizedisplay),
- isnullstr(obj.goodsno)],
- dwn: [isnullstr(obj.zsczcolor1typedisplay)+' | '+
- isnullstr(obj.zsclaritytype1display)+' | '+
- isnullstr(obj.zscuttype1display)+' | '+
- isnullstr(obj.zspolishtype1display)+' | '+
- isnullstr(obj.zssymmetrytype1display)+' | '+
- isnullstr(obj.zsfluorescencetype1display)+' | '+
- isnullstr(obj.zscerttypedisplay),
- obj.zscurrencytypedisplayunit+obj.price.toFixed(2)],
- isChecked: false}
- })
- })
- })
- },
- fail: (emsg) => {
- hideLoading(() => {}, emsg)
- }
- })
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options: any) {
- /// 数据显示
- try {
- const item = JSON.parse(options.item)
- if (item) {
- this.setData({
- order: item,
- orderValue: {
- up: [isnullstr(item.zsshapetypedisplay),
- isnullstr(item.zssize),
- isnullstr(item.zscategorydisplay)],
- dwn: [isnullstr(item.zscolortypedisplay)+' | '+
- isnullstr(item.zsclaritytypedisplay)+' | '+
- isnullstr(item.zscuttypedisplay)+' | '+
- isnullstr(item.zssymmetrytypedisplay)+' | '+
- isnullstr(item.zspolishtypedisplay)+' | '+
- isnullstr(item.zsfluorescencetypedisplay)]
- }
- })
- }
- /// 查询我的库存
- this.queryMyWRPosition()
- /// 查询履约模板信息
- this.queryPermancePlanTmp()
- } catch (error) {
- console.log(error)
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|