ProjectInspection.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. v-if="item.projectStartDate || item.projectEndDate"
  16. label="项目起止"
  17. :value="formatDate(item.projectStartDate) + ' 至 ' + formatDate(item.projectEndDate)"
  18. />
  19. <CommonInfoRow
  20. v-if="item.startDate || item.endDate"
  21. label="中检起止"
  22. :value="formatDate(item.startDate) + ' 至 ' + formatDate(item.endDate)"
  23. noBorder
  24. />
  25. </CommonListCard>
  26. </view>
  27. <!-- 详情弹窗 -->
  28. <InspDetailPopup ref="detailPopupRef" />
  29. </view>
  30. </template>
  31. <script setup lang="ts">
  32. import { ref, onMounted } from 'vue';
  33. import { useProjectStore } from '@/store/modules/project';
  34. import { inspApprovalStatusOptions } from '@/constants';
  35. import InspDetailPopup from './InspDetailPopup.vue';
  36. import { formatDate } from '@/utils/date';
  37. import CommonListCard from '@/components/ui/CommonListCard.vue';
  38. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  39. const props = defineProps<{
  40. projectId: number;
  41. projectType: string;
  42. }>();
  43. const projectStore = useProjectStore();
  44. const detailPopupRef = ref<any>(null);
  45. /**
  46. * 页面加载时根据传进来的projectId发请求获取中检列表数据
  47. */
  48. onMounted(() => {
  49. if (props.projectId) {
  50. projectStore.fetchInspList(props.projectId, props.projectType);
  51. }
  52. });
  53. /**
  54. * 获取状态标签展示处理
  55. */
  56. const getStatusLabel = (status: string | number) => {
  57. if (!status) return '待提交';
  58. const match = inspApprovalStatusOptions.find(o => o.dictValue == status);
  59. return String(match ? match.dictLabel : status);
  60. };
  61. /**
  62. * 获取对应状态的 UI 类型
  63. */
  64. const getStatusType = (status: string | number) => {
  65. const match = inspApprovalStatusOptions.find(o => o.dictValue == status);
  66. if (!match) return 'info';
  67. return match.type || 'primary';
  68. };
  69. /**
  70. * 查看中检详情
  71. */
  72. const handleDetail = (item: any) => {
  73. detailPopupRef.value?.open(item, props.projectType);
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .insp-container {
  78. min-height: 400rpx;
  79. position: relative;
  80. }
  81. .list-wrapper {
  82. display: flex;
  83. flex-direction: column;
  84. gap: 20rpx;
  85. }
  86. </style>