index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <List key="id" :data="list" class="scene-list">
  3. <template #action>
  4. <slot name="action" />
  5. </template>
  6. <template #atom="{ item }">
  7. <div
  8. v-if="item.raw === fuseModel"
  9. @click="updateCurrent(item.raw)"
  10. class="all-scene-model-list"
  11. >
  12. <ModelList
  13. :class="{ active: current === fuseModel }"
  14. :title="getModelTypeDesc(fuseModel as any)"
  15. :show-content="showModelList"
  16. >
  17. <template #action>
  18. <ui-icon
  19. :type="`pull-${showModelList ? 'up' : 'down'}`"
  20. @click="showModelList = !showModelList"
  21. ctrl
  22. />
  23. </template>
  24. </ModelList>
  25. </div>
  26. <div
  27. class="scene"
  28. :class="{ disabled: item.raw.status !== SceneStatus.SUCCESS }"
  29. @click="updateCurrent(item.raw)"
  30. v-else-if="item.raw.type !== SceneType.SWMX"
  31. >
  32. <div
  33. :class="{full:!(canSync(item as Scene) && !voffline && currentLayout === RoutesName.show)} "
  34. >
  35. <p>
  36. {{ item.raw.name }}
  37. </p>
  38. <p>
  39. {{ SceneTypeDesc[item.raw.type as SceneType] }}
  40. </p>
  41. </div>
  42. <Button
  43. size="small"
  44. type="primary"
  45. ghost
  46. style="float: right"
  47. v-if="canSync(item as Scene) && !voffline && currentLayout === RoutesName.show"
  48. @click.stop="sync(item as Scene)"
  49. >
  50. 同屏勘验
  51. </Button>
  52. </div>
  53. </template>
  54. </List>
  55. </template>
  56. <script lang="ts" setup>
  57. import { computed, nextTick, ref, watch } from "vue";
  58. import {
  59. scenes,
  60. SceneType,
  61. SceneTypeDesc,
  62. fuseModels,
  63. SceneStatus,
  64. getSWKKSyncLink,
  65. caseProject,
  66. } from "@/store";
  67. import List from "@/components/list/index.vue";
  68. import ModelList from "../model-list/index.vue";
  69. import { fuseModel, getModelTypeDesc } from "@/model";
  70. import { Button } from "ant-design-vue";
  71. import { custom } from "@/env";
  72. import type { ModelType, FuseModelType } from "@/model";
  73. import type { Scene } from "@/store";
  74. import { currentLayout, RoutesName } from "@/router";
  75. const emit = defineEmits<{ (e: "update:current", data: ModelType): void }>();
  76. const props = defineProps<{ current: ModelType }>();
  77. const showModelList = ref(true);
  78. const voffline = offline;
  79. const canSync = (scene: Scene) =>
  80. [
  81. SceneType.SWKK,
  82. SceneType.DSFXJ,
  83. SceneType.SWKJ,
  84. SceneType.SWSSMX,
  85. SceneType.SWYDMX,
  86. ].includes(scene.raw.type);
  87. const sync = async (scene: Scene) => {
  88. const link = await getSWKKSyncLink(scene);
  89. window.open(link);
  90. };
  91. const list = computed(() => {
  92. const sceneList = true
  93. ? scenes.value
  94. .filter((scene) => scene.type !== SceneType.SWMX)
  95. .map((scene) => ({
  96. raw: scene,
  97. select:
  98. props.current !== fuseModel &&
  99. props.current.num === scene.num &&
  100. props.current.type === scene.type,
  101. }))
  102. : [];
  103. if (fuseModels.value.length) {
  104. return [{ raw: fuseModel }, ...sceneList];
  105. } else {
  106. return sceneList;
  107. }
  108. });
  109. const updateCurrent = (scene: FuseModelType | Scene) => {
  110. if (scene === fuseModel) {
  111. emit("update:current", scene);
  112. } else {
  113. emit("update:current", { type: scene.type, num: scene.num });
  114. }
  115. };
  116. const stopWatch = watch(
  117. list,
  118. () => {
  119. if (!list.value.some((model) => model.raw === fuseModel) && list.value.length) {
  120. if (!custom.recordIng) {
  121. updateCurrent(list.value[0].raw as any);
  122. nextTick(() => stopWatch());
  123. }
  124. }
  125. },
  126. { immediate: true }
  127. );
  128. </script>
  129. <style lang="scss">
  130. .scene-list > .content > li {
  131. padding: 0 !important;
  132. }
  133. .scene {
  134. padding: 0 20px;
  135. display: flex;
  136. align-items: center;
  137. overflow: hidden;
  138. justify-content: space-between;
  139. > div {
  140. flex: 1;
  141. max-width: 100%;
  142. &.full {
  143. max-width: 100%;
  144. }
  145. &:not(.full) {
  146. max-width: calc(100% - 80px);
  147. }
  148. }
  149. p {
  150. height: 1.5em;
  151. overflow: hidden;
  152. text-overflow: ellipsis;
  153. word-break: keep-all;
  154. line-height: 1.5em;
  155. }
  156. }
  157. .all-scene-model-list .scene-model-list {
  158. margin-bottom: -20px;
  159. margin-top: -20px;
  160. .header {
  161. padding: 30px 20px 20px;
  162. h3 {
  163. font-size: 20px;
  164. font-weight: bold;
  165. color: #ffffff;
  166. }
  167. }
  168. &.active .header {
  169. background-color: rgba(0, 200, 175, 0.16);
  170. }
  171. .content li:last-child .atom-content {
  172. border: none;
  173. }
  174. }
  175. </style>