ProjectInspection.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="insp-container">
  3. <uv-empty v-if="projectStore.fetchInspListLoading" mode="list" text="加载中..."></uv-empty>
  4. <uv-empty v-else-if="!projectStore.inspList || projectStore.inspList.length === 0" mode="data" text="暂无中检信息"></uv-empty>
  5. <view v-else class="list-wrapper">
  6. <CommonListCard
  7. v-for="(item, index) in projectStore.inspList"
  8. :key="index"
  9. :title="String(item.batchName || '未知批次')"
  10. :statusLabel="getStatusLabel(item.approvalStatus)"
  11. :statusType="getStatusType(item.approvalStatus)"
  12. @click="handleDetail(item)"
  13. >
  14. <CommonInfoRow
  15. label="负责人"
  16. :value="item.projectHeadName || '--'"
  17. />
  18. <CommonInfoRow
  19. v-if="item.projectStartDate || item.projectEndDate"
  20. label="项目起止"
  21. :value="formatDate(item.projectStartDate) + ' 至 ' + formatDate(item.projectEndDate)"
  22. />
  23. <CommonInfoRow
  24. v-if="item.startDate || item.endDate"
  25. label="中检起止"
  26. :value="formatDate(item.startDate) + ' 至 ' + formatDate(item.endDate)"
  27. noBorder
  28. />
  29. </CommonListCard>
  30. </view>
  31. <!-- 详情弹窗 -->
  32. <InspDetailPopup ref="detailPopupRef" />
  33. </view>
  34. </template>
  35. <script setup lang="ts">
  36. import { ref, onMounted } from 'vue';
  37. import { useProjectStore } from '@/store/modules/project';
  38. import { inspApprovalStatusOptions } from '@/constants';
  39. import InspDetailPopup from './InspDetailPopup.vue';
  40. import { formatDate } from '@/utils/date';
  41. import CommonListCard from '@/components/ui/CommonListCard.vue';
  42. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  43. const props = defineProps<{
  44. projectId: number;
  45. projectType: string;
  46. }>();
  47. const projectStore = useProjectStore();
  48. const detailPopupRef = ref<any>(null);
  49. /**
  50. * 页面加载时根据传进来的projectId发请求获取中检列表数据
  51. */
  52. onMounted(() => {
  53. if (props.projectId) {
  54. projectStore.fetchInspList(props.projectId, props.projectType);
  55. }
  56. });
  57. /**
  58. * 获取状态标签展示处理
  59. */
  60. const getStatusLabel = (status: string | number) => {
  61. if (!status) return '待提交';
  62. const match = inspApprovalStatusOptions.find(o => o.dictValue == status);
  63. return String(match ? match.dictLabel : status);
  64. };
  65. /**
  66. * 获取对应状态的 UI 类型
  67. */
  68. const getStatusType = (status: string | number) => {
  69. const match = inspApprovalStatusOptions.find(o => o.dictValue == status);
  70. if (!match) return 'info';
  71. return match.type || 'primary';
  72. };
  73. /**
  74. * 查看中检详情
  75. */
  76. const handleDetail = (item: any) => {
  77. detailPopupRef.value?.open(item, props.projectType);
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. .insp-container {
  82. min-height: 400rpx;
  83. position: relative;
  84. }
  85. .list-wrapper {
  86. display: flex;
  87. flex-direction: column;
  88. gap: 20rpx;
  89. }
  90. </style>