supplyRecord.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. getDiffOrderList(){
  25. wx.showLoading({
  26. title: '加载中...',
  27. });
  28. util.request(api.getDiffOrderList, {
  29. bookDetailId:this.data.bookno
  30. }, 'GET').then(res => {
  31. wx.hideLoading();
  32. if (res.errno === 0) {
  33. this.setData({
  34. recordList:res.data
  35. });
  36. }
  37. }).catch(err => {
  38. wx.hideLoading();
  39. });
  40. },
  41. /**
  42. * 生命周期函数--监听页面初次渲染完成
  43. */
  44. onReady: function () {
  45. },
  46. goDetail(e){
  47. let id=e.currentTarget.dataset.id
  48. wx.navigateTo({
  49. url: '/pages/supplyDetail/supplyDetail?id='+id,
  50. })
  51. },
  52. goEdit(){
  53. wx.navigateBack();
  54. },
  55. minusNum(e){
  56. let index=e.currentTarget.dataset.index;
  57. let num=e.currentTarget.dataset.num;
  58. if(num<=1){
  59. wx.showToast({
  60. title: '数量不能再少了',
  61. icon: 'none',
  62. duration: 3000
  63. });
  64. return false;
  65. }else{
  66. let item='supplyList['+index+']'+'.num';
  67. this.setData({
  68. [item]:num-1,
  69. });
  70. }
  71. },
  72. addNum(e){
  73. let index=e.currentTarget.dataset.index;
  74. let num=e.currentTarget.dataset.num;
  75. let item='supplyList['+index+']'+'.num';
  76. this.setData({
  77. [item]:num+1,
  78. });
  79. },
  80. delItem(e){
  81. let index=e.currentTarget.dataset.index;
  82. let supplyList=this.data.supplyList;
  83. supplyList.splice(index, 1);
  84. this.setData({
  85. supplyList: supplyList
  86. });
  87. },
  88. addItem(){
  89. this.setData({
  90. supplyList: this.data.supplyList.concat({name:''}),
  91. })
  92. },
  93. pickerCancel(){
  94. this.setData({
  95. showPicker:false
  96. });
  97. },
  98. showTypePicker(e){
  99. let index=e.currentTarget.dataset.index;
  100. this.setData({
  101. currentItem:index,
  102. showPicker:true
  103. })
  104. },
  105. pickerConfirm(e){
  106. let value=e.detail.value;
  107. let index=e.detail.index;
  108. let item1='supplyList['+this.data.currentItem+']'+'.name';
  109. this.setData({
  110. [item1]:value,
  111. showPicker:false,
  112. });
  113. },
  114. /**
  115. * 生命周期函数--监听页面显示
  116. */
  117. onShow: function () {
  118. this.getDiffOrderList();
  119. },
  120. onHide: function () {
  121. },
  122. onUnload: function () {
  123. },
  124. /**
  125. * 页面相关事件处理函数--监听用户下拉动作
  126. */
  127. onPullDownRefresh: function () {
  128. },
  129. /**
  130. * 页面上拉触底事件的处理函数
  131. */
  132. onReachBottom: function () {
  133. },
  134. /**
  135. * 用户点击右上角分享
  136. */
  137. onShareAppMessage: function () {
  138. },
  139. })