1、文件选择各个审计内容分离保存
2、勾选目录后,自动选择文件
This commit is contained in:
@@ -106,6 +106,7 @@
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
currentCompanyId: number;
|
currentCompanyId: number;
|
||||||
|
selectionKey?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@@ -169,29 +170,52 @@
|
|||||||
return buildTree(0);
|
return buildTree(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
const lastSelectedDirKeys = ref<(string | number)[]>([]);
|
const selectionStateMap = ref<
|
||||||
const lastSelectedFileKeys = ref<(string | number)[]>([]);
|
Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
dirKeys: (string | number)[];
|
||||||
|
fileKeys: (string | number)[];
|
||||||
|
}
|
||||||
|
>
|
||||||
|
>({});
|
||||||
// const currentSectionIndex = ref(2); // 默认是审计内容3
|
// const currentSectionIndex = ref(2); // 默认是审计内容3
|
||||||
const selectedDocList = ref<string[]>([]);
|
const selectedDocList = ref<string[]>([]);
|
||||||
const selectedFileList = ref<string[]>([]);
|
const selectedFileList = ref<string[]>([]);
|
||||||
const selectedFileKeys = ref<(string | number)[]>([]);
|
const selectedFileKeys = ref<(string | number)[]>([]);
|
||||||
const checkedDirKeys = ref<(string | number)[]>([]); // 新增:勾选的目录keys
|
const checkedDirKeys = ref<(string | number)[]>([]); // 新增:勾选的目录keys
|
||||||
|
const dirFileKeyCache = ref<Record<string, (string | number)[]>>({});
|
||||||
|
const getSelectionStorageKey = () => props.selectionKey || '__default__';
|
||||||
|
|
||||||
|
const saveSelectionState = () => {
|
||||||
|
selectionStateMap.value[getSelectionStorageKey()] = {
|
||||||
|
dirKeys: [...checkedDirKeys.value],
|
||||||
|
fileKeys: [...selectedFileKeys.value]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const restoreSelectionState = () => {
|
||||||
|
const state = selectionStateMap.value[getSelectionStorageKey()];
|
||||||
|
checkedDirKeys.value = [...(state?.dirKeys || [])];
|
||||||
|
selectedFileKeys.value = [...(state?.fileKeys || [])];
|
||||||
|
selectedDocList.value = checkedDirKeys.value.map((key) => key.toString());
|
||||||
|
selectedFileList.value = selectedFileKeys.value.map((key) =>
|
||||||
|
key.toString()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleDocSelectCancel = () => {
|
const handleDocSelectCancel = () => {
|
||||||
// 保存当前选择状态
|
saveSelectionState();
|
||||||
lastSelectedDirKeys.value = [...checkedDirKeys.value];
|
|
||||||
lastSelectedFileKeys.value = [...selectedFileKeys.value];
|
|
||||||
showDocSelect.value = false;
|
showDocSelect.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const confirmSelection = () => {
|
const confirmSelection = () => {
|
||||||
// 保存当前选择状态
|
saveSelectionState();
|
||||||
lastSelectedDirKeys.value = [...checkedDirKeys.value];
|
|
||||||
lastSelectedFileKeys.value = [...selectedFileKeys.value];
|
|
||||||
|
|
||||||
// 传递选择的数据给父组件
|
// 传递选择的数据给父组件
|
||||||
emit('confirm', {
|
emit('confirm', {
|
||||||
dirKeys: lastSelectedDirKeys.value,
|
dirKeys: [...checkedDirKeys.value],
|
||||||
fileKeys: lastSelectedFileKeys.value
|
fileKeys: [...selectedFileKeys.value]
|
||||||
});
|
});
|
||||||
|
|
||||||
message.success(
|
message.success(
|
||||||
@@ -240,10 +264,72 @@
|
|||||||
loadCloudFiles();
|
loadCloudFiles();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 新增:目录勾选处理
|
const getCheckedKeyList = (checkedKeys: any) => {
|
||||||
const onDirCheck = (checkedKeys: (string | number)[]) => {
|
return Array.isArray(checkedKeys)
|
||||||
checkedDirKeys.value = checkedKeys;
|
? checkedKeys
|
||||||
selectedDocList.value = checkedKeys.map((key) => key.toString());
|
: Array.isArray(checkedKeys?.checked)
|
||||||
|
? checkedKeys.checked
|
||||||
|
: [];
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDirFileKeys = async (dirKey: string | number) => {
|
||||||
|
const cacheKey = String(dirKey);
|
||||||
|
if (dirFileKeyCache.value[cacheKey]) {
|
||||||
|
return dirFileKeyCache.value[cacheKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
const files = await listAiCloudFile({
|
||||||
|
docId: Number(dirKey)
|
||||||
|
});
|
||||||
|
const fileKeys = (files || [])
|
||||||
|
.map((item) => item.id)
|
||||||
|
.filter((id) => id !== undefined && id !== null) as (string | number)[];
|
||||||
|
|
||||||
|
dirFileKeyCache.value[cacheKey] = fileKeys;
|
||||||
|
return fileKeys;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 目录勾选处理:勾选目录时全选该目录下文件,取消时反选
|
||||||
|
const onDirCheck = async (checkedKeys: any) => {
|
||||||
|
const nextCheckedKeys = getCheckedKeyList(checkedKeys);
|
||||||
|
const prevCheckedKeys = [...checkedDirKeys.value];
|
||||||
|
const addedKeys = nextCheckedKeys.filter(
|
||||||
|
(key) => !prevCheckedKeys.includes(key)
|
||||||
|
);
|
||||||
|
const removedKeys = prevCheckedKeys.filter(
|
||||||
|
(key) => !nextCheckedKeys.includes(key)
|
||||||
|
);
|
||||||
|
|
||||||
|
checkedDirKeys.value = nextCheckedKeys;
|
||||||
|
selectedDocList.value = nextCheckedKeys.map((key) => key.toString());
|
||||||
|
|
||||||
|
if (!addedKeys.length && !removedKeys.length) {
|
||||||
|
saveSelectionState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const addedFileGroups = await Promise.all(
|
||||||
|
addedKeys.map((key) => getDirFileKeys(key))
|
||||||
|
);
|
||||||
|
const removedFileGroups = await Promise.all(
|
||||||
|
removedKeys.map((key) => getDirFileKeys(key))
|
||||||
|
);
|
||||||
|
|
||||||
|
const nextFileKeySet = new Set<(string | number)>(selectedFileKeys.value);
|
||||||
|
addedFileGroups.flat().forEach((key) => nextFileKeySet.add(key));
|
||||||
|
removedFileGroups.flat().forEach((key) => nextFileKeySet.delete(key));
|
||||||
|
|
||||||
|
selectedFileKeys.value = Array.from(nextFileKeySet);
|
||||||
|
selectedFileList.value = selectedFileKeys.value.map((key) =>
|
||||||
|
key.toString()
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
message.error('目录文件联动选择失败');
|
||||||
|
console.error('目录文件联动选择失败:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveSelectionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 异步加载子节点
|
// 异步加载子节点
|
||||||
@@ -276,7 +362,8 @@
|
|||||||
selectedRows: AiCloudFile[]
|
selectedRows: AiCloudFile[]
|
||||||
) => {
|
) => {
|
||||||
selectedFileKeys.value = selectedRowKeys;
|
selectedFileKeys.value = selectedRowKeys;
|
||||||
selectedFileList.value = selectedRows.map((row) => row.id!.toString());
|
selectedFileList.value = selectedRowKeys.map((key) => key.toString());
|
||||||
|
saveSelectionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 清空选择
|
// 清空选择
|
||||||
@@ -291,6 +378,8 @@
|
|||||||
selectedDocList.value = [selectedKeys.value[0].toString()];
|
selectedDocList.value = [selectedKeys.value[0].toString()];
|
||||||
checkedDirKeys.value = [selectedKeys.value[0]]; // 新增:重新勾选当前目录
|
checkedDirKeys.value = [selectedKeys.value[0]]; // 新增:重新勾选当前目录
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveSelectionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadCloudFiles = async () => {
|
const loadCloudFiles = async () => {
|
||||||
@@ -334,6 +423,8 @@
|
|||||||
|
|
||||||
const open = () => {
|
const open = () => {
|
||||||
showDocSelect.value = true;
|
showDocSelect.value = true;
|
||||||
|
restoreSelectionState();
|
||||||
|
dirFileKeyCache.value = {};
|
||||||
loadAllCloudDocs();
|
loadAllCloudDocs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -491,6 +491,7 @@
|
|||||||
<FileModal
|
<FileModal
|
||||||
ref="fileModal"
|
ref="fileModal"
|
||||||
:current-company-id="currentCompanyId"
|
:current-company-id="currentCompanyId"
|
||||||
|
:selection-key="currentFileSelectionKey"
|
||||||
@confirm="handleFileSelectConfirm"
|
@confirm="handleFileSelectConfirm"
|
||||||
/>
|
/>
|
||||||
<HistoryModal
|
<HistoryModal
|
||||||
@@ -598,12 +599,20 @@
|
|||||||
// ========== 文档选择相关 ==========
|
// ========== 文档选择相关 ==========
|
||||||
const fileModal = ref();
|
const fileModal = ref();
|
||||||
const currentSectionIndex = ref(0);
|
const currentSectionIndex = ref(0);
|
||||||
|
const currentFileSelectionKey = ref('');
|
||||||
const selectedDocList = ref<string[]>([]);
|
const selectedDocList = ref<string[]>([]);
|
||||||
const selectedFileList = ref<string[]>([]);
|
const selectedFileList = ref<string[]>([]);
|
||||||
const selectedFileKeys = ref<(string | number)[]>([]);
|
const selectedFileKeys = ref<(string | number)[]>([]);
|
||||||
const checkedDirKeys = ref<(string | number)[]>([]);
|
const checkedDirKeys = ref<(string | number)[]>([]);
|
||||||
const lastSelectedDirKeys = ref<(string | number)[]>([]);
|
const tableFileSelectionMap = reactive<
|
||||||
const lastSelectedFileKeys = ref<(string | number)[]>([]);
|
Record<
|
||||||
|
string,
|
||||||
|
{
|
||||||
|
dirKeys: (string | number)[];
|
||||||
|
fileKeys: (string | number)[];
|
||||||
|
}
|
||||||
|
>
|
||||||
|
>({});
|
||||||
|
|
||||||
// ========== 取证单相关 ==========
|
// ========== 取证单相关 ==========
|
||||||
const evidenceModalVisible = ref(false);
|
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 */
|
/* 更新visible */
|
||||||
@@ -728,6 +765,11 @@
|
|||||||
section.data = [];
|
section.data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentSectionIndex.value === sectionIndex) {
|
||||||
|
currentFileSelectionKey.value = tableKey;
|
||||||
|
applyTableFileSelection(tableKey);
|
||||||
|
}
|
||||||
|
|
||||||
selectedRowsMap[sectionIndex] = [];
|
selectedRowsMap[sectionIndex] = [];
|
||||||
selectedRowKeysMap[sectionIndex] = [];
|
selectedRowKeysMap[sectionIndex] = [];
|
||||||
|
|
||||||
@@ -736,10 +778,16 @@
|
|||||||
|
|
||||||
/* 处理文件选择确认 */
|
/* 处理文件选择确认 */
|
||||||
const handleFileSelectConfirm = (data: { dirKeys: (string | number)[], fileKeys: (string | number)[] }) => {
|
const handleFileSelectConfirm = (data: { dirKeys: (string | number)[], fileKeys: (string | number)[] }) => {
|
||||||
|
if (currentFileSelectionKey.value) {
|
||||||
|
saveTableFileSelection(
|
||||||
|
currentFileSelectionKey.value,
|
||||||
|
data.dirKeys,
|
||||||
|
data.fileKeys
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
checkedDirKeys.value = data.dirKeys;
|
checkedDirKeys.value = data.dirKeys;
|
||||||
selectedFileKeys.value = data.fileKeys;
|
selectedFileKeys.value = data.fileKeys;
|
||||||
lastSelectedDirKeys.value = [...data.dirKeys];
|
|
||||||
lastSelectedFileKeys.value = [...data.fileKeys];
|
|
||||||
selectedDocList.value = data.dirKeys.map((key) => key.toString());
|
selectedDocList.value = data.dirKeys.map((key) => key.toString());
|
||||||
selectedFileList.value = data.fileKeys.map((key) => key.toString());
|
selectedFileList.value = data.fileKeys.map((key) => key.toString());
|
||||||
};
|
};
|
||||||
@@ -751,14 +799,8 @@
|
|||||||
const tableInfo = getTableInfo(sectionIndex);
|
const tableInfo = getTableInfo(sectionIndex);
|
||||||
if (!tableInfo) return;
|
if (!tableInfo) return;
|
||||||
|
|
||||||
checkedDirKeys.value = [...lastSelectedDirKeys.value];
|
currentFileSelectionKey.value = tableInfo.tableKey;
|
||||||
selectedFileKeys.value = [...lastSelectedFileKeys.value];
|
applyTableFileSelection(tableInfo.tableKey);
|
||||||
selectedDocList.value = lastSelectedDirKeys.value.map((key) =>
|
|
||||||
key.toString()
|
|
||||||
);
|
|
||||||
selectedFileList.value = lastSelectedFileKeys.value.map((key) =>
|
|
||||||
key.toString()
|
|
||||||
);
|
|
||||||
|
|
||||||
fileModal.value.open();
|
fileModal.value.open();
|
||||||
};
|
};
|
||||||
@@ -885,8 +927,8 @@
|
|||||||
history:
|
history:
|
||||||
section.data?.length > 0 ? JSON.stringify(section.data, null, 2) : '',
|
section.data?.length > 0 ? JSON.stringify(section.data, null, 2) : '',
|
||||||
suggestion: section.suggestion || '',
|
suggestion: section.suggestion || '',
|
||||||
docList: checkedDirKeys.value,
|
docList: getTableFileSelection(tableKey).dirKeys,
|
||||||
fileList: selectedFileKeys.value,
|
fileList: getTableFileSelection(tableKey).fileKeys,
|
||||||
// 重大经济决策调查表需要三重一大数据
|
// 重大经济决策调查表需要三重一大数据
|
||||||
...(currentTable.value === 'decisionTable'
|
...(currentTable.value === 'decisionTable'
|
||||||
? { data: tripleOneData.value }
|
? { data: tripleOneData.value }
|
||||||
@@ -1067,8 +1109,8 @@
|
|||||||
kbIds: props.data?.kbId || '',
|
kbIds: props.data?.kbId || '',
|
||||||
libraryIds: props.data?.libraryIds || '',
|
libraryIds: props.data?.libraryIds || '',
|
||||||
projectLibrary: props.data?.projectLibrary || '',
|
projectLibrary: props.data?.projectLibrary || '',
|
||||||
docList: checkedDirKeys.value,
|
docList: getTableFileSelection(tableKey).dirKeys,
|
||||||
fileList: selectedFileKeys.value,
|
fileList: getTableFileSelection(tableKey).fileKeys,
|
||||||
|
|
||||||
// 重大经济决策调查表需要三重一大数据
|
// 重大经济决策调查表需要三重一大数据
|
||||||
...(currentTable.value === 'decisionTable'
|
...(currentTable.value === 'decisionTable'
|
||||||
@@ -1288,8 +1330,8 @@
|
|||||||
projectId: form.id,
|
projectId: form.id,
|
||||||
formCommit: section.formCommit || 0,
|
formCommit: section.formCommit || 0,
|
||||||
chapterTitle: chapterTitle,
|
chapterTitle: chapterTitle,
|
||||||
docList: checkedDirKeys.value,
|
docList: getTableFileSelection(getTableKey(sectionIndex)).dirKeys,
|
||||||
fileList: selectedFileKeys.value
|
fileList: getTableFileSelection(getTableKey(sectionIndex)).fileKeys
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
section.generating = false;
|
section.generating = false;
|
||||||
@@ -1394,6 +1436,11 @@
|
|||||||
// 保存表格生成数据
|
// 保存表格生成数据
|
||||||
const tableKey = `${section.tableType}_${tableValue}`;
|
const tableKey = `${section.tableType}_${tableValue}`;
|
||||||
saveTableGenerationData(tableKey, requestData, responseData, interfaceName);
|
saveTableGenerationData(tableKey, requestData, responseData, interfaceName);
|
||||||
|
saveTableFileSelection(
|
||||||
|
tableKey,
|
||||||
|
Array.isArray(requestData?.docList) ? requestData.docList : [],
|
||||||
|
Array.isArray(requestData?.fileList) ? requestData.fileList : []
|
||||||
|
);
|
||||||
|
|
||||||
// 使用数据映射函数
|
// 使用数据映射函数
|
||||||
const dataMapper = createDataMapper(tableValue);
|
const dataMapper = createDataMapper(tableValue);
|
||||||
@@ -1426,6 +1473,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentFileSelectionKey.value = tableKey;
|
||||||
|
applyTableFileSelection(tableKey);
|
||||||
|
|
||||||
// 特殊处理数据存储
|
// 特殊处理数据存储
|
||||||
if (tableValue === 'tripleOne') {
|
if (tableValue === 'tripleOne') {
|
||||||
tripleOneData.value = data;
|
tripleOneData.value = data;
|
||||||
@@ -1823,12 +1873,17 @@
|
|||||||
return cloned;
|
return cloned;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
const currentSelection = getTableFileSelection(tableKey);
|
||||||
|
const normalizedRequestData = {
|
||||||
|
...(generationData.requestData || {}),
|
||||||
|
docList: [...currentSelection.dirKeys],
|
||||||
|
fileList: [...currentSelection.fileKeys]
|
||||||
|
};
|
||||||
|
|
||||||
const aiHistory = {
|
const aiHistory = {
|
||||||
projectId: props.data?.id,
|
projectId: props.data?.id,
|
||||||
interfaceName: correctInterfaceName, // 使用正确的接口名称
|
interfaceName: correctInterfaceName, // 使用正确的接口名称
|
||||||
requestData: generationData.requestData
|
requestData: JSON.stringify(normalizedRequestData),
|
||||||
? JSON.stringify(generationData.requestData)
|
|
||||||
: '',
|
|
||||||
responseData: JSON.stringify(normalizedResponseData)
|
responseData: JSON.stringify(normalizedResponseData)
|
||||||
// 其他字段后端会自动设置
|
// 其他字段后端会自动设置
|
||||||
};
|
};
|
||||||
@@ -1871,6 +1926,9 @@
|
|||||||
const next = { ...gen.responseData, data: [] };
|
const next = { ...gen.responseData, data: [] };
|
||||||
tableGenerationData[tableKey].responseData = next;
|
tableGenerationData[tableKey].responseData = next;
|
||||||
}
|
}
|
||||||
|
if (tableFileSelectionMap[tableKey] !== undefined) {
|
||||||
|
delete tableFileSelectionMap[tableKey];
|
||||||
|
}
|
||||||
|
|
||||||
if (exportStates[tableKey] !== undefined)
|
if (exportStates[tableKey] !== undefined)
|
||||||
delete exportStates[tableKey];
|
delete exportStates[tableKey];
|
||||||
@@ -2041,6 +2099,14 @@
|
|||||||
Object.keys(generatingEvidenceStates).forEach((key) => {
|
Object.keys(generatingEvidenceStates).forEach((key) => {
|
||||||
delete generatingEvidenceStates[key as any];
|
delete generatingEvidenceStates[key as any];
|
||||||
});
|
});
|
||||||
|
Object.keys(tableFileSelectionMap).forEach((key) => {
|
||||||
|
delete tableFileSelectionMap[key];
|
||||||
|
});
|
||||||
|
currentFileSelectionKey.value = '';
|
||||||
|
selectedDocList.value = [];
|
||||||
|
selectedFileList.value = [];
|
||||||
|
selectedFileKeys.value = [];
|
||||||
|
checkedDirKeys.value = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user