Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

228 rindas
8.4 KiB

  1. <template>
  2. <v-app>
  3. <v-navigation-drawer
  4. v-model="drawer"
  5. width="130"
  6. :clipped="$vuetify.breakpoint.lgAndUp"
  7. app
  8. >
  9. <v-list dense>
  10. <template v-for="item in items">
  11. <v-list-group
  12. v-if="item.children"
  13. :key="item.text"
  14. v-model="item.model"
  15. :prepend-icon="item.model ? item.icon : item['icon-alt']"
  16. append-icon=""
  17. >
  18. <template v-slot:activator>
  19. <v-list-item-content>
  20. <v-list-item-title>
  21. {{ item.text }}
  22. </v-list-item-title>
  23. </v-list-item-content>
  24. </template>
  25. <v-list-item
  26. v-for="(child, i) in item.children"
  27. :key="i"
  28. link
  29. :to="child.route"
  30. >
  31. <v-list-item-action v-if="child.icon">
  32. <v-icon>{{ child.icon }}</v-icon>
  33. </v-list-item-action>
  34. <v-list-item-content>
  35. <v-list-item-title>
  36. {{ child.text }}
  37. </v-list-item-title>
  38. </v-list-item-content>
  39. </v-list-item>
  40. </v-list-group>
  41. <v-list-item
  42. v-else
  43. :key="item.text"
  44. link
  45. dense
  46. :to="item.route"
  47. class="px-0 pl-5"
  48. >
  49. <!-- <v-list-item-action>-->
  50. <!-- <v-icon>{{ item.icon }}</v-icon>-->
  51. <!-- </v-list-item-action>-->
  52. <v-list-item-content>
  53. <v-list-item-title class="font-weight-bold subtitle-2">
  54. {{ item.text }}
  55. </v-list-item-title>
  56. </v-list-item-content>
  57. </v-list-item>
  58. </template>
  59. </v-list>
  60. </v-navigation-drawer>
  61. <v-app-bar
  62. :clipped-left="$vuetify.breakpoint.lgAndUp"
  63. app
  64. color="blue darken-3"
  65. dark
  66. dense
  67. >
  68. <v-app-bar-nav-icon @click.stop="drawer = !drawer"/>
  69. <v-toolbar-title
  70. style="width: 400px"
  71. class="ml-0 pl-4"
  72. >
  73. <span class="hidden-sm-and-down">資訊資產管理系統</span>
  74. </v-toolbar-title>
  75. <v-spacer/>
  76. <v-menu
  77. offset-y
  78. origin="center center"
  79. :nudge-bottom="10"
  80. transition="scale-transition">
  81. <template v-slot:activator="{on}">
  82. <v-btn
  83. icon
  84. large
  85. v-on="on"
  86. >
  87. <v-avatar
  88. size="32px"
  89. item
  90. >
  91. <v-btn
  92. color="primary lighten-2"
  93. class="white--text"
  94. >
  95. {{ username.slice(1) }}
  96. </v-btn>
  97. </v-avatar>
  98. </v-btn>
  99. </template>
  100. <v-list class="pa-0">
  101. <v-list>
  102. <v-list-item>
  103. <v-list-item-avatar>
  104. <v-icon
  105. class="blue--text"
  106. >
  107. mdi-account
  108. </v-icon>
  109. </v-list-item-avatar>
  110. <v-list-item-content>
  111. <v-list-item-title>{{ username }}</v-list-item-title>
  112. </v-list-item-content>
  113. </v-list-item>
  114. </v-list>
  115. <v-divider/>
  116. <v-list-item
  117. v-for="(item,index) in menuitems"
  118. :key="index"
  119. :to="!item.href ? {name: item.name} : null"
  120. :href="item.href"
  121. ripple="ripple"
  122. :disabled="item.disabled"
  123. :target="item.target"
  124. rel="noopener"
  125. @click="item.click"
  126. >
  127. <v-list-item-action v-if="item.icon">
  128. <v-icon>{{ item.icon }}</v-icon>
  129. </v-list-item-action>
  130. <v-list-item-content>
  131. <v-list-item-title>{{ item.title }}</v-list-item-title>
  132. </v-list-item-content>
  133. </v-list-item>
  134. </v-list>
  135. </v-menu>
  136. </v-app-bar>
  137. <v-content>
  138. <keep-alive>
  139. <router-view></router-view>
  140. </keep-alive>
  141. </v-content>
  142. <v-snackbar v-model="error" top :timeout="2500">
  143. {{ message }}
  144. <v-btn
  145. color="pink"
  146. text
  147. @click="error = false"
  148. >
  149. Close
  150. </v-btn>
  151. </v-snackbar>
  152. </v-app>
  153. </template>
  154. <script>
  155. export default {
  156. components: {},
  157. props: {
  158. source: String,
  159. },
  160. data() {
  161. return {
  162. dialog: false,
  163. drawer: null,
  164. error: false,
  165. message: "",
  166. items: [{'text': '全域搜尋', 'route': '/search'}],
  167. username: localStorage.getItem('username'),
  168. this1: this,
  169. menuitems: [
  170. {
  171. icon: 'mdi-exit-to-app',
  172. href: '#',
  173. title: '登出',
  174. click: () => {
  175. this.this1.logout();
  176. },
  177. },
  178. ],
  179. }
  180. },
  181. created() {
  182. this.$root.$on('showError', (message) => {
  183. this.error = true;
  184. this.message = message;
  185. });
  186. },
  187. computed: {
  188. isAdmin() {
  189. let level = localStorage.getItem('level');
  190. return (level != null && level === '0');
  191. },
  192. },
  193. mounted() {
  194. this.getRoutes();
  195. },
  196. methods: {
  197. logout() {
  198. this.$emit("authenticated", null);
  199. },
  200. async getRoutes() {
  201. this.addFeatureByLevel(localStorage.getItem('level'));
  202. this.$axios.get('/routes').then((resp) => {
  203. resp.data.data.forEach((item) => {
  204. let route = {'text': '', 'route': ''};
  205. route.text = item.descript;
  206. route.route = `/inventory/${item.tablename}`;
  207. this.items.push(route);
  208. });
  209. });
  210. },
  211. addFeatureByLevel(level) {
  212. //超級管理員
  213. if (level === '0') {
  214. this.items.push({'text': '資訊資產群組', 'route': '/asset_group'});
  215. this.items.push({'text': '帳號與權限管理', 'route': '/account'});
  216. }
  217. //一般管理員
  218. if (level === '1') {
  219. this.items.push({text: '資訊資產群組', route: '/asset_group'});
  220. }
  221. }
  222. }
  223. }
  224. </script>