AssessmentBatchForm.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="document-form">
  3. <uv-loading-icon v-if="loading" mode="circle" text="正在加载详情..."></uv-loading-icon>
  4. <template v-else-if="form">
  5. <view class="common-section-card">
  6. <view class="section-title">基本信息</view>
  7. <view class="info-row">
  8. <text class="label">批次名称</text>
  9. <text class="value">{{ form.batchName || '-' }}</text>
  10. </view>
  11. <view class="info-row">
  12. <text class="label">考核方案</text>
  13. <text class="value">{{ currentSchemeLabel || '-' }}</text>
  14. </view>
  15. <view class="info-row">
  16. <text class="label">开始日期</text>
  17. <text class="value">{{ form.startDate || '-' }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">截止日期</text>
  21. <text class="value">{{ form.endDate || '-' }}</text>
  22. </view>
  23. <view class="info-row">
  24. <text class="label">备注</text>
  25. <text class="value">{{ form.remark || '-' }}</text>
  26. </view>
  27. </view>
  28. </template>
  29. <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. import { ref, onMounted, watch, computed } from 'vue';
  34. import { useDocumentApi } from '@/api/document';
  35. import to from 'await-to-js';
  36. const props = defineProps<{
  37. code: string;
  38. }>();
  39. const documentApi = useDocumentApi();
  40. const form = ref<any>(null);
  41. const schemeList = ref<any[]>([]);
  42. const loading = ref(false);
  43. const currentSchemeLabel = computed(() => {
  44. if (form.value?.schemeName) return form.value.schemeName;
  45. if (!form.value?.schemeId) return '';
  46. const item = schemeList.value.find(s => s.id === form.value.schemeId);
  47. return item ? item.schemeName : form.value.schemeId;
  48. });
  49. const fetchData = async () => {
  50. if (!props.code) return;
  51. loading.value = true;
  52. // 1. 获取详情
  53. const [err, res] = await to(documentApi.getAssessmentBatchById(props.code));
  54. if (!err && res?.data) {
  55. form.value = res.data;
  56. }
  57. // 2. 获取方案列表(对齐PC logic, 用于翻译方案ID)
  58. const [sErr, sRes] = await to(documentApi.getAssessmentSchemeList());
  59. if (!sErr && sRes?.data?.list) {
  60. schemeList.value = sRes.data.list;
  61. }
  62. loading.value = false;
  63. };
  64. onMounted(() => {
  65. fetchData();
  66. });
  67. watch(() => props.code, () => {
  68. fetchData();
  69. });
  70. </script>
  71. <style lang="scss" scoped>
  72. @import "./common.scss";
  73. </style>