add.js 5.9 KB

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