supplyRecord.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. const app = getApp()
  2. const util = require("../../../utils/jmsUtil.js");
  3. const api = require('../../../api/jms.js');
  4. import moment from 'moment'
  5. Page({
  6. data: {
  7. bookno:'',
  8. recordList:[],
  9. showPicker:false,
  10. currentItem:'',
  11. supplyList:[{name:'',num:1},{name:'',num:1}],
  12. columns:['超时补差','携带大型设备'],
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. if(options.bookno){
  19. this.setData({
  20. bookno:options.bookno
  21. });
  22. }
  23. },
  24. goAddDiff(){
  25. app.globalData.diffId=0;
  26. wx.navigateTo({
  27. url: '/pages/temp/serviceSupply/serviceSupply?bookno='+this.data.bookno,
  28. });
  29. },
  30. getDiffOrderList(){
  31. wx.showLoading({
  32. title: '加载中...',
  33. });
  34. util.request(api.getDiffOrderList, {
  35. bookDetailId:this.data.bookno
  36. }, 'GET').then(res => {
  37. wx.hideLoading();
  38. if (res.errno === 0) {
  39. this.setData({
  40. recordList:res.data
  41. });
  42. }
  43. }).catch(err => {
  44. wx.hideLoading();
  45. });
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function () {
  51. },
  52. goDetail(e){
  53. let id=e.currentTarget.dataset.id
  54. wx.navigateTo({
  55. url: '/pages/temp/supplyDetail/supplyDetail?id='+id,
  56. })
  57. },
  58. goEdit(){
  59. wx.navigateBack();
  60. },
  61. minusNum(e){
  62. let index=e.currentTarget.dataset.index;
  63. let num=e.currentTarget.dataset.num;
  64. if(num<=1){
  65. wx.showToast({
  66. title: '数量不能再少了',
  67. icon: 'none',
  68. duration: 3000
  69. });
  70. return false;
  71. }else{
  72. let item='supplyList['+index+']'+'.num';
  73. this.setData({
  74. [item]:num-1,
  75. });
  76. }
  77. },
  78. addNum(e){
  79. let index=e.currentTarget.dataset.index;
  80. let num=e.currentTarget.dataset.num;
  81. let item='supplyList['+index+']'+'.num';
  82. this.setData({
  83. [item]:num+1,
  84. });
  85. },
  86. delItem(e){
  87. let index=e.currentTarget.dataset.index;
  88. let supplyList=this.data.supplyList;
  89. supplyList.splice(index, 1);
  90. this.setData({
  91. supplyList: supplyList
  92. });
  93. },
  94. addItem(){
  95. this.setData({
  96. supplyList: this.data.supplyList.concat({name:''}),
  97. })
  98. },
  99. pickerCancel(){
  100. this.setData({
  101. showPicker:false
  102. });
  103. },
  104. showTypePicker(e){
  105. let index=e.currentTarget.dataset.index;
  106. this.setData({
  107. currentItem:index,
  108. showPicker:true
  109. })
  110. },
  111. pickerConfirm(e){
  112. let value=e.detail.value;
  113. let index=e.detail.index;
  114. let item1='supplyList['+this.data.currentItem+']'+'.name';
  115. this.setData({
  116. [item1]:value,
  117. showPicker:false,
  118. });
  119. },
  120. /**
  121. * 生命周期函数--监听页面显示
  122. */
  123. onShow: function () {
  124. console.log('onShow')
  125. this.getDiffOrderList();
  126. },
  127. onHide: function () {
  128. },
  129. onUnload: function () {
  130. },
  131. /**
  132. * 页面相关事件处理函数--监听用户下拉动作
  133. */
  134. onPullDownRefresh: function () {
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. onReachBottom: function () {
  140. },
  141. /**
  142. * 用户点击右上角分享
  143. */
  144. onShareAppMessage: function () {
  145. },
  146. })