task.vue 3.9 KB

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