index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 type { ModelType, FuseModelType } from "@/model";
  72. import type { Scene } from "@/store";
  73. import { currentLayout, RoutesName } from "@/router";
  74. const emit = defineEmits<{ (e: "update:current", data: ModelType): void }>();
  75. const props = defineProps<{ current: ModelType }>();
  76. const showModelList = ref(true);
  77. const voffline = offline;
  78. const canSync = (scene: Scene) =>
  79. [
  80. SceneType.SWKK,
  81. SceneType.DSFXJ,
  82. SceneType.SWKJ,
  83. SceneType.SWSSMX,
  84. SceneType.SWYDMX,
  85. ].includes(scene.raw.type);
  86. const sync = async (scene: Scene) => {
  87. const link = await getSWKKSyncLink(scene);
  88. window.open(link);
  89. };
  90. const list = computed(() => {
  91. const sceneList = true
  92. ? scenes.value
  93. .filter((scene) => scene.type !== SceneType.SWMX)
  94. .map((scene) => ({
  95. raw: scene,
  96. select:
  97. props.current !== fuseModel &&
  98. props.current.num === scene.num &&
  99. props.current.type === scene.type,
  100. }))
  101. : [];
  102. if (fuseModels.value.length) {
  103. return [{ raw: fuseModel }, ...sceneList];
  104. } else {
  105. return sceneList;
  106. }
  107. });
  108. const updateCurrent = (scene: FuseModelType | Scene) => {
  109. if (scene === fuseModel) {
  110. emit("update:current", scene);
  111. } else {
  112. emit("update:current", { type: scene.type, num: scene.num });
  113. }
  114. };
  115. const stopWatch = watch(
  116. list,
  117. () => {
  118. if (!list.value.some((model) => model.raw === fuseModel) && list.value.length) {
  119. updateCurrent(list.value[0].raw as any);
  120. nextTick(() => stopWatch());
  121. }
  122. },
  123. { immediate: true }
  124. );
  125. </script>
  126. <style lang="scss">
  127. .scene-list > .content > li {
  128. padding: 0 !important;
  129. }
  130. .scene {
  131. padding: 0 20px;
  132. display: flex;
  133. align-items: center;
  134. overflow: hidden;
  135. justify-content: space-between;
  136. > div {
  137. flex: 1;
  138. max-width: 100%;
  139. &.full {
  140. max-width: 100%;
  141. }
  142. &:not(.full) {
  143. max-width: calc(100% - 80px);
  144. }
  145. }
  146. p {
  147. height: 1.5em;
  148. overflow: hidden;
  149. text-overflow: ellipsis;
  150. word-break: keep-all;
  151. line-height: 1.5em;
  152. }
  153. }
  154. .all-scene-model-list .scene-model-list {
  155. margin-bottom: -20px;
  156. margin-top: -20px;
  157. .header {
  158. padding: 30px 20px 20px;
  159. h3 {
  160. font-size: 20px;
  161. font-weight: bold;
  162. color: #ffffff;
  163. }
  164. }
  165. &.active .header {
  166. background-color: rgba(0, 200, 175, 0.16);
  167. }
  168. .content li:last-child .atom-content {
  169. border: none;
  170. }
  171. }
  172. </style>