LeftMenuLayoutAdministrador.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <q-drawer
  3. v-bind="$attrs"
  4. :model-value="true"
  5. show-if-above
  6. no-swipe-close
  7. no-swipe-open
  8. :width="235"
  9. :mini-width="64"
  10. :breakpoint="500"
  11. :mini="navigation_store.miniState"
  12. :behavior="'desktop'"
  13. class="left-menu-drawer"
  14. >
  15. <div class="column full-height no-wrap left-menu-inner">
  16. <div class="left-menu-items-wrapper column full-height no-wrap">
  17. <div class="left-menu-bg-overlay" />
  18. <div class="left-menu-bg-tint" />
  19. <q-list class="left-menu-list column no-wrap">
  20. <template v-for="(item, index) in navigation_store.navigationItems" :key="index">
  21. <template v-if="item.permission">
  22. <q-item
  23. v-if="item.type === 'single'"
  24. v-ripple
  25. clickable
  26. :exact="item.name === 'HomePage'"
  27. exact-active-class="menu-selected"
  28. active-class="menu-selected"
  29. :to="{ name: item.name }"
  30. class="left-menu-item"
  31. >
  32. <q-item-section avatar>
  33. <q-icon :name="item.icon" class="left-menu-icon" />
  34. </q-item-section>
  35. <q-item-section v-if="!navigation_store.miniState">{{ $t(item.title) }}</q-item-section>
  36. <q-tooltip
  37. v-if="navigation_store.miniState"
  38. anchor="center right"
  39. self="center left"
  40. :offset="[10, 10]"
  41. >{{ $t(item.title) }}</q-tooltip>
  42. </q-item>
  43. <div v-else>
  44. <template v-if="!navigation_store.miniState">
  45. <q-expansion-item
  46. v-model="isExpasionItemExpanded[index]"
  47. :class="{ 'menu-selected': childrenAreActive(item.childrens) && !isExpasionItemExpanded[index] }"
  48. class="left-menu-item"
  49. >
  50. <template #header>
  51. <q-item-section avatar>
  52. <q-icon :name="item.icon" class="left-menu-icon" />
  53. </q-item-section>
  54. <q-item-section>{{ $t(item.title) }}</q-item-section>
  55. </template>
  56. <div v-for="child in item.childrens" :key="child.name">
  57. <q-item
  58. v-ripple
  59. clickable
  60. :to="{ name: child.name }"
  61. exact
  62. exact-active-class="menu-selected"
  63. class="q-pl-lg left-menu-item"
  64. >
  65. <q-item-section avatar>
  66. <q-icon :name="child.icon" class="left-menu-icon" />
  67. </q-item-section>
  68. <q-item-section>{{ $t(child.title) }}</q-item-section>
  69. </q-item>
  70. </div>
  71. </q-expansion-item>
  72. </template>
  73. <template v-else>
  74. <q-item
  75. v-ripple
  76. clickable
  77. :class="{ 'menu-selected': childrenAreActive(item.childrens) }"
  78. class="left-menu-item"
  79. >
  80. <q-item-section avatar>
  81. <q-icon :name="item.icon" class="left-menu-icon" />
  82. </q-item-section>
  83. <q-tooltip anchor="center right" self="center left" :offset="[10, 10]">
  84. {{ $t(item.title) }}
  85. </q-tooltip>
  86. <q-menu class="menu-drawer" anchor="center right" self="top start">
  87. <q-list>
  88. <q-item
  89. v-for="child in item.childrens"
  90. :key="child.name"
  91. v-ripple
  92. v-close-popup
  93. clickable
  94. :to="{ name: child.name }"
  95. exact
  96. exact-active-class="menu-selected"
  97. class="menu-drawer"
  98. >
  99. <q-item-section avatar>
  100. <q-icon :name="child.icon" class="left-menu-icon" />
  101. </q-item-section>
  102. <q-item-section>{{ $t(child.title) }}</q-item-section>
  103. </q-item>
  104. </q-list>
  105. </q-menu>
  106. </q-item>
  107. </template>
  108. </div>
  109. </template>
  110. </template>
  111. </q-list>
  112. <q-list class="q-mt-auto left-menu-footer">
  113. <q-item v-ripple class="left-menu-item left-menu-logout text-center" clickable @click="logoutFn">
  114. <q-item-section avatar >
  115. <q-icon name="logout" class="left-menu-icon left-menu-logout__icon"/>
  116. </q-item-section>
  117. <q-item-section v-if="!navigation_store.miniState" class="text-violet-normal">{{ $t('auth.logout') }}</q-item-section>
  118. <q-tooltip v-if="navigation_store.miniState" anchor="center right" self="center left" :offset="[10, 10]">
  119. {{ $t('auth.logout') }}
  120. </q-tooltip>
  121. </q-item>
  122. <q-item v-ripple class="left-menu-item" clickable @click="openUrl('https://softpar.inf.br')">
  123. <div class="flex full-width justify-center">
  124. <q-img
  125. :src="navigation_store.miniState || $q.screen.lt.md ? LogoSoftparMini : $q.dark.isActive ? LogoSoftparLight : LogoSoftparDark"
  126. style="height: 30px"
  127. :style="navigation_store.miniState || $q.screen.lt.md ? 'max-width: 48px; width: 48px' : 'max-width: 100px; width: 100%'"
  128. />
  129. </div>
  130. </q-item>
  131. </q-list>
  132. <div
  133. class="full-width text-center q-pb-xs cursor-pointer left-menu-version"
  134. @click="gotoVersionPage()"
  135. >
  136. <span v-if="!(navigation_store.miniState || $q.screen.lt.md)" class="text-caption text-weight-light">
  137. {{ $t('common.terms.version') + ' ' + version }}
  138. </span>
  139. <span v-else class="text-caption text-weight-light">{{ version }}</span>
  140. </div>
  141. </div>
  142. </div>
  143. </q-drawer>
  144. </template>
  145. <script setup>
  146. import { ref, watchEffect, onMounted } from "vue";
  147. import { useAuth } from "src/composables/useAuth";
  148. import { useRouter, useRoute } from "vue-router";
  149. import { navigationStore } from "src/stores/navigation";
  150. import { useQuasar } from "quasar";
  151. import { version } from "src/../package.json";
  152. import LogoSoftparLight from "src/assets/softpar_logo_light.svg";
  153. import LogoSoftparDark from "src/assets/softpar_logo_dark.svg";
  154. import LogoSoftparMini from "src/assets/softpar_logo_mini.svg";
  155. const { logout } = useAuth();
  156. const router = useRouter();
  157. const route = useRoute();
  158. const navigation_store = navigationStore();
  159. const $q = useQuasar();
  160. const childrenAreActive = (children) => {
  161. if (!Array.isArray(children) || children.length === 0) {
  162. return false;
  163. }
  164. return children.some((child) => route?.name === child?.name);
  165. };
  166. const isExpasionItemExpanded = ref([]);
  167. watchEffect(() => {
  168. if ($q.screen.lt.md) {
  169. navigation_store.miniState = true;
  170. isExpasionItemExpanded.value.forEach((_, index) => {
  171. isExpasionItemExpanded.value[index] = false;
  172. });
  173. }
  174. });
  175. const logoutFn = async () => {
  176. await logout();
  177. router.push({ name: "LoginPage" });
  178. };
  179. const openUrl = (url) => {
  180. window.open(url, "_blank");
  181. };
  182. const gotoVersionPage = () => {
  183. router.push({ name: "SystemVersionsPage" });
  184. };
  185. onMounted(() => {
  186. navigation_store.navigationItems.forEach((item, index) => {
  187. if (childrenAreActive(item.childrens)) {
  188. isExpasionItemExpanded.value[index] = true;
  189. }
  190. });
  191. });
  192. </script>
  193. <style lang="scss" scoped>
  194. @use "sass:map";
  195. @use "src/css/quasar.variables.scss" as vars;
  196. :deep(.q-drawer) {
  197. background: transparent !important;
  198. box-shadow: none !important;
  199. border: none !important;
  200. }
  201. .left-menu-drawer {
  202. background: transparent;
  203. }
  204. .left-menu-inner {
  205. height: 100%;
  206. background: transparent;
  207. }
  208. .left-menu-items-wrapper {
  209. position: relative;
  210. flex: 1;
  211. overflow: hidden;
  212. border-radius: 8px;
  213. &::before {
  214. content: "";
  215. position: absolute;
  216. inset: 0;
  217. background-color: vars.$violet-light;
  218. z-index: 0;
  219. }
  220. .left-menu-bg-overlay {
  221. position: absolute;
  222. inset: 0;
  223. background-image: url("src/assets/pessoas_fundo.jpg");
  224. background-size: cover;
  225. background-position: center top;
  226. opacity: 0.15;
  227. mix-blend-mode: multiply;
  228. z-index: 1;
  229. pointer-events: none;
  230. }
  231. .left-menu-bg-tint {
  232. display: none;
  233. }
  234. }
  235. .left-menu-list {
  236. position: relative;
  237. z-index: 3;
  238. padding-top: 8px;
  239. }
  240. .left-menu-item {
  241. position: relative;
  242. z-index: 3;
  243. color: vars.$violet-normal !important;
  244. border-radius: 6px;
  245. margin: 2px 8px;
  246. &:hover {
  247. background-color: rgba(vars.$violet-normal, 0.08);
  248. }
  249. }
  250. .left-menu-icon {
  251. font-size: 20px;
  252. color: vars.$violet-normal;
  253. }
  254. .menu-selected {
  255. background-color: rgba(vars.$violet-normal, 0.12) !important;
  256. color: vars.$violet-normal !important;
  257. }
  258. :deep(.q-expansion-item__header) {
  259. color: vars.$violet-normal;
  260. }
  261. .left-menu-footer {
  262. position: relative;
  263. z-index: 3;
  264. border-top: 1px solid rgba(vars.$violet-normal, 0.15);
  265. padding-top: 4px;
  266. }
  267. .left-menu-logout__icon {
  268. color: map.get(vars.$colors, "violet-normal") !important;
  269. }
  270. .left-menu-version {
  271. position: relative;
  272. z-index: 3;
  273. color: rgba(vars.$violet-normal, 0.6);
  274. font-size: 0.75rem;
  275. padding-bottom: 6px;
  276. }
  277. </style>