完善审计报告生成页面
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:visible="visible"
|
||||
title="编辑行数据"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
:confirm-loading="loading"
|
||||
width="600px"
|
||||
:visible="visible"
|
||||
title="编辑行数据"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
:confirm-loading="loading"
|
||||
width="600px"
|
||||
>
|
||||
<template #title>
|
||||
<div class="modal-title">
|
||||
@@ -17,23 +17,23 @@
|
||||
</template>
|
||||
|
||||
<a-alert
|
||||
v-if="displayRecords.length > 1"
|
||||
type="info"
|
||||
show-icon
|
||||
style="margin-bottom: 12px"
|
||||
:message="`已选择 ${displayRecords.length} 条记录,将把当前修改同步到这些记录`"
|
||||
v-if="displayRecords.length > 1"
|
||||
type="info"
|
||||
show-icon
|
||||
style="margin-bottom: 12px"
|
||||
:message="`已选择 ${displayRecords.length} 条记录,将把当前修改同步到这些记录`"
|
||||
/>
|
||||
<a-list
|
||||
v-if="displayRecords.length > 1"
|
||||
size="small"
|
||||
bordered
|
||||
:data-source="displayRecords"
|
||||
style="margin-bottom: 12px; max-height: 160px; overflow-y: auto"
|
||||
v-if="displayRecords.length > 1"
|
||||
size="small"
|
||||
bordered
|
||||
:data-source="displayRecords"
|
||||
style="margin-bottom: 12px; max-height: 160px; overflow-y: auto"
|
||||
>
|
||||
<template #renderItem="{ item, index }">
|
||||
<a-list-item
|
||||
:class="['record-item', { active: index === selectedRecordIndex }]"
|
||||
@click="selectRecord(index)"
|
||||
:class="['record-item', { active: index === selectedRecordIndex }]"
|
||||
@click="selectRecord(index)"
|
||||
>
|
||||
<span class="record-label">#{{ index + 1 }}</span>
|
||||
</a-list-item>
|
||||
@@ -45,22 +45,23 @@
|
||||
<a-form-item :label="field.title" v-if="!field.children">
|
||||
<template v-if="field.type === 'textarea'">
|
||||
<a-textarea
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:rows="4"
|
||||
:placeholder="`请输入${field.title}`"
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:rows="4"
|
||||
:placeholder="`请输入${field.title}`"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="field.dataIndex === 'workPaperIndex'">
|
||||
<a-textarea
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:rows="4"
|
||||
:placeholder="'每行一个文件,格式为:file_id||文件名||url'"
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:rows="4"
|
||||
:placeholder="'每行一个文件,格式为:file_id||文件名||url'"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-input
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:placeholder="`请输入${field.title}`"
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
v-model:value="activeFormData[field.dataIndex]"
|
||||
:placeholder="`请输入${field.title}`"
|
||||
/>
|
||||
</template>
|
||||
</a-form-item>
|
||||
@@ -71,14 +72,14 @@
|
||||
<div class="field-group-title">{{ field.title }}</div>
|
||||
<div class="field-group-content">
|
||||
<a-form-item
|
||||
v-for="childField in field.children"
|
||||
:key="childField.key"
|
||||
:label="childField.title"
|
||||
class="nested-field-item"
|
||||
v-for="childField in field.children"
|
||||
:key="childField.key"
|
||||
:label="childField.title"
|
||||
class="nested-field-item"
|
||||
>
|
||||
<a-input
|
||||
v-model:value="activeFormData[childField.dataIndex]"
|
||||
:placeholder="`请输入${childField.title}`"
|
||||
v-model:value="activeFormData[childField.dataIndex]"
|
||||
:placeholder="`请输入${childField.title}`"
|
||||
/>
|
||||
</a-form-item>
|
||||
</div>
|
||||
@@ -90,207 +91,219 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
record: any;
|
||||
fields: any[];
|
||||
records?: any[];
|
||||
}>();
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
record: any;
|
||||
fields: any[];
|
||||
records?: any[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits(['update:visible', 'save']);
|
||||
const emit = defineEmits(['update:visible', 'save']);
|
||||
|
||||
const loading = ref(false);
|
||||
const formDataList = ref<any[]>([]);
|
||||
const selectedRecordIndex = ref(0);
|
||||
const loading = ref(false);
|
||||
const formDataList = ref<any[]>([]);
|
||||
const selectedRecordIndex = ref(0);
|
||||
|
||||
const displayRecords = computed(() => {
|
||||
if (props.records && Array.isArray(props.records) && props.records.length) {
|
||||
return props.records;
|
||||
}
|
||||
if (props.record) return [props.record];
|
||||
return [];
|
||||
});
|
||||
|
||||
const transformRecordToFormData = (record: any) => {
|
||||
if (!record) return {};
|
||||
const recordCopy = JSON.parse(JSON.stringify(record));
|
||||
|
||||
if (
|
||||
hasWorkPaperIndexField.value &&
|
||||
recordCopy.workPaperIndex &&
|
||||
Array.isArray(recordCopy.workPaperIndex)
|
||||
) {
|
||||
recordCopy.workPaperIndex = recordCopy.workPaperIndex
|
||||
.map((item: any) => {
|
||||
if (typeof item === 'object') {
|
||||
return `${item.fileId || ''}||${item.fileName || ''}||${item.fileUrl || ''}`;
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
return recordCopy;
|
||||
};
|
||||
|
||||
const hasWorkPaperIndexField = computed(() => {
|
||||
return (props.fields || []).some((field) => {
|
||||
return field?.dataIndex === 'workPaperIndex' || field?.key === 'workPaperIndex';
|
||||
const displayRecords = computed(() => {
|
||||
if (props.records && Array.isArray(props.records) && props.records.length) {
|
||||
return props.records;
|
||||
}
|
||||
if (props.record) return [props.record];
|
||||
return [];
|
||||
});
|
||||
});
|
||||
|
||||
// 处理字段,将嵌套结构展平
|
||||
const processedFields = computed(() => {
|
||||
const processed: any[] = [];
|
||||
const transformRecordToFormData = (record: any) => {
|
||||
if (!record) return {};
|
||||
const recordCopy = JSON.parse(JSON.stringify(record));
|
||||
|
||||
(props.fields || []).forEach(field => {
|
||||
if (field.children && Array.isArray(field.children)) {
|
||||
// 处理有子字段的情况(如职务)
|
||||
processed.push({
|
||||
...field,
|
||||
children: field.children.flatMap(child =>
|
||||
child.children && Array.isArray(child.children)
|
||||
if (
|
||||
hasWorkPaperIndexField.value &&
|
||||
recordCopy.workPaperIndex &&
|
||||
Array.isArray(recordCopy.workPaperIndex)
|
||||
) {
|
||||
recordCopy.workPaperIndex = recordCopy.workPaperIndex
|
||||
.map((item: any) => {
|
||||
if (typeof item === 'object') {
|
||||
return `${item.fileId || ''}||${item.fileName || ''}||${
|
||||
item.fileUrl || ''
|
||||
}`;
|
||||
}
|
||||
return item;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
return recordCopy;
|
||||
};
|
||||
|
||||
const hasWorkPaperIndexField = computed(() => {
|
||||
return (props.fields || []).some((field) => {
|
||||
return (
|
||||
field?.dataIndex === 'workPaperIndex' || field?.key === 'workPaperIndex'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// 处理字段,将嵌套结构展平
|
||||
const processedFields = computed(() => {
|
||||
const processed: any[] = [];
|
||||
|
||||
(props.fields || []).forEach((field) => {
|
||||
if (field.children && Array.isArray(field.children)) {
|
||||
// 处理有子字段的情况(如职务)
|
||||
processed.push({
|
||||
...field,
|
||||
children: field.children.flatMap(
|
||||
(child) =>
|
||||
child.children && Array.isArray(child.children)
|
||||
? child.children // 如果是多层嵌套,直接取孙子字段
|
||||
: child // 否则就是子字段
|
||||
)
|
||||
});
|
||||
} else {
|
||||
processed.push(field);
|
||||
}
|
||||
)
|
||||
});
|
||||
} else {
|
||||
processed.push(field);
|
||||
}
|
||||
});
|
||||
|
||||
return processed;
|
||||
});
|
||||
|
||||
return processed;
|
||||
});
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
selectedRecordIndex.value = 0;
|
||||
formDataList.value = displayRecords.value.map((rec) =>
|
||||
transformRecordToFormData(rec)
|
||||
);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
selectedRecordIndex.value = 0;
|
||||
formDataList.value = displayRecords.value.map((rec) =>
|
||||
transformRecordToFormData(rec)
|
||||
const handleOk = () => {
|
||||
if (!formDataList.value || formDataList.value.length === 0) {
|
||||
message.warning('没有数据可保存');
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理workPaperIndex:将字符串转换回对象数组
|
||||
const dataToSave = formDataList.value.map((item) => {
|
||||
const cloned = JSON.parse(JSON.stringify(item || {}));
|
||||
if (
|
||||
hasWorkPaperIndexField.value &&
|
||||
cloned.workPaperIndex &&
|
||||
typeof cloned.workPaperIndex === 'string'
|
||||
) {
|
||||
const lines = cloned.workPaperIndex
|
||||
.split('\n')
|
||||
.filter((line: string) => line.trim() !== '');
|
||||
cloned.workPaperIndex = lines.map((line: string) => {
|
||||
const parts = line.split('||');
|
||||
if (parts.length >= 3) {
|
||||
return {
|
||||
fileId: parts[0] || '',
|
||||
fileName: parts[1] || '',
|
||||
fileUrl: parts[2] || ''
|
||||
};
|
||||
}
|
||||
return line;
|
||||
});
|
||||
}
|
||||
return cloned;
|
||||
});
|
||||
|
||||
loading.value = true;
|
||||
emit('save', dataToSave);
|
||||
loading.value = false;
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const selectRecord = (index: number) => {
|
||||
if (index < 0 || index >= displayRecords.value.length) return;
|
||||
selectedRecordIndex.value = index;
|
||||
if (!formDataList.value[index]) {
|
||||
formDataList.value[index] = transformRecordToFormData(
|
||||
displayRecords.value[index]
|
||||
);
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
};
|
||||
|
||||
const handleOk = () => {
|
||||
if (!formDataList.value || formDataList.value.length === 0) {
|
||||
message.warning('没有数据可保存');
|
||||
return;
|
||||
}
|
||||
|
||||
// 处理workPaperIndex:将字符串转换回对象数组
|
||||
const dataToSave = formDataList.value.map((item) => {
|
||||
const cloned = JSON.parse(JSON.stringify(item || {}));
|
||||
if (hasWorkPaperIndexField.value && cloned.workPaperIndex && typeof cloned.workPaperIndex === 'string') {
|
||||
const lines = cloned.workPaperIndex.split('\n').filter((line: string) => line.trim() !== '');
|
||||
cloned.workPaperIndex = lines.map((line: string) => {
|
||||
const parts = line.split('||');
|
||||
if (parts.length >= 3) {
|
||||
return {
|
||||
fileId: parts[0] || '',
|
||||
fileName: parts[1] || '',
|
||||
fileUrl: parts[2] || ''
|
||||
};
|
||||
}
|
||||
return line;
|
||||
});
|
||||
const activeFormData = computed({
|
||||
get() {
|
||||
if (!displayRecords.value.length) return {};
|
||||
if (!formDataList.value[selectedRecordIndex.value]) {
|
||||
formDataList.value[selectedRecordIndex.value] =
|
||||
transformRecordToFormData(
|
||||
displayRecords.value[selectedRecordIndex.value]
|
||||
);
|
||||
}
|
||||
return formDataList.value[selectedRecordIndex.value] || {};
|
||||
},
|
||||
set(val) {
|
||||
if (!displayRecords.value.length) return;
|
||||
formDataList.value[selectedRecordIndex.value] = val || {};
|
||||
}
|
||||
return cloned;
|
||||
});
|
||||
|
||||
loading.value = true;
|
||||
emit('save', dataToSave);
|
||||
loading.value = false;
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const selectRecord = (index: number) => {
|
||||
if (index < 0 || index >= displayRecords.value.length) return;
|
||||
selectedRecordIndex.value = index;
|
||||
if (!formDataList.value[index]) {
|
||||
formDataList.value[index] = transformRecordToFormData(
|
||||
displayRecords.value[index]
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const activeFormData = computed({
|
||||
get() {
|
||||
if (!displayRecords.value.length) return {};
|
||||
if (!formDataList.value[selectedRecordIndex.value]) {
|
||||
formDataList.value[selectedRecordIndex.value] = transformRecordToFormData(
|
||||
displayRecords.value[selectedRecordIndex.value]
|
||||
);
|
||||
}
|
||||
return formDataList.value[selectedRecordIndex.value] || {};
|
||||
},
|
||||
set(val) {
|
||||
if (!displayRecords.value.length) return;
|
||||
formDataList.value[selectedRecordIndex.value] = val || {};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.nested-fields {
|
||||
margin-bottom: 16px;
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
.nested-fields {
|
||||
margin-bottom: 16px;
|
||||
border: 1px solid #f0f0f0;
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.field-group-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: #1890ff;
|
||||
}
|
||||
.field-group-title {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.field-group-content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
.field-group-content {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.nested-field-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.nested-field-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.modal-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.record-label {
|
||||
display: inline-block;
|
||||
width: 36px;
|
||||
color: #888;
|
||||
}
|
||||
.record-label {
|
||||
display: inline-block;
|
||||
width: 36px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.record-text {
|
||||
color: #333;
|
||||
}
|
||||
.record-text {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.record-item {
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
.record-item {
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.record-item:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.record-item:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.record-item.active {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
.record-item.active {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -72,11 +72,22 @@
|
||||
<tr>
|
||||
<th>审计(调查)事项</th>
|
||||
<td>
|
||||
<textarea
|
||||
v-model="form.auditMatter"
|
||||
class="cell-input single"
|
||||
placeholder="填写审计(调查)事项"
|
||||
></textarea>
|
||||
<a-select style="min-width: 600px"
|
||||
v-model:value="form.auditMatter"
|
||||
placeholder="请选择审计(调查)事项"
|
||||
>
|
||||
<a-select-option
|
||||
v-for="(item, index) in auditMatterOptions"
|
||||
:key="index"
|
||||
:value="item"
|
||||
>{{ item }}</a-select-option
|
||||
>
|
||||
</a-select>
|
||||
<!-- <textarea-->
|
||||
<!-- v-model="form.auditMatter"-->
|
||||
<!-- class="cell-input single"-->
|
||||
<!-- placeholder="填写审计(调查)事项"-->
|
||||
<!-- ></textarea>-->
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -257,7 +268,10 @@
|
||||
import { PropType, reactive, ref, watch } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { PwlProject } from '@/api/pwl/pwlProject/model';
|
||||
import { downloadAuditEvidence, saveAuditEvidence } from '@/api/ai/auditContent';
|
||||
import {
|
||||
downloadAuditEvidence,
|
||||
saveAuditEvidence
|
||||
} from '@/api/ai/auditContent';
|
||||
|
||||
type BaseInfo = {
|
||||
caseIndex?: string;
|
||||
@@ -286,6 +300,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
const auditMatterOptions = [
|
||||
'贯彻执行党和国家经济方针政策、决策部署情况',
|
||||
'企业发展战略规划的制定、执行和效果情况',
|
||||
'重大经济事项的决策、执行和效果情况',
|
||||
'企业法人治理结构的建立、健全和运行情况,内部控制制度的制定和执行情况',
|
||||
'企业财务的真实合法效益情况,风险管控情况,境外资产管理情况,生态环境保护情况',
|
||||
'在经济活动中落实有关党风廉政建设责任和遵守廉洁从业规定情况',
|
||||
'以往审计发现问题的整改情况',
|
||||
'其他需要审计的内容'
|
||||
];
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
}>();
|
||||
@@ -342,21 +367,30 @@
|
||||
console.log('===== applyBaseInfo 开始执行 =====');
|
||||
console.log('1. selectedRows:', props.selectedRows);
|
||||
console.log('2. baseInfo:', props.baseInfo);
|
||||
console.log('3. baseInfo.auditMatterType:', props.baseInfo?.auditMatterType);
|
||||
console.log(
|
||||
'3. baseInfo.auditMatterType:',
|
||||
props.baseInfo?.auditMatterType
|
||||
);
|
||||
|
||||
// 重置表单为默认值
|
||||
Object.assign(form, defaultForm(), props.baseInfo || {});
|
||||
|
||||
console.log('4. Object.assign 后的 form.auditMatterType:', form.auditMatterType);
|
||||
|
||||
|
||||
console.log(
|
||||
'4. Object.assign 后的 form.auditMatterType:',
|
||||
form.auditMatterType
|
||||
);
|
||||
|
||||
// 特殊处理:确保 auditMatterType 被正确复制(Object.assign 可能会覆盖)
|
||||
if (props.baseInfo?.auditMatterType) {
|
||||
form.auditMatterType = props.baseInfo.auditMatterType;
|
||||
console.log('✓ 5. 显式设置后的 form.auditMatterType:', form.auditMatterType);
|
||||
console.log(
|
||||
'✓ 5. 显式设置后的 form.auditMatterType:',
|
||||
form.auditMatterType
|
||||
);
|
||||
} else {
|
||||
console.warn('✗ 5. auditMatterType 为空或未设置,无法复制');
|
||||
}
|
||||
|
||||
|
||||
console.log('===== applyBaseInfo 执行完毕 =====');
|
||||
|
||||
// 如果有传入的selectedRows,直接使用第一个对象的数据(生成取证单时通常只有一个)
|
||||
@@ -366,8 +400,15 @@
|
||||
|
||||
// 直接将后端返回的数据映射到表单字段
|
||||
form.caseIndex =
|
||||
props.baseInfo?.caseIndex || props.project?.caseIndex || form.caseIndex || '';
|
||||
form.projectName = props.project?.code || evidenceData.projectName || form.projectName || '';
|
||||
props.baseInfo?.caseIndex ||
|
||||
props.project?.caseIndex ||
|
||||
form.caseIndex ||
|
||||
'';
|
||||
form.projectName =
|
||||
props.project?.code ||
|
||||
evidenceData.projectName ||
|
||||
form.projectName ||
|
||||
'';
|
||||
form.auditedTarget =
|
||||
evidenceData.auditedTarget || form.auditedTarget || '';
|
||||
form.auditMatter = evidenceData.auditMatter || form.auditMatter || '';
|
||||
@@ -439,7 +480,10 @@
|
||||
watch(
|
||||
() => props.baseInfo,
|
||||
(newVal) => {
|
||||
console.log('watch baseInfo triggered, newVal.auditMatterType:', newVal?.auditMatterType);
|
||||
console.log(
|
||||
'watch baseInfo triggered, newVal.auditMatterType:',
|
||||
newVal?.auditMatterType
|
||||
);
|
||||
if (props.visible) {
|
||||
applyBaseInfo();
|
||||
}
|
||||
@@ -514,7 +558,7 @@
|
||||
feedbackDeadline: form.feedbackDeadline,
|
||||
history: '' // 历史内容,如果需要的话
|
||||
};
|
||||
|
||||
|
||||
console.log('=== 保存取证单 ===');
|
||||
console.log('form:', form);
|
||||
console.log('form.auditMatterType:', form.auditMatterType);
|
||||
@@ -582,7 +626,9 @@
|
||||
link.href = url;
|
||||
|
||||
// 设置文件名
|
||||
const fileName = `审计取证单_${form.projectName || '取证单'}_${form.caseIndex || ''}.docx`;
|
||||
const fileName = `审计取证单_${form.projectName || '取证单'}_${
|
||||
form.caseIndex || ''
|
||||
}.docx`;
|
||||
link.setAttribute('download', fileName);
|
||||
|
||||
// 触发下载
|
||||
|
||||
@@ -80,11 +80,12 @@ const props = defineProps<{
|
||||
visible: boolean;
|
||||
interfaceName?: string;
|
||||
projectId?: number;
|
||||
chapter?: any; // 当前章节对象
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
(e: 'select', record: any): void;
|
||||
(e: 'select', record: any, chapter?: any): void;
|
||||
}>();
|
||||
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
@@ -99,7 +100,11 @@ const datasource: DatasourceFunction = async ({ page, limit, orders }) => {
|
||||
if (orders) {
|
||||
Object.assign(params, orders);
|
||||
}
|
||||
console.log(props,'props');
|
||||
|
||||
console.log('===== HistoryModal Props =====', props);
|
||||
console.log('interfaceName:', props.interfaceName);
|
||||
console.log('projectId:', props.projectId);
|
||||
|
||||
// 使用传入的接口名称进行过滤
|
||||
if (props.interfaceName) {
|
||||
params.interfaceName = props.interfaceName;
|
||||
@@ -107,6 +112,8 @@ const datasource: DatasourceFunction = async ({ page, limit, orders }) => {
|
||||
if (props.projectId) {
|
||||
params.projectId = props.projectId;
|
||||
}
|
||||
|
||||
console.log('查询参数 params:', params);
|
||||
|
||||
try {
|
||||
const result = await pageAiHistory(params);
|
||||
@@ -116,14 +123,23 @@ const datasource: DatasourceFunction = async ({ page, limit, orders }) => {
|
||||
let processingTime = '';
|
||||
|
||||
try {
|
||||
// responseData 直接就是 AI 生成的文本内容,不是 JSON 对象
|
||||
// 这里只是为了统计展示信息,不影响主要内容显示
|
||||
if (record.responseData) {
|
||||
const responseData = JSON.parse(record.responseData);
|
||||
if (responseData.data && Array.isArray(responseData.data)) {
|
||||
dataCount = responseData.data.length;
|
||||
} else if (responseData.data?.data && Array.isArray(responseData.data.data)) {
|
||||
dataCount = responseData.data.data.length;
|
||||
// 尝试解析是否为 JSON 格式(兼容旧数据)
|
||||
try {
|
||||
const parsed = JSON.parse(record.responseData);
|
||||
if (parsed.data && Array.isArray(parsed.data)) {
|
||||
dataCount = parsed.data.length;
|
||||
} else if (parsed.data?.data && Array.isArray(parsed.data.data)) {
|
||||
dataCount = parsed.data.data.length;
|
||||
}
|
||||
processingTime = parsed.processing_time || parsed.generated_time || '';
|
||||
} catch (e) {
|
||||
// 如果不是 JSON,说明是纯文本,不需要统计这些数据
|
||||
dataCount = 0;
|
||||
processingTime = '';
|
||||
}
|
||||
processingTime = responseData.processing_time || responseData.generated_time || '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('解析响应数据失败:', error);
|
||||
@@ -258,6 +274,14 @@ const getRequestDataPreview = (record: any) => {
|
||||
const hasValidData = (record: any) => {
|
||||
try {
|
||||
if (record.responseData) {
|
||||
// responseData 可能是纯文本(AI 生成的审计报告内容),也可能是 JSON 对象
|
||||
// 对于纯文本,只要有内容就认为有效
|
||||
if (typeof record.responseData === 'string') {
|
||||
// 如果是字符串,检查是否非空
|
||||
return record.responseData.trim().length > 0;
|
||||
}
|
||||
|
||||
// 如果是对象,尝试解析 JSON
|
||||
const responseData = JSON.parse(record.responseData);
|
||||
const hasData = (responseData.data && Array.isArray(responseData.data) && responseData.data.length > 0) ||
|
||||
(responseData.data?.data && Array.isArray(responseData.data.data) && responseData.data.data.length > 0);
|
||||
@@ -265,13 +289,15 @@ const hasValidData = (record: any) => {
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('检查数据有效性失败:', error);
|
||||
// 如果解析失败,但有 responseData 字符串,也认为有效(说明是纯文本)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleSelect = (record: any) => {
|
||||
if (!hasValidData(record)) return;
|
||||
emit('select', record);
|
||||
emit('select', record, props.chapter);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -170,45 +170,34 @@
|
||||
<!-- </div>-->
|
||||
<!-- 单内容部分 -->
|
||||
<template v-if="!item.children">
|
||||
<a-textarea
|
||||
v-model:value="item.content"
|
||||
:rows="item.rows || 8"
|
||||
:placeholder="'点击(AI生成)按钮让AI为您生成该部分内容,或直接填入'"
|
||||
class="content-textarea"
|
||||
style="margin-top: 16px; background-color: #f0fdf4"
|
||||
/>
|
||||
|
||||
<div style="margin-top: 12px;">
|
||||
<div class="question-prompt">AI小助手</div>
|
||||
<div class="textarea-with-button" style="width: 600px">
|
||||
<a-textarea
|
||||
v-model:value="item.suggestion"
|
||||
:rows="3"
|
||||
placeholder="请输入您的要求并回车..."
|
||||
class="suggestion-textarea-inner"
|
||||
@pressEnter="generateContent(index)"
|
||||
/>
|
||||
<a-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="generateContent(index)"
|
||||
:loading="item.generating"
|
||||
class="send-button-inner"
|
||||
>
|
||||
<template #icon>
|
||||
<RobotOutlined/>
|
||||
</template>
|
||||
发送
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="content-with-ai-button">
|
||||
<a-textarea
|
||||
v-model:value="item.content"
|
||||
:rows="item.rows || 8"
|
||||
:placeholder="'点击 (AI 生成) 按钮让 AI 为您生成该部分内容,或直接填入'"
|
||||
class="content-textarea"
|
||||
style="background-color: #f0fdf4"
|
||||
/>
|
||||
<a-button
|
||||
type="primary"
|
||||
size="large"
|
||||
@click="generateContent(index)"
|
||||
:loading="item.generating"
|
||||
class="ai-generate-btn"
|
||||
>
|
||||
<template #icon>
|
||||
<RobotOutlined/>
|
||||
</template>
|
||||
AI 生成
|
||||
</a-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 多内容部分 -->
|
||||
<template v-else>
|
||||
<div v-for="(child, childIndex) in item.children" :key="childIndex" class="child-section" style="border-left: 3px solid #1890ff; padding-left: 16px; margin-bottom: 20px;">
|
||||
<div class="child-title" style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<span style="font-weight: bold;">{{ child.name }}</span>
|
||||
<template v-if="item.children">
|
||||
<div v-for="(child, childIndex) in item.children" :key="childIndex" class="child-section">
|
||||
<div class="child-header">
|
||||
<span class="child-title">{{ `(${childIndex + 1})${child.name}` }}</span>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
@@ -236,10 +225,10 @@
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
size="small"
|
||||
size="large"
|
||||
@click.stop="generateContent(index, childIndex)"
|
||||
:loading="child.generating"
|
||||
class="child-action-button ai-generate-button"
|
||||
class="ai-generate-btn"
|
||||
>
|
||||
<template #icon>
|
||||
<RobotOutlined/>
|
||||
@@ -253,34 +242,8 @@
|
||||
:rows="child.rows || 6"
|
||||
:placeholder="child.placeholder"
|
||||
class="content-textarea"
|
||||
style="margin-top: 12px; background-color: #f0fdf4"
|
||||
style="background-color: #f0fdf4"
|
||||
/>
|
||||
|
||||
<!-- AI小助手功能 -->
|
||||
<div style="margin-top: 12px">
|
||||
<div class="question-prompt">AI小助手</div>
|
||||
<div class="textarea-with-button" style="width: 600px">
|
||||
<a-textarea
|
||||
v-model:value="child.suggestion"
|
||||
:rows="3"
|
||||
placeholder="请输入优化提示词并回车..."
|
||||
class="suggestion-textarea-inner"
|
||||
@pressEnter="generateContent(index, childIndex)"
|
||||
/>
|
||||
<a-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="generateContent(index, childIndex)"
|
||||
:loading="child.generating"
|
||||
class="send-button-inner"
|
||||
>
|
||||
<template #icon>
|
||||
<RobotOutlined/>
|
||||
</template>
|
||||
发送
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</a-card>
|
||||
@@ -1807,24 +1770,68 @@ export default {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.content-with-ai-button {
|
||||
position: relative;
|
||||
margin-top: 16px;
|
||||
|
||||
.ant-textarea {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.ai-generate-btn {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
z-index: 10;
|
||||
background-color: #722ed1 !important;
|
||||
border-color: #722ed1 !important;
|
||||
|
||||
&:hover {
|
||||
background-color: #9254de !important;
|
||||
border-color: #9254de !important;
|
||||
box-shadow: 0 4px 12px rgba(114, 46, 209, 0.4) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.child-section {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px dashed #e8e8e8;
|
||||
position: relative;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.child-title {
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
padding-left: 8px;
|
||||
border-left: 3px solid #1890ff;
|
||||
.child-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
padding: 12px 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px 6px 0 0;
|
||||
border-left: 3px solid #1890ff;
|
||||
|
||||
.child-title {
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.ai-generate-btn {
|
||||
background-color: #722ed1 !important;
|
||||
border-color: #722ed1 !important;
|
||||
|
||||
&:hover {
|
||||
background-color: #9254de !important;
|
||||
border-color: #9254de !important;
|
||||
box-shadow: 0 4px 12px rgba(114, 46, 209, 0.4) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content-textarea {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user