edit.js 6.0 KB

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