index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!--
  2. * @Author: Badguy
  3. * @Date: 2022-05-17 15:56:46
  4. * @LastEditTime: 2022-05-27 17:02:16
  5. * @LastEditors: your name
  6. * @Description: 时区下拉选择菜单
  7. * have a nice day!
  8. -->
  9. <template>
  10. <el-dropdown
  11. :hide-on-click="false"
  12. @command="commandHandler"
  13. >
  14. <img
  15. class="btn-img btn-shadow"
  16. src="../../assets/baggage/ic_time.png"
  17. >
  18. <!-- <span class="time-zone-text">{{ currentDropdownItem.text }}</span> -->
  19. <el-dropdown-menu
  20. slot="dropdown"
  21. class="time-zone"
  22. >
  23. <el-dropdown-item
  24. v-for="(item, index) in DropdownItems"
  25. :key="index"
  26. :class="{ 'time-zone-selected': timeZone === item.command }"
  27. :command="item.command"
  28. :disabled="item.disabled"
  29. >{{ item.text }}</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </template>
  33. <script>
  34. import { mapGetters } from 'vuex'
  35. export default {
  36. name: 'TimeZoneSelector',
  37. data() {
  38. return {
  39. DropdownItems: [
  40. {
  41. text: '国内Local/国际UTC',
  42. disabled: true
  43. },
  44. {
  45. text: 'Local',
  46. command: 8
  47. },
  48. {
  49. text: 'UTC',
  50. command: 0
  51. }
  52. ]
  53. }
  54. },
  55. computed: {
  56. ...mapGetters(['timeZone']),
  57. currentDropdownItem() {
  58. return this.DropdownItems.find(item => item.command === this.timeZone)
  59. }
  60. },
  61. methods: {
  62. commandHandler(command) {
  63. this.$store.dispatch('timeZone/setTimeZone', command)
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .time-zone {
  70. .el-dropdown-menu__item {
  71. padding-left: 30px;
  72. font-family: Helvetica, 'Microsoft YaHei';
  73. font-size: 12px;
  74. color: #101116;
  75. position: relative;
  76. &.is-disabled {
  77. color: #909399;
  78. }
  79. &.time-zone-selected::before {
  80. content: '√';
  81. position: absolute;
  82. left: 10px;
  83. }
  84. }
  85. }
  86. </style>