TaskList.vue 2.6 KB

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