supplyDetail.js 3.0 KB

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