edit.js 5.9 KB

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