index.vue 4.0 KB

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