|
@@ -32,10 +32,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { system, personnel, government, record, serve, enterprise, duijiehui, site, user, links, permission, dictionary } from '@/util/role_menu.js';
|
|
|
+import { index, personnel, government, record, serve, enterprise, duijiehui, site, user, links, defaultMenu } from '@/util/role_menu.js';
|
|
|
import * as menus from '@/util/role_menu.js';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
-const { mapActions } = createNamespacedHelpers('marketcolumn');
|
|
|
+const { mapActions } = createNamespacedHelpers('login');
|
|
|
import _ from 'lodash';
|
|
|
export default {
|
|
|
name: 'sideMenu',
|
|
@@ -48,67 +48,38 @@ export default {
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
},
|
|
|
- created() {
|
|
|
- this.serrch();
|
|
|
- if (this.menu.length === 0) this.getMenuList();
|
|
|
- },
|
|
|
+ created() {},
|
|
|
methods: {
|
|
|
- ...mapActions(['fetch', 'create', 'update', 'query']),
|
|
|
- async serrch() {
|
|
|
- const res = await this.query();
|
|
|
+ ...mapActions(['toGetMenu', 'logout']),
|
|
|
+ async search() {
|
|
|
+ if (!this.user.uid) return;
|
|
|
if (this.user.role == '1') {
|
|
|
- this.menu.push(system, personnel, government, record, serve, enterprise, duijiehui, site, user, links, permission, dictionary);
|
|
|
+ this.menu.push(index, ...defaultMenu, personnel, government, record, serve, enterprise, duijiehui, site, user, links);
|
|
|
return;
|
|
|
}
|
|
|
- for (const val of this.user.columnid) {
|
|
|
- var result = res.data.filter(item => item.id == val);
|
|
|
- for (const acc of result) {
|
|
|
- if (acc.name == system.name) {
|
|
|
- this.menu.push(system);
|
|
|
- } else if (acc.name == personnel.name) {
|
|
|
- this.menu.push(personnel);
|
|
|
- } else if (acc.name == government.name) {
|
|
|
- this.menu.push(government);
|
|
|
- } else if (acc.name == record.name) {
|
|
|
- this.menu.push(record);
|
|
|
- } else if (acc.name == serve.name) {
|
|
|
- this.menu.push(serve);
|
|
|
- } else if (acc.name == enterprise.name) {
|
|
|
- this.menu.push(enterprise);
|
|
|
- } else if (acc.name == site.name) {
|
|
|
- this.menu.push(site);
|
|
|
- } else if (acc.name == user.name) {
|
|
|
- this.menu.push(user);
|
|
|
- } else if (acc.name == links.name) {
|
|
|
- this.menu.push(links);
|
|
|
- } else if (acc.name == permission.name) {
|
|
|
- this.menu.push(permission);
|
|
|
- } else if (acc.name == dictionary.name) {
|
|
|
- this.menu.push(dictionary);
|
|
|
- }
|
|
|
- console.log(this.menu);
|
|
|
- }
|
|
|
+ const res = await this.toGetMenu({ id: this.user.uid });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ let menu = res.data.menus;
|
|
|
+ menu = menu.map(i => {
|
|
|
+ return { name: i.role_name, path: i.url };
|
|
|
+ });
|
|
|
+ let duplicate = JSON.parse(JSON.stringify(this.menu));
|
|
|
+ duplicate.push(...menu);
|
|
|
+ let nm = _.uniqBy(duplicate, 'path');
|
|
|
+ this.$set(this, `menu`, nm);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
selectMenu(path) {
|
|
|
this.$router.push({ path: path });
|
|
|
},
|
|
|
- getMenuList() {
|
|
|
- let res = _.uniqBy(this.menuList, 'menuid');
|
|
|
- for (const item of res) {
|
|
|
- this.menu.push(_.get(menus, item.code));
|
|
|
- }
|
|
|
- },
|
|
|
- openMenuList(index) {
|
|
|
- if (!this.$refs.collapse[index].show) {
|
|
|
- this.$refs.collapse.forEach(item => {
|
|
|
- item.show = false;
|
|
|
- });
|
|
|
- this.$refs.collapse[index].show = true;
|
|
|
- } else {
|
|
|
- this.$refs.collapse[index].show = false;
|
|
|
- }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ user: {
|
|
|
+ handler(val, oval) {
|
|
|
+ if (val && !_.isEqual(val, oval)) this.search();
|
|
|
+ },
|
|
|
+ immediate: true,
|
|
|
},
|
|
|
},
|
|
|
};
|