TaskList.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="task">
  3. <van-action-sheet
  4. v-model:show="taskTrueFalseBy"
  5. title="任务中心"
  6. close-on-click-action
  7. @cancel="taskTrueFalseBy=false"
  8. >
  9. <div class="task-content">
  10. <table class="task-table">
  11. <thead>
  12. <tr>
  13. <th style="width: 80px">任务号</th>
  14. <th style="width: 60px">货主</th>
  15. <th style="width: 72px">创建时间</th>
  16. <th>创建人</th>
  17. <th style="width: 40px">状态</th>
  18. <th style="width: 50px">操作</th>
  19. </tr>
  20. </thead>
  21. <tbody>
  22. <tr v-for="(item, index) in taskList" :key="index" :class="{'odd-row': index % 2 !=0}">
  23. <td>{{ item.code }}</td>
  24. <td>{{ item.ownerName }}</td>
  25. <td>{{ item.createTime }}</td>
  26. <td>{{ item.creator }}</td>
  27. <td :style="statusStyle(item.status)" >{{ item.status }}</td>
  28. <td><van-button plain size="mini" type="primary" @click="onTaskDetail(item)">接受任务</van-button></td>
  29. </tr>
  30. </tbody>
  31. </table>
  32. </div>
  33. </van-action-sheet>
  34. </div>
  35. </template>
  36. <script setup lang="ts">
  37. import { nextTick, onMounted, ref } from 'vue'
  38. import { useRouter } from 'vue-router'
  39. const taskTrueFalseBy=ref(false)
  40. const taskList=ref({})
  41. onMounted(()=>{
  42. nextTick(() => {
  43. window.scrollTo(0, 0);
  44. });
  45. })
  46. const statusStyle = (status) => {
  47. switch (status) {
  48. case '作业中':
  49. return { color: '#ff941a' }
  50. case '创建':
  51. return { color: '#07c160' }
  52. default:
  53. return { color: '#000' }
  54. }
  55. }
  56. const show = async (list) => {
  57. taskList.value = list
  58. taskTrueFalseBy.value = true
  59. }
  60. const router = useRouter()
  61. const emit = defineEmits()
  62. const onTaskDetail = (item) => {
  63. taskTrueFalseBy.value = false
  64. if(item.type){
  65. router.push({name:'BlindTask',query: { code:item.code,typeCode:item.typeCode }})
  66. }else {
  67. emit('selectMode',item.code)
  68. }
  69. }
  70. defineExpose({show})
  71. </script>
  72. <style scoped lang="sass">
  73. .task
  74. .task-content
  75. width: 100%
  76. height: 65vh
  77. overflow-y: auto
  78. .task-table
  79. width: 100%
  80. border-collapse: collapse
  81. table-layout: fixed
  82. font-size: 12px
  83. .task-table th, .task-table td
  84. text-align: center
  85. border: 1px solid #ccc
  86. word-wrap: break-word
  87. word-break: break-all
  88. font-weight: 500
  89. .task-table thead
  90. background-color: #3f8dff
  91. position: sticky
  92. top: 0
  93. z-index: 1
  94. color: white
  95. font-size: 14px
  96. .task-table tbody tr.odd-row
  97. background-color: #e4f2ff
  98. </style>