123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <template>
- <List key="id" :data="list" class="scene-list">
- <template #action>
- <slot name="action" />
- </template>
- <template #atom="{ item }">
- <div
- v-if="item.raw === fuseModel"
- @click="updateCurrent(item.raw)"
- class="all-scene-model-list"
- >
- <ModelList
- :class="{ active: current === fuseModel }"
- :title="getModelTypeDesc(fuseModel as any)"
- :show-content="showModelList"
- >
- <template #action>
- <ui-icon
- :type="`pull-${showModelList ? 'up' : 'down'}`"
- @click="showModelList = !showModelList"
- ctrl
- />
- </template>
- </ModelList>
- </div>
- <div
- class="scene"
- :class="{ disabled: item.raw.status !== SceneStatus.SUCCESS }"
- @click="updateCurrent(item.raw)"
- v-else-if="item.raw.type !== SceneType.SWMX"
- >
- <div
- :class="{full:!(canSync(item as Scene) && !voffline && currentLayout === RoutesName.show)} "
- >
- <p>
- {{ item.raw.name }}
- </p>
- <p>
- {{ SceneTypeDesc[item.raw.type as SceneType] }}
- </p>
- </div>
- <Button
- size="small"
- type="primary"
- ghost
- style="float: right"
- v-if="canSync(item as Scene) && !voffline && currentLayout === RoutesName.show"
- @click.stop="sync(item as Scene)"
- >
- 同屏勘验
- </Button>
- </div>
- </template>
- </List>
- </template>
- <script lang="ts" setup>
- import { computed, nextTick, ref, watch } from "vue";
- import {
- scenes,
- SceneType,
- SceneTypeDesc,
- fuseModels,
- SceneStatus,
- getSWKKSyncLink,
- caseProject,
- } from "@/store";
- import List from "@/components/list/index.vue";
- import ModelList from "../model-list/index.vue";
- import { fuseModel, getModelTypeDesc } from "@/model";
- import { Button } from "ant-design-vue";
- import { custom } from "@/env";
- import type { ModelType, FuseModelType } from "@/model";
- import type { Scene } from "@/store";
- import { currentLayout, RoutesName } from "@/router";
- const emit = defineEmits<{ (e: "update:current", data: ModelType): void }>();
- const props = defineProps<{ current: ModelType }>();
- const showModelList = ref(true);
- const voffline = offline;
- const canSync = (scene: Scene) =>
- [
- SceneType.SWKK,
- SceneType.DSFXJ,
- SceneType.SWKJ,
- SceneType.SWSSMX,
- SceneType.SWYDMX,
- ].includes(scene.raw.type);
- const sync = async (scene: Scene) => {
- const link = await getSWKKSyncLink(scene);
- window.open(link);
- };
- const list = computed(() => {
- const sceneList = true
- ? scenes.value
- .filter((scene) => scene.type !== SceneType.SWMX)
- .map((scene) => ({
- raw: scene,
- select:
- props.current !== fuseModel &&
- props.current.num === scene.num &&
- props.current.type === scene.type,
- }))
- : [];
- if (fuseModels.value.length) {
- return [{ raw: fuseModel }, ...sceneList];
- } else {
- return sceneList;
- }
- });
- const updateCurrent = (scene: FuseModelType | Scene) => {
- if (scene === fuseModel) {
- emit("update:current", scene);
- } else {
- emit("update:current", { type: scene.type, num: scene.num });
- }
- };
- const stopWatch = watch(
- list,
- () => {
- if (!list.value.some((model) => model.raw === fuseModel) && list.value.length) {
- if (!custom.recordIng) {
- updateCurrent(list.value[0].raw as any);
- nextTick(() => stopWatch());
- }
- }
- },
- { immediate: true }
- );
- </script>
- <style lang="scss">
- .scene-list > .content > li {
- padding: 0 !important;
- }
- .scene {
- padding: 0 20px;
- display: flex;
- align-items: center;
- overflow: hidden;
- justify-content: space-between;
- > div {
- flex: 1;
- max-width: 100%;
- &.full {
- max-width: 100%;
- }
- &:not(.full) {
- max-width: calc(100% - 80px);
- }
- }
- p {
- height: 1.5em;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: keep-all;
- line-height: 1.5em;
- }
- }
- .all-scene-model-list .scene-model-list {
- margin-bottom: -20px;
- margin-top: -20px;
- .header {
- padding: 30px 20px 20px;
- h3 {
- font-size: 20px;
- font-weight: bold;
- color: #ffffff;
- }
- }
- &.active .header {
- background-color: rgba(0, 200, 175, 0.16);
- }
- .content li:last-child .atom-content {
- border: none;
- }
- }
- </style>
|