index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view v-if="!refreshPage" class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="任务" :show-left="!showTabbar">
  6. <!-- #ifndef MP-WEIXIN -->
  7. <button
  8. class="button white-btn"
  9. @click="handleToSearch">
  10. <text class="wk wk-search" />
  11. </button>
  12. <!-- #endif -->
  13. </wk-nav-bar>
  14. <!-- #ifdef MP-WEIXIN -->
  15. <view class="search-box linear-gradient">
  16. <view class="box" @click="handleToSearch">
  17. <text class="wk wk-search" />
  18. <text class="wk-placeholder">
  19. 请输入任务名称
  20. </text>
  21. </view>
  22. </view>
  23. <!-- #endif -->
  24. <view class="filter-group">
  25. <wk-base-filter :tabs="taskOptions" @filter="handleFilter" />
  26. </view>
  27. <wk-scroll-view
  28. :status="listStatus"
  29. class="list-scroll"
  30. @refresh="getList({}, true)"
  31. @loadmore="getList()">
  32. <task-item
  33. v-for="(item, index) in listData"
  34. :key="index"
  35. :index="index"
  36. :item-data="item"
  37. @status="handleToChangeStatus" />
  38. </wk-scroll-view>
  39. </view>
  40. <wk-drag-button
  41. v-if="showAddBtn"
  42. @click="handleToAdd">
  43. <view class="wk-drag-btn">
  44. <text class="wk wk-plus icon" />
  45. </view>
  46. </wk-drag-button>
  47. <uni-popup ref="popup" type="dialog">
  48. <uni-popup-dialog
  49. :content="dialogMsg"
  50. type="warning"
  51. @confirm="handleDialogConfirm" />
  52. </uni-popup>
  53. <wk-tabbar
  54. v-if="showTabbar"
  55. v-model="footerIndex"
  56. :list="mixinFooterNav" />
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. QueryTaskList,
  62. SetWorkTaskStatus,
  63. SaveWorkTask
  64. } from 'API/oa/task'
  65. import TaskItem from './components/taskItem.vue'
  66. import tabbar from '@/mixins/tabbar.js'
  67. import mainListMixins from '@/mixins/mainList.js'
  68. import { mapGetters } from 'vuex'
  69. export default {
  70. name: 'TaskIndex',
  71. components: {
  72. TaskItem
  73. },
  74. mixins: [tabbar, mainListMixins],
  75. data() {
  76. return {
  77. guid: null,
  78. filterData: {
  79. type: 1,
  80. status: 1
  81. },
  82. refreshPage: false,
  83. taskOptions: [
  84. {
  85. label: '任务类型',
  86. field: 'type',
  87. value: 0,
  88. valueData: 0,
  89. options: [
  90. {label: '全部', value: 0},
  91. {label: '我负责的', value: 1},
  92. {label: '我参与的', value: 3}
  93. ]
  94. },
  95. {
  96. label: '任务状态',
  97. field: 'status',
  98. value: 1,
  99. valueData: 1,
  100. options: [
  101. {label: '全部', value: '_delete_'},
  102. {label: '正在进行', value: 1},
  103. {label: '已结束', value: 5}
  104. ]
  105. },
  106. {
  107. label: '优先级',
  108. field: 'priority',
  109. value: '_delete_',
  110. valueData: 0,
  111. options: [
  112. {label: '全部', value: '_delete_'},
  113. {label: '高', value: 3},
  114. {label: '中', value: 2},
  115. {label: '低', value: 1},
  116. {label: '无', value: 0},
  117. ]
  118. },
  119. ],
  120. dialogMsg: '',
  121. dialogConfig: null
  122. }
  123. },
  124. computed: {
  125. showAddBtn() {
  126. // return this.$auth('crm.customer.save')
  127. return true
  128. }
  129. },
  130. onShow() {
  131. if (this.refreshPage) {
  132. this.$nextTick(() => {
  133. this.refreshPage = false
  134. this.getList({}, true)
  135. })
  136. }
  137. },
  138. onLoad(options) {
  139. if (options.type) {
  140. const val = Number(options.type)
  141. if (!isNaN(val)) {
  142. const findIndex = this.taskOptions[0].options.findIndex(o => o.value === val)
  143. if (findIndex !== -1) {
  144. this.taskOptions[0].valueData = findIndex
  145. this.taskOptions[0].value = val
  146. this.filterData.type = val
  147. }
  148. }
  149. }
  150. this.getList()
  151. },
  152. methods: {
  153. getList(params = {}, refresh = false) {
  154. this.listStatus = 'loading'
  155. if (refresh) {
  156. this.listParams.page = 0
  157. }
  158. this.listParams.page++
  159. this.listParams = Object.assign(this.listParams, params)
  160. QueryTaskList({
  161. ...this.listParams,
  162. ...this.filterData
  163. }).then(response => {
  164. const res = response.page
  165. if (this.listParams.page === 1) {
  166. this.listData = []
  167. }
  168. this.listData = this.listData.concat(res.list)
  169. if (res.hasOwnProperty('lastPage')) {
  170. this.listStatus = res.lastPage ? 'noMore' : 'more'
  171. } else {
  172. this.listStatus = res.list.length === 0 ? 'noMore' : 'more'
  173. }
  174. }).catch(() => {
  175. this.listStatus = 'more'
  176. })
  177. },
  178. handleToSearch() {
  179. this.$Router.navigateTo('/pages_task/search')
  180. },
  181. handleFilter(item) {
  182. this.filterData[item.field] = item.value
  183. if (this.filterData.status === '_delete_') {
  184. delete this.filterData.status
  185. }
  186. if (this.filterData.priority === '_delete_') {
  187. delete this.filterData.priority
  188. }
  189. this.getList({}, true)
  190. },
  191. handleToChangeStatus(data) {
  192. this.dialogMsg = '您确定要更改该任务的状态吗?'
  193. this.dialogConfig = data
  194. this.$refs.popup.open()
  195. },
  196. handleDialogConfirm(next) {
  197. if (!this.dialogConfig) {
  198. next()
  199. return
  200. }
  201. SetWorkTaskStatus({
  202. taskId: this.dialogConfig.taskId,
  203. status: this.dialogConfig.status
  204. }).then(() => {
  205. this.$toast('更改成功')
  206. const index = this.dialogConfig.index
  207. this.listData[index].status = this.dialogConfig.status
  208. this.$set(this.listData, index, this.listData[index])
  209. next()
  210. this.dialogConfig = null
  211. }).catch(() => {})
  212. },
  213. handleToAdd() {
  214. this.$Router.navigateTo({
  215. url: '/pages_task/add'
  216. })
  217. }
  218. }
  219. }
  220. </script>
  221. <style scoped lang="scss">
  222. .main-container {
  223. .white-btn {
  224. .wk-search {
  225. font-weight: 400;
  226. font-size: 42rpx;
  227. }
  228. }
  229. .search-box {
  230. width: 100%;
  231. padding: 10rpx 32rpx 20rpx;
  232. .box {
  233. width: 100%;
  234. height: 62rpx;
  235. color: #BBBBBB;
  236. background-color: white;
  237. border-radius: 12rpx;
  238. padding: 0 20rpx;
  239. @include left;
  240. .wk-search {
  241. margin-right: 15rpx;
  242. }
  243. }
  244. }
  245. .list-scroll {
  246. flex: 1;
  247. overflow-y: hidden;
  248. }
  249. }
  250. </style>