edit.js 7.4 KB

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