allocation.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. // pages/loadAppoint/allocationIndex.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. showModal: false,
  9. defaultText: '请选择',
  10. isSubmitting: false,
  11. str:' ',
  12. loginStatus: wx.getStorageSync('loginStatus') ? wx.getStorageSync('loginStatus') : false,
  13. roleCodeList: wx.getStorageSync('roleCodeList') ? wx.getStorageSync('roleCodeList') : '',
  14. searchVal: '',
  15. //分页
  16. limit: 10,
  17. requestStatu: '加载中...',
  18. page: 1,
  19. totalPages: 1,
  20. more: false,
  21. nomore: '',
  22. resData:[],
  23. show: false,
  24. loadPointId:'',//起卸地点
  25. loadTimeId:'',//起卸时段
  26. loadPointArray:[],//装卸点位
  27. loadPointIndex:null,
  28. loadTimeArray:[], //装卸时间
  29. loadTimeIndex:null,
  30. loadUserArray:[], //执行员
  31. loadUserIndex:null,
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad(options) {
  37. this.setData({
  38. appointId : options.appointId,
  39. })
  40. //起卸点位
  41. this.getAllocationListFun()
  42. },
  43. //列表
  44. getAllocationListFun: function () {
  45. this.setData({
  46. page: 1
  47. })
  48. let params = {
  49. current : this.data.page,
  50. size : this.data.limit,
  51. appointId : this.data.appointId,
  52. appointType : '1'
  53. }
  54. app.request.pageFirst({
  55. url: app.API.bizloaddispatchPage,
  56. page: this,
  57. params: params,
  58. })
  59. },
  60. //装卸点位
  61. loadPointData:function(){
  62. app.request.GET({
  63. url: app.API.loadPoint,
  64. params: {'appointType' : '1'},
  65. page: this,
  66. successFun: true
  67. }).then(res => {
  68. this.setData({
  69. loadPointArray:res.data.data
  70. })
  71. })
  72. },
  73. //装卸时间
  74. loadTimeData:function(){
  75. app.request.GET({
  76. url: app.API.loadTimeNow,
  77. params: {
  78. pointId : this.data.loadPointArray[this.data.loadPointIndex].id,
  79. },
  80. page: this,
  81. successFun: true
  82. }).then(res => {
  83. let timeList = res.data.data
  84. timeList.forEach((element,index) => {
  85. timeList[index].time = element.beginTime + '~' + element.endTime
  86. });
  87. this.setData({
  88. loadTimeArray : timeList
  89. })
  90. })
  91. },
  92. //装卸时间
  93. loadUserData:function(){
  94. app.request.GET({
  95. url: app.API.roleUser,
  96. params: {
  97. roleName : '起卸员',
  98. },
  99. page: this,
  100. successFun: true
  101. }).then(res => {
  102. this.setData({
  103. loadUserArray:res.data.data
  104. })
  105. })
  106. },
  107. //下拉选择
  108. bindPickerChange: function (e) { //下拉菜单
  109. let { pickername } = e.target.dataset
  110. let getIndex = pickername + 'Index'
  111. app.util.getPickerIndex(this, getIndex, e);
  112. switch (pickername) {
  113. case 'loadPoint': //客户
  114. this.loadTimeData() //获取起卸时段
  115. break;
  116. }
  117. },
  118. // 添加S
  119. showPopup(e) {
  120. let { id, loadPoint, loadTime, userId } = e.currentTarget.dataset
  121. this.setData({
  122. show: true,
  123. id: id,
  124. loadPointId:loadPoint,//起卸地点
  125. loadTimeId:loadTime,//起卸时段
  126. userId:userId
  127. });
  128. this.loadPointData()
  129. this.loadUserData()
  130. },
  131. onClose() {
  132. this.setData({
  133. show: false,
  134. id: '',
  135. loadPointId:'',//起卸地点
  136. loadTimeId:'',//起卸时段
  137. userId:'',//执行员
  138. });
  139. },
  140. /**
  141. * 生命周期函数--监听页面初次渲染完成
  142. */
  143. onReady() {
  144. },
  145. /**
  146. * 生命周期函数--监听页面显示
  147. */
  148. onShow() {
  149. },
  150. //页面跳转
  151. toLink: function (e) {
  152. let { url } = e.currentTarget.dataset
  153. wx.navigateTo({
  154. url: url
  155. })
  156. },
  157. //表单提交 carTaskAdd
  158. formSubmitAllocation: function ({detail:{value}}) {
  159. var warn = ""; //弹框时提示的内容
  160. if (value.loadPointId == '') {
  161. warn = "请选择装卸点位!";
  162. } else if(value.loadTimeId == ''){
  163. warn = "请选择装卸时间!";
  164. } else if(value.userId == ''){
  165. warn = "请选择执行员!";
  166. }
  167. if (warn != '') {
  168. app.util.checkForm(warn);
  169. } else {
  170. app.request.POST({
  171. url: app.API.appointAdd,
  172. params: value,
  173. page: this,
  174. isLoadingTxt: '提交中...',
  175. isSubmitting: true,
  176. successFun: true
  177. }).then(res => {
  178. wx.showToast({
  179. title: '新增成功',
  180. icon: 'success',
  181. duration: 2000,
  182. mask:true,
  183. complete: function () {
  184. setTimeout(() => {
  185. wx.navigateBack()
  186. }, 1500) //延迟时间
  187. }
  188. })
  189. })
  190. }
  191. },
  192. /**
  193. * 生命周期函数--监听页面隐藏
  194. */
  195. onHide() {
  196. },
  197. /**
  198. * 生命周期函数--监听页面卸载
  199. */
  200. onUnload() {
  201. },
  202. /**
  203. * 页面相关事件处理函数--监听用户下拉动作
  204. */
  205. onPullDownRefresh: function () {
  206. this.setData({
  207. searchVal: ''
  208. })
  209. if (wx.getStorageSync('loginStatus')) {
  210. this.getAllocationListFun();
  211. } else {
  212. wx.stopPullDownRefresh();
  213. }
  214. },
  215. /**
  216. * 页面上拉触底事件的处理函数
  217. */
  218. onReachBottom: function () {
  219. this.data.page++;
  220. let params = {
  221. current : this.data.page,
  222. size : this.data.limit,
  223. appointId : this.data.appointId,
  224. appointType : '1'
  225. }
  226. app.request.pageFirst({
  227. url: app.API.bizloaddispatchPage,
  228. page: this,
  229. params: params,
  230. loadType: true //加载类型,是否是下拉加载
  231. });
  232. },
  233. /**
  234. * 用户点击右上角分享
  235. */
  236. onShareAppMessage() {
  237. }
  238. })