added ESlint 语法检测

This commit is contained in:
何秀钢
2021-06-02 14:11:45 +08:00
parent 3932a8fbf3
commit 2f0465a1a1
94 changed files with 5031 additions and 4790 deletions
+182 -181
View File
@@ -1,7 +1,7 @@
<template>
<div class="authority">
<div class="button-box clearflex">
<el-button @click="addAuthority('0')" type="primary">新增角色</el-button>
<el-button type="primary" @click="addAuthority('0')">新增角色</el-button>
</div>
<el-table
:data="tableData"
@@ -11,74 +11,74 @@
stripe
style="width: 100%"
>
<el-table-column label="角色id" min-width="180" prop="authorityId"></el-table-column>
<el-table-column label="角色名称" min-width="180" prop="authorityName"></el-table-column>
<el-table-column label="角色id" min-width="180" prop="authorityId" />
<el-table-column label="角色名称" min-width="180" prop="authorityName" />
<el-table-column fixed="right" label="操作" width="460">
<template slot-scope="scope">
<el-button @click="opdendrawer(scope.row)" size="small" type="primary">设置权限</el-button>
<el-button size="small" type="primary" @click="opdendrawer(scope.row)">设置权限</el-button>
<el-button
@click="addAuthority(scope.row.authorityId)"
icon="el-icon-plus"
size="small"
type="primary"
@click="addAuthority(scope.row.authorityId)"
>新增子角色</el-button>
<el-button
@click="copyAuthority(scope.row)"
icon="el-icon-copy-document"
size="small"
type="primary"
@click="copyAuthority(scope.row)"
>拷贝</el-button>
<el-button
@click="editAuthority(scope.row)"
icon="el-icon-edit"
size="small"
type="primary"
@click="editAuthority(scope.row)"
>编辑</el-button>
<el-button
@click="deleteAuth(scope.row)"
icon="el-icon-delete"
size="small"
type="danger"
@click="deleteAuth(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<!-- 新增角色弹窗 -->
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible">
<el-form :model="form" :rules="rules" ref="authorityForm">
<el-form ref="authorityForm" :model="form" :rules="rules">
<el-form-item label="父级角色" prop="parentId">
<el-cascader
v-model="form.parentId"
:disabled="dialogType=='add'"
:options="AuthorityOption"
:props="{ checkStrictly: true,label:'authorityName',value:'authorityId',disabled:'disabled',emitPath:false}"
:show-all-levels="false"
filterable
v-model="form.parentId"
></el-cascader>
/>
</el-form-item>
<el-form-item label="角色ID" prop="authorityId">
<el-input :disabled="dialogType=='edit'" autocomplete="off" v-model="form.authorityId"></el-input>
<el-input v-model="form.authorityId" :disabled="dialogType=='edit'" autocomplete="off" />
</el-form-item>
<el-form-item label="角色姓名" prop="authorityName">
<el-input autocomplete="off" v-model="form.authorityName"></el-input>
<el-input v-model="form.authorityName" autocomplete="off" />
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<div slot="footer" class="dialog-footer">
<el-button @click="closeDialog">取 消</el-button>
<el-button @click="enterDialog" type="primary">确 定</el-button>
<el-button type="primary" @click="enterDialog">确 定</el-button>
</div>
</el-dialog>
<el-drawer :visible.sync="drawer" :with-header="false" size="40%" title="角色配置" v-if="drawer">
<el-drawer v-if="drawer" :visible.sync="drawer" :with-header="false" size="40%" title="角色配置">
<el-tabs :before-leave="autoEnter" class="role-box" type="border-card">
<el-tab-pane label="角色菜单">
<Menus :row="activeRow" ref="menus" />
<Menus ref="menus" :row="activeRow" />
</el-tab-pane>
<el-tab-pane label="角色api">
<apis :row="activeRow" ref="apis" />
<apis ref="apis" :row="activeRow" />
</el-tab-pane>
<el-tab-pane label="资源权限">
<Datas :authority="tableData" :row="activeRow" ref="datas" />
<Datas ref="datas" :authority="tableData" :row="activeRow" />
</el-tab-pane>
</el-tabs>
</el-drawer>
@@ -94,266 +94,267 @@ import {
createAuthority,
updateAuthority,
copyAuthority
} from "@/api/authority";
} from '@/api/authority'
import Menus from "@/view/superAdmin/authority/components/menus";
import Apis from "@/view/superAdmin/authority/components/apis";
import Datas from "@/view/superAdmin/authority/components/datas";
import Menus from '@/view/superAdmin/authority/components/menus'
import Apis from '@/view/superAdmin/authority/components/apis'
import Datas from '@/view/superAdmin/authority/components/datas'
import infoList from "@/mixins/infoList";
import infoList from '@/mixins/infoList'
export default {
name: "Authority",
mixins: [infoList],
data() {
var mustUint = (rule, value, callback) => {
if (!/^[0-9]*[1-9][0-9]*$/.test(value)) {
return callback(new Error("请输入正整数"));
}
return callback();
};
return {
AuthorityOption: [
{
authorityId: "0",
authorityName: "根角色"
}
],
listApi: getAuthorityList,
drawer: false,
dialogType: "add",
activeRow: {},
activeUserId: 0,
dialogTitle: "新增角色",
dialogFormVisible: false,
apiDialogFlag: false,
copyForm: {},
form: {
authorityId: "",
authorityName: "",
parentId: "0"
},
rules: {
authorityId: [
{ required: true, message: "请输入角色ID", trigger: "blur" },
{ validator: mustUint, trigger: "blur" }
],
authorityName: [
{ required: true, message: "请输入角色名", trigger: "blur" }
],
parentId: [
{ required: true, message: "请选择请求方式", trigger: "blur" }
]
}
};
},
name: 'Authority',
components: {
Menus,
Apis,
Datas
},
mixins: [infoList],
data() {
var mustUint = (rule, value, callback) => {
if (!/^[0-9]*[1-9][0-9]*$/.test(value)) {
return callback(new Error('请输入正整数'))
}
return callback()
}
return {
AuthorityOption: [
{
authorityId: '0',
authorityName: '根角色'
}
],
listApi: getAuthorityList,
drawer: false,
dialogType: 'add',
activeRow: {},
activeUserId: 0,
dialogTitle: '新增角色',
dialogFormVisible: false,
apiDialogFlag: false,
copyForm: {},
form: {
authorityId: '',
authorityName: '',
parentId: '0'
},
rules: {
authorityId: [
{ required: true, message: '请输入角色ID', trigger: 'blur' },
{ validator: mustUint, trigger: 'blur' }
],
authorityName: [
{ required: true, message: '请输入角色名', trigger: 'blur' }
],
parentId: [
{ required: true, message: '请选择请求方式', trigger: 'blur' }
]
}
}
},
async created() {
this.pageSize = 999
await this.getTableData()
},
methods: {
autoEnter(activeName, oldActiveName) {
const paneArr = ["menus", "apis", "datas"];
const paneArr = ['menus', 'apis', 'datas']
if (oldActiveName) {
if (this.$refs[paneArr[oldActiveName]].needConfirm) {
this.$refs[paneArr[oldActiveName]].enterAndNext();
this.$refs[paneArr[oldActiveName]].needConfirm = false;
this.$refs[paneArr[oldActiveName]].enterAndNext()
this.$refs[paneArr[oldActiveName]].needConfirm = false
}
}
},
// 拷贝角色
copyAuthority(row) {
this.setOptions();
this.dialogTitle = "拷贝角色";
this.dialogType = "copy";
for (let k in this.form) {
this.form[k] = row[k];
this.setOptions()
this.dialogTitle = '拷贝角色'
this.dialogType = 'copy'
for (const k in this.form) {
this.form[k] = row[k]
}
this.copyForm = row;
this.dialogFormVisible = true;
this.copyForm = row
this.dialogFormVisible = true
},
opdendrawer(row) {
this.drawer = true;
this.activeRow = row;
this.drawer = true
this.activeRow = row
},
// 删除角色
deleteAuth(row) {
this.$confirm("此操作将永久删除该角色, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
this.$confirm('此操作将永久删除该角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async () => {
const res = await deleteAuthority({ authorityId: row.authorityId });
if (res.code == 0) {
.then(async() => {
const res = await deleteAuthority({ authorityId: row.authorityId })
if (res.code === 0) {
this.$message({
type: "success",
message: "删除成功!"
});
if (this.tableData.length == 1 && this.page > 1 ) {
this.page--;
type: 'success',
message: '删除成功!'
})
if (this.tableData.length === 1 && this.page > 1) {
this.page--
}
this.getTableData();
this.getTableData()
}
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除"
});
});
type: 'info',
message: '已取消删除'
})
})
},
// 初始化表单
initForm() {
if (this.$refs.authorityForm) {
this.$refs.authorityForm.resetFields();
this.$refs.authorityForm.resetFields()
}
this.form = {
authorityId: "",
authorityName: "",
parentId: "0"
};
authorityId: '',
authorityName: '',
parentId: '0'
}
},
// 关闭窗口
closeDialog() {
this.initForm();
this.dialogFormVisible = false;
this.apiDialogFlag = false;
this.initForm()
this.dialogFormVisible = false
this.apiDialogFlag = false
},
// 确定弹窗
async enterDialog() {
if (this.form.authorityId == "0") {
if (this.form.authorityId === '0') {
this.$message({
type: "error",
message: "角色id不能为0"
});
return false;
type: 'error',
message: '角色id不能为0'
})
return false
}
this.$refs.authorityForm.validate(async valid => {
if (valid) {
switch (this.dialogType) {
case "add":
case 'add':
{
const res = await createAuthority(this.form);
if (res.code == 0) {
const res = await createAuthority(this.form)
if (res.code === 0) {
this.$message({
type: "success",
message: "添加成功!"
});
this.getTableData();
this.closeDialog();
type: 'success',
message: '添加成功!'
})
this.getTableData()
this.closeDialog()
}
}
break;
case "edit":
break
case 'edit':
{
const res = await updateAuthority(this.form);
if (res.code == 0) {
const res = await updateAuthority(this.form)
if (res.code === 0) {
this.$message({
type: "success",
message: "添加成功!"
});
this.getTableData();
this.closeDialog();
type: 'success',
message: '添加成功!'
})
this.getTableData()
this.closeDialog()
}
}
break;
case "copy": {
break
case 'copy': {
const data = {
authority: {
authorityId: "string",
authorityName: "string",
authorityId: 'string',
authorityName: 'string',
datauthorityId: [],
parentId: "string"
parentId: 'string'
},
oldAuthorityId: 0
};
data.authority.authorityId = this.form.authorityId;
data.authority.authorityName = this.form.authorityName;
data.authority.parentId = this.form.parentId;
data.authority.dataAuthorityId = this.copyForm.dataAuthorityId;
data.oldAuthorityId = this.copyForm.authorityId;
const res = await copyAuthority(data);
if (res.code == 0) {
}
data.authority.authorityId = this.form.authorityId
data.authority.authorityName = this.form.authorityName
data.authority.parentId = this.form.parentId
data.authority.dataAuthorityId = this.copyForm.dataAuthorityId
data.oldAuthorityId = this.copyForm.authorityId
const res = await copyAuthority(data)
if (res.code === 0) {
this.$message({
type: "success",
message: "复制成功!"
});
this.getTableData();
type: 'success',
message: '复制成功!'
})
this.getTableData()
}
}
}
this.initForm();
this.dialogFormVisible = false;
this.initForm()
this.dialogFormVisible = false
}
});
})
},
setOptions() {
this.AuthorityOption = [
{
authorityId: "0",
authorityName: "根角色"
authorityId: '0',
authorityName: '根角色'
}
];
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false);
]
this.setAuthorityOptions(this.tableData, this.AuthorityOption, false)
},
setAuthorityOptions(AuthorityData, optionsData, disabled) {
this.form.authorityId = String(this.form.authorityId);
this.form.authorityId = String(this.form.authorityId)
AuthorityData &&
AuthorityData.map(item => {
if (item.children && item.children.length) {
const option = {
authorityId: item.authorityId,
authorityName: item.authorityName,
disabled: disabled || item.authorityId == this.form.authorityId,
disabled: disabled || item.authorityId === this.form.authorityId,
children: []
};
}
this.setAuthorityOptions(
item.children,
option.children,
disabled || item.authorityId == this.form.authorityId
);
optionsData.push(option);
disabled || item.authorityId === this.form.authorityId
)
optionsData.push(option)
} else {
const option = {
authorityId: item.authorityId,
authorityName: item.authorityName,
disabled: disabled || item.authorityId == this.form.authorityId
};
optionsData.push(option);
disabled: disabled || item.authorityId === this.form.authorityId
}
optionsData.push(option)
}
});
})
},
// 增加角色
addAuthority(parentId) {
this.initForm();
this.dialogTitle = "新增角色";
this.dialogType = "add";
this.form.parentId = parentId;
this.setOptions();
this.dialogFormVisible = true;
this.initForm()
this.dialogTitle = '新增角色'
this.dialogType = 'add'
this.form.parentId = parentId
this.setOptions()
this.dialogFormVisible = true
},
// 编辑角色
editAuthority(row) {
this.setOptions();
this.dialogTitle = "编辑角色";
this.dialogType = "edit";
for (let key in this.form) {
this.form[key] = row[key];
this.setOptions()
this.dialogTitle = '编辑角色'
this.dialogType = 'edit'
for (const key in this.form) {
this.form[key] = row[key]
}
this.setOptions();
this.dialogFormVisible = true;
this.setOptions()
this.dialogFormVisible = true
}
},
async created() {
this.pageSize = 999;
await this.getTableData();
}
};
}
</script>
<style lang="scss">
.authority {
.el-input-number {
@@ -375,4 +376,4 @@ export default {
overflow: auto;
}
}
</style>
</style>
@@ -1,21 +1,22 @@
<template>
<div>
<div class="clearflex">
<el-button @click="authApiEnter" class="fl-right" size="small" type="primary">确 定</el-button>
<el-button class="fl-right" size="small" type="primary" @click="authApiEnter">确 定</el-button>
</div>
<el-tree
ref="apiTree"
:data="apiTreeData"
:default-checked-keys="apiTreeIds"
:props="apiDefaultProps"
@check="nodeChange"
default-expand-all
highlight-current
node-key="onlyId"
ref="apiTree"
show-checkbox
></el-tree>
@check="nodeChange"
/>
</div>
</template>
<script>
import { getAllApis } from '@/api/api'
import { UpdateCasbin, getPolicyPathByAuthorityId } from '@/api/casbin'
@@ -33,28 +34,43 @@ export default {
return {
apiTreeData: [],
apiTreeIds: [],
needConfirm:false,
needConfirm: false,
apiDefaultProps: {
children: 'children',
label: 'description'
}
}
},
async created() {
// 获取api并整理成树结构
const res2 = await getAllApis()
const apis = res2.data.apis
this.apiTreeData = this.buildApiTree(apis)
const res = await getPolicyPathByAuthorityId({
authorityId: this.row.authorityId
})
this.activeUserId = this.row.authorityId
this.apiTreeIds = []
res.data.paths && res.data.paths.map(item => {
this.apiTreeIds.push('p:' + item.path + 'm:' + item.method)
})
},
methods: {
nodeChange(){
nodeChange() {
this.needConfirm = true
},
// 暴露给外层使用的切换拦截统一方法
enterAndNext(){
enterAndNext() {
this.authApiEnter()
},
// 创建api树方法
buildApiTree(apis) {
const apiObj = new Object()
const apiObj = {}
apis &&
apis.map(item => {
item.onlyId = "p:"+item.path+"m:"+item.method
if (Object.prototype.hasOwnProperty.call(apiObj,item.apiGroup)) {
item.onlyId = 'p:' + item.path + 'm:' + item.method
if (Object.prototype.hasOwnProperty.call(apiObj, item.apiGroup)) {
apiObj[item.apiGroup].push(item)
} else {
Object.assign(apiObj, { [item.apiGroup]: [item] })
@@ -75,10 +91,10 @@ export default {
async authApiEnter() {
const checkArr = this.$refs.apiTree.getCheckedNodes(true)
var casbinInfos = []
checkArr&&checkArr.map(item=>{
checkArr && checkArr.map(item => {
var casbinInfo = {
path:item.path,
method:item.method
path: item.path,
method: item.method
}
casbinInfos.push(casbinInfo)
})
@@ -86,27 +102,10 @@ export default {
authorityId: this.activeUserId,
casbinInfos
})
if (res.code == 0) {
this.$message({ type: 'success', message: "api设置成功" })
if (res.code === 0) {
this.$message({ type: 'success', message: 'api设置成功' })
}
}
},
async created() {
// 获取api并整理成树结构
const res2 = await getAllApis()
const apis = res2.data.apis
this.apiTreeData = this.buildApiTree(apis)
const res = await getPolicyPathByAuthorityId({
authorityId: this.row.authorityId
})
this.activeUserId = this.row.authorityId
this.apiTreeIds = []
res.data.paths&&res.data.paths.map(item=>{
this.apiTreeIds.push("p:"+item.path+"m:"+item.method)
})
}
}
</script>
<style lang="scss">
</style>
@@ -1,27 +1,21 @@
<template>
<div>
<div class="clearflex" style="margin:18px">
<el-button @click="authDataEnter" class="fl-right" size="small" type="primary">确 定</el-button>
<el-button @click="all" class="fl-left" size="small" type="primary">全选</el-button>
<el-button @click="self" class="fl-left" size="small" type="primary">本角色</el-button>
<el-button @click="selfAndChildren" class="fl-left" size="small" type="primary">本角色及子角色</el-button>
<div class="clearflex" style="margin:18px">
<el-button class="fl-right" size="small" type="primary" @click="authDataEnter">确 定</el-button>
<el-button class="fl-left" size="small" type="primary" @click="all">全选</el-button>
<el-button class="fl-left" size="small" type="primary" @click="self">本角色</el-button>
<el-button class="fl-left" size="small" type="primary" @click="selfAndChildren">本角色及子角色</el-button>
</div>
<el-checkbox-group v-model="dataAuthorityId" @change="selectAuthority">
<el-checkbox v-for="(item,key) in authoritys" :label="item" :key="key">{{item.authorityName}}</el-checkbox>
<el-checkbox-group v-model="dataAuthorityId" @change="selectAuthority">
<el-checkbox v-for="(item,key) in authoritys" :key="key" :label="item">{{ item.authorityName }}</el-checkbox>
</el-checkbox-group>
</div>
</template>
<script>
import {setDataAuthority} from '@/api/authority'
import { setDataAuthority } from '@/api/authority'
export default {
name: 'Datas',
data() {
return {
authoritys:[],
dataAuthorityId:[],
needConfirm:false
}
},
props: {
row: {
default: function() {
@@ -36,69 +30,74 @@ export default {
type: Array
}
},
methods:{
// 暴露给外层使用的切换拦截统一方法
enterAndNext(){
this.authDataEnter()
},
all(){
this.dataAuthorityId = [...this.authoritys]
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
self(){
this.dataAuthorityId = this.authoritys.filter(item=>item.authorityId===this.row.authorityId)
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
selfAndChildren(){
const arrBox = []
this.getChildrenId(this.row,arrBox)
this.dataAuthorityId = this.authoritys.filter(item=>arrBox.indexOf(item.authorityId)>-1)
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
getChildrenId(row,arrBox){
arrBox.push(row.authorityId)
row.children&&row.children.map(item=>{
this.getChildrenId(item,arrBox)
})
},
// 提交
async authDataEnter(){
const res = await setDataAuthority(this.row)
if(res.code == 0){
this.$message({ type: 'success', message: "资源设置成功" })
}
},
// 平铺角色
roundAuthority(authoritys){
authoritys&&authoritys.map(item=>{
const obj = {}
obj.authorityId = item.authorityId
obj.authorityName = item.authorityName
this.authoritys.push(obj)
if(item.children&&item.children.length){
this.roundAuthority(item.children)
}
})
},
// 选择
selectAuthority(){
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
}
data() {
return {
authoritys: [],
dataAuthorityId: [],
needConfirm: false
}
},
created() {
this.authoritys = []
this.dataAuthorityId = []
this.roundAuthority(this.authority)
this.row.dataAuthorityId&&this.row.dataAuthorityId.map(item=>{
const obj = this.authoritys&&this.authoritys.filter(au=>au.authorityId === item.authorityId)&&this.authoritys.filter(au=>au.authorityId === item.authorityId)[0]
this.dataAuthorityId.push(obj)
this.authoritys = []
this.dataAuthorityId = []
this.roundAuthority(this.authority)
this.row.dataAuthorityId && this.row.dataAuthorityId.map(item => {
const obj = this.authoritys && this.authoritys.filter(au => au.authorityId === item.authorityId) && this.authoritys.filter(au => au.authorityId === item.authorityId)[0]
this.dataAuthorityId.push(obj)
})
},
methods: {
// 暴露给外层使用的切换拦截统一方法
enterAndNext() {
this.authDataEnter()
},
all() {
this.dataAuthorityId = [...this.authoritys]
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
self() {
this.dataAuthorityId = this.authoritys.filter(item => item.authorityId === this.row.authorityId)
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
selfAndChildren() {
const arrBox = []
this.getChildrenId(this.row, arrBox)
this.dataAuthorityId = this.authoritys.filter(item => arrBox.indexOf(item.authorityId) > -1)
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
},
getChildrenId(row, arrBox) {
arrBox.push(row.authorityId)
row.children && row.children.map(item => {
this.getChildrenId(item, arrBox)
})
},
// 提交
async authDataEnter() {
const res = await setDataAuthority(this.row)
if (res.code === 0) {
this.$message({ type: 'success', message: '资源设置成功' })
}
},
// 平铺角色
roundAuthority(authoritys) {
authoritys && authoritys.map(item => {
const obj = {}
obj.authorityId = item.authorityId
obj.authorityName = item.authorityName
this.authoritys.push(obj)
if (item.children && item.children.length) {
this.roundAuthority(item.children)
}
})
},
// 选择
selectAuthority() {
this.row.dataAuthorityId = this.dataAuthorityId
this.needConfirm = true
}
}
}
</script>
<style lang="less">
</style>
@@ -1,40 +1,42 @@
<template>
<div>
<div class="clearflex">
<el-button @click="relation" class="fl-right" size="small" type="primary">确 定</el-button>
<el-button class="fl-right" size="small" type="primary" @click="relation">确 定</el-button>
</div>
<el-tree
ref="menuTree"
:data="menuTreeData"
:default-checked-keys="menuTreeIds"
:props="menuDefaultProps"
@check="nodeChange"
default-expand-all
highlight-current
node-key="ID"
ref="menuTree"
show-checkbox
@check="nodeChange"
>
<span class="custom-tree-node" slot-scope="{ node , data }">
<span slot-scope="{ node , data }" class="custom-tree-node">
<span>{{ node.label }}</span>
<span>
<el-button
type="text"
size="mini"
:style="{color:row.defaultRouter == data.name?'#E6A23C':'#85ce61'}"
:style="{color:row.defaultRouter === data.name?'#E6A23C':'#85ce61'}"
:disabled="!node.checked"
@click="() => setDefault(data)">
{{row.defaultRouter == data.name?"首页":"设为首页"}}
@click="() => setDefault(data)"
>
{{ row.defaultRouter === data.name?"首页":"设为首页" }}
</el-button>
</span>
</span>
</el-tree>
</div>
</template>
<script>
import { getBaseMenuTree, getMenuAuthority, addMenuAuthority } from '@/api/menu'
import {
updateAuthority,
} from "@/api/authority";
updateAuthority
} from '@/api/authority'
export default {
name: 'Menus',
props: {
@@ -49,45 +51,15 @@ export default {
return {
menuTreeData: [],
menuTreeIds: [],
needConfirm:false,
needConfirm: false,
menuDefaultProps: {
children: 'children',
label: function(data){
label: function(data) {
return data.meta.title
}
}
}
},
methods: {
async setDefault(data){
const res = await updateAuthority({authorityId: this.row.authorityId,AuthorityName: this.row.authorityName,parentId: this.row.parentId,defaultRouter:data.name})
if(res.code == 0){
this.$message({type:"success",message:"设置成功"})
this.row.defaultRouter = res.data.authority.defaultRouter
}
},
nodeChange(){
this.needConfirm = true
},
// 暴露给外层使用的切换拦截统一方法
enterAndNext(){
this.relation()
},
// 关联树 确认方法
async relation() {
const checkArr = this.$refs.menuTree.getCheckedNodes(false, true)
const res = await addMenuAuthority({
menus: checkArr,
authorityId: this.row.authorityId
})
if (res.code == 0) {
this.$message({
type: 'success',
message: '菜单设置成功!'
})
}
}
},
async created() {
// 获取所有菜单树
const res = await getBaseMenuTree()
@@ -103,8 +75,36 @@ export default {
}
})
this.menuTreeIds = arr
},
methods: {
async setDefault(data) {
const res = await updateAuthority({ authorityId: this.row.authorityId, AuthorityName: this.row.authorityName, parentId: this.row.parentId, defaultRouter: data.name })
if (res.code === 0) {
this.$message({ type: 'success', message: '设置成功' })
this.row.defaultRouter = res.data.authority.defaultRouter
}
},
nodeChange() {
this.needConfirm = true
},
// 暴露给外层使用的切换拦截统一方法
enterAndNext() {
this.relation()
},
// 关联树 确认方法
async relation() {
const checkArr = this.$refs.menuTree.getCheckedNodes(false, true)
const res = await addMenuAuthority({
menus: checkArr,
authorityId: this.row.authorityId
})
if (res.code === 0) {
this.$message({
type: 'success',
message: '菜单设置成功!'
})
}
}
}
}
</script>
<style lang="scss">
</style>