pending.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="common-page" style="padding: 0;">
  3. <view class="filter-bar">
  4. <view class="picker-trigger" @tap.stop="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/getMyHandleWorkOrder" @updateList="updateList" ref="scrollRef"
  14. :otherParams="otherParams" method="get" :diffHeight="150">
  15. <WorkorderItem v-for="(cell, idx) in dataList" :key="idx" :item="cell" :showDuration="true"
  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. // 获取任务类型字典
  31. const getTaskTypeOptions = async () => {
  32. try {
  33. const res = await uni.$u.http.get('/system/dict/data/type/task_type')
  34. if (res.code === 200 && res.data) {
  35. // 添加"全部"选项
  36. taskTypeOptions.value = [
  37. { text: '全部', value: '' }
  38. ].concat(res.data.map(item => ({
  39. text: item.dictLabel,
  40. value: parseInt(item.dictValue)
  41. })))
  42. }
  43. } catch (e) {
  44. console.error('获取任务类型失败', e)
  45. }
  46. }
  47. const otherParams = ref({
  48. type: 2, // 工单类型:2-收书
  49. taskType: '' // 任务类型
  50. })
  51. const updateList = (data) => {
  52. console.log(data, 'data')
  53. // 如果data是响应对象,提取rows
  54. dataList.value = data
  55. }
  56. const refreshList = () => {
  57. scrollRef.value?.resetUpScroll()
  58. }
  59. const onPickConfirm = (e) => {
  60. const val = e?.value?.[0]
  61. selectedTaskType.value = val
  62. otherParams.value = {
  63. ...otherParams.value,
  64. taskType: val?.value === '' || val?.value === undefined ? '' : val.value
  65. }
  66. pickerShow.value = false
  67. refreshList()
  68. }
  69. const onQuery = () => {
  70. refreshList()
  71. }
  72. const onReset = () => {
  73. selectedTaskType.value = null
  74. otherParams.value.taskType = ''
  75. refreshList()
  76. }
  77. const goDetail = (cell) => {
  78. const id = cell?.id || ''
  79. uni.navigateTo({
  80. url: `/pages/order/recycle/detail?id=${id}`
  81. })
  82. }
  83. onShow(() => {
  84. // 加载任务类型字典
  85. getTaskTypeOptions()
  86. refreshList()
  87. })
  88. </script>
  89. <style lang="scss" scoped>
  90. .filter-bar {
  91. display: flex;
  92. align-items: center;
  93. padding: 20rpx;
  94. background-color: #ffffff;
  95. gap: 16rpx;
  96. }
  97. .picker-trigger {
  98. flex: 1;
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-between;
  102. padding: 10rpx 20rpx;
  103. border: 1rpx solid #e6e8eb;
  104. border-radius: 8rpx;
  105. min-width: 200px;
  106. }
  107. .picker-label {
  108. font-size: 28rpx;
  109. color: #333;
  110. }
  111. .list-con {
  112. padding: 10rpx 30rpx;
  113. gap: 30rpx;
  114. }
  115. .ml-10 {
  116. margin-left: 10rpx;
  117. }
  118. </style>