|
@@ -24,6 +24,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import _ from 'lodash';
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
const { mapActions } = createNamespacedHelpers('role');
|
|
|
export default {
|
|
@@ -45,16 +46,26 @@ export default {
|
|
|
methods: {
|
|
|
...mapActions(['query', 'create', 'update', 'delete']),
|
|
|
async search() {
|
|
|
- const res = await this.query();
|
|
|
- if (this.$checkRes(res)) {
|
|
|
- let data = res.data.reverse();
|
|
|
- data = data.map(i => {
|
|
|
- let { role_name: name, url: cpt } = i;
|
|
|
- return { name, cpt };
|
|
|
- });
|
|
|
- this.$set(this, `menuList`, data);
|
|
|
- this.setRight(this.active);
|
|
|
+ let data;
|
|
|
+ if (this.user.role == '0' && !_.get(this.user, 'pid')) {
|
|
|
+ const res = await this.query();
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ data = res.data.reverse();
|
|
|
+ data = this.dataChange(data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let menus = _.get(this.user, 'menus');
|
|
|
+ data = this.dataChange(JSON.parse(menus));
|
|
|
}
|
|
|
+ this.$set(this, `menuList`, data);
|
|
|
+ this.setRight(this.active);
|
|
|
+ },
|
|
|
+ dataChange(data) {
|
|
|
+ data = data.map(i => {
|
|
|
+ let { role_name: name, url: cpt } = i;
|
|
|
+ return { name, cpt };
|
|
|
+ });
|
|
|
+ return data;
|
|
|
},
|
|
|
// 菜单跳转
|
|
|
setRight(index) {
|