index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div>
  3. <van-nav-bar title="专项服务" @click-left="$router.back()" left-arrow fixed placeholder safe-area-inset-top />
  4. <div class="box">
  5. <van-tabs v-if="roleIdStr==21" v-model="active" @change="changetabs">
  6. <van-tab title="服务计划"></van-tab>
  7. <van-tab title="服务完成"></van-tab>
  8. </van-tabs>
  9. <van-search v-show="active==1||roleIdStr!=21" v-model="historyform.name" shape="round" show-action placeholder="请输入姓名 项目内容" @search="onSearch">
  10. <template #action>
  11. <div @click="onSearch">搜索</div>
  12. </template>
  13. </van-search>
  14. </div>
  15. <van-list v-if="roleIdStr==21" class="mt" v-model="loading" :immediate-check="false" :finished="finished" finished-text="没有更多了" @load="onLoad">
  16. <servicePlan v-if="active==0" :planformList='planformList'></servicePlan>
  17. <serviceComplete v-if="active==1" :historyList="historyList"></serviceComplete>
  18. </van-list>
  19. <van-list v-else v-model="loading" class="his" :immediate-check="false" :finished="finished" finished-text="没有更多了" @load="onLoad">
  20. <serviceComplete :historyList="historyList"></serviceComplete>
  21. </van-list>
  22. </div>
  23. </template>
  24. <script>
  25. import { pageAppProject, pageProjectHistory } from '../../api/index.js'
  26. import servicePlan from './serviceplan.vue'
  27. import serviceComplete from './serviceComplete.vue'
  28. export default {
  29. components: { servicePlan, serviceComplete },
  30. data() {
  31. return {
  32. roleIdStr: JSON.parse(sessionStorage.getItem('userInfo')).roleIdStr,
  33. active: 0,
  34. value: '',
  35. loading: false,
  36. finished: false,
  37. planform: {
  38. pageNum: 1,
  39. pageSuze: 10,
  40. },
  41. historyform: {
  42. pageNum: 1,
  43. pageSuze: 10,
  44. },
  45. planformList: [],
  46. historyList: [],
  47. }
  48. },
  49. activated() {
  50. this.loading = true
  51. this.pageAppProject()
  52. this.pageProjectHistory()
  53. },
  54. methods: {
  55. onSearch() {
  56. this.historyform.pageNum = 1
  57. this.pageProjectHistory()
  58. },
  59. onLoad() {
  60. if (this.roleIdStr != 21) {
  61. this.active = 1
  62. }
  63. if (this.active == 0) {
  64. this.planform.pageNum = this.planform.pageNum + 1
  65. this.pageAppProject()
  66. } else if (this.active == 1) {
  67. this.historyform.pageNum = this.historyform.pageNum + 1
  68. this.pageProjectHistory()
  69. }
  70. },
  71. changetabs() {
  72. this.loading = true
  73. if (this.active == 0) {
  74. this.planform.pageNum = 1
  75. this.pageAppProject()
  76. } else if (this.active == 1) {
  77. this.historyform.pageNum = 1
  78. this.pageProjectHistory()
  79. }
  80. },
  81. async pageAppProject() {
  82. const res = await pageAppProject(this.planform)
  83. this.loading = false
  84. if (this.planform.pageNum == 1) {
  85. this.planformList = res.data.records
  86. } else {
  87. this.planformList = this.planformList.concat(res.data.records)
  88. }
  89. if (this.planformList.length >= res.data.total) {
  90. this.finished = true
  91. } else {
  92. this.finished = false
  93. }
  94. },
  95. async pageProjectHistory() {
  96. const res = await pageProjectHistory(this.historyform)
  97. this.loading = false
  98. if (this.historyform.pageNum == 1) {
  99. this.historyList = res.data.records
  100. } else {
  101. this.historyList = this.historyList.concat(res.data.records)
  102. }
  103. if (this.historyList.length >= res.data.total) {
  104. this.finished = true
  105. } else {
  106. this.finished = false
  107. }
  108. },
  109. },
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .box {
  114. position: fixed;
  115. top: 80px;
  116. width: 100%;
  117. z-index: 9999;
  118. }
  119. .mt {
  120. margin-top: 80px;
  121. }
  122. .his {
  123. margin-top: 100px;
  124. }
  125. </style>