From d7d08748690261986b7983bf6814bffa8702c0cb Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Thu, 21 May 2026 15:15:43 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=87=E6=A1=A3=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=AC=E5=85=B1=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/components/FileModal.vue | 464 +++++++++++++++--- .../pwlProject/components/reportContent.vue | 116 +++-- 2 files changed, 469 insertions(+), 111 deletions(-) diff --git a/src/views/pwl/pwlProject/components/components/FileModal.vue b/src/views/pwl/pwlProject/components/components/FileModal.vue index d21f5af..8c2caff 100644 --- a/src/views/pwl/pwlProject/components/components/FileModal.vue +++ b/src/views/pwl/pwlProject/components/components/FileModal.vue @@ -11,8 +11,25 @@
+
+ + + + +
- 文档目录 + {{ activeSource === 'company' ? '公司文档目录' : '公共库目录' }}
已选择 {{ checkedDirKeys.length }} 个目录, - {{ selectedFileList.length }} 个文件当前已选择 {{ checkedDirKeys.length }} 个目录, + {{ selectedFileList.length }} 个文件;合计 + {{ mergedDirKeys.length }} 个目录,{{ mergedFileKeys.length }} 个文件 - 清空选择 + 清空当前 确认选择 @@ -57,10 +75,14 @@
diff --git a/src/views/pwl/pwlProject/components/reportContent.vue b/src/views/pwl/pwlProject/components/reportContent.vue index 00491af..3560c56 100644 --- a/src/views/pwl/pwlProject/components/reportContent.vue +++ b/src/views/pwl/pwlProject/components/reportContent.vue @@ -492,6 +492,7 @@ ref="fileModal" :current-company-id="currentCompanyId" :selection-key="currentFileSelectionKey" + :selection-state="getTableFileSelection(currentFileSelectionKey)" @confirm="handleFileSelectConfirm" /> ; + type SourceSelectionState = { + dirKeys: SelectionKey[]; + fileKeys: SelectionKey[]; + currentDirKey?: SelectionKey; + dirFileSelections: DirFileSelectionMap; + }; + type TableFileSelectionState = { + activeSource: DocSourceType; + company: SourceSelectionState; + public: SourceSelectionState; + dirKeys: SelectionKey[]; + fileKeys: SelectionKey[]; + }; + + const dedupeSelectionKeys = (keys: SelectionKey[] = []) => { + return Array.from( + new Set(keys.filter((key) => key !== undefined && key !== null)) + ); + }; + + const cloneDirFileSelections = ( + dirFileSelections?: DirFileSelectionMap + ): DirFileSelectionMap => { + return Object.fromEntries( + Object.entries(dirFileSelections || {}).map(([key, value]) => [ + key, + [...value] + ]) + ); + }; + + const cloneSourceSelectionState = ( + state?: Partial + ): SourceSelectionState => { + return { + dirKeys: dedupeSelectionKeys([...(state?.dirKeys || [])]), + fileKeys: dedupeSelectionKeys([...(state?.fileKeys || [])]), + currentDirKey: state?.currentDirKey, + dirFileSelections: cloneDirFileSelections(state?.dirFileSelections) + }; + }; + + const normalizeTableFileSelection = ( + selection?: Partial + ): TableFileSelectionState => { + const hasSourceState = !!(selection?.company || selection?.public); + const company = cloneSourceSelectionState(selection?.company); + const publicState = cloneSourceSelectionState(selection?.public); + + if (!hasSourceState) { + company.dirKeys = dedupeSelectionKeys([...(selection?.dirKeys || [])]); + company.fileKeys = dedupeSelectionKeys([...(selection?.fileKeys || [])]); + } + + return { + activeSource: selection?.activeSource === 'public' ? 'public' : 'company', + company, + public: publicState, + dirKeys: dedupeSelectionKeys([...company.dirKeys, ...publicState.dirKeys]), + fileKeys: dedupeSelectionKeys([ + ...company.fileKeys, + ...publicState.fileKeys + ]) + }; + }; + const useForm = Form.useForm; const props = defineProps<{ @@ -602,16 +672,10 @@ const currentFileSelectionKey = ref(''); const selectedDocList = ref([]); const selectedFileList = ref([]); - const selectedFileKeys = ref<(string | number)[]>([]); - const checkedDirKeys = ref<(string | number)[]>([]); + const selectedFileKeys = ref([]); + const checkedDirKeys = ref([]); const tableFileSelectionMap = reactive< - Record< - string, - { - dirKeys: (string | number)[]; - fileKeys: (string | number)[]; - } - > + Record >({}); // ========== 取证单相关 ========== @@ -704,12 +768,7 @@ }; const getTableFileSelection = (tableKey: string) => { - return ( - tableFileSelectionMap[tableKey] || { - dirKeys: [], - fileKeys: [] - } - ); + return normalizeTableFileSelection(tableFileSelectionMap[tableKey]); }; const applyTableFileSelection = (tableKey: string) => { @@ -722,13 +781,9 @@ const saveTableFileSelection = ( tableKey: string, - dirKeys: (string | number)[] = [], - fileKeys: (string | number)[] = [] + selection?: Partial ) => { - tableFileSelectionMap[tableKey] = { - dirKeys: [...dirKeys], - fileKeys: [...fileKeys] - }; + tableFileSelectionMap[tableKey] = normalizeTableFileSelection(selection); }; // ========== 通用方法 ========== @@ -777,13 +832,9 @@ }; /* 处理文件选择确认 */ - const handleFileSelectConfirm = (data: { dirKeys: (string | number)[], fileKeys: (string | number)[] }) => { + const handleFileSelectConfirm = (data: TableFileSelectionState) => { if (currentFileSelectionKey.value) { - saveTableFileSelection( - currentFileSelectionKey.value, - data.dirKeys, - data.fileKeys - ); + saveTableFileSelection(currentFileSelectionKey.value, data); } checkedDirKeys.value = data.dirKeys; @@ -1438,8 +1489,12 @@ saveTableGenerationData(tableKey, requestData, responseData, interfaceName); saveTableFileSelection( tableKey, - Array.isArray(requestData?.docList) ? requestData.docList : [], - Array.isArray(requestData?.fileList) ? requestData.fileList : [] + requestData?.fileSelectionState || { + dirKeys: Array.isArray(requestData?.docList) ? requestData.docList : [], + fileKeys: Array.isArray(requestData?.fileList) + ? requestData.fileList + : [] + } ); // 使用数据映射函数 @@ -1877,7 +1932,8 @@ const normalizedRequestData = { ...(generationData.requestData || {}), docList: [...currentSelection.dirKeys], - fileList: [...currentSelection.fileKeys] + fileList: [...currentSelection.fileKeys], + fileSelectionState: normalizeTableFileSelection(currentSelection) }; const aiHistory = {