add.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // pages/reservationPipe/add.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showModal: false,
  9. defaultText: '请选择',
  10. isSubmitting: false,
  11. orderArray:[], //管桩计划
  12. orderIndex:null,
  13. appointmentStatusArray: [{
  14. dictValue: "",
  15. dictLabel: "全部状态"
  16. }],
  17. appointmentStatusIndex: 0,
  18. isKeyboard: false, //是否显示车牌输入键盘
  19. inputOnFocusIndex: '', //当前锁定的车号位置
  20. licensePlate: '', //用于提交
  21. inputPlates: '', //用于显示
  22. },
  23. //输入框焦点聚焦时隐藏车牌号输入框
  24. hideKeybord: function () {
  25. this.setData({
  26. isKeyboard: false,
  27. inputOnFocusIndex: ''
  28. })
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. //获取管桩计划信息
  35. this.getorderData()
  36. },
  37. //选择管桩计划
  38. getorderData:function(){
  39. app.request.GET({
  40. url: app.API.bizpipeplanList,
  41. params: {},
  42. page: this,
  43. successFun: true
  44. }).then(res => {
  45. let orderList = res.data.data
  46. orderList.forEach((element,index) => {
  47. orderList[index].name = element.planNumber
  48. });
  49. this.setData({
  50. orderArray: orderList
  51. })
  52. })
  53. },
  54. //获取车牌号
  55. licensePlate: function (e) {
  56. this.setData({
  57. licensePlate: e.detail.carNum
  58. })
  59. },
  60. //下拉选择
  61. bindPickerChange: function (e) {
  62. let { pickername } = e.target.dataset
  63. let getIndex = pickername + 'Index'
  64. app.util.getPickerIndex(this, getIndex, e);
  65. switch (pickername) {
  66. case 'order': //管桩计划
  67. this.setData({
  68. planNumber : this.data.orderArray[this.data.orderIndex].planNumber,
  69. planName : this.data.orderArray[this.data.orderIndex].planName,
  70. planCount : this.data.orderArray[this.data.orderIndex].planCount,
  71. planAlreadyCount: this.data.orderArray[this.data.orderIndex].planAlreadyCount,
  72. })
  73. break;
  74. }
  75. },
  76. // 单选
  77. dangerStatusChange: function (e) {
  78. this.setData({
  79. [e.currentTarget.dataset.radiotype]: e.detail.value
  80. })
  81. },
  82. //多选
  83. checkboxChange: function (e) {
  84. this.setData({
  85. [e.currentTarget.dataset.checkboxtype]: e.detail
  86. })
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. bindscrolltolowerFun() {
  92. },
  93. //表单提交 carTaskAdd
  94. formSubmit: function ({detail:{value}}) {
  95. var warn = ""; //弹框时提示的内容
  96. let reg = /^1[3-9]\d{9}$/;
  97. var xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
  98. var creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;
  99. //value.certificateNoImage = this.data.originalInvoicePhoto
  100. if (value.orderId == '') {
  101. warn = "请选择管桩计划订单!";
  102. } else if (value.licenseNumber == '') {
  103. warn = "车牌不能为空!";
  104. } else if (value.licenseNumber.length < 7) {
  105. warn = "请选择完整车牌号!";
  106. } else if (value.licenseNumber.length == 7 && !creg.test(value.licenseNumber)) {
  107. warn = "车牌号格式错误!";
  108. } else if (value.licenseNumber.length == 8 && !xreg.test(value.licenseNumber)) {
  109. warn = "车牌号格式错误!";
  110. } else if(value.driverName == ''){
  111. warn = "请输入司机姓名!";
  112. } else if(value.driverMobile == ''){
  113. warn = "请输入司机电话!";
  114. }
  115. if (warn != '') {
  116. app.util.checkForm(warn);
  117. } else {
  118. app.request.POST({
  119. url: app.API.appointmentPipeAdd,
  120. params: value,
  121. page: this,
  122. isLoadingTxt: '提交中...',
  123. isSubmitting: true,
  124. successFun: true
  125. }).then(res => {
  126. wx.showToast({
  127. title: '新增成功',
  128. icon: 'success',
  129. duration: 2000,
  130. mask:true,
  131. complete: function () {
  132. setTimeout(() => {
  133. wx.navigateBack()
  134. }, 1500) //延迟时间
  135. }
  136. })
  137. })
  138. }
  139. },
  140. /**
  141. * 生命周期函数--监听页面初次渲染完成
  142. */
  143. onReady: function () {
  144. },
  145. /**
  146. * 生命周期函数--监听页面显示
  147. */
  148. onShow: function () {
  149. },
  150. /**
  151. * 生命周期函数--监听页面隐藏
  152. */
  153. onHide: function () {
  154. },
  155. /**
  156. * 生命周期函数--监听页面卸载
  157. */
  158. onUnload: function () {
  159. },
  160. /**
  161. * 页面相关事件处理函数--监听用户下拉动作
  162. */
  163. onPullDownRefresh: function () {
  164. },
  165. /**
  166. * 页面上拉触底事件的处理函数
  167. */
  168. onReachBottom: function () {
  169. },
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {
  174. }
  175. })