orderloadReplace.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // pages/salesOrderMan/orderloadAdd.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. orderId:'',
  9. goodsConfId:'',
  10. orderNumber:'',
  11. confStartTime:'',
  12. confEndTime:'',
  13. defaultText: '请选择',
  14. isSubmitting: false,
  15. loadPointArray:[],//装卸点位
  16. loadPointIndex:null,
  17. loadTimeArray:[], //装卸时间
  18. loadTimeIndex:null,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. this.setData({
  25. id : options.id,
  26. orderId : options.orderId,
  27. goodsConfId : options.deliveryTimeId,
  28. orderNumber : options.orderNumber,
  29. confStartTime : options.confStartTime,
  30. confEndTime :options.confEndTime,
  31. })
  32. //装卸点位
  33. this.loadPointData()
  34. },
  35. //装卸点位
  36. loadPointData:function(){
  37. app.request.GET({
  38. url: app.API.loadPoint,
  39. params: {},
  40. page: this,
  41. successFun: true
  42. }).then(res => {
  43. this.setData({
  44. loadPointArray:res.data.data
  45. })
  46. })
  47. },
  48. //装卸时间
  49. loadTimeData:function(){
  50. app.request.GET({
  51. url: app.API.loadTime,
  52. params: {
  53. pointId : this.data.loadPointArray[this.data.loadPointIndex].id,
  54. goodsConfId : this.data.goodsConfId,
  55. orderId : this.data.orderId,
  56. orderFlag : "2" // 新增1 更换2
  57. },
  58. page: this,
  59. successFun: true
  60. }).then(res => {
  61. let orderList = res.data.data
  62. orderList.forEach((element,index) => {
  63. orderList[index].time = element.beginTime + '~' + element.endTime
  64. });
  65. this.setData({
  66. loadTimeArray:orderList
  67. })
  68. })
  69. },
  70. //下拉选择
  71. bindPickerChange: function (e) { //下拉菜单
  72. let { pickername } = e.target.dataset
  73. let getIndex = pickername + 'Index'
  74. app.util.getPickerIndex(this, getIndex, e);
  75. switch (pickername) {
  76. case 'loadPoint': //客户
  77. this.loadTimeData() //获取销售订单
  78. break;
  79. }
  80. },
  81. /**
  82. * 页面上拉触底事件的处理函数
  83. */
  84. bindscrolltolowerFun() {
  85. },
  86. //表单提交 carTaskAdd
  87. formSubmit: function ({detail:{value}}) {
  88. var warn = ""; //弹框时提示的内容
  89. if (value.loadPointId == '') {
  90. warn = "请选择装卸点位!";
  91. } else if(value.loadTimeId == ''){
  92. warn = "请选择装卸时间!";
  93. }
  94. if (warn != '') {
  95. app.util.checkForm(warn);
  96. } else {
  97. app.request.POST({
  98. url: app.API.orderloadReplace,
  99. params: value,
  100. page: this,
  101. isLoadingTxt: '提交中...',
  102. isSubmitting: true,
  103. successFun: true
  104. }).then(res => {
  105. wx.showToast({
  106. title: '更换成功',
  107. icon: 'success',
  108. duration: 2000,
  109. mask:true,
  110. complete: function () {
  111. setTimeout(() => {
  112. wx.navigateBack()
  113. }, 1500) //延迟时间
  114. }
  115. })
  116. })
  117. }
  118. },
  119. /**
  120. * 生命周期函数--监听页面初次渲染完成
  121. */
  122. onReady: function () {
  123. },
  124. /**
  125. * 生命周期函数--监听页面显示
  126. */
  127. onShow: function () {
  128. },
  129. /**
  130. * 生命周期函数--监听页面隐藏
  131. */
  132. onHide: function () {
  133. },
  134. /**
  135. * 生命周期函数--监听页面卸载
  136. */
  137. onUnload: function () {
  138. },
  139. /**
  140. * 页面相关事件处理函数--监听用户下拉动作
  141. */
  142. onPullDownRefresh: function () {
  143. },
  144. /**
  145. * 页面上拉触底事件的处理函数
  146. */
  147. onReachBottom: function () {
  148. },
  149. /**
  150. * 用户点击右上角分享
  151. */
  152. onShareAppMessage: function () {
  153. }
  154. })