search.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="uni-app">
  3. <view class="status-bar" />
  4. <view class="main-container">
  5. <wk-nav-bar title="任务" />
  6. <view class="search-box">
  7. <text class="wk wk-search" />
  8. <input
  9. v-model="keyword"
  10. type="text"
  11. :maxlength="50"
  12. placeholder="请输入任务名称"
  13. placeholder-class="wk-placeholder"
  14. class="input-core">
  15. <image
  16. :src="$static('images/icon/delete_fill.png')"
  17. alt=""
  18. class="delete-icon"
  19. @click="handleClear" />
  20. </view>
  21. <view class="list-view">
  22. <wk-scroll-view
  23. :status="listStatus"
  24. :refresh="false"
  25. class="list-scroll"
  26. @loadmore="getList()">
  27. <task-item
  28. v-for="(item, index) in listData"
  29. :key="index"
  30. :index="index"
  31. :item-data="item"
  32. @status="handleToChangeStatus" />
  33. </wk-scroll-view>
  34. </view>
  35. </view>
  36. <uni-popup ref="popup" type="dialog">
  37. <uni-popup-dialog
  38. :content="dialogMsg"
  39. type="warning"
  40. @confirm="handleDialogConfirm" />
  41. </uni-popup>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. QueryTaskList,
  47. SetWorkTaskStatus,
  48. SaveWorkTask
  49. } from 'API/oa/task'
  50. import TaskItem from './components/taskItem.vue'
  51. export default {
  52. name: 'TaskSearch',
  53. components: {
  54. TaskItem
  55. },
  56. data() {
  57. return {
  58. keyword: '',
  59. timer: null,
  60. params: {
  61. page: 0,
  62. limit: 15,
  63. type: 0,
  64. search: ''
  65. },
  66. listStatus: 'more',
  67. listData: [],
  68. dialogMsg: '',
  69. dialogConfig: null
  70. }
  71. },
  72. watch: {
  73. keyword(val) {
  74. // 禁止输入 emoji
  75. const regStr = /[\ud800-\udbff]|[\udc00-\udfff]/g;
  76. if (regStr.test(val)) {
  77. val = val.replace(regStr, '');
  78. }
  79. this.keyword = val
  80. this.params.page = 0
  81. if (this.timer) {
  82. clearTimeout(this.timer)
  83. this.timer = null
  84. }
  85. this.timer = setTimeout(() => {
  86. clearTimeout(this.timer)
  87. this.timer = null
  88. this.params.search = this.keyword
  89. this.getList()
  90. }, 800)
  91. },
  92. },
  93. methods: {
  94. /**
  95. * 获取选项列表
  96. */
  97. getList() {
  98. this.params.page++
  99. this.listStatus = 'loading'
  100. QueryTaskList({
  101. ...this.params
  102. }).then(response => {
  103. const res = response.page
  104. if (this.params.page === 1) {
  105. this.listData = []
  106. }
  107. console.log(res.list)
  108. this.listData = this.listData.concat(res.list)
  109. this.listStatus = res.lastPage ? 'noMore' : 'more'
  110. }).catch(() => {
  111. this.listStatus = 'more'
  112. })
  113. },
  114. handleClear() {
  115. this.keyword = ''
  116. },
  117. handleToChangeStatus(data) {
  118. this.dialogMsg = '您确定要更改该任务的状态吗?'
  119. this.dialogConfig = data
  120. this.$refs.popup.open()
  121. },
  122. handleDialogConfirm(next) {
  123. if (!this.dialogConfig) {
  124. next()
  125. return
  126. }
  127. SetWorkTaskStatus({
  128. taskId: this.dialogConfig.taskId,
  129. status: this.dialogConfig.status
  130. }).then(() => {
  131. this.$toast('更改成功')
  132. const index = this.dialogConfig.index
  133. this.listData[index].status = this.dialogConfig.status
  134. this.$set(this.listData, index, this.listData[index])
  135. next()
  136. this.dialogConfig = null
  137. }).catch(() => {})
  138. },
  139. }
  140. }
  141. </script>
  142. <style scoped lang="scss">
  143. .main-container {
  144. .search-box {
  145. background-color: white;
  146. padding: 10rpx 30rpx;
  147. @include left;
  148. .wk-search {
  149. font-size: 38rpx;
  150. color: $light;
  151. }
  152. .input-core {
  153. flex: 1;
  154. height: 76rpx;
  155. font-size: 28rpx;
  156. padding: 0 20rpx;
  157. display: block;
  158. }
  159. .delete-icon {
  160. width: 32rpx;
  161. height: 32rpx;
  162. }
  163. }
  164. .list-view {
  165. flex: 1;
  166. overflow: hidden;
  167. margin-top: 15rpx;
  168. .list-scroll {
  169. width: 100%;
  170. height: 100%;
  171. overflow: hidden;
  172. .cell {
  173. border-bottom: 1rpx solid $border-color;
  174. padding: 20rpx 0;
  175. .cell-title {
  176. font-size: 30rpx;
  177. }
  178. .cell-desc {
  179. font-size: 24rpx;
  180. color: $gray;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. </style>