|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { onMounted, ref, type Ref } from "vue";
|
|
|
|
|
|
|
+import { computed, onMounted, ref, type Ref } from "vue";
|
|
|
import { useRoute } from "vue-router";
|
|
import { useRoute } from "vue-router";
|
|
|
import { PlusOutlined } from "@ant-design/icons-vue";
|
|
import { PlusOutlined } from "@ant-design/icons-vue";
|
|
|
import PageHeader from '@/components/PageHeader.vue';
|
|
import PageHeader from '@/components/PageHeader.vue';
|
|
@@ -12,6 +12,13 @@ import type { Chapter, ChapterType, ReportSaveRequest } from "@/types/report.typ
|
|
|
import { ChapterManager } from "@/models/report.model";
|
|
import { ChapterManager } from "@/models/report.model";
|
|
|
import ChapterEditor from "./components/ChapterEditor.vue";
|
|
import ChapterEditor from "./components/ChapterEditor.vue";
|
|
|
import * as reportService from "@/services/report.service";
|
|
import * as reportService from "@/services/report.service";
|
|
|
|
|
+import { CompLog } from "@/helpers/log.helper";
|
|
|
|
|
+
|
|
|
|
|
+const route = useRoute();
|
|
|
|
|
+
|
|
|
|
|
+const report: Ref<ReportSaveRequest | null> = ref(null);
|
|
|
|
|
+
|
|
|
|
|
+const companyId = computed(() => report.value?.companyId || 0)
|
|
|
|
|
|
|
|
// 报告元数据
|
|
// 报告元数据
|
|
|
const metadata: Ref<any[]> = ref([]);
|
|
const metadata: Ref<any[]> = ref([]);
|
|
@@ -30,20 +37,37 @@ function onChapterTypeSelected(type: ChapterType) {
|
|
|
|
|
|
|
|
function onChapterChange(index: number, data: Chapter) {
|
|
function onChapterChange(index: number, data: Chapter) {
|
|
|
chapterManager.value.setChapter(index, data);
|
|
chapterManager.value.setChapter(index, data);
|
|
|
|
|
+ if (report.value) {
|
|
|
|
|
+ const chapter = report.value.chapters[index];
|
|
|
|
|
+ report.value.chapters[index] = {...chapter, ...data};
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const route = useRoute();
|
|
|
|
|
|
|
+function onCompanyChange(companyId: number) {
|
|
|
|
|
+ if (report.value) {
|
|
|
|
|
+ report.value.companyId = companyId;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
-const report: Ref<ReportSaveRequest | null> = ref(null);
|
|
|
|
|
|
|
+const saveLoading = ref(false);
|
|
|
|
|
+
|
|
|
|
|
+function onSave() {
|
|
|
|
|
+ if (report.value) {
|
|
|
|
|
+ saveLoading.value = true;
|
|
|
|
|
+ reportService.save(report.value).then(() => {
|
|
|
|
|
+ saveLoading.value = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
const id = parseInt(route.params.id as string);
|
|
const id = parseInt(route.params.id as string);
|
|
|
if (id && id > 0) {
|
|
if (id && id > 0) {
|
|
|
reportService.get(id).then((data) => {
|
|
reportService.get(id).then((data) => {
|
|
|
report.value = data;
|
|
report.value = data;
|
|
|
- }).catch((err) => {
|
|
|
|
|
- console.log(err);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const chapters = report.value.chapters;
|
|
|
|
|
+ chapterManager.value.setChapters(chapters);
|
|
|
|
|
+ }).catch(CompLog.logErr('ReportEditorView'));
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
@@ -53,7 +77,7 @@ onMounted(() => {
|
|
|
<a-row :gutter="24">
|
|
<a-row :gutter="24">
|
|
|
<a-col :span="12">
|
|
<a-col :span="12">
|
|
|
<div class="metadata-wrap">
|
|
<div class="metadata-wrap">
|
|
|
- <RelationCompanyInput />
|
|
|
|
|
|
|
+ <RelationCompanyInput v-model:id="companyId" @change="onCompanyChange" />
|
|
|
<ReportCategory />
|
|
<ReportCategory />
|
|
|
<DynamicMeta @change="onMetaChange" />
|
|
<DynamicMeta @change="onMetaChange" />
|
|
|
</div>
|
|
</div>
|
|
@@ -79,7 +103,7 @@ onMounted(() => {
|
|
|
</div>
|
|
</div>
|
|
|
<div class="bottom-button-group">
|
|
<div class="bottom-button-group">
|
|
|
<a-space>
|
|
<a-space>
|
|
|
- <a-button type="primary">保存</a-button>
|
|
|
|
|
|
|
+ <a-button type="primary" @click="onSave" :loading="saveLoading">保存</a-button>
|
|
|
<a-button>预览</a-button>
|
|
<a-button>预览</a-button>
|
|
|
<a-button>导出</a-button>
|
|
<a-button>导出</a-button>
|
|
|
<a-button>保存为模板</a-button>
|
|
<a-button>保存为模板</a-button>
|