修改工作底稿可以直接预览

This commit is contained in:
2026-02-02 16:02:21 +08:00
parent 4ed51bb06a
commit 8cf26ca53a

View File

@@ -212,8 +212,12 @@
> >
<div class="flex justify-start items-center"> <div class="flex justify-start items-center">
<a-space> <a-space>
<a-button type="primary" @click.native="editRow(index)">编辑</a-button> <a-button type="primary" @click.native="editRow(index)"
<a-button type="primary" danger @click.native="deleteRow(index)">删除</a-button> >编辑</a-button
>
<a-button type="primary" danger @click.native="deleteRow(index)"
>删除</a-button
>
<a-button>导出</a-button> <a-button>导出</a-button>
<a-button @click="openEvidenceModal(index)" <a-button @click="openEvidenceModal(index)"
>导出取证单</a-button >导出取证单</a-button
@@ -332,32 +336,18 @@
/> />
<!-- 新格式支持 --> <!-- 新格式支持 -->
<a <span
v-if="fileItem.fileUrl" v-if="fileItem.fileUrl"
:href="fileItem.fileUrl" @click.stop="handleFilePreview(fileItem)"
target="_blank"
@click.stop="handleFileDownload(fileItem, $event)"
class="file-link cursor-pointer text-wrap" class="file-link cursor-pointer text-wrap"
style="color: #1890ff; text-decoration: none" style="color: #1890ff; text-decoration: none"
> >
{{ {{ fileItem.fileName || '未命名文件' }}
(data.caseIndex || '审计-[2026]-xxx') + </span>
'-' +
String(fileIndex + 1).padStart(3, '0') +
'-' +
(fileItem.fileName || '未命名文件')
}}
</a>
<!-- 旧格式兼容 --> <!-- 旧格式兼容 -->
<span v-else class="cursor-pointer text-wrap"> <span v-else class="cursor-pointer text-wrap">
{{ {{ fileItem.fileName || fileItem || '未命名文件' }}
(data.caseIndex || '审计-[2026]-xxx') +
'-' +
String(fileIndex + 1).padStart(3, '0') +
'-' +
(fileItem.fileName || fileItem || '未命名文件')
}}
</span> </span>
</div> </div>
</div> </div>
@@ -631,10 +621,7 @@
): TableProps['rowSelection'] => { ): TableProps['rowSelection'] => {
return { return {
selectedRowKeys: selectedRowKeysMap[sectionIndex] || [], selectedRowKeys: selectedRowKeysMap[sectionIndex] || [],
onChange: ( onChange: (selectedRowKeys: (string | number)[], selectedRows: any[]) => {
selectedRowKeys: (string | number)[],
selectedRows: any[]
) => {
selectedRowsMap[sectionIndex] = selectedRows; selectedRowsMap[sectionIndex] = selectedRows;
selectedRowKeysMap[sectionIndex] = selectedRowKeys; selectedRowKeysMap[sectionIndex] = selectedRowKeys;
} }
@@ -768,7 +755,8 @@
const section: any = navigationItems.value[sectionIndex]; const section: any = navigationItems.value[sectionIndex];
const tableInfo = getTableInfo(sectionIndex); const tableInfo = getTableInfo(sectionIndex);
evidenceBaseInfo.caseIndex = (form as any).caseIndex || props.data?.caseIndex || ''; evidenceBaseInfo.caseIndex =
(form as any).caseIndex || props.data?.caseIndex || '';
evidenceBaseInfo.projectName = form.name || props.data?.name || ''; evidenceBaseInfo.projectName = form.name || props.data?.name || '';
evidenceBaseInfo.auditedTarget = evidenceBaseInfo.auditedTarget =
(form as any).nickname || (props.data as any)?.nickname || ''; (form as any).nickname || (props.data as any)?.nickname || '';
@@ -918,12 +906,14 @@
} }
section.suggestion = ''; section.suggestion = '';
const recordCount = currentTable.value === 'personnel' const recordCount =
currentTable.value === 'personnel'
? mappedData.mainData.length ? mappedData.mainData.length
: mappedData.length; : mappedData.length;
message.success( message.success(
`成功生成 ${recordCount} 条${currentTable.title}记录` + `成功生成 ${recordCount} 条${currentTable.title}记录` +
(currentTable.value === 'personnel' && mappedData.extraData?.length > 0 (currentTable.value === 'personnel' &&
mappedData.extraData?.length > 0
? `,以及 ${mappedData.extraData.length} 条福利费明细记录` ? `,以及 ${mappedData.extraData.length} 条福利费明细记录`
: '') : '')
); );
@@ -961,27 +951,36 @@
historyData = JSON.stringify(generationData.responseData, null, 2); historyData = JSON.stringify(generationData.responseData, null, 2);
} else if (section.data && section.data.length > 0) { } else if (section.data && section.data.length > 0) {
// 如果没有生成数据,使用当前表格数据 // 如果没有生成数据,使用当前表格数据
historyData = JSON.stringify({ historyData = JSON.stringify(
{
success: true, success: true,
data: section.data, data: section.data,
data_source: currentTable.value data_source: currentTable.value
}, null, 2); },
null,
2
);
} }
// 检查history是否为空 - 新增的验证逻辑 // 检查history是否为空 - 新增的验证逻辑
if (!historyData || historyData.trim() === '') { if (!historyData || historyData.trim() === '') {
message.error('无法生成取证单:没有找到相关的审计数据,请先生成表格内容'); message.error(
'无法生成取证单:没有找到相关的审计数据,请先生成表格内容'
);
return; return;
} }
// 调用generateAuditEvidence API // 调用generateAuditEvidence API
const projectCaseIndex = (form as any).caseIndex || props.data?.caseIndex || ''; const projectCaseIndex =
(form as any).caseIndex || props.data?.caseIndex || '';
const requestData = { const requestData = {
// 基础信息 // 基础信息
caseIndex: projectCaseIndex, caseIndex: projectCaseIndex,
projectName: form.name || props.data?.name || '', projectName: form.name || props.data?.name || '',
auditedTarget: (form as any).nickname || (props.data as any)?.nickname || '', auditedTarget:
auditMatter: currentTable.title || section?.title || section?.name || '', (form as any).nickname || (props.data as any)?.nickname || '',
auditMatter:
currentTable.title || section?.title || section?.name || '',
summaryTitle: section?.title || section?.name || '', summaryTitle: section?.title || section?.name || '',
auditRecord: '', auditRecord: '',
auditFinding: '', auditFinding: '',
@@ -1024,7 +1023,9 @@
userName: '' userName: ''
}; };
const apiResult = await auditContentApi.generateAuditEvidence(requestData); const apiResult = await auditContentApi.generateAuditEvidence(
requestData
);
if (apiResult.code === 0 && apiResult.data?.success) { if (apiResult.code === 0 && apiResult.data?.success) {
message.success('取证单生成成功'); message.success('取证单生成成功');
@@ -1033,9 +1034,19 @@
// 自动打开取证单预览弹窗并填充数据 // 自动打开取证单预览弹窗并填充数据
evidenceBaseInfo.caseIndex = projectCaseIndex; evidenceBaseInfo.caseIndex = projectCaseIndex;
evidenceBaseInfo.projectName = apiResult.data.projectName || form.name || props.data?.name || ''; evidenceBaseInfo.projectName =
evidenceBaseInfo.auditedTarget = apiResult.data.auditedTarget || (form as any).nickname || (props.data as any)?.nickname || ''; apiResult.data.projectName || form.name || props.data?.name || '';
evidenceBaseInfo.auditMatter = apiResult.data.auditMatter || currentTable.title || section?.title || section?.name || ''; evidenceBaseInfo.auditedTarget =
apiResult.data.auditedTarget ||
(form as any).nickname ||
(props.data as any)?.nickname ||
'';
evidenceBaseInfo.auditMatter =
apiResult.data.auditMatter ||
currentTable.title ||
section?.title ||
section?.name ||
'';
// 将生成的取证单数据作为选中的行数据传入,包含所有字段 // 将生成的取证单数据作为选中的行数据传入,包含所有字段
const evidenceData = { const evidenceData = {
@@ -1075,7 +1086,9 @@
evidenceSelectedRows.value = [evidenceData]; evidenceSelectedRows.value = [evidenceData];
evidenceModalVisible.value = true; evidenceModalVisible.value = true;
} else { } else {
throw new Error(apiResult.data?.error || apiResult.message || '生成取证单失败'); throw new Error(
apiResult.data?.error || apiResult.message || '生成取证单失败'
);
} }
} catch (error: any) { } catch (error: any) {
console.error('生成取证单失败:', error); console.error('生成取证单失败:', error);
@@ -1500,19 +1513,16 @@
section.data.splice(uiIndex, 1, merged); section.data.splice(uiIndex, 1, merged);
} }
if ( if (editingTableKey.value && tableGenerationData[editingTableKey.value]) {
editingTableKey.value &&
tableGenerationData[editingTableKey.value]
) {
const responseData = const responseData =
tableGenerationData[editingTableKey.value].responseData; tableGenerationData[editingTableKey.value].responseData;
if (responseData && responseData.data && Array.isArray(responseData.data)) { if (
const rawIndex = findRawIndex( responseData &&
responseData.data, responseData.data &&
targetRow, Array.isArray(responseData.data)
uiIndex ) {
); const rawIndex = findRawIndex(responseData.data, targetRow, uiIndex);
if (rawIndex !== -1) { if (rawIndex !== -1) {
responseData.data[rawIndex] = { responseData.data[rawIndex] = {
@@ -1534,8 +1544,7 @@
} }
const currentSelections = selectedRowsMap[editingSectionIndex.value] || []; const currentSelections = selectedRowsMap[editingSectionIndex.value] || [];
selectedRowsMap[editingSectionIndex.value] = currentSelections selectedRowsMap[editingSectionIndex.value] = currentSelections.map(
.map(
(row: any) => (row: any) =>
section.data.find((item: any) => item.key === row.key) || row section.data.find((item: any) => item.key === row.key) || row
); );
@@ -1583,7 +1592,9 @@
targetRow?.id !== null && targetRow?.id !== null &&
targetRow?.id !== ''; targetRow?.id !== '';
if (hasValidId) { if (hasValidId) {
const byId = responseList.findIndex((item: any) => item.id === targetRow.id); const byId = responseList.findIndex(
(item: any) => item.id === targetRow.id
);
if (byId !== -1) return byId; if (byId !== -1) return byId;
} }
@@ -1617,7 +1628,9 @@
const rawIndexesToDelete: number[] = []; const rawIndexesToDelete: number[] = [];
selectedRows.forEach((row: any) => { selectedRows.forEach((row: any) => {
const uiIndex = section.data.findIndex((item: any) => item.key === row.key); const uiIndex = section.data.findIndex(
(item: any) => item.key === row.key
);
if (uiIndex !== -1) uiIndexesToDelete.push(uiIndex); if (uiIndex !== -1) uiIndexesToDelete.push(uiIndex);
if (responseData) { if (responseData) {
@@ -1659,7 +1672,9 @@
selectedRowsMap[sectionIndex] = []; selectedRowsMap[sectionIndex] = [];
selectedRowKeysMap[sectionIndex] = []; selectedRowKeysMap[sectionIndex] = [];
message.success(`已删除${uniqueUiIndexes.length || selectedRows.length}条记录`); message.success(
`已删除${uniqueUiIndexes.length || selectedRows.length}条记录`
);
}; };
/* 保存当前表格到历史记录 */ /* 保存当前表格到历史记录 */
@@ -1950,6 +1965,20 @@
} }
} }
); );
const handleFilePreview = (file) => {
console.log(
file.fileUrl,
`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
file.fileUrl
)}`
);
window.open(
`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
file.fileUrl
)}`
);
};
</script> </script>
<script lang="ts"> <script lang="ts">