1、文件选择各个审计内容分离保存

2、勾选目录后,自动选择文件
This commit is contained in:
2026-05-11 18:13:33 +08:00
parent 22ea9a1e25
commit e6b9831da8
2 changed files with 193 additions and 36 deletions

View File

@@ -491,6 +491,7 @@
<FileModal
ref="fileModal"
:current-company-id="currentCompanyId"
:selection-key="currentFileSelectionKey"
@confirm="handleFileSelectConfirm"
/>
<HistoryModal
@@ -598,12 +599,20 @@
// ========== 文档选择相关 ==========
const fileModal = ref();
const currentSectionIndex = ref(0);
const currentFileSelectionKey = ref('');
const selectedDocList = ref<string[]>([]);
const selectedFileList = ref<string[]>([]);
const selectedFileKeys = ref<(string | number)[]>([]);
const checkedDirKeys = ref<(string | number)[]>([]);
const lastSelectedDirKeys = ref<(string | number)[]>([]);
const lastSelectedFileKeys = ref<(string | number)[]>([]);
const tableFileSelectionMap = reactive<
Record<
string,
{
dirKeys: (string | number)[];
fileKeys: (string | number)[];
}
>
>({});
// ========== 取证单相关 ==========
const evidenceModalVisible = ref(false);
@@ -694,6 +703,34 @@
};
};
const getTableFileSelection = (tableKey: string) => {
return (
tableFileSelectionMap[tableKey] || {
dirKeys: [],
fileKeys: []
}
);
};
const applyTableFileSelection = (tableKey: string) => {
const selection = getTableFileSelection(tableKey);
checkedDirKeys.value = [...selection.dirKeys];
selectedFileKeys.value = [...selection.fileKeys];
selectedDocList.value = selection.dirKeys.map((key) => key.toString());
selectedFileList.value = selection.fileKeys.map((key) => key.toString());
};
const saveTableFileSelection = (
tableKey: string,
dirKeys: (string | number)[] = [],
fileKeys: (string | number)[] = []
) => {
tableFileSelectionMap[tableKey] = {
dirKeys: [...dirKeys],
fileKeys: [...fileKeys]
};
};
// ========== 通用方法 ==========
/* 更新visible */
@@ -728,6 +765,11 @@
section.data = [];
}
if (currentSectionIndex.value === sectionIndex) {
currentFileSelectionKey.value = tableKey;
applyTableFileSelection(tableKey);
}
selectedRowsMap[sectionIndex] = [];
selectedRowKeysMap[sectionIndex] = [];
@@ -736,10 +778,16 @@
/* 处理文件选择确认 */
const handleFileSelectConfirm = (data: { dirKeys: (string | number)[], fileKeys: (string | number)[] }) => {
if (currentFileSelectionKey.value) {
saveTableFileSelection(
currentFileSelectionKey.value,
data.dirKeys,
data.fileKeys
);
}
checkedDirKeys.value = data.dirKeys;
selectedFileKeys.value = data.fileKeys;
lastSelectedDirKeys.value = [...data.dirKeys];
lastSelectedFileKeys.value = [...data.fileKeys];
selectedDocList.value = data.dirKeys.map((key) => key.toString());
selectedFileList.value = data.fileKeys.map((key) => key.toString());
};
@@ -751,14 +799,8 @@
const tableInfo = getTableInfo(sectionIndex);
if (!tableInfo) return;
checkedDirKeys.value = [...lastSelectedDirKeys.value];
selectedFileKeys.value = [...lastSelectedFileKeys.value];
selectedDocList.value = lastSelectedDirKeys.value.map((key) =>
key.toString()
);
selectedFileList.value = lastSelectedFileKeys.value.map((key) =>
key.toString()
);
currentFileSelectionKey.value = tableInfo.tableKey;
applyTableFileSelection(tableInfo.tableKey);
fileModal.value.open();
};
@@ -885,8 +927,8 @@
history:
section.data?.length > 0 ? JSON.stringify(section.data, null, 2) : '',
suggestion: section.suggestion || '',
docList: checkedDirKeys.value,
fileList: selectedFileKeys.value,
docList: getTableFileSelection(tableKey).dirKeys,
fileList: getTableFileSelection(tableKey).fileKeys,
// 重大经济决策调查表需要三重一大数据
...(currentTable.value === 'decisionTable'
? { data: tripleOneData.value }
@@ -1067,8 +1109,8 @@
kbIds: props.data?.kbId || '',
libraryIds: props.data?.libraryIds || '',
projectLibrary: props.data?.projectLibrary || '',
docList: checkedDirKeys.value,
fileList: selectedFileKeys.value,
docList: getTableFileSelection(tableKey).dirKeys,
fileList: getTableFileSelection(tableKey).fileKeys,
// 重大经济决策调查表需要三重一大数据
...(currentTable.value === 'decisionTable'
@@ -1288,8 +1330,8 @@
projectId: form.id,
formCommit: section.formCommit || 0,
chapterTitle: chapterTitle,
docList: checkedDirKeys.value,
fileList: selectedFileKeys.value
docList: getTableFileSelection(getTableKey(sectionIndex)).dirKeys,
fileList: getTableFileSelection(getTableKey(sectionIndex)).fileKeys
});
} finally {
section.generating = false;
@@ -1394,6 +1436,11 @@
// 保存表格生成数据
const tableKey = `${section.tableType}_${tableValue}`;
saveTableGenerationData(tableKey, requestData, responseData, interfaceName);
saveTableFileSelection(
tableKey,
Array.isArray(requestData?.docList) ? requestData.docList : [],
Array.isArray(requestData?.fileList) ? requestData.fileList : []
);
// 使用数据映射函数
const dataMapper = createDataMapper(tableValue);
@@ -1426,6 +1473,9 @@
}
}
currentFileSelectionKey.value = tableKey;
applyTableFileSelection(tableKey);
// 特殊处理数据存储
if (tableValue === 'tripleOne') {
tripleOneData.value = data;
@@ -1823,12 +1873,17 @@
return cloned;
})();
const currentSelection = getTableFileSelection(tableKey);
const normalizedRequestData = {
...(generationData.requestData || {}),
docList: [...currentSelection.dirKeys],
fileList: [...currentSelection.fileKeys]
};
const aiHistory = {
projectId: props.data?.id,
interfaceName: correctInterfaceName, // 使用正确的接口名称
requestData: generationData.requestData
? JSON.stringify(generationData.requestData)
: '',
requestData: JSON.stringify(normalizedRequestData),
responseData: JSON.stringify(normalizedResponseData)
// 其他字段后端会自动设置
};
@@ -1871,6 +1926,9 @@
const next = { ...gen.responseData, data: [] };
tableGenerationData[tableKey].responseData = next;
}
if (tableFileSelectionMap[tableKey] !== undefined) {
delete tableFileSelectionMap[tableKey];
}
if (exportStates[tableKey] !== undefined)
delete exportStates[tableKey];
@@ -2041,6 +2099,14 @@
Object.keys(generatingEvidenceStates).forEach((key) => {
delete generatingEvidenceStates[key as any];
});
Object.keys(tableFileSelectionMap).forEach((key) => {
delete tableFileSelectionMap[key];
});
currentFileSelectionKey.value = '';
selectedDocList.value = [];
selectedFileList.value = [];
selectedFileKeys.value = [];
checkedDirKeys.value = [];
}
}
);