orderloadAdd.js 3.5 KB

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