index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <RightPano v-if="custom.currentModel && active" class="merge-layout">
  3. <ui-group>
  4. <template #header>
  5. <Actions class="edit-header" :items="actionItems" v-model:current="currentItem" />
  6. </template>
  7. <ui-group-option label="等比缩放">
  8. <template #icon>
  9. <a
  10. class="set-prop"
  11. :class="{ disabled: isOld || currentItem }"
  12. @click="router.push({
  13. name: RoutesName.proportion,
  14. params: { id: custom.currentModel!.id, save: '1' },
  15. })"
  16. >设置比例</a
  17. >
  18. </template>
  19. <ui-input
  20. type="range"
  21. v-model="custom.currentModel.scale"
  22. v-bind="modelRange.scaleRange"
  23. :ctrl="false"
  24. width="100%"
  25. >
  26. <template #icon>%</template>
  27. </ui-input>
  28. </ui-group-option>
  29. <!-- <ui-group-option label="离地高度">
  30. <ui-input
  31. type="range"
  32. v-model="custom.currentModel.bottom"
  33. v-bind="modelRange.bottomRange"
  34. :ctrl="false"
  35. width="100%"
  36. >
  37. <template #icon>m</template>
  38. </ui-input>
  39. </ui-group-option> -->
  40. <ui-group-option label="模型不透明度">
  41. <ui-input
  42. type="range"
  43. v-model="custom.currentModel.opacity"
  44. v-bind="modelRange.opacityRange"
  45. :ctrl="false"
  46. width="100%"
  47. >
  48. <template #icon>%</template>
  49. </ui-input>
  50. </ui-group-option>
  51. <ui-group-option>
  52. <!-- :disabled="currentItem" -->
  53. <ui-button
  54. :class="{ disabled: isOld }"
  55. @click="router.push({
  56. name: RoutesName.registration,
  57. params: {id: custom.currentModel!.id, save: '1' }
  58. })"
  59. >配准</ui-button
  60. >
  61. </ui-group-option>
  62. <ui-group-option>
  63. <ui-button @click="reset">恢复默认</ui-button>
  64. </ui-group-option>
  65. </ui-group>
  66. </RightPano>
  67. </template>
  68. <script lang="ts" setup>
  69. import { RoutesName, router } from "@/router";
  70. import { RightPano } from "@/layout";
  71. import { autoSaveFuseModels, defaultFuseModelAttrs, isOld } from "@/store";
  72. import { togetherCallback } from "@/utils";
  73. import { sdk, getSceneModel, modelRange } from "@/sdk";
  74. import { useViewStack, useActive } from "@/hook";
  75. import {
  76. showLeftPanoStack,
  77. custom,
  78. modelsChangeStoreStack,
  79. showRightPanoStack,
  80. } from "@/env";
  81. import { ref, nextTick, watchEffect, computed, watch } from "vue";
  82. import { Dialog } from "bill/expose-common";
  83. import Actions from "@/components/actions/index.vue";
  84. import type { ActionsProps, ActionsItem } from "@/components/actions/index.vue";
  85. const active = useActive();
  86. const actionItems: ActionsProps["items"] = [
  87. {
  88. icon: "move",
  89. text: "移动",
  90. action: () => {
  91. getSceneModel(custom.currentModel)?.enterMoveMode();
  92. return () => getSceneModel(custom.currentModel)?.leaveTransform();
  93. },
  94. },
  95. {
  96. icon: "flip",
  97. text: "旋转",
  98. action: () => {
  99. getSceneModel(custom.currentModel)?.enterRotateMode();
  100. return () => {
  101. getSceneModel(custom.currentModel)?.leaveTransform();
  102. };
  103. },
  104. },
  105. ];
  106. const currentItem = ref<ActionsItem | null>(null);
  107. watchEffect(() => {
  108. if (!custom.currentModel) {
  109. currentItem.value = null;
  110. }
  111. });
  112. watch(
  113. () => custom.currentModel,
  114. () => {
  115. currentItem.value = null;
  116. }
  117. );
  118. const reset = async () => {
  119. if (custom.currentModel && (await Dialog.confirm("确定恢复默认?此操作无法撤销"))) {
  120. Object.assign(custom.currentModel, {
  121. ...defaultFuseModelAttrs,
  122. rotation: getSceneModel(custom.currentModel)!.getDefaultRotation(),
  123. });
  124. await nextTick();
  125. custom.currentModel && (custom.currentModel.bottom = 0);
  126. }
  127. };
  128. useViewStack(() =>
  129. togetherCallback([
  130. showLeftPanoStack.push(ref(true)),
  131. showRightPanoStack.push(computed(() => !!custom.currentModel)),
  132. modelsChangeStoreStack.push(ref(true)),
  133. () => (currentItem.value = null),
  134. ])
  135. );
  136. useViewStack(autoSaveFuseModels);
  137. useViewStack(() => {
  138. sdk.showGrid();
  139. return () => {
  140. sdk.hideGrid();
  141. };
  142. });
  143. </script>
  144. <style lang="scss">
  145. .merge-layout {
  146. .ui-input .text.suffix input {
  147. padding-left: 5px;
  148. padding-right: 15px;
  149. }
  150. .ui-input .text.suffix .retouch {
  151. right: 5px;
  152. }
  153. }
  154. .set-prop {
  155. cursor: pointer;
  156. }
  157. </style>