add.js 5.3 KB

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