AssessmentBatchForm.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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">{{ formatDate(form.startDate) }}</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="label">截止日期</text>
  21. <text class="value">{{ formatDate(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 { formatDate } from '@/utils/date';
  36. import to from 'await-to-js';
  37. const props = defineProps<{
  38. code: string;
  39. }>();
  40. const documentApi = useDocumentApi();
  41. const form = ref<any>(null);
  42. const schemeList = ref<any[]>([]);
  43. const loading = ref(false);
  44. const currentSchemeLabel = computed(() => {
  45. if (form.value?.schemeName) return form.value.schemeName;
  46. if (!form.value?.schemeId) return '';
  47. const item = schemeList.value.find(s => s.id === form.value.schemeId);
  48. return item ? item.schemeName : form.value.schemeId;
  49. });
  50. const fetchData = async () => {
  51. if (!props.code) return;
  52. loading.value = true;
  53. // 1. 获取详情
  54. const [err, res] = await to(documentApi.getAssessmentBatchById(props.code));
  55. if (!err && res?.data) {
  56. form.value = res.data;
  57. }
  58. // 2. 获取方案列表(对齐PC logic, 用于翻译方案ID)
  59. const [sErr, sRes] = await to(documentApi.getAssessmentSchemeList());
  60. if (!sErr && sRes?.data?.list) {
  61. schemeList.value = sRes.data.list;
  62. }
  63. loading.value = false;
  64. };
  65. onMounted(() => {
  66. fetchData();
  67. });
  68. watch(() => props.code, () => {
  69. fetchData();
  70. });
  71. </script>
  72. <style lang="scss" scoped>
  73. @import "./common.scss";
  74. </style>