task.vue 4.1 KB

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