integral_application_list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="integral_application_list_box">
  3. <van-nav-bar title="我申请的" left-text="返回" @click-left="$route_back" left-arrow></van-nav-bar>
  4. <van-search v-model="filter.keyword" maxlength="20" placeholder="请输入申请事由搜索" />
  5. <van-tabs v-model="filter.type">
  6. <van-tab title="全部申请" name="all"></van-tab>
  7. <van-tab title="已通过" name="complete"></van-tab>
  8. <van-tab title="待审批" name="waiting"></van-tab>
  9. <van-tab title="被驳回" name="refuse"></van-tab>
  10. </van-tabs>
  11. <div class="body_com has_header">
  12. <scroller ref="my_scroller" :on-refresh="refresh" :on-infinite="infinite">
  13. <van-cell-group :border="false">
  14. <van-cell
  15. class="task_list"
  16. v-for="(item, index) in list"
  17. :key="index"
  18. @click="detail(item)"
  19. >
  20. <template slot="title">
  21. <span class="title" style="padding-right: 0.2rem;">{{item.remark.customize || item.remark.rule}}</span>
  22. </template>
  23. <template slot="right-icon">
  24. <span class="point_text">
  25. <span class="red" v-if="item.review_point > 0">+{{ item.review_point }}{{$isPt_id(item.pt_id)}}</span>
  26. <span class="green" v-if="item.review_point < 0">{{ item.review_point }}{{$isPt_id(item.pt_id)}}</span>
  27. </span>
  28. </template>
  29. <template slot="label">
  30. <div class="clear" style="margin-top: 0.3rem">
  31. <span class="fl date color_ccc" style="font-size: 0.28rem;">{{item.event_time}}</span>
  32. </div>
  33. <div class="clear" style=" position: absolute; right: 0.32rem; bottom: 0.28rem;">
  34. <span class="fr text_yellow" v-if="item.status == 0">待审批</span>
  35. <span class="fr text_green" v-if="item.status == 1">申请成功</span>
  36. <span class="fr text_red" v-if="item.status == 2">被驳回</span>
  37. </div>
  38. </template>
  39. </van-cell>
  40. </van-cell-group>
  41. <noData :list="list" />
  42. </scroller>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import Vue from 'vue'
  48. import { Tab, Tabs, Search } from 'vant'
  49. import request from '@/utils/request'
  50. import {_debounce} from '@/utils/auth'
  51. Vue.use(Tab)
  52. Vue.use(Tabs).use(Search)
  53. export default {
  54. name: 'integral_application_list',
  55. comments: {},
  56. data () {
  57. return {
  58. title: '我的申请',
  59. list: null,
  60. filter: {
  61. page: 1,
  62. pt_id: 0,
  63. page_size: 30,
  64. type: 'all',
  65. keyword: ''
  66. },
  67. types_list: {},
  68. types_list_array: []
  69. }
  70. },
  71. watch: {
  72. 'filter.type': function (val) {
  73. let self = this
  74. this.list = null
  75. this.$toast.loading({
  76. message: '正在加载'
  77. })
  78. this.refresh(function () {
  79. self.$toast.clear()
  80. })
  81. },
  82. 'filter.keyword': {
  83. deep: true,
  84. handler: _debounce(function () {
  85. this.refresh(function () {})
  86. })
  87. }
  88. },
  89. methods: {
  90. get_point_types () {
  91. let self = this
  92. request('get', '/api/integral/types').then(res => {
  93. if (res.data.code == 1) {
  94. for (let i in res.data.data.list) {
  95. self.types_list[res.data.data.list[i].id] = res.data.data.list[i].name
  96. }
  97. self.types_list_array = res.data.data.list
  98. }
  99. })
  100. },
  101. get_list (done) {
  102. let self = this
  103. request('get', '/api/integral/review/apply/list', self.filter).then((res) => {
  104. done()
  105. if (res.data.code == 1) {
  106. self.$refs.my_scroller.finishInfinite(res.data.data.list.length != 30) // 停止上滚加载下一页,由于服务器端没有统一空数据和正常数据的格式,所以通过total字段来判定数据是否存在下一页
  107. if (res.data.data.total) {
  108. for (let i in res.data.data.list) {
  109. self.list.push(res.data.data.list[i])
  110. }
  111. }
  112. self.filter.page++
  113. } else {
  114. self.$refs.my_scroller.finishInfinite(true)
  115. }
  116. })
  117. },
  118. refresh (done) {
  119. let self = this
  120. this.filter.page = 1
  121. this.get_list(function () {
  122. self.list = []
  123. done()
  124. })
  125. },
  126. infinite (done) {
  127. this.get_list(done)
  128. },
  129. // 积分申请详情
  130. detail (data) {
  131. this.$router.push({ name: 'approval_detail', query: { review_id: data.id, title: '申请详情' } })
  132. }
  133. },
  134. mounted () {
  135. this.$nextTick(function () {
  136. this.$refs.my_scroller.finishInfinite(false)
  137. this.get_point_types()
  138. this.$refs.my_scroller.triggerPullToRefresh()
  139. })
  140. },
  141. activated () {
  142. // 使用keep_alive_update更新列表,不请求接口了,吴俊源
  143. /* if (this.isMounted) {
  144. this.$refs.my_scroller.triggerPullToRefresh()
  145. } else {
  146. this.isMounted = true
  147. } */
  148. },
  149. keep_alive_update: {
  150. // 运用缓存更新方法来完成返回后的更新
  151. update_approval_list: function (vm, data) {
  152. for (let i in vm.list) {
  153. if (vm.list[i].id == data.review_id) {
  154. vm.list.splice(i, 1)
  155. }
  156. }
  157. vm.$forceUpdate()
  158. }
  159. }
  160. }
  161. </script>
  162. <style scoped lang="less">
  163. .body_com {
  164. height: calc(100% - 1.8rem);
  165. position: relative;
  166. }
  167. .task_list {
  168. /deep/ & .van-cell__value {
  169. flex: none;
  170. }
  171. .title {
  172. font-size: 0.36rem;
  173. min-height: 22px;
  174. display: inline-block;
  175. display: -webkit-box;
  176. -webkit-box-orient: vertical;
  177. -webkit-line-clamp: 2;
  178. overflow: hidden;
  179. }
  180. }
  181. .text_red{
  182. color: #F56C6C;
  183. background-color:rgba(245,108,108, 0.3);
  184. // border-radius:4px;
  185. // padding: 3px;
  186. }
  187. .text_yellow{
  188. color: #FF9600;
  189. background-color:rgba(255,150,0, 0.3);
  190. // border-radius:4px;
  191. // padding: 3px;
  192. }
  193. .text_green{
  194. color: #4BD964;
  195. background-color:rgba(75,217,100, 0.3);
  196. // border-radius:4px;
  197. // padding: 3px;
  198. }
  199. .color_red{
  200. color: #F56C6C;
  201. }
  202. .color_green{
  203. color: #4BD964;
  204. }
  205. .overText {
  206. word-break: break-all;
  207. text-overflow: ellipsis;
  208. overflow: hidden;
  209. display: -webkit-box;
  210. -webkit-line-clamp: 2;
  211. -webkit-box-orient: vertical;
  212. }
  213. .point_text{font-size:0.4rem;}
  214. </style>