|
|
@@ -203,13 +203,13 @@ import { useRoute } from 'vue-router';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { getCaseInquestInfo, saveCaseInquestInfo, getCaseDetailInfo, saveCaseDetailInfo } from '@/store/case';
|
|
|
import { getCaseFileImageInfo } from '@/store/editCsae';
|
|
|
+import { router, RouteName } from '@/router';
|
|
|
|
|
|
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: '',
|
|
|
@@ -273,8 +273,9 @@ const loadInquest = async () => {
|
|
|
const hasPreset = !!route.query.presetKey;
|
|
|
const isNew = idParam === undefined && !hasPreset;
|
|
|
if (isNew) { resetInquest(); return; }
|
|
|
- const res: any = await getCaseFileImageInfo(filesId.value);
|
|
|
- const data = res?.inquest ?? res ?? {};
|
|
|
+ // const res: any = await getCaseFileImageInfo(filesId.value);
|
|
|
+ const res: any = await getCaseInquestInfo(idParam);
|
|
|
+ const data = res?.inquest ?? res?.data ?? res ?? {};
|
|
|
Object.assign(inquest, {}, data)
|
|
|
console.log('loadInquest1', data, inquest, hasPreset, Array.isArray(data));
|
|
|
// 新格式:数组,按路由ID选择
|
|
|
@@ -287,7 +288,6 @@ const loadInquest = async () => {
|
|
|
Object.assign(inquest, data );
|
|
|
}
|
|
|
}
|
|
|
- console.log('loadInquest11', data, inquest, hasPreset);
|
|
|
await nextTick()
|
|
|
loadingCout.value += 1;
|
|
|
} catch (e) {
|
|
|
@@ -315,7 +315,7 @@ const loadExtract = async () => {
|
|
|
const hasPreset = !!route.query.presetKey;
|
|
|
const isNew = idParam === undefined && !hasPreset;
|
|
|
if (isNew) { resetExtract(); return; }
|
|
|
- const res: any = await getCaseDetailInfo(props.caseId);
|
|
|
+ const res: any = await getCaseDetailInfo(idParam);
|
|
|
const data = res?.data ?? {};
|
|
|
if (Array.isArray(data)) {
|
|
|
const picked = idParam !== undefined ? data.find((d: any) => Number(d?.id) === idParam) : undefined;
|
|
|
@@ -325,6 +325,7 @@ const loadExtract = async () => {
|
|
|
Object.assign(extract, { ...extract, ...(data || {}) });
|
|
|
}
|
|
|
}
|
|
|
+ console.error('获取提取清单', data, extract);
|
|
|
} catch (e) {
|
|
|
console.error('获取提取清单失败', e);
|
|
|
}
|
|
|
@@ -352,35 +353,44 @@ watch([visible, type], async ([v, t]) => {
|
|
|
// applyInquestPreset();
|
|
|
} else {
|
|
|
await loadExtract();
|
|
|
- applyExtractPreset();
|
|
|
+ // applyExtractPreset();
|
|
|
}
|
|
|
}, { immediate: true });
|
|
|
-const setDataInfo = (data: any) => {
|
|
|
+const getDataInfo = () => {
|
|
|
if (type.value === 'inquest') {
|
|
|
- applyInquestPreset();
|
|
|
+ loadInquest();
|
|
|
} else {
|
|
|
- applyExtractPreset();
|
|
|
+ loadExtract();
|
|
|
}
|
|
|
};
|
|
|
const handleSave = async (): Promise<any> => {
|
|
|
try {
|
|
|
let res: any;
|
|
|
+ const idParam = (extract as any).id || (route.query.id ? Number(route.query.id) : undefined);
|
|
|
if (type.value === 'inquest') {
|
|
|
- const idParam = (inquest as any).id || (route.query.id ? Number(route.query.id) : undefined);
|
|
|
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);
|
|
|
const payload = idParam !== undefined ? { id: idParam, ...extract } : { ...extract };
|
|
|
res = await saveCaseDetailInfo(props.caseId, payload);
|
|
|
const savedId = res?.data?.id || res?.data?.data?.id;
|
|
|
if (savedId) (extract as any).id = savedId;
|
|
|
}
|
|
|
+ let resData = res?.data;
|
|
|
console.log('保存成功', res?.data);
|
|
|
- return res?.data || true;
|
|
|
+ if(!idParam){
|
|
|
+ const current = router.currentRoute.value;
|
|
|
+ router.replace({
|
|
|
+ name: RouteName.fireDetails,
|
|
|
+ params: current.params,
|
|
|
+ query: {...current.query, id: resData.id || '' },
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return resData || true;
|
|
|
} catch (e) {
|
|
|
console.error('保存失败', e);
|
|
|
ElMessage.error('保存失败,请稍后重试');
|