action.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <Tabs activeKey="t" width="100%">
  3. <TabPane key="t" tab="设置动画">
  4. <ui-group>
  5. <ui-group-option>
  6. <SignItem label="名称" not-apply>
  7. <ui-input
  8. width="100%"
  9. type="text"
  10. ref="nameInput"
  11. class="nameInput"
  12. placeholder="请输入名称"
  13. v-model="data.name"
  14. :maxlength="100"
  15. />
  16. </SignItem>
  17. </ui-group-option>
  18. <ui-group-option>
  19. <SignItem label="幅度" not-apply>
  20. <Slider v-model:value="data.amplitude" :min="0.1" :max="1" :step="0.1" />
  21. </SignItem>
  22. </ui-group-option>
  23. <ui-group-option>
  24. <SignItem label="速度" not-apply>
  25. <template v-slot:append>
  26. <span v-if="dur">时长: {{ round(dur, 2) }}S</span>
  27. </template>
  28. <Slider v-model:value="data.speed" :min="0.1" :max="10" :step="0.1" />
  29. </SignItem>
  30. </ui-group-option>
  31. <ui-group-option class="item">
  32. <span class="label">持续时间</span>
  33. <span class="oper">
  34. <ui-input
  35. width="75px"
  36. type="number"
  37. ref="nameInput"
  38. placeholder="请输入"
  39. :modelValue="data.duration"
  40. :min="0.1"
  41. @change="(ev: any) => $emit('updateDuration', Math.max(0.1, Number(ev.target.value)))"
  42. />
  43. &nbsp;S
  44. </span>
  45. </ui-group-option>
  46. </ui-group>
  47. </TabPane>
  48. </Tabs>
  49. </template>
  50. <script lang="ts" setup>
  51. import { Slider, TabPane, Tabs } from "ant-design-vue";
  52. import { AnimationModel, AnimationModelAction } from "@/api";
  53. import SignItem from "@/views/tagging-position/sign-item.vue";
  54. import { amMap } from "@/sdk/association/animation";
  55. import { computed, ref } from "vue";
  56. import { round } from "@/utils";
  57. const props = defineProps<{ data: AnimationModelAction; am: AnimationModel }>();
  58. defineEmits<{ (e: "updateDuration", dur: number): void }>();
  59. const dur = computed(() => {
  60. const actions = amMap[props.am.id].am?.getSupportActions() || [];
  61. const action = actions.find((item) => item.name === props.data.key);
  62. if (action?.duration) {
  63. return action?.duration / props.data.speed;
  64. }
  65. });
  66. </script>
  67. <style scoped lang="scss">
  68. .item {
  69. display: flex;
  70. align-items: center;
  71. justify-content: space-between;
  72. }
  73. </style>