|
@@ -25,7 +25,7 @@ import {
|
|
|
tableCoverHeight,
|
|
|
overviewData,
|
|
|
} from "../../store.ts";
|
|
|
-import { nextTick, onUnmounted, reactive } from "vue";
|
|
|
+import { nextTick, onUnmounted } from "vue";
|
|
|
import { DataGroupId } from "@/constant/index.ts";
|
|
|
import { Group } from "konva/lib/Group";
|
|
|
import { Mode } from "@/constant/mode.ts";
|
|
@@ -34,7 +34,7 @@ import { repTabulationStore } from "../tabulation/gen-tab.ts";
|
|
|
import { router } from "../../router.ts";
|
|
|
import { overviewId, params, tabulationId } from "@/example/env.ts";
|
|
|
import { listener } from "@/utils/event.ts";
|
|
|
-import { repeatedlyOnly } from "@/utils/shared.ts";
|
|
|
+import { mergeFuns, repeatedlyOnly } from "@/utils/shared.ts";
|
|
|
import saveAs from "@/utils/file-serve.ts";
|
|
|
|
|
|
const props = defineProps<{ title: string }>();
|
|
@@ -155,9 +155,69 @@ const setViewToTableCover = async () => {
|
|
|
] as const;
|
|
|
};
|
|
|
|
|
|
+const setViewToKanKanCover = async () => {
|
|
|
+ const oldViewMat = draw.viewer.viewMat;
|
|
|
+ const oldBack = draw.config.back && { ...draw.config.back };
|
|
|
+ const oldShowGrid = draw.config.showGrid;
|
|
|
+ const oldLabelLineConfig = { ...draw.config.labelLineConfig };
|
|
|
+ draw.config.labelLineConfig.stroke = "#FFFFFF";
|
|
|
+ draw.config.labelLineConfig.shadowColor = "#000000";
|
|
|
+ draw.config.labelLineConfig.fontSize = 18;
|
|
|
+ const pop = draw.mode.push(Mode.readonly);
|
|
|
+ draw.config.showGrid = false;
|
|
|
+ draw.config.back = undefined;
|
|
|
+
|
|
|
+ const set: any = {
|
|
|
+ stroke: "#FFFFFF",
|
|
|
+ fill: undefined,
|
|
|
+ color: "#FFFFFF",
|
|
|
+ fontColor: "#FFFFFF",
|
|
|
+ };
|
|
|
+ const cSet: any = {
|
|
|
+ text: {
|
|
|
+ fill: "#FFFFFF",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ const typeItems: any = Object.entries(draw.store.typeItems);
|
|
|
+ const lineData = draw.store.getTypeItems("line")[0];
|
|
|
+ if (lineData) {
|
|
|
+ typeItems.push(["lines", lineData.lines]);
|
|
|
+ }
|
|
|
+ const clearupItems = typeItems.map(([type, items]: any) => {
|
|
|
+ const cleanups: (() => void)[] = [];
|
|
|
+ items.forEach((item: any) => {
|
|
|
+ const itemSet = type in cSet ? cSet[type] : set;
|
|
|
+ const setKeys = Object.keys(itemSet);
|
|
|
+
|
|
|
+ for (const key of setKeys) {
|
|
|
+ if (key in item) {
|
|
|
+ const oldVal = item[key];
|
|
|
+ cleanups.push(() => (item[key] = oldVal));
|
|
|
+ } else {
|
|
|
+ cleanups.push(() => delete item[key]);
|
|
|
+ }
|
|
|
+ item[key] = itemSet[key];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return mergeFuns(cleanups);
|
|
|
+ });
|
|
|
+
|
|
|
+ draw.initViewport(70);
|
|
|
+ await nextTick();
|
|
|
+ const blob = await getImage(draw, "image/png");
|
|
|
+ mergeFuns(clearupItems)();
|
|
|
+ pop();
|
|
|
+ draw.config.back = oldBack;
|
|
|
+ draw.config.labelLineConfig = oldLabelLineConfig;
|
|
|
+ draw.config.showGrid = oldShowGrid;
|
|
|
+ draw.viewer.setViewMat(oldViewMat);
|
|
|
+ await nextTick();
|
|
|
+ return blob;
|
|
|
+};
|
|
|
+
|
|
|
const saveHandler = repeatedlyOnly(async () => {
|
|
|
const storeData = draw.getData();
|
|
|
- const [tabBlob, listBlob, scale, rect] = await draw.enterTemp(async () => {
|
|
|
+ const [tabBlob, listBlob, kkBlob, scale, rect] = await draw.enterTemp(async () => {
|
|
|
const back = draw.config.back;
|
|
|
const [rect, recover] = await setViewToTableCover();
|
|
|
await nextTick();
|
|
@@ -171,17 +231,21 @@ const saveHandler = repeatedlyOnly(async () => {
|
|
|
const listBlob = await getImage(draw, "image/jpg");
|
|
|
recover();
|
|
|
await nextTick();
|
|
|
- return [tabBlob, listBlob, scale, rect] as const;
|
|
|
+
|
|
|
+ const kkBlob = await setViewToKanKanCover();
|
|
|
+ return [tabBlob, listBlob, kkBlob, scale, rect] as const;
|
|
|
});
|
|
|
|
|
|
- const [tabUrl, listUrl] = await Promise.all([
|
|
|
+ const [tabUrl, listUrl, kankanUrl] = await Promise.all([
|
|
|
window.platform.uploadResourse(new File([tabBlob], `tabulation-cover.png`)),
|
|
|
window.platform.uploadResourse(new File([listBlob], `list-cover.png`)),
|
|
|
+ window.platform.uploadResourse(new File([kkBlob], `kankan-cover.png`)),
|
|
|
]);
|
|
|
|
|
|
overviewId.value = await window.platform.saveOverviewData(overviewId.value, {
|
|
|
...overviewData.value,
|
|
|
listCover: listUrl,
|
|
|
+ kankanCover: kankanUrl,
|
|
|
store: storeData,
|
|
|
viewport: draw!.viewer.transform.m,
|
|
|
});
|