ShowDetailDrawer.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script setup lang="ts">
  2. /**
  3. * @Name: ShowDetailDrawer.vue
  4. * @Description: 产品属性-查看详情抽屉
  5. * @Author: xinyan
  6. */
  7. import * as api from '../api';
  8. import { useResponse } from '/@/utils/useResponse';
  9. import { Warning } from '@element-plus/icons-vue';
  10. const showDetailDrawer = <Ref>useTemplateRef('showEnumDrawer');
  11. const viewOpen = defineModel({ default: false });
  12. const props = defineProps({
  13. rowData: <any>Object,
  14. });
  15. const { rowData } = props;
  16. const deptData = ref([]);
  17. async function fetchAllDept() {
  18. const resp = await useResponse(api.getAllDept)
  19. deptData.value = resp.data;
  20. }
  21. function getDeptName(id) {
  22. const department = deptData.value.find(dept => dept.id === Number(id)); // 确保 id 是数字
  23. return department ? department.name : id;
  24. }
  25. onMounted(() => {
  26. fetchAllDept();
  27. });
  28. </script>
  29. <template>
  30. <div class="drawer-container">
  31. <el-drawer ref="showDetailDrawer" v-model="viewOpen" style="width: 40%" >
  32. <template #title>
  33. <div>
  34. <span style="font-size: 16px; font-weight: bold">查看:</span>
  35. <el-check-tag checked style="pointer-events: none;margin-left: 5px">{{ rowData.name }}</el-check-tag>
  36. </div>
  37. </template>
  38. <div class="p-5">
  39. <el-descriptions :column="1" border>
  40. <el-descriptions-item label="ID">
  41. {{ rowData.id }}
  42. </el-descriptions-item>
  43. <el-descriptions-item label="属性名称">
  44. {{ rowData.name }}
  45. </el-descriptions-item>
  46. <el-descriptions-item label="数据值">
  47. {{ rowData.key }}
  48. </el-descriptions-item>
  49. <el-descriptions-item label="创建人">
  50. {{ rowData.creator_name }}
  51. </el-descriptions-item>
  52. <el-descriptions-item label="所属部门">
  53. <template #label>
  54. <div style="display: flex;align-items: center">
  55. 所属部门
  56. <el-tooltip effect="dark" content="默认不填则为当前创建用户的部门ID" placement="top">
  57. <el-icon>
  58. <Warning />
  59. </el-icon>
  60. </el-tooltip>
  61. </div>
  62. </template>
  63. {{ getDeptName(rowData.dept_belong_id) }}
  64. </el-descriptions-item>
  65. <el-descriptions-item label="更新时间">
  66. {{ rowData.update_datetime }}
  67. </el-descriptions-item>
  68. <el-descriptions-item label="创建时间">
  69. {{ rowData.create_datetime }}
  70. </el-descriptions-item>
  71. </el-descriptions>
  72. </div>
  73. </el-drawer>
  74. </div>
  75. </template>
  76. <style scoped>
  77. </style>