add.js 6.1 KB

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