index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <List :title="title" rawKey="id" :data="modelList" :showContent="showContent">
  3. <template #action>
  4. <slot name="action" />
  5. </template>
  6. <template #atom="{ item }">
  7. <ModelSign
  8. :canChange="canChange"
  9. :model="item.raw"
  10. @delete="modelDelete(item.raw)"
  11. @click="(mode: any) => modelChangeSelect(item.raw, mode)"
  12. />
  13. </template>
  14. </List>
  15. <Teleport to="#left-pano" v-if="panoModel">
  16. <div class="mode-tab strengthen">
  17. <div
  18. class="mode-icon-layout"
  19. @click="modelChangeSelect(panoModel, 'fuse')"
  20. :class="{ active: custom.showMode === 'fuse' }"
  21. >
  22. <ui-icon type="show_3d_n" class="icon" ctrl />
  23. </div>
  24. <div
  25. class="mode-icon-layout"
  26. @click="modelChangeSelect(panoModel, 'pano')"
  27. :class="{ active: custom.showMode === 'pano' }"
  28. >
  29. <ui-icon type="show_roaming_n" class="icon" ctrl />
  30. </div>
  31. </div>
  32. </Teleport>
  33. </template>
  34. <script lang="ts" setup>
  35. import { computed, watchEffect } from "vue";
  36. import { custom } from "@/env";
  37. import List from "@/components/list/index.vue";
  38. import ModelSign from "./sign.vue";
  39. import { getSupperPanoModel } from "@/sdk/association";
  40. import { fuseModels, getFuseModelShowVariable } from "@/store";
  41. import type { FuseModel } from "@/store";
  42. import { currentModel, fuseModel } from "@/model";
  43. export type ModelListProps = {
  44. title?: string;
  45. canChange?: boolean;
  46. showContent?: boolean;
  47. };
  48. withDefaults(defineProps<ModelListProps>(), {
  49. title: "数据列表",
  50. change: false,
  51. showContent: true,
  52. });
  53. defineEmits<{
  54. (e: "deleteModel", model: FuseModel): void;
  55. (e: "clickModel", model: FuseModel): void;
  56. }>();
  57. const panoModel = getSupperPanoModel();
  58. const modelList = computed(() =>
  59. fuseModels.value.map((model) => ({
  60. raw: model,
  61. select: custom.currentModel === model && currentModel.value === fuseModel,
  62. }))
  63. );
  64. const modelChangeSelect = (model: FuseModel, mode: "pano" | "fuse") => {
  65. if (getFuseModelShowVariable(model).value) {
  66. if (custom.currentModel === model && mode === custom.showMode) {
  67. custom.currentModel = null;
  68. custom.showMode = "fuse";
  69. } else {
  70. custom.currentModel = model;
  71. custom.showMode = mode;
  72. }
  73. }
  74. };
  75. watchEffect(() => {
  76. if (custom.currentModel && !getFuseModelShowVariable(custom.currentModel).value) {
  77. custom.currentModel = null;
  78. }
  79. });
  80. const modelDelete = (model: FuseModel) => {
  81. const index = fuseModels.value.indexOf(model);
  82. if (~index) {
  83. fuseModels.value.splice(index, 1);
  84. }
  85. };
  86. </script>
  87. <style lang="scss" scoped src="./style.scss"></style>