ProjectChanges.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="module-container">
  3. <uv-empty v-if="projectStore.fetchChangeListLoading" mode="list" text="加载中..."></uv-empty>
  4. <uv-empty v-else-if="projectStore.changeList.length === 0" mode="data" text="暂无变更信息"></uv-empty>
  5. <view v-else class="list-wrapper">
  6. <CommonListCard
  7. v-for="(item, index) in projectStore.changeList"
  8. :key="index"
  9. :title="(index + 1) + '. ' + getChangeTypeName(item.changeType)"
  10. :statusLabel="getStatusLabel(item.approvalStatus)"
  11. :statusType="getStatusType(item.approvalStatus)"
  12. @click="handleViewDetail(item)"
  13. >
  14. <CommonInfoRow label="申请人" :value="item.createdName" />
  15. <CommonInfoRow label="申请时间" :value="item.createdTime ? dayjs(item.createdTime).format('YYYY-MM-DD') : '--'" noBorder />
  16. </CommonListCard>
  17. </view>
  18. <!-- 详情弹窗 -->
  19. <ChangeDetailPopup ref="detailPopupRef" />
  20. </view>
  21. </template>
  22. <script setup lang="ts">
  23. import { ref, onMounted } from 'vue';
  24. import { useProjectStore } from '@/store/modules/project';
  25. import { approvalStatusOptions, changeTypeOptions } from '@/constants';
  26. import ChangeDetailPopup from './ChangeDetailPopup.vue';
  27. import dayjs from 'dayjs';
  28. import CommonListCard from '@/components/ui/CommonListCard.vue';
  29. import CommonInfoRow from '@/components/ui/CommonInfoRow.vue';
  30. const props = defineProps<{
  31. projectId: number;
  32. projectType: string;
  33. }>();
  34. const projectStore = useProjectStore();
  35. const detailPopupRef = ref<any>(null);
  36. onMounted(() => {
  37. if (props.projectId) {
  38. projectStore.fetchProjectChanges(props.projectId, props.projectType);
  39. }
  40. });
  41. const handleViewDetail = (item: any) => {
  42. detailPopupRef.value?.open(item, props.projectType, props.projectId);
  43. };
  44. const getChangeTypeName = (type: string | number) => {
  45. const typeStr = String(type);
  46. const found = changeTypeOptions.find((opt: any) => opt.dictValue === typeStr);
  47. return found ? found.dictLabel : '未知变更';
  48. };
  49. const getStatusLabel = (status: string | number) => {
  50. const statusStr = String(status);
  51. const found = approvalStatusOptions.find((opt: any) => opt.dictValue === statusStr);
  52. return found ? found.dictLabel : '未知状态';
  53. };
  54. const getStatusType = (status: string | number) => {
  55. const statusStr = String(status);
  56. switch (statusStr) {
  57. case '10': return 'info';
  58. case '20': return 'primary';
  59. case '30': return 'success';
  60. case '40': return 'error';
  61. default: return 'info';
  62. }
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .module-container {
  67. min-height: 400rpx;
  68. position: relative;
  69. }
  70. .list-wrapper {
  71. display: flex;
  72. flex-direction: column;
  73. gap: 20rpx;
  74. }
  75. </style>