tangning недель назад: 3
Родитель
Сommit
ed2238da5d
1 измененных файлов с 23 добавлено и 7 удалено
  1. 23 7
      src/view/newFireCase/newFireDetails/editFilePage.vue

+ 23 - 7
src/view/newFireCase/newFireDetails/editFilePage.vue

@@ -1,7 +1,7 @@
 <template>
   <div v-if="visible" class="edit-file-page">
     <div class="page-body">
-      <div v-if="type === 'inquest'">
+      <div v-if="type === 'inquest'" :key="loadingCout">
         <h3 class="title">基本信息</h3>
         <div class="content">
           <div class="line">
@@ -198,15 +198,18 @@
 </template>
 
 <script setup lang="ts">
-import { reactive, computed, watch, onMounted } from 'vue';
+import { reactive, computed, watch, onMounted, ref, nextTick } from 'vue';
 import { useRoute } from 'vue-router';
 import { ElMessage } from 'element-plus';
 import { getCaseInquestInfo, saveCaseInquestInfo, getCaseDetailInfo, saveCaseDetailInfo } from '@/store/case';
+import { getCaseFileImageInfo } from '@/store/editCsae';
 
 const props = defineProps<{ caseId: number; currentRecord: object; editOrShow: string }>();
 const route = useRoute();
 const visible = computed(() => route.query.editSub === 'records' || route.query.editSub === 'editInspection');
 const type = computed(() => (route.query.type as string) === 'extraction' ? 'extraction' : 'inquest');
+const loadingCout = ref(0)
+const filesId = ref<string | number | null>(route.query.filesId)
 
 const inquest = reactive<any>({
   count: '',
@@ -270,8 +273,10 @@ const loadInquest = async () => {
     const hasPreset = !!route.query.presetKey;
     const isNew = idParam === undefined && !hasPreset;
     if (isNew) { resetInquest(); return; }
-    const res: any = await getCaseInquestInfo(props.caseId);
-    const data = res?.data ?? {};
+    const res: any = await getCaseFileImageInfo(filesId.value);
+    const data = res?.inquest ?? res ?? {};
+    Object.assign(inquest, {}, data)
+    console.log('loadInquest1', data, inquest, hasPreset, Array.isArray(data));
     // 新格式:数组,按路由ID选择
     if (Array.isArray(data)) {
       const picked = idParam !== undefined ? data.find((d: any) => Number(d?.id) === idParam) : undefined;
@@ -279,9 +284,12 @@ const loadInquest = async () => {
     } else {
       // 旧格式:单对象,配合 preset 使用;若无 preset,仍允许编辑现有对象
       if (hasPreset) {
-        Object.assign(inquest, { ...inquest, ...(data || {}) });
+        Object.assign(inquest, data );
       }
     }
+    console.log('loadInquest11', data, inquest, hasPreset);
+    await nextTick()
+    loadingCout.value += 1;
   } catch (e) {
     console.error('获取勗验笔录失败', e);
   }
@@ -341,13 +349,19 @@ watch([visible, type], async ([v, t]) => {
   if (!v) return;
   if (t === 'inquest') {
     await loadInquest();
-    applyInquestPreset();
+    // applyInquestPreset();
   } else {
     await loadExtract();
     applyExtractPreset();
   }
 }, { immediate: true });
-
+const setDataInfo = (data: any) => {
+  if (type.value === 'inquest') {
+    applyInquestPreset();
+  } else {
+    applyExtractPreset();
+  }
+};
 const handleSave = async (): Promise<any> => {
   try {
     let res: any;
@@ -356,6 +370,7 @@ const handleSave = async (): Promise<any> => {
       const payload = idParam !== undefined ? { id: idParam, ...inquest } : { ...inquest };
       res = await saveCaseInquestInfo(props.caseId, payload);
       const savedId = res?.data?.id || res?.data?.data?.id;
+      // filesId.value = savedId;
       if (savedId) (inquest as any).id = savedId;
     } else {
       const idParam = (extract as any).id || (route.query.id ? Number(route.query.id) : undefined);
@@ -364,6 +379,7 @@ const handleSave = async (): Promise<any> => {
       const savedId = res?.data?.id || res?.data?.data?.id;
       if (savedId) (extract as any).id = savedId;
     }
+    console.log('保存成功', res?.data);
     return res?.data || true;
   } catch (e) {
     console.error('保存失败', e);