index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div class="go-edit-bottom">
  3. <edit-history></edit-history>
  4. <n-space class="bottom-ri">
  5. <!-- 快捷键提示 -->
  6. <n-popselect :options="shortcutKeyOptions" size="medium">
  7. <n-button class="scale-btn" quaternary size="mini">
  8. <n-icon class="lock-icon" size="18" :depth="2">
  9. <DicomOverlayIcon></DicomOverlayIcon>
  10. </n-icon>
  11. </n-button>
  12. </n-popselect>
  13. <!-- 缩放比例 -->
  14. <n-select
  15. :disabled="lockScale"
  16. class="scale-btn"
  17. v-model:value="filterValue"
  18. size="mini"
  19. :options="filterOptions"
  20. @update:value="selectHandle"
  21. ></n-select>
  22. <!-- 锁定缩放 -->
  23. <n-tooltip trigger="hover">
  24. <template #trigger>
  25. <n-button @click="lockHandle" text>
  26. <n-icon
  27. class="lock-icon"
  28. :class="{ color: lockScale }"
  29. size="18"
  30. :depth="2"
  31. >
  32. <lock-closed-outline-icon v-if="lockScale"></lock-closed-outline-icon>
  33. <lock-open-outline-icon v-else></lock-open-outline-icon>
  34. </n-icon>
  35. </n-button>
  36. </template>
  37. <span>{{ lockScale ? '解锁' : '锁定' }}当前比例</span>
  38. </n-tooltip>
  39. <!-- 拖动 -->
  40. <n-slider
  41. class="scale-slider"
  42. v-model:value="sliderValue"
  43. :default-value="50"
  44. :min="10"
  45. :max="200"
  46. :step="5"
  47. :format-tooltip="sliderFormatTooltip"
  48. :disabled="lockScale"
  49. :marks="sliderMaks"
  50. @update:value="sliderHandle"
  51. ></n-slider>
  52. </n-space>
  53. </div>
  54. </template>
  55. <script setup lang="ts">
  56. import { reactive, ref, toRefs, watchEffect } from 'vue'
  57. import { icon } from '@/plugins'
  58. import { EditHistory } from '../EditHistory/index'
  59. import { useDesignStore } from '@/store/modules/designStore/designStore'
  60. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  61. import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
  62. const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5
  63. const { DicomOverlayIcon } = icon.carbon
  64. // 全局颜色
  65. const designStore = useDesignStore()
  66. const themeColor = ref(designStore.getAppTheme)
  67. const chartEditStore = useChartEditStore()
  68. const { lockScale, scale } = toRefs(chartEditStore.getEditCanvas)
  69. // 缩放选项
  70. let filterOptions = [
  71. {
  72. label: '200%',
  73. value: 200
  74. },
  75. {
  76. label: '150%',
  77. value: 150
  78. },
  79. {
  80. label: '100%',
  81. value: 100
  82. },
  83. {
  84. label: '50%',
  85. value: 50
  86. },
  87. {
  88. label: '自适应',
  89. value: 0
  90. }
  91. ]
  92. // 选择值
  93. const filterValue = ref('')
  94. // 用户自选择
  95. const selectHandle = (v: number) => {
  96. if (v === 0) {
  97. chartEditStore.computedScale()
  98. return
  99. }
  100. chartEditStore.setScale(v / 100)
  101. }
  102. // 点击锁处理
  103. const lockHandle = () => {
  104. chartEditStore.setEditCanvas(EditCanvasTypeEnum.LOCK_SCALE, !lockScale.value)
  105. }
  106. // 拖动
  107. const sliderValue = ref(100)
  108. // 拖动格式化
  109. const sliderFormatTooltip = (v: string) => `${v}%`
  110. // 拖动处理
  111. const sliderHandle = (v: number) => {
  112. chartEditStore.setScale(v / 100)
  113. }
  114. const sliderMaks = reactive({
  115. 100: ''
  116. })
  117. // 快捷键
  118. const shortcutKeyOptions = [
  119. {
  120. label: '键盘快捷键列表',
  121. value: '1'
  122. },
  123. {
  124. label: 'Ctrl + ↑ 向上移动',
  125. value: '2'
  126. },
  127. {
  128. label: 'Ctrl + → 向右移动',
  129. value: '3'
  130. },
  131. {
  132. label: 'Ctrl + ↓ 向下移动',
  133. value: '4'
  134. },
  135. {
  136. label: 'Ctrl + ← 向左移动',
  137. value: '5'
  138. },
  139. {
  140. label: 'Ctrl + Delete 删除',
  141. value: '6'
  142. },
  143. {
  144. label: 'Ctrl + C 复制',
  145. value: '7'
  146. },
  147. {
  148. label: 'Ctrl + X 剪切',
  149. value: '8'
  150. },
  151. {
  152. label: 'Ctrl + V 粘贴',
  153. value: '9'
  154. },
  155. {
  156. label: 'Ctrl + Z 后退',
  157. value: '10'
  158. },
  159. {
  160. label: 'Ctrl + Shift + Z 前进',
  161. value: '11'
  162. }
  163. ]
  164. // 监听 scale 变化
  165. watchEffect(() => {
  166. const value = (scale.value * 100).toFixed(0)
  167. filterValue.value = `${value}%`
  168. sliderValue.value = parseInt(value)
  169. })
  170. </script>
  171. <style lang="scss" scoped>
  172. @include go(edit-bottom) {
  173. width: 100%;
  174. padding: 0 10px;
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. .bottom-ri {
  179. position: relative;
  180. top: 15px;
  181. .lock-icon {
  182. padding-top: 4px;
  183. &.color {
  184. color: v-bind('themeColor');
  185. }
  186. }
  187. .scale-btn {
  188. font-size: 12px;
  189. @include deep() {
  190. .n-base-selection-label {
  191. padding: 3px;
  192. }
  193. }
  194. }
  195. .scale-slider {
  196. position: relative;
  197. top: -4px;
  198. width: 200px;
  199. }
  200. }
  201. }
  202. </style>