|
|
@@ -18,6 +18,9 @@ import { message } from "ant-design-vue";
|
|
|
import TemplateSaveModal from "./components/TemplateSaveModal.vue";
|
|
|
import type { ReportTemplateModal } from "./reportComponent.types";
|
|
|
|
|
|
+const _componentName = 'ReportEditorView'
|
|
|
+const logError = CompLog.logErr(_componentName)
|
|
|
+
|
|
|
const route = useRoute();
|
|
|
|
|
|
const report: Ref<ReportSaveRequest | null> = ref(null);
|
|
|
@@ -28,7 +31,7 @@ const metadata: Ref<ReportMetadataItem[]> = ref([]);
|
|
|
// 章节类型选择器可见状态
|
|
|
const chapterTypeSelectVisible = ref(false);
|
|
|
// 章节管理对象
|
|
|
-const chapterManager = ref(new ChapterManager());
|
|
|
+const chapterManager = new ChapterManager();
|
|
|
|
|
|
function onMetaChange(data: ReportMetadataItem[]) {
|
|
|
metadata.value = data;
|
|
|
@@ -38,15 +41,23 @@ function onMetaChange(data: ReportMetadataItem[]) {
|
|
|
}
|
|
|
|
|
|
function onChapterTypeSelected(type: ChapterType) {
|
|
|
- chapterManager.value.addChapter(type);
|
|
|
+ chapterManager.addChapter(type);
|
|
|
}
|
|
|
|
|
|
function onChapterChange(index: number, data: Chapter) {
|
|
|
- chapterManager.value.setChapter(index, data);
|
|
|
- if (report.value) {
|
|
|
- const chapter = report.value.chapters[index];
|
|
|
- report.value.chapters[index] = {...chapter, ...data};
|
|
|
- }
|
|
|
+ chapterManager.setChapter(index, data);
|
|
|
+}
|
|
|
+
|
|
|
+function onChapterMoveUp(index: number) {
|
|
|
+ chapterManager.moveUp(index)
|
|
|
+}
|
|
|
+
|
|
|
+function onChapterMoveDown(index: number) {
|
|
|
+ chapterManager.moveDown(index)
|
|
|
+}
|
|
|
+
|
|
|
+function onChapterRemove(index: number) {
|
|
|
+ chapterManager.remove(index)
|
|
|
}
|
|
|
|
|
|
function onCompanyChange(companyId: number) {
|
|
|
@@ -71,7 +82,7 @@ function onSave() {
|
|
|
message.success("保存成功")
|
|
|
}).catch((err) => {
|
|
|
saveLoading.value = false;
|
|
|
- CompLog.logErr(err);
|
|
|
+ logError(err);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -99,7 +110,7 @@ function onSaveTemplate(modalData: ReportTemplateModal) {
|
|
|
reportTemplateService.save(reportTemplateSave).then(() => {
|
|
|
templateSaveModal.value?.complete()
|
|
|
}).catch((err) => {
|
|
|
- CompLog.logErr(err)
|
|
|
+ logError(err)
|
|
|
templateSaveModal.value?.complete()
|
|
|
})
|
|
|
}
|
|
|
@@ -110,8 +121,8 @@ onMounted(() => {
|
|
|
reportService.get(id).then((data) => {
|
|
|
report.value = data;
|
|
|
const chapters = report.value.chapters;
|
|
|
- chapterManager.value.setChapters(chapters);
|
|
|
- }).catch(CompLog.logErr('ReportEditorView'));
|
|
|
+ chapterManager.setChapters(chapters);
|
|
|
+ }).catch(logError);
|
|
|
}
|
|
|
});
|
|
|
</script>
|
|
|
@@ -131,12 +142,15 @@ onMounted(() => {
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
<a-divider />
|
|
|
- <div class="chapter-wrap">
|
|
|
+ <div class="chapter-wrap" v-if="report">
|
|
|
<ChapterEditor
|
|
|
v-for="(item, index) in chapterManager.getChapters()"
|
|
|
:key="index"
|
|
|
:data="item"
|
|
|
@change="onChapterChange(index, $event)"
|
|
|
+ @move-up="onChapterMoveUp(index)"
|
|
|
+ @move-down="onChapterMoveDown(index)"
|
|
|
+ @remove="onChapterRemove(index)"
|
|
|
/>
|
|
|
</div>
|
|
|
<div class="add-chapter-wrap">
|