| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <template>
- <view class="document-form">
- <uv-loading-icon v-if="loading" mode="circle" text="正在加载详情..."></uv-loading-icon>
- <template v-else-if="form">
- <view class="common-section-card">
- <view class="section-title">基本信息</view>
- <view class="info-row">
- <text class="label">批次名称</text>
- <text class="value">{{ form.batchName || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="label">考核方案</text>
- <text class="value">{{ currentSchemeLabel || '-' }}</text>
- </view>
- <view class="info-row">
- <text class="label">开始日期</text>
- <text class="value">{{ formatDate(form.startDate) }}</text>
- </view>
- <view class="info-row">
- <text class="label">截止日期</text>
- <text class="value">{{ formatDate(form.endDate) }}</text>
- </view>
- <view class="info-row">
- <text class="label">备注</text>
- <text class="value">{{ form.remark || '-' }}</text>
- </view>
- </view>
- </template>
- <uv-empty v-else mode="data" text="暂无数据"></uv-empty>
- </view>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, watch, computed } from 'vue';
- import { useDocumentApi } from '@/api/document';
- import { formatDate } from '@/utils/date';
- import to from 'await-to-js';
- const props = defineProps<{
- code: string;
- }>();
- const documentApi = useDocumentApi();
- const form = ref<any>(null);
- const schemeList = ref<any[]>([]);
- const loading = ref(false);
- const currentSchemeLabel = computed(() => {
- if (form.value?.schemeName) return form.value.schemeName;
- if (!form.value?.schemeId) return '';
- const item = schemeList.value.find(s => s.id === form.value.schemeId);
- return item ? item.schemeName : form.value.schemeId;
- });
- const fetchData = async () => {
- if (!props.code) return;
- loading.value = true;
-
- // 1. 获取详情
- const [err, res] = await to(documentApi.getAssessmentBatchById(props.code));
- if (!err && res?.data) {
- form.value = res.data;
- }
-
- // 2. 获取方案列表(对齐PC logic, 用于翻译方案ID)
- const [sErr, sRes] = await to(documentApi.getAssessmentSchemeList());
- if (!sErr && sRes?.data?.list) {
- schemeList.value = sRes.data.list;
- }
-
- loading.value = false;
- };
- onMounted(() => {
- fetchData();
- });
- watch(() => props.code, () => {
- fetchData();
- });
- </script>
- <style lang="scss" scoped>
- @import "./common.scss";
- </style>
|