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