index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <List
  3. :title="title"
  4. rawKey="id"
  5. :class="['scene-model-list', listClass]"
  6. :data="modelList"
  7. :showContent="showContent"
  8. >
  9. <template #header v-if="$slots.header"><slot name="header" /></template>
  10. <template #action>
  11. <slot name="action" />
  12. </template>
  13. <template #atom="{ item }">
  14. <ModelSign
  15. :canChange="canChange"
  16. :model="item.raw"
  17. @delete="modelDelete(item.raw)"
  18. @click="(mode: any) => flyModel(item.raw, mode, true)"
  19. />
  20. </template>
  21. </List>
  22. </template>
  23. <script lang="ts" setup>
  24. import { computed, watchEffect } from "vue";
  25. import { custom } from "@/env";
  26. import List from "@/components/list/index.vue";
  27. import ModelSign from "./sign.vue";
  28. import { activeModel, getSupperPanoModel } from "@/sdk/association";
  29. import { fuseModels, getFuseModelShowVariable } from "@/store";
  30. import type { FuseModel } from "@/store";
  31. import { currentModel, fuseModel, loadModel } from "@/model";
  32. import { flyModel } from "@/hook/use-fly";
  33. import { sdk } from "@/sdk/sdk";
  34. watchEffect(
  35. () => {
  36. console.error("modeChange", custom.showMode);
  37. },
  38. { flush: "sync" }
  39. );
  40. export type ModelListProps = {
  41. title?: string;
  42. canChange?: boolean;
  43. showContent?: boolean;
  44. listClass?: string;
  45. };
  46. withDefaults(defineProps<ModelListProps>(), {
  47. title: "数据列表",
  48. change: false,
  49. showContent: true,
  50. });
  51. defineEmits<{
  52. (e: "deleteModel", model: FuseModel): void;
  53. (e: "clickModel", model: FuseModel): void;
  54. }>();
  55. const modelList = computed(() =>
  56. fuseModels.value.map((model) => ({
  57. raw: model,
  58. select: custom.currentModel === model && currentModel.value === fuseModel,
  59. }))
  60. );
  61. watchEffect(() => {
  62. if (custom.currentModel && !getFuseModelShowVariable(custom.currentModel).value) {
  63. activeModel({ showMode: "fuse" });
  64. }
  65. });
  66. const modelDelete = (model: FuseModel) => {
  67. if (custom.currentModel === model) {
  68. activeModel({ showMode: "fuse" });
  69. }
  70. const index = fuseModels.value.indexOf(model);
  71. if (~index) {
  72. fuseModels.value.splice(index, 1);
  73. }
  74. };
  75. </script>
  76. <style lang="scss" scoped src="./style.scss"></style>