index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div v-if="custom.showViewSetting && currentModel === fuseModel && !params.pure">
  3. <Dropdown placement="top">
  4. <div class="strengthen show-setting">
  5. <span>{{ $t("sys.showSetting") }}</span>
  6. <DownOutlined />
  7. </div>
  8. <template #overlay>
  9. <Menu>
  10. <menu-item v-for="option in showOptions">
  11. <ui-input
  12. @click.stop
  13. type="checkbox"
  14. :modelValue="option.stack.value"
  15. @update:modelValue="(s: boolean) => option.stack.value = s"
  16. :label="option.text"
  17. />
  18. </menu-item>
  19. </Menu>
  20. </template>
  21. </Dropdown>
  22. </div>
  23. </template>
  24. <script setup lang="ts">
  25. import { Dropdown, Menu, MenuItem } from "ant-design-vue";
  26. import {
  27. custom,
  28. params,
  29. showMeasuresStack,
  30. showMonitorsStack,
  31. showPathsStack,
  32. showTaggingsStack,
  33. } from "@/env";
  34. import { DownOutlined } from "@ant-design/icons-vue";
  35. import { computed, watch, watchEffect } from "vue";
  36. import { selectPaths } from "@/store";
  37. import { currentModel, fuseModel } from "@/model";
  38. import { ui18n } from "@/lang";
  39. const props = defineProps<{ value?: Record<string, boolean> }>();
  40. const emit = defineEmits<{ (e: "update:value", v: Record<string, boolean>): void }>();
  41. const showOptions = [
  42. {
  43. key: "showTagging",
  44. text: ui18n.t("tagging.name"),
  45. stack: showTaggingsStack.current.value,
  46. },
  47. {
  48. key: "showMeasure",
  49. text: ui18n.t("measure.name"),
  50. stack: showMeasuresStack.current.value,
  51. },
  52. {
  53. key: "showPath",
  54. text: ui18n.t("path.name"),
  55. stack: computed({
  56. get: () => {
  57. return selectPaths.all.value || selectPaths.selects.value.length > 0;
  58. },
  59. set: (val: boolean) => {
  60. selectPaths.all.value = val;
  61. console.log(selectPaths.selects.value);
  62. },
  63. }),
  64. },
  65. ];
  66. watch(
  67. () => props.value,
  68. () => {
  69. if (!props.value) return;
  70. showOptions.forEach((item) => {
  71. item.stack.value = props.value![item.key];
  72. });
  73. },
  74. { immediate: true }
  75. );
  76. watchEffect(() => {
  77. emit(
  78. "update:value",
  79. Object.fromEntries(showOptions.map((item) => [item.key, item.stack.value] as const))
  80. );
  81. });
  82. </script>
  83. <style lang="scss" scoped>
  84. .show-setting {
  85. width: 160px;
  86. height: 34px;
  87. background: rgba(27, 27, 28, 0.9);
  88. border-radius: 4px;
  89. display: flex;
  90. padding: 8px;
  91. align-items: center;
  92. justify-content: space-between;
  93. }
  94. </style>