bill 1 месяц назад
Родитель
Сommit
f570ec3b10
2 измененных файлов с 34 добавлено и 13 удалено
  1. 31 11
      src/components/tagging/sign-new.vue
  2. 3 2
      src/views/tagging/hot/style-type-select.vue

+ 31 - 11
src/components/tagging/sign-new.vue

@@ -1,6 +1,6 @@
 <template>
   <div
-    v-if="show && posStyle"
+    v-if="task3D && show && posStyle"
     class="hot-item pc"
     :style="posStyle"
     @mouseenter="isHover = true"
@@ -78,6 +78,7 @@ import type { Tagging, TaggingPosition } from "@/store";
 import { useCameraChange, usePixel } from "@/hook/use-pixel";
 import { inRevise } from "bill/utils";
 import { defStyleType } from "@/api";
+import mitt from "mitt";
 
 export type SignProps = { tagging: Tagging; scenePos: TaggingPosition; show?: boolean };
 
@@ -94,7 +95,6 @@ const emit = defineEmits<{
 const desc = ref<HTMLDivElement>();
 const showDesc = computed(() => {
   const a = desc.value?.innerText.trim();
-  console.error("--aaa->", desc.value, a);
   return a;
 });
 
@@ -112,15 +112,34 @@ const queryItems = computed(() =>
   }))
 );
 const taggingStyle = computed(() => getTaggingStyle(props.tagging.styleId));
-const tag = markRaw(
-  sdk.createTagging({
-    ...props.scenePos,
-    title: props.tagging.title,
-    position: props.scenePos.localPos,
-    canMove: false,
-    image: getFileUrl(taggingStyle.value!.icon),
-  })
-) as TaggingPositionNode;
+let task3D = sdk.createTagging({
+  ...props.scenePos,
+  title: props.tagging.title,
+  position: props.scenePos.localPos,
+  canMove: false,
+  image: getFileUrl(taggingStyle.value!.icon),
+});
+if (!task3D) {
+  emit("delete");
+}
+const emptyfn = () => {};
+const tag = (task3D
+  ? markRaw(task3D)
+  : {
+      changeCanMove: emptyfn,
+      changeMat: emptyfn,
+      changeFontSize: emptyfn,
+      changeTitle: emptyfn,
+      visibilityTitle: emptyfn,
+      changeType: emptyfn,
+      changeImage: emptyfn,
+      changePosition: emptyfn,
+      changeLineHeight: emptyfn,
+      visibility: emptyfn,
+      getImageCenter: emptyfn,
+      bus: mitt(),
+      destroy: emptyfn,
+    }) as TaggingPositionNode;
 const showDelete = ref(false);
 tag.showDelete = (show) => {
   showDelete.value = show;
@@ -308,6 +327,7 @@ defineExpose(tag);
       p {
         margin-bottom: 10px;
         display: flex;
+
         span {
           flex: 0 0 auto;
         }

+ 3 - 2
src/views/tagging/hot/style-type-select.vue

@@ -36,7 +36,7 @@ const allType = { name: ui18n.t("sys.all"), id: -1 };
 const getTypeCount = (item: any) => {
   if (item.id === allType.id) {
     return taggings.value.length;
-  } else if (item.children) {
+  } else if (item.children?.length) {
     return item.children.reduceRight((c: number, item: any) => {
       return (
         c +
@@ -58,13 +58,14 @@ const getItems = (types = styleTypes): any => {
       let count = 0;
       if (props.count) {
         count = getTypeCount(item);
+        console.log("items", item.name, count);
       }
       return {
         label: item.name + (props.count ? ` (${count}) ` : ""),
         title: item.name,
         count,
         key: item.id,
-        children: "children" in item ? getItems(item.children) : null,
+        children: item.children?.length ? getItems(item.children) : null,
       };
     })
     .filter((item) => !props.count || item.count || item.key === allType.id);