task.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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="190" 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. onLoad() {
  84. let taskType=uni.getStorageSync('taskType')
  85. if(taskType){
  86. uni.removeStorage('taskType')
  87. this.current=taskType
  88. }
  89. this.startList()
  90. },
  91. mounted() {
  92. },
  93. methods: {
  94. setProductId(productId) {
  95. console.log('productId:' + productId)
  96. this.productId = productId
  97. this.startList()
  98. },
  99. startList() {
  100. if (this.current === 1) {
  101. this.getDayBacklogList()
  102. } else {
  103. this.totalNum = 999;
  104. this.taskList = [];
  105. this.page = 1;
  106. this.isAjax = false;
  107. this.getTaskReceiving();
  108. }
  109. },
  110. getDayBacklogList() {
  111. if (this.isAjax || (this.totalNum <= this.backlogList.length)) {
  112. return;
  113. }
  114. getDayBacklogList({
  115. 'selectStr': this.selectStr
  116. }).then((res) => {
  117. if (res.code === 1) {
  118. this.backlogList = res.data.items
  119. this.totalNum = res.data.totalNum
  120. }
  121. })
  122. },
  123. getTaskReceiving() {
  124. if (this.isAjax || (this.totalNum <= this.taskList.length)) {
  125. return;
  126. }
  127. this.isAjax = true;
  128. getTaskList({
  129. 'status': this.tabsList[this.current].id,
  130. 'selectStr': this.selectStr,
  131. 'phone': this.phone,
  132. 'name': this.name,
  133. 'productId': this.productId,
  134. 'stageId': this.stageId,
  135. 'departmentId': this.departmentId,
  136. 'startDate': this.startDate,
  137. 'endDate': this.endDate,
  138. 'page': this.page,
  139. }).then((res) => {
  140. this.isAjax = false;
  141. if (res.code === 1) {
  142. this.totalNum = res.data.totalNum
  143. this.taskList.push(...res.data.items)
  144. ++this.page;
  145. }
  146. })
  147. },
  148. tabsChange(index) {
  149. if (index !== this.current) {
  150. this.current = index;
  151. this.startList()
  152. }
  153. },
  154. // 下拉刷新
  155. onRefresh() {
  156. this.startList()
  157. },
  158. // 滚动到底部
  159. onScrollBottom() {
  160. if (this.current === 1) {
  161. this.getDayBacklogList()
  162. } else {
  163. this.getTaskReceiving();
  164. }
  165. },
  166. },
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. </style>