edit.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. // pages/reservationLoadAppoint/edit.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showModal: false,
  9. defaultText: '请选择',
  10. isSubmitting: false,
  11. loadPointArray:[], //装货点位
  12. loadPointIndex:null,
  13. loadTimeArray:[], //装卸时间
  14. loadTimeIndex:null,
  15. excessConfigArray:[], //装卸时间
  16. excessConfigIndex:null,
  17. isKeyboard: false, //是否显示车牌输入键盘
  18. inputOnFocusIndex: '', //当前锁定的车号位置
  19. licensePlate: '', //用于提交
  20. inputPlates: '', //用于显示
  21. },
  22. //输入框焦点聚焦时隐藏车牌号输入框
  23. hideKeybord: function () {
  24. this.setData({
  25. isKeyboard: false,
  26. inputOnFocusIndex: ''
  27. })
  28. },
  29. /**
  30. * 生命周期函数--监听页面加载
  31. */
  32. onLoad: function (options) {
  33. //获取详情
  34. var pages = getCurrentPages();
  35. var prevPage = pages[pages.length - 2];
  36. let getInfo = prevPage.data.resData[options.index]
  37. let getCarNumArr = getInfo.licenseNumber ? getInfo.licenseNumber.split('') : ''
  38. let inputPlates = {};
  39. for (let i = 0; i < getCarNumArr.length; i++) {
  40. inputPlates['index' + i] = getCarNumArr[i]
  41. }
  42. this.setData({
  43. info : getInfo,
  44. orderId : getInfo.orderId,
  45. driverId : wx.getStorageSync('id'),
  46. inputPlates : inputPlates,
  47. isNewEnergy : getCarNumArr.length > 7 ? true : false,
  48. licensePlate: getInfo.licenseNumber,
  49. })
  50. //获取装卸点位下拉列表
  51. this.loadPointData()
  52. //获取车辆轴数下拉列表
  53. this.getCarzheData()
  54. app.request.GET({
  55. url: app.API.bizloadappointDetail,
  56. params: {'id' : getInfo.orderId},
  57. page: this,
  58. successFun: true
  59. }).then(res => {
  60. let getInfo = res.data.data;
  61. this.setData({
  62. loadNumber : getInfo.loadNumber,
  63. customerName : getInfo.customerName,
  64. goodsName : getInfo.goodsName,
  65. goodsModel : getInfo.goodsModel,
  66. })
  67. })
  68. },
  69. //获取装卸点位下拉列表
  70. loadPointData:function(){
  71. app.request.GET({
  72. url: app.API.bizloaddispatchList,
  73. params: {
  74. 'appointId': this.data.orderId,
  75. 'loadType': '2'
  76. },
  77. page: this,
  78. successFun: true
  79. }).then(res => {
  80. this.setData({
  81. loadPointArray : res.data.data,
  82. loadPointIndex : this.data.info.loadPointId?app.util.getDicIndex(res.data.data, this.data.info.loadPointId, 'loadPointId'):null
  83. })
  84. console.info("this.data.info.loadPointIndex---" + this.data.loadPointIndex)
  85. if(this.data.info.loadPointId){
  86. this.loadTimeData()
  87. }
  88. })
  89. },
  90. //装卸时间
  91. loadTimeData:function(){
  92. app.request.GET({
  93. url: app.API.bizloaddispatchTimeList,
  94. params: {
  95. orderId : this.data.orderId,
  96. loadPointId : this.data.loadPointArray[this.data.loadPointIndex].loadPointId,
  97. loadType : '2'
  98. },
  99. page: this,
  100. successFun: true
  101. }).then(res => {
  102. let loadTimeList = res.data.data
  103. loadTimeList.forEach((element,index) => {
  104. loadTimeList[index].time = element.beginTime + '~' + element.endTime
  105. });
  106. this.setData({
  107. loadTimeArray : loadTimeList,
  108. loadTimeIndex : this.data.info.loadTimeId?app.util.getDicIndex(loadTimeList, this.data.info.loadTimeId, 'loadTimeId'):null
  109. })
  110. console.info("this.data.info.loadTimeIndex---" + this.data.loadTimeIndex)
  111. })
  112. },
  113. //获取车辆轴数下拉列表
  114. getCarzheData:function(){
  115. app.request.GET({
  116. url: app.API.bizexcessconfigList,
  117. params: {},
  118. page: this,
  119. successFun: true
  120. }).then(res => {
  121. let excessConfigList = res.data.data
  122. excessConfigList.forEach((element,index) => {
  123. excessConfigList[index].name = element.vehicleAxleNumber+'轴'
  124. });
  125. this.setData({
  126. excessConfigArray : excessConfigList,
  127. excessConfigIndex : this.data.info.overId?app.util.getDicIndex(excessConfigList, this.data.info.overId, 'id'):null
  128. })
  129. console.info("this.data.info.excessConfigIndex---" + this.data.excessConfigIndex)
  130. })
  131. },
  132. //获取车牌号
  133. licensePlate: function (e) {
  134. this.setData({
  135. licensePlate: e.detail.carNum
  136. })
  137. },
  138. //下拉选择
  139. bindPickerChange: function (e) {
  140. let { pickername } = e.target.dataset
  141. let getIndex = pickername + 'Index'
  142. app.util.getPickerIndex(this, getIndex, e);
  143. switch (pickername) {
  144. case 'loadPoint': //装货点位
  145. this.loadTimeData() //获取装货时间
  146. break;
  147. }
  148. },
  149. // 单选
  150. dangerStatusChange: function (e) {
  151. this.setData({
  152. [e.currentTarget.dataset.radiotype]: e.detail.value
  153. })
  154. },
  155. //多选
  156. checkboxChange: function (e) {
  157. this.setData({
  158. [e.currentTarget.dataset.checkboxtype]: e.detail
  159. })
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. bindscrolltolowerFun() {
  165. },
  166. //表单提交 carTaskAdd
  167. formSubmit: function ({detail:{value}}) {
  168. var warn = ""; //弹框时提示的内容
  169. let reg = /^1[3-9]\d{9}$/;
  170. var xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
  171. var creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
  172. //value.certificateNoImage = this.data.originalInvoicePhoto
  173. if (value.orderId == '') {
  174. warn = "请选择起卸预约订单!";
  175. } else if (value.licenseNumber == '') {
  176. warn = "车牌不能为空!";
  177. } else if (value.licenseNumber.length < 7) {
  178. warn = "请选择完整车牌号!";
  179. } else if (value.licenseNumber.length == 7 && !creg.test(value.licenseNumber)) {
  180. warn = "车牌号格式错误!";
  181. } else if (value.licenseNumber.length == 8 && !xreg.test(value.licenseNumber)) {
  182. warn = "车牌号格式错误!";
  183. } else if (value.overId == '') {
  184. warn = "请选择车辆轴数!";
  185. } else if(value.driverName == ''){
  186. warn = "请输入司机姓名!";
  187. } else if(value.driverMobile == ''){
  188. warn = "请输入司机电话!";
  189. }
  190. if (warn != '') {
  191. app.util.checkForm(warn);
  192. } else {
  193. app.request.POST({
  194. url: app.API.loadEdit,
  195. params: value,
  196. page: this,
  197. isLoadingTxt: '提交中...',
  198. isSubmitting: true,
  199. successFun: true
  200. }).then(res => {
  201. wx.showToast({
  202. title: '修改成功',
  203. icon: 'success',
  204. duration: 2000,
  205. mask:true,
  206. complete: function () {
  207. setTimeout(() => {
  208. wx.navigateBack()
  209. }, 1500) //延迟时间
  210. }
  211. })
  212. })
  213. }
  214. },
  215. /**
  216. * 生命周期函数--监听页面初次渲染完成
  217. */
  218. onReady: function () {
  219. },
  220. /**
  221. * 生命周期函数--监听页面显示
  222. */
  223. onShow: function () {
  224. },
  225. /**
  226. * 生命周期函数--监听页面隐藏
  227. */
  228. onHide: function () {
  229. },
  230. /**
  231. * 生命周期函数--监听页面卸载
  232. */
  233. onUnload: function () {
  234. },
  235. /**
  236. * 页面相关事件处理函数--监听用户下拉动作
  237. */
  238. onPullDownRefresh: function () {
  239. },
  240. /**
  241. * 页面上拉触底事件的处理函数
  242. */
  243. onReachBottom: function () {
  244. },
  245. /**
  246. * 用户点击右上角分享
  247. */
  248. onShareAppMessage: function () {
  249. }
  250. })