replace.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. carzheArray:[],//车辆轴数
  12. carzheIndex:'',
  13. orderArray:[],//订单
  14. orderIndex:null,
  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(true)
  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. carzheArray: res.data.data,
  58. loadPointArray : [],
  59. carzheIndex: app.util.getDicIndex(res.data.data, this.data.info.overId, 'id'),
  60. })
  61. })
  62. },
  63. //装卸点位
  64. loadPointData:function(type){
  65. let orderIdSelect = type ? this.data.info.orderId : this.data.orderArray[this.data.orderIndex].orderId
  66. app.request.GET({
  67. url: app.API.stoneAppointPointList,
  68. params: {
  69. orderId: orderIdSelect
  70. },
  71. page: this,
  72. successFun: true
  73. }).then(res => {
  74. this.setData({
  75. loadPointArray : res.data.data,
  76. loadPointIndex : null,
  77. loadTimeArray : []
  78. })
  79. //初始化详情
  80. if(type){
  81. this.setData({
  82. loadPointIndex : app.util.getDicIndex(res.data.data, this.data.info.loadPointId, 'loadPointId')
  83. })
  84. this.loadTimeData(true)
  85. }
  86. })
  87. },
  88. //装卸时间
  89. loadTimeData:function(type){
  90. console.info("------type-------" + type)
  91. let pointIdSelect = type ? this.data.info.loadPointId : this.data.loadPointArray[this.data.loadPointIndex].loadPointId
  92. let orderIdSelect = type ? this.data.info.orderId : this.data.orderArray[this.data.orderIndex].orderId
  93. app.request.GET({
  94. url: app.API.stoneAppointLoadTimeList,
  95. params: {
  96. pointId : pointIdSelect,
  97. orderId : orderIdSelect
  98. },
  99. page: this,
  100. successFun: true
  101. }).then(res => {
  102. let orderList = res.data.data
  103. orderList.forEach((element,index) => {
  104. orderList[index].time = element.beginTime + '~' + element.endTime
  105. });
  106. this.setData({
  107. loadTimeArray : orderList,
  108. loadTimeIndex : null
  109. })
  110. //初始化详情
  111. if(type){
  112. this.setData({
  113. loadTimeIndex : app.util.getDicIndex(orderList, this.data.info.loadTimeId, 'loadTimeId')
  114. })
  115. }
  116. })
  117. },
  118. //下拉选择
  119. bindPickerChange: function (e) { //下拉菜单
  120. let { pickername } = e.target.dataset
  121. let getIndex = pickername + 'Index'
  122. app.util.getPickerIndex(this, getIndex, e);
  123. switch (pickername) {
  124. case 'order': //订单
  125. this.loadPointData() //获取装卸点位
  126. break;
  127. case 'loadPoint': //装卸点位
  128. this.loadTimeData(false) //获取装卸时间
  129. break;
  130. }
  131. },
  132. // 单选
  133. dangerStatusChange: function (e) {
  134. this.setData({
  135. [e.currentTarget.dataset.radiotype]: e.detail.value
  136. })
  137. },
  138. //多选
  139. checkboxChange: function (e) {
  140. console.log(e.detail)
  141. this.setData({
  142. [e.currentTarget.dataset.checkboxtype]: e.detail
  143. })
  144. },
  145. /**
  146. * 页面上拉触底事件的处理函数
  147. */
  148. bindscrolltolowerFun() {
  149. },
  150. formSubmit: function ({detail:{value}}) {
  151. let formData = value;
  152. var warn = ""; //弹框时提示的内容
  153. if (typeof formData.orderId == 'undefined' || formData.orderId == '') {
  154. warn = "请选择订单!";
  155. } else if (typeof formData.loadPointId == 'undefined' || formData.loadPointId == '') {
  156. warn = "请选择装卸点位!";
  157. } else if (typeof formData.loadTimeId == 'undefined' || formData.loadTimeId == '') {
  158. warn = "请选择装卸时间!";
  159. }
  160. if (warn != '') {
  161. app.util.checkForm(warn);
  162. } else {
  163. app.request.POST({
  164. url: app.API.stoneAppointReplace,
  165. params: value,
  166. page: this,
  167. isLoadingTxt: '提交中...',
  168. isSubmitting: true,
  169. successFun: true
  170. }).then(res => {
  171. wx.showToast({
  172. title: '修改成功',
  173. icon: 'success',
  174. duration: 2000,
  175. mask:true,
  176. complete: function () {
  177. setTimeout(() => {
  178. wx.navigateBack()
  179. }, 1500) //延迟时间
  180. }
  181. })
  182. })
  183. }
  184. },
  185. /**
  186. * 生命周期函数--监听页面初次渲染完成
  187. */
  188. onReady: function () {
  189. },
  190. /**
  191. * 生命周期函数--监听页面显示
  192. */
  193. onShow: function () {
  194. },
  195. /**
  196. * 生命周期函数--监听页面隐藏
  197. */
  198. onHide: function () {
  199. },
  200. /**
  201. * 生命周期函数--监听页面卸载
  202. */
  203. onUnload: function () {
  204. },
  205. /**
  206. * 页面相关事件处理函数--监听用户下拉动作
  207. */
  208. onPullDownRefresh: function () {
  209. },
  210. /**
  211. * 页面上拉触底事件的处理函数
  212. */
  213. onReachBottom: function () {
  214. },
  215. /**
  216. * 用户点击右上角分享
  217. */
  218. onShareAppMessage: function () {
  219. }
  220. })