list.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import * as requestAPI from '../../models/dataModel'
  2. Page({
  3. data: {
  4. inspectionList: [],
  5. scCode: '',
  6. poCode: '',
  7. current: 1,
  8. size: 10,
  9. total: 0,
  10. selectinspectionList: []
  11. },
  12. onLoad: function (options) {
  13. this.setData({
  14. poCode: options?options.poCode:this.data.poCode,
  15. scCode: options?options.scCode:this.data.scCode
  16. })
  17. },
  18. onReady() {
  19. this.getinspectionList()
  20. },
  21. onUnload() {
  22. },
  23. // 获取样品单列表
  24. getinspectionList() {
  25. //wx.showLoading({title: '加载中', icon: 'loading'});
  26. let form = {
  27. current: this.data.current,
  28. size: this.data.size,
  29. scCode: this.data.scCode,
  30. poCode: this.data.poCode
  31. }
  32. requestAPI.getInspectionList(form).then(res => {
  33. this.setData({
  34. inspectionList: res.data.data.records,
  35. total: res.data.data.total
  36. })
  37. })
  38. },
  39. // 获取资料详情
  40. getDetail: function (event) {
  41. let filterList = this.data.inspectionList.filter(item=>{return item.id == event.currentTarget.dataset.id})
  42. wx.navigateTo({
  43. url: `/pages/inspection/detail?ids=${filterList[0].id}&scpCode=${filterList[0].scpCode}&scCode=${filterList[0].scCode}&poCode=${filterList[0].poCode}&picture=${filterList[0].picture}`,
  44. })
  45. },
  46. selectList:function(e) {
  47. let tempList = this.data.inspectionList
  48. tempList[e.currentTarget.dataset.index].checked = !tempList[e.currentTarget.dataset.index].checked
  49. this.setData({
  50. inspectionList: tempList
  51. })
  52. },
  53. // 下拉刷新
  54. onPullDownRefresh: function () {
  55. wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画
  56. this.onLoad(); //刷新页面
  57. setTimeout(function () {
  58. wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
  59. wx.stopPullDownRefresh(); //停止下拉动作
  60. }, 2000)
  61. },
  62. // 下拉加载
  63. onReachBottom: function () {
  64. if (this.data.size > this.data.total) {
  65. return;
  66. } else {
  67. this.getinspectionList();
  68. this.setData({
  69. size: this.data.size+10
  70. })
  71. }
  72. },
  73. openPreview: function (event) {
  74. wx.previewImage({
  75. urls: new Array(event.currentTarget.dataset.url),
  76. })
  77. },
  78. // 全选反选
  79. selectall() {
  80. let tempList = this.data.inspectionList
  81. for(let i of tempList) {
  82. i.checked =!i.checked
  83. }
  84. this.setData({
  85. inspectionList: tempList
  86. })
  87. },
  88. // 进入图片选择界面
  89. generate() {
  90. let tempList = []
  91. let filterList = []
  92. for(let i of this.data.inspectionList) {
  93. if(i.checked) {
  94. tempList.push(i.id)
  95. filterList.push(i)
  96. }
  97. }
  98. if(tempList.length==0) {
  99. wx.showToast({
  100. title: `至少选择一个货号`,
  101. icon: 'warn',
  102. duration: 30000
  103. })
  104. return
  105. }
  106. wx.navigateTo({
  107. url: `/pages/inspection/detail?ids=${tempList.join('-')}&scpCode='多个货号'&scCode=${filterList[0].scCode}&poCode=${filterList[0].poCode}&picture=''`,
  108. })
  109. }
  110. })