index.vue 2.6 KB

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