my_approve.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. var app = getApp()
  2. var that;
  3. Page({
  4. data: {
  5. date: app.globalData.month,
  6. activeIndex: 1,
  7. httpType: 'waiting',
  8. keyword: '',
  9. page: 1,
  10. isBh: false,//是否显示驳回弹窗
  11. textArea: "",
  12. disabled: false,
  13. },
  14. onLoad() {
  15. that = this;
  16. dd.setNavigationBar({ title: "我的审批" });
  17. },
  18. onShow() {
  19. this.refreshData();
  20. },
  21. //当在详情返回时刷新列表,但你请求接口
  22. refreshData(id){
  23. if(this.data.page==1){
  24. dd.hideLoading();
  25. that.getData();
  26. }else{
  27. console.log("进来了")
  28. if(id){//当page不为一并下一页返回上一页不执行onshow()
  29. var arr=this.data.dataList;
  30. arr.forEach((element,index) => {
  31. if(element.id==id){
  32. arr.splice(index, 1);
  33. }
  34. });
  35. this.setData({
  36. dataList:arr
  37. })
  38. }
  39. }
  40. },
  41. bindTextAreaBlur(e) {
  42. this.setData({
  43. textArea: e.detail.value
  44. });
  45. },
  46. confirmBh() {
  47. var item = that.data.bhItem;
  48. if (that.data.textArea=='') {
  49. app.globalData.showToast("请输入审批意见");
  50. return;
  51. }
  52. this.setData({disabled:true});
  53. app.$post("api/integral/review", { review_id: item.id, remark: that.data.textArea, action: "refuse", ticket_count: 0 }).then((res) => {
  54. that.closeBh()
  55. app.globalData.showToast("已驳回");
  56. that.setData({disabled:false});
  57. that.refreshData(item.id);
  58. })
  59. },
  60. closeBh() {
  61. this.setData({ isBh: false,textArea:''})
  62. },
  63. openBh(e) {
  64. var item = e.target.dataset.item;
  65. this.setData({
  66. isBh: true,
  67. bhItem: item
  68. })
  69. },
  70. activeItem(e) {
  71. var index = e.target.dataset.index;
  72. this.setData({
  73. activeIndex: index,
  74. httpType: index == '1' ? 'waiting' : 'reviewed',
  75. page: 1,
  76. dataList: []
  77. })
  78. this.getData();
  79. },
  80. //选择规则分类
  81. bindKeyInput(e) {
  82. this.setData({
  83. keyword: e.detail.value,
  84. page: 1,
  85. });
  86. this.getData();
  87. dd.hideKeyboard();
  88. },
  89. openSearch() {
  90. app.globalData.showToast("暂不支持筛选");
  91. },
  92. openDetail(e) {
  93. var id = e.target.dataset.item.id;
  94. dd.navigateTo({
  95. url: '../approveDetail/approveDetail?id=' + id
  96. })
  97. },
  98. getData(type) {
  99. app.$get("api/integral/review/list", { type: that.data.httpType, page: that.data.page, pt_id: 0, page_size: 20, keyword: that.data.keyword }).then((res) => {
  100. var data = res.data.data.list || [];
  101. var dataList = that.data.dataList || [];
  102. if (type == '2') {
  103. if (data.length < 20) {
  104. this.setData({
  105. dataList: dataList.concat(data),
  106. isData: true
  107. })
  108. }else{
  109. this.setData({
  110. dataList: dataList.concat(data),
  111. })
  112. }
  113. } else {
  114. this.setData({ dataList: data,isData: false })
  115. }
  116. })
  117. },
  118. //上啦加载
  119. onScrollToLower() {
  120. if (!that.data.isData) {
  121. this.setData({ page: ++that.data.page })
  122. this.getData("2");
  123. }
  124. },
  125. });