GetUnits.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="row items-baseline">
  3. <div class="col-xs-12 col-sm-auto text-weight-bold text-center q-px-md q-py-sm">
  4. <div :style="flexRowTitleStyle">
  5. Units
  6. </div>
  7. </div>
  8. <div class="col-xs-grow col-sm">
  9. <div class="row justify-xs-center justify-sm-start items-center">
  10. <div class="col-auto" >
  11. <q-select
  12. v-model="localUnits"
  13. :options="unitsOptions"
  14. class="q-pa-xs"
  15. outlined
  16. dense
  17. options-dense
  18. style="width: 7em"
  19. behavior="menu"
  20. >
  21. </q-select>
  22. </div>
  23. <div class="col-auto" >
  24. <div class="row q-py-xs q-px-md items-center justify-center">
  25. <div class="q-pr-xs"> Source units </div>
  26. <q-select
  27. v-model="localSourceUnits"
  28. :options="sourceUnitsOptions"
  29. outlined
  30. dense
  31. options-dense
  32. option-value="label"
  33. option-label="label"
  34. >
  35. <template #option="scope">
  36. <q-item :label="scope.opt.title" dense>
  37. <q-item-section class="text-weight-bold">{{ scope.opt.title }}</q-item-section>
  38. </q-item>
  39. <template v-for="child in scope.opt.children" :key="child.label">
  40. <q-item v-close-popup dense clickable
  41. @click="localSourceUnits = child"
  42. >
  43. <q-item-section> <q-item-label class="q-ml-md"> {{child.label}} </q-item-label> </q-item-section>
  44. </q-item>
  45. </template>
  46. </template>
  47. </q-select>
  48. <div class="row q-py-xs items-center">
  49. <q-checkbox v-model="isSourceSameUnits" size="sm"/>
  50. <div>same</div>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- <div class="col-auto" >-->
  55. <!-- units: {{localSourceUnits}}-->
  56. <!-- <br> store: {{$store.state.guiRuntime}}-->
  57. <!-- </div>-->
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script lang="ts">
  63. import {
  64. defineComponent,
  65. computed,
  66. } from 'vue'
  67. import { useStore } from 'src/store'
  68. import { flexRowTitleStyle } from 'components/utils'
  69. export default defineComponent({
  70. name: 'GetHostIndex',
  71. components: {},
  72. setup() {
  73. const unitsOptions = [ 'nm', 'mkm', 'mm', 'cm', 'm', 'km' ]
  74. const sourceUnitsOptions = [
  75. { title: 'Frequency',
  76. children: [{label: 'Hz'},{label: 'kHz'},{label: 'MHz'},{label: 'GHz'},{label: 'THz'}]},
  77. { title: 'Energy',
  78. children: [{label: 'meV'}, {label: 'eV'}]},
  79. { title: 'Period duration',
  80. children: [{label: 'ps'}, {label: 'fs'}]}
  81. ]
  82. const $store = useStore()
  83. const isSourceSameUnits = computed({
  84. get: () => $store.state.guiRuntime.isSourceSameUnits,
  85. set: val => $store.commit('guiRuntime/setIsSourceSameUnits', val)
  86. })
  87. const localUnits = computed({
  88. get: () => $store.state.guiRuntime.units,
  89. set: val => $store.commit('guiRuntime/setUnits', val)
  90. })
  91. const localSourceUnits = computed({
  92. get: () => {return {label:$store.state.guiRuntime.sourceUnits}},
  93. set: val => $store.commit('guiRuntime/setSourceUnits', val.label)
  94. })
  95. return { isSourceSameUnits, flexRowTitleStyle,
  96. unitsOptions, localUnits,
  97. localSourceUnits, sourceUnitsOptions }
  98. },
  99. })
  100. </script>