my-list.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="common-page" style="padding: 0;">
  3. <view class="filter-bar">
  4. <view class="picker-trigger" @tap="pickerShow = true">
  5. <text class="picker-label">{{ selectedTaskType?.text || '任务类型' }}</text>
  6. <u-icon name="arrow-down" size="16" color="#666"></u-icon>
  7. </view>
  8. <u-button class="ml-10" type="primary" size="small" @click="onQuery">查询</u-button>
  9. <u-button class="ml-10" size="small" @click="onReset">重置</u-button>
  10. </view>
  11. <u-picker :show="pickerShow" :columns="[taskTypeOptions]" title="选择任务类型" @confirm="onPickConfirm"
  12. @cancel="pickerShow = false" @close="pickerShow = false"></u-picker>
  13. <PageScroll requestStr="/app/workOrder/getMyWorkOrder" @updateList="updateList" ref="scrollRef"
  14. :otherParams="otherParams" method="get" :diffHeight="150">
  15. <WorkorderItem v-for="(cell, idx) in dataList" :key="idx" :item="cell" :showDuration="false"
  16. @click="goDetail(cell)" class="mt-20" />
  17. </PageScroll>
  18. </view>
  19. </template>
  20. <script setup>
  21. import { ref } from 'vue'
  22. import { onShow } from '@dcloudio/uni-app'
  23. import PageScroll from '@/components/pageScroll/index.vue'
  24. import WorkorderItem from '../components/workorder-item.vue'
  25. const dataList = ref([])
  26. const scrollRef = ref(null)
  27. const pickerShow = ref(false)
  28. const selectedTaskType = ref(null)
  29. const taskTypeOptions = ref([])
  30. const getTaskTypeOptions = async () => {
  31. try {
  32. const res = await uni.$u.http.get('/system/dict/data/type/task_type')
  33. if (res.code === 200 && res.data) {
  34. taskTypeOptions.value = [{ text: '全部', value: '' }].concat(res.data.map(item => ({
  35. text: item.dictLabel,
  36. value: parseInt(item.dictValue)
  37. })))
  38. }
  39. } catch (e) {
  40. console.error('获取任务类型失败', e)
  41. }
  42. }
  43. const otherParams = ref({
  44. type: 2,
  45. taskType: ''
  46. })
  47. const updateList = (data) => {
  48. dataList.value = data
  49. }
  50. const refreshList = () => {
  51. scrollRef.value?.resetUpScroll()
  52. }
  53. const onPickConfirm = (e) => {
  54. const val = e?.value?.[0]
  55. selectedTaskType.value = val
  56. otherParams.value.taskType = val?.value || ''
  57. pickerShow.value = false
  58. }
  59. const onQuery = () => {
  60. refreshList()
  61. }
  62. const onReset = () => {
  63. selectedTaskType.value = null
  64. otherParams.value.taskType = ''
  65. refreshList()
  66. }
  67. const goDetail = (cell) => {
  68. const id = cell?.id || ''
  69. uni.navigateTo({
  70. url: `/pages/order/recycle/detail?id=${id}`
  71. })
  72. }
  73. onShow(() => {
  74. getTaskTypeOptions()
  75. refreshList()
  76. })
  77. </script>
  78. <style lang="scss" scoped>
  79. .filter-bar {
  80. display: flex;
  81. align-items: center;
  82. padding: 20rpx;
  83. background-color: #ffffff;
  84. gap: 16rpx;
  85. }
  86. .picker-trigger {
  87. flex: 1;
  88. display: flex;
  89. align-items: center;
  90. justify-content: space-between;
  91. padding: 10rpx 20rpx;
  92. border: 1rpx solid #e6e8eb;
  93. border-radius: 8rpx;
  94. min-width: 200px;
  95. }
  96. .picker-label {
  97. font-size: 28rpx;
  98. color: #333;
  99. }
  100. .ml-10 { margin-left: 10rpx; }
  101. .mt-20 { margin-top: 20rpx; }
  102. </style>