task.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="total-page page-box page-env-20 scroll_content task-bg">
  3. <Nav :title="'任务'" :genre="1" :back="false" is_fixed></Nav>
  4. <view>
  5. <Search :placeholder="'客户姓名或电话'"></Search>
  6. <view style="height: 100rpx;">
  7. <z-tabs ref="tabs" :list="tabsList" :active-style="{color:'#10B261',fontWeight:'bold',fontSize:'28rpx'}"
  8. :bar-style="{background:'#10B261'}" :inactive-style="{fontWeight:'bold',fontSize:'28rpx'}"
  9. :current="current" :bar-animate-mode="'worm'" @change="tabsChange" />
  10. </view>
  11. </view>
  12. <task-ima-tab @setProductId="setProductId" :num-type="0"></task-ima-tab>
  13. <EnScroll ref="scroll" :navHeight="105" is_tabHeight @onRefresh="onRefresh" @onScrollBottom="onScrollBottom">
  14. <view v-if="current===1">
  15. <TaskItem :type="5" is_bottom :task-list="backlogList"></TaskItem>
  16. </view>
  17. <view v-else>
  18. <TaskItem :type="1" is_bottom :task-list="taskList"></TaskItem>
  19. </view>
  20. </EnScroll>
  21. <Tab :tab-index="1"></Tab>
  22. </view>
  23. </template>
  24. <script>
  25. // 任务列表
  26. import TaskItem from "@/common/task/task-item.vue";
  27. import TaskImaTab from "@/common/task/task_ima_tab.vue";
  28. import {
  29. getDayBacklogList,
  30. getTaskList
  31. } from "@/api/task";
  32. export default {
  33. components: {
  34. TaskImaTab,
  35. TaskItem,
  36. },
  37. data() {
  38. return {
  39. tabHeight: uni.getStorageSync('tab_height'),
  40. current: 0,
  41. swiperCurrent: 0,
  42. tabsList: [{
  43. name: '全部',
  44. dot_color: 'red',
  45. disabled: false,
  46. 'id': 0,
  47. }, {
  48. name: '新进',
  49. dot_color: 'yellow',
  50. disabled: false,
  51. 'id': 6,
  52. }, {
  53. 'id': 1,
  54. name: '待办',
  55. dot_color: '',
  56. disabled: false
  57. }, {
  58. 'id': 2,
  59. name: '完成',
  60. dot_color: '',
  61. disabled: false
  62. }, {
  63. 'id': 3,
  64. name: '拒绝',
  65. dot_color: '',
  66. disabled: false
  67. }],
  68. selectStr: '',
  69. startDate: '',
  70. endDate: '',
  71. phone: '',
  72. name: '',
  73. productId: 0,
  74. stageId: [],
  75. departmentId: [],
  76. totalNum: 99999,
  77. taskList: [],
  78. page: 1,
  79. isAjax: false,
  80. backlogList: [],
  81. }
  82. },
  83. mounted() {
  84. this.startList()
  85. },
  86. methods: {
  87. setProductId(productId) {
  88. console.log('productId:' + productId)
  89. this.productId = productId
  90. this.startList()
  91. },
  92. startList() {
  93. if (this.current === 1) {
  94. this.getDayBacklogList()
  95. } else {
  96. this.totalNum = 999;
  97. this.taskList = [];
  98. this.page = 1;
  99. this.isAjax = false;
  100. this.getTaskReceiving();
  101. }
  102. },
  103. getDayBacklogList() {
  104. if (this.isAjax || (this.totalNum <= this.backlogList.length)) {
  105. return;
  106. }
  107. getDayBacklogList({
  108. 'selectStr': this.selectStr
  109. }).then((res) => {
  110. if (res.code === 1) {
  111. this.backlogList = res.data.items
  112. this.totalNum = res.data.totalNum
  113. }
  114. })
  115. },
  116. getTaskReceiving() {
  117. if (this.isAjax || (this.totalNum <= this.taskList.length)) {
  118. return;
  119. }
  120. this.isAjax = true;
  121. getTaskList({
  122. 'status': this.tabsList[this.current].id,
  123. 'selectStr': this.selectStr,
  124. 'phone': this.phone,
  125. 'name': this.name,
  126. 'productId': this.productId,
  127. 'stageId': this.stageId,
  128. 'departmentId': this.departmentId,
  129. 'startDate': this.startDate,
  130. 'endDate': this.endDate,
  131. 'page': this.page,
  132. }).then((res) => {
  133. this.isAjax = false;
  134. if (res.code === 1) {
  135. this.totalNum = res.data.totalNum
  136. this.taskList.push(...res.data.items)
  137. ++this.page;
  138. }
  139. })
  140. },
  141. tabsChange(index) {
  142. if (index !== this.current) {
  143. this.current = index;
  144. this.startList()
  145. }
  146. },
  147. // 下拉刷新
  148. onRefresh() {
  149. this.startList()
  150. },
  151. // 滚动到底部
  152. onScrollBottom() {
  153. if (this.current === 1) {
  154. this.getDayBacklogList()
  155. } else {
  156. this.getTaskReceiving();
  157. }
  158. },
  159. },
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. </style>