replace.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // pages/index/replace.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showModal: false,
  9. defaultText: '请选择',
  10. isSubmitting: false,
  11. overArray:[],//车辆轴数
  12. overIndex:'',
  13. orderArray:[],//订单
  14. orderIndex:'',
  15. loadPointArray:[],//装卸点位
  16. loadPointIndex:null,
  17. loadTimeArray:[], //装卸时间
  18. loadTimeIndex:null,
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. //获取详情
  25. var pages = getCurrentPages();
  26. var prevPage = pages[pages.length - 2];
  27. let getInfo = prevPage.data.resData[options.index]
  28. this.setData({
  29. info: getInfo
  30. })
  31. this.getSelectData()
  32. },
  33. //获取订单下拉列表、车辆轴数下拉列表
  34. getSelectData:function(){
  35. //获取订单下拉列表
  36. app.request.GET({
  37. url: app.API.stoneAppointSupplierList,
  38. params: { licenseNumber : this.data.info.licenseNumber },
  39. page: this,
  40. successFun: true
  41. }).then(res => {
  42. this.setData({
  43. orderArray: res.data.data,
  44. orderIndex: app.util.getDicIndex(res.data.data, this.data.info.orderId, 'orderId'),
  45. })
  46. // 初始装卸点位
  47. this.loadPointData('info')
  48. })
  49. //获取车辆轴数下拉列表
  50. app.request.GET({
  51. url: app.API.getCarzheList,
  52. params: {},
  53. page: this,
  54. successFun: true
  55. }).then(res => {
  56. this.setData({
  57. overArray: res.data.data,
  58. overIndex: app.util.getDicIndex(res.data.data, this.data.info.overId, 'id'),
  59. })
  60. })
  61. },
  62. //装卸点位
  63. loadPointData:function(type){
  64. app.request.GET({
  65. url: app.API.stoneAppointPointList,
  66. params: {
  67. orderId: this.data.orderArray[this.data.orderIndex].orderId ? this.data.orderArray[this.data.orderIndex].orderId : this.data.info.orderId
  68. },
  69. page: this,
  70. successFun: true
  71. }).then(res => {
  72. this.setData({
  73. loadPointArray : res.data.data,
  74. loadPointIndex : app.util.getDicIndex(res.data.data, this.data.info.loadPointId, 'loadPointId'),
  75. })
  76. if(type){
  77. this.loadTimeData('info')
  78. }
  79. })
  80. },
  81. //装卸时间
  82. loadTimeData:function(type){
  83. let pointIdSelect = this.data.loadPointArray[this.data.loadPointIndex].loadPointId
  84. let orderIdSelect = this.data.orderArray[this.data.orderIndex].orderId
  85. app.request.GET({
  86. url: app.API.stoneAppointLoadTimeList,
  87. params: {
  88. pointId : pointIdSelect,
  89. orderId : orderIdSelect
  90. },
  91. page: this,
  92. successFun: true
  93. }).then(res => {
  94. let orderList = res.data.data
  95. orderList.forEach((element,index) => {
  96. orderList[index].time = element.beginTime + '~' + element.endTime
  97. });
  98. this.setData({
  99. loadTimeArray : orderList
  100. })
  101. //初始化详情 或者是 选择订单和装卸定位和初始值一样时 装卸时间默认为初始选择项
  102. if(type || (this.data.info.loadPointId == pointIdSelect && this.data.info.orderId == orderIdSelect)){
  103. this.setData({
  104. loadTimeIndex : app.util.getDicIndex(orderList, this.data.info.loadTimeId, 'loadTimeId')
  105. })
  106. }
  107. })
  108. },
  109. //下拉选择
  110. bindPickerChange: function (e) { //下拉菜单
  111. let { pickername } = e.target.dataset
  112. let getIndex = pickername + 'Index'
  113. app.util.getPickerIndex(this, getIndex, e);
  114. switch (pickername) {
  115. case 'order': //订单
  116. this.loadTimeData() //获取装卸时间
  117. break;
  118. case 'loadPoint': //装卸点位
  119. this.loadTimeData() //获取装卸时间
  120. break;
  121. }
  122. },
  123. // 单选
  124. dangerStatusChange: function (e) {
  125. this.setData({
  126. [e.currentTarget.dataset.radiotype]: e.detail.value
  127. })
  128. },
  129. //多选
  130. checkboxChange: function (e) {
  131. console.log(e.detail)
  132. this.setData({
  133. [e.currentTarget.dataset.checkboxtype]: e.detail
  134. })
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. bindscrolltolowerFun() {
  140. },
  141. formSubmit: function ({detail:{value}}) {
  142. let formData = value;
  143. var warn = ""; //弹框时提示的内容
  144. if (typeof formData.orderId == 'undefined' || formData.orderId == '') {
  145. warn = "请选择订单!";
  146. } else if (typeof formData.loadPointId == 'undefined' || formData.loadPointId == '') {
  147. warn = "请选择装卸点位!";
  148. } else if (typeof formData.loadTimeId == 'undefined' || formData.loadTimeId == '') {
  149. warn = "请选择装卸时间!";
  150. }
  151. if (warn != '') {
  152. app.util.checkForm(warn);
  153. } else {
  154. app.request.POST({
  155. url: app.API.stoneAppointReplace,
  156. params: value,
  157. page: this,
  158. isLoadingTxt: '提交中...',
  159. isSubmitting: true,
  160. successFun: true
  161. }).then(res => {
  162. wx.showToast({
  163. title: '修改成功',
  164. icon: 'success',
  165. duration: 2000,
  166. mask:true,
  167. complete: function () {
  168. setTimeout(() => {
  169. wx.navigateBack()
  170. }, 1500) //延迟时间
  171. }
  172. })
  173. })
  174. }
  175. },
  176. /**
  177. * 生命周期函数--监听页面初次渲染完成
  178. */
  179. onReady: function () {
  180. },
  181. /**
  182. * 生命周期函数--监听页面显示
  183. */
  184. onShow: function () {
  185. },
  186. /**
  187. * 生命周期函数--监听页面隐藏
  188. */
  189. onHide: function () {
  190. },
  191. /**
  192. * 生命周期函数--监听页面卸载
  193. */
  194. onUnload: function () {
  195. },
  196. /**
  197. * 页面相关事件处理函数--监听用户下拉动作
  198. */
  199. onPullDownRefresh: function () {
  200. },
  201. /**
  202. * 页面上拉触底事件的处理函数
  203. */
  204. onReachBottom: function () {
  205. },
  206. /**
  207. * 用户点击右上角分享
  208. */
  209. onShareAppMessage: function () {
  210. }
  211. })