lotDetail.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div v-loading="loading">
  3. <el-descriptions
  4. v-if="detail.ID"
  5. :column="3"
  6. border
  7. >
  8. <el-descriptions-item label="ID">{{ detail.ID }}</el-descriptions-item>
  9. <el-descriptions-item label="区域编码">{{ detail.lot_code }}</el-descriptions-item>
  10. <el-descriptions-item label="区域名称">{{ detail.lot_name }}</el-descriptions-item>
  11. <el-descriptions-item label="总车位">{{ detail.capacity }}</el-descriptions-item>
  12. <el-descriptions-item label="已占用">
  13. <span class="space-value occupied">{{ detail.occupied || 0 }}</span>
  14. </el-descriptions-item>
  15. <el-descriptions-item label="剩余车位">
  16. <span class="space-value" :class="{ full: detail.available === 0 }">{{ detail.available || 0 }}</span>
  17. </el-descriptions-item>
  18. <el-descriptions-item label="满位准入" :span="3">
  19. <div class="policy-tags">
  20. <el-tag :type="detail.allow_temporary_when_full ? 'success' : 'info'" effect="plain">
  21. 临时车{{ detail.allow_temporary_when_full ? '允许' : '禁止' }}
  22. </el-tag>
  23. <el-tag :type="detail.allow_monthly_when_full ? 'success' : 'info'" effect="plain">
  24. 月租车{{ detail.allow_monthly_when_full ? '允许' : '禁止' }}
  25. </el-tag>
  26. <el-tag :type="detail.allow_vip_when_full ? 'success' : 'info'" effect="plain">
  27. VIP 车{{ detail.allow_vip_when_full ? '允许' : '禁止' }}
  28. </el-tag>
  29. </div>
  30. </el-descriptions-item>
  31. <el-descriptions-item label="备注" :span="3">{{ detail.description || '-' }}</el-descriptions-item>
  32. <el-descriptions-item label="创建时间" :span="3">{{ detail.CreatedAt || '-' }}</el-descriptions-item>
  33. <el-descriptions-item label="更新时间" :span="3">{{ detail.UpdatedAt || '-' }}</el-descriptions-item>
  34. </el-descriptions>
  35. <div v-if="!detail.ID && !loading" style="text-align: center; color: #999; margin-top: 40px;">
  36. 请从左侧选择一个停车场
  37. </div>
  38. <div v-if="detail.ID" class="action-bar">
  39. <el-button type="primary" icon="Edit" @click="handleEdit">编辑</el-button>
  40. <el-button type="danger" icon="Delete" @click="handleDelete">删除</el-button>
  41. </div>
  42. </div>
  43. </template>
  44. <script setup>
  45. import { ref, watch } from 'vue'
  46. import { obtainPullOverId } from '@/api/pullOver'
  47. const props = defineProps({
  48. parkId: {
  49. type: Number,
  50. default: 0,
  51. },
  52. })
  53. const emit = defineEmits(['edit', 'delete'])
  54. const loading = ref(false)
  55. const detail = ref({})
  56. const fetchDetail = async (id) => {
  57. if (!id || id === 0) {
  58. detail.value = {}
  59. return
  60. }
  61. loading.value = true
  62. try {
  63. const res = await obtainPullOverId(id)
  64. if (res.code === 0) {
  65. detail.value = res.data || {}
  66. }
  67. } finally {
  68. loading.value = false
  69. }
  70. }
  71. const handleEdit = () => {
  72. emit('edit', detail.value)
  73. }
  74. const handleDelete = () => {
  75. emit('delete', detail.value.ID)
  76. }
  77. watch(
  78. () => props.parkId,
  79. (val) => {
  80. fetchDetail(val)
  81. },
  82. { immediate: true }
  83. )
  84. </script>
  85. <style scoped lang="scss">
  86. .action-bar {
  87. margin-top: 20px;
  88. display: flex;
  89. gap: 10px;
  90. }
  91. .space-value {
  92. color: #16805b;
  93. font-weight: 600;
  94. }
  95. .space-value.occupied {
  96. color: #b26a00;
  97. }
  98. .space-value.full {
  99. color: #c03639;
  100. }
  101. .policy-tags {
  102. display: flex;
  103. flex-wrap: wrap;
  104. gap: 8px;
  105. }
  106. </style>