|
|
@@ -8,12 +8,15 @@ import ReportCategory from './components/report-create/ReportCategory.vue';
|
|
|
import DynamicMeta from './components/dynamic-meta/DynamicMeta.vue';
|
|
|
import ChapterTypeSelect from "./components/ChapterTypeSelect.vue";
|
|
|
import LogoComponent from "./components/LogoComponent.vue";
|
|
|
-import type { Chapter, ChapterType, ReportMetadataItem, ReportSaveRequest } from "@/types/report.types";
|
|
|
+import type { Chapter, ChapterType, ReportMetadataItem, ReportSaveRequest, ReportTemplateSave } from "@/types/report.types";
|
|
|
import { ChapterManager } from "@/models/report.model";
|
|
|
import ChapterEditor from "./components/ChapterEditor.vue";
|
|
|
import * as reportService from "@/services/report.service";
|
|
|
+import * as reportTemplateService from "@/services/reportTemplate.service"
|
|
|
import { CompLog } from "@/helpers/log.helper";
|
|
|
import { message } from "ant-design-vue";
|
|
|
+import TemplateSaveModal from "./components/TemplateSaveModal.vue";
|
|
|
+import type { ReportTemplateModal } from "./reportComponent.types";
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
@@ -55,7 +58,6 @@ function onCompanyChange(companyId: number) {
|
|
|
const saveLoading = ref(false);
|
|
|
|
|
|
function onSave() {
|
|
|
- console.log('report', report.value);
|
|
|
if (report.value) {
|
|
|
const reportName = (report.value.name || '').trim();
|
|
|
if (reportName == '') {
|
|
|
@@ -74,6 +76,34 @@ function onSave() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const templateSaveModal = ref<InstanceType<typeof TemplateSaveModal> | null>(null);
|
|
|
+
|
|
|
+function showTemplateSaveModal() {
|
|
|
+ templateSaveModal.value?.show();
|
|
|
+}
|
|
|
+
|
|
|
+function onSaveTemplate(modalData: ReportTemplateModal) {
|
|
|
+ let chapters = report.value?.chapters.map((chapter) => {
|
|
|
+ return {
|
|
|
+ title: chapter.title
|
|
|
+ } as Chapter
|
|
|
+ })
|
|
|
+ const reportTemplateSave: ReportTemplateSave = {
|
|
|
+ name: modalData.templateName,
|
|
|
+ logoPath: report.value?.logoPath || '',
|
|
|
+ metadata: report.value?.metadata || [],
|
|
|
+ chapters: chapters || [],
|
|
|
+ tags: modalData.tags,
|
|
|
+ }
|
|
|
+
|
|
|
+ reportTemplateService.save(reportTemplateSave).then(() => {
|
|
|
+ templateSaveModal.value?.complete()
|
|
|
+ }).catch((err) => {
|
|
|
+ CompLog.logErr(err)
|
|
|
+ templateSaveModal.value?.complete()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
const id = parseInt(route.params.id as string);
|
|
|
if (id && id > 0) {
|
|
|
@@ -120,10 +150,11 @@ onMounted(() => {
|
|
|
<a-button type="primary" @click="onSave" :loading="saveLoading">保存</a-button>
|
|
|
<a-button>预览</a-button>
|
|
|
<a-button>导出</a-button>
|
|
|
- <a-button>保存为模板</a-button>
|
|
|
+ <a-button @click="showTemplateSaveModal">另保存为模板</a-button>
|
|
|
</a-space>
|
|
|
</div>
|
|
|
<ChapterTypeSelect @ok="onChapterTypeSelected" v-model:visible="chapterTypeSelectVisible" />
|
|
|
+ <TemplateSaveModal ref="templateSaveModal" @ok="onSaveTemplate" />
|
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|