first commit
This commit is contained in:
@@ -0,0 +1,887 @@
|
||||
<!--#
|
||||
layout("/layouts/platform.html"){
|
||||
#-->
|
||||
|
||||
<style>
|
||||
.highlight {
|
||||
background-color: yellow;
|
||||
font-weight: bold;
|
||||
padding: 1px 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="app" v-cloak>
|
||||
<el-card shadow="never">
|
||||
<el-row type="flex" style="column-gap: 10px">
|
||||
<el-select v-model="pageForm.system_name" style="width: 180px" filterable clearable
|
||||
placeholder="请选择所属模块">
|
||||
<el-option v-for="item in menuOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
<el-input placeholder="请输入内容" v-model="pageForm.searchKeyword" style="width: 300px"
|
||||
@keyup.enter.native="doSearch">
|
||||
<el-select v-model="pageForm.searchName" slot="prepend" placeholder="查询类型" style="width: 120px">
|
||||
<el-option label="角色名称" value="`name`"></el-option>
|
||||
<el-option label="角色标识" value="`code`"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-input placeholder="请输入内容" v-model="pageForm.searchKeyword2" @keyup.enter.native="doSearch"
|
||||
style="width: 300px">
|
||||
<el-select v-model="pageForm.searchName2" slot="prepend" placeholder="查询类型" style="width: 80px">
|
||||
<el-option label="姓名" value="username"></el-option>
|
||||
<el-option label="工号" value="loginname"></el-option>
|
||||
</el-select>
|
||||
</el-input>
|
||||
<el-button icon="el-icon-search" @click="doSearch" type="primary"></el-button>
|
||||
|
||||
<div style="margin-left: auto">
|
||||
<el-button size="medium" @click="openAdd" type="primary">
|
||||
<i class="ti-plus"></i>
|
||||
新建角色
|
||||
</el-button>
|
||||
<el-button @click="$refs.sortRef.onOpen()" size="medium" type="primary" icon="el-icon-sort">排序
|
||||
</el-button>
|
||||
</div>
|
||||
</el-row>
|
||||
|
||||
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
||||
<!-- <el-button size="medium" @click="doSettingMemberRole" type="primary"><i class="el-icon-s-tools"></i>-->
|
||||
<!-- 一键设会员角色-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
||||
<!-- <el-button size="medium" @click="doPublic" type="primary">一键设置公共角色</el-button>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="pull-right offscreen-right mt5 ml5">-->
|
||||
<!-- <el-button size="medium" @click="openAdd" type="primary"><i class="ti-plus"></i> 新建角色</el-button>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <div class="pull-right offscreen-right mt5">-->
|
||||
<!-- <el-button size="medium" @click="exportRoles" type="primary"><i class="el-icon-download"></i> 导出角色-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </div>-->
|
||||
</el-card>
|
||||
<el-card shadow="never" class="mt10">
|
||||
<el-table
|
||||
:data="tableData"
|
||||
@sort-change="pageOrder"
|
||||
header-align="center"
|
||||
:default-sort="{prop: 'serialNumber', order: 'ascending'}"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column sortable type="index" :index="indexMethod" label="序号" width="100px"
|
||||
align="center"></el-table-column>
|
||||
<el-table-column sortable prop="name" label="角色名称" align="center"></el-table-column>
|
||||
<el-table-column sortable prop="sort" label="排序编号" align="center"></el-table-column>
|
||||
<el-table-column prop="code" sortable label="角色标识" align="center"
|
||||
:show-overflow-tooltip="true"></el-table-column>
|
||||
<!-- <el-table-column prop="menuName" label="所属模块" align="center" :show-overflow-tooltip="true" sortable>-->
|
||||
<!-- <template slot-scope="scope">
|
||||
<span v-if="scope.row.unit==null" style="font-weight: bold">
|
||||
系统角色
|
||||
</span>
|
||||
<span v-if="scope.row.unit!=null">
|
||||
{{scope.row.unit.name}}
|
||||
</span>
|
||||
</template>-->
|
||||
</el-table-column>
|
||||
<el-table-column sortable prop="disabled" label="启用状态" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.disabled" class="fa fa-circle text-danger ml5"></i>
|
||||
<i v-if="!scope.row.disabled" class="fa fa-circle text-success ml5"></i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useronline" label="操作" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-dropdown @command="dropdownCommand">
|
||||
<el-button size="mini">
|
||||
<i class="ti-settings"></i>
|
||||
<span class="ti-angle-down"></span>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item :command="{type:'role',id:scope.row.id,name:scope.row.name}">
|
||||
查看系统权限
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{type:'menu',id:scope.row.id,name:scope.row.name}">
|
||||
分配PC系统权限
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{type:'h5_menu',id:scope.row.id,name:scope.row.name}">
|
||||
分配H5系统权限
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{type:'user',id:scope.row.id,name:scope.row.name}">关联用户
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided
|
||||
:command="{type:'enable',id:scope.row.id,name:scope.row.name,row:scope.row}">
|
||||
启用
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
:command="{type:'disable',id:scope.row.id,name:scope.row.name,row:scope.row}">禁用
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item divided :command="{type:'edit',id:scope.row.id}">修改</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
:command="{type:'delete',id:scope.row.id,name:scope.row.name}"
|
||||
v-if="scope.row.code!='superadmin'&&scope.row.code!='public'"
|
||||
>
|
||||
删除
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--#include("/layouts/pagination.html"){}#-->
|
||||
</el-card>
|
||||
|
||||
<el-dialog append-to-body title="新建角色" :visible.sync="addDialogVisible" :close-on-click-modal="false"
|
||||
width="70%">
|
||||
<el-form :model="formData" ref="addForm" :rules="formRules" size="small" label-width="80px">
|
||||
<!-- <el-form-item class="is-required" prop="system_name" label="所属系统" label-width="80px">-->
|
||||
<!-- <el-select v-model="formData.system_name" style="width: 100%" filterable clearable placeholder="请选择">-->
|
||||
<!-- <el-option v-for="item in menuOptions" :key="item.name" :label="item.name" :value="item.name"></el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item prop="name" label="角色名称">
|
||||
<el-input maxlength="50" placeholder="角色名称" v-model="formData.name" auto-complete="off" tabindex="2"
|
||||
type="text"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" label="角色标识">
|
||||
<el-input maxlength="150" placeholder="角色标识" v-model="formData.code" auto-complete="off"
|
||||
tabindex="3" type="text"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="sort" label="排序编号">
|
||||
<el-input-number placeholder="排序编号" v-model="formData.sort"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="disabled" label="启用状态">
|
||||
<el-switch v-model="formData.disabled" active-color="#ff4949" inactive-color="#13ce66"></el-switch>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item prop="" label="分配权限">-->
|
||||
<!-- <el-row style="margin-bottom: 3px">-->
|
||||
<!-- <el-button size="small" @click="addRoleSelAll">全选</el-button>-->
|
||||
<!-- <el-button size="small" @click="addRoleSelClear">清空</el-button>-->
|
||||
<!-- </el-row>-->
|
||||
<!-- <el-tree ref="addMenuTree" :data="addMenuData" show-checkbox check-strictly node-key="id" :props="defaultProps">-->
|
||||
<!-- <span class="custom-tree-node" slot-scope="scope">-->
|
||||
<!-- <span>{{ scope.node.label }}</span>-->
|
||||
<!-- <span>-->
|
||||
<!-- <span v-if="scope.data.type=='menu'" style="font-weight: bold">菜单权限</span>-->
|
||||
<!-- <span v-if="scope.data.type=='data'">数据权限</span>-->
|
||||
<!-- </span>-->
|
||||
<!-- </span>-->
|
||||
<!-- </el-tree>-->
|
||||
<!-- </el-form-item>-->
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="addDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doAdd">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog append-to-body title="修改角色" :visible.sync="editDialogVisible" :close-on-click-modal="false"
|
||||
width="40%">
|
||||
<el-form :model="formData" ref="editForm" :rules="formRules" size="small" label-width="80px">
|
||||
<el-form-item prop="name" label="角色名称">
|
||||
<el-input maxlength="50" placeholder="角色名称" v-model="formData.name" auto-complete="off" tabindex="2"
|
||||
type="text"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" label="角色标识">
|
||||
<el-input maxlength="150" placeholder="角色标识" v-model="formData.code" auto-complete="off"
|
||||
tabindex="3" type="text"></el-input>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item prop="code" label="所属系统">-->
|
||||
<!-- <el-select v-model="formData.system_name" style="width: 100%" filterable clearable placeholder="请选择">-->
|
||||
<!-- <el-option v-for="item in menuOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<el-form-item prop="sort" label="排序编号">
|
||||
<el-input-number placeholder="排序编号" v-model="formData.sort"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item prop="disabled" label="启用状态">
|
||||
<el-switch v-model="formData.disabled" active-color="#ff4949" inactive-color="#13ce66"></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="editDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doEdit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog :title="roleDialogTitle" :visible.sync="roleDialogVisible" width="70%">
|
||||
<el-table :data="roleTableData" style="width: 100%" size="small" :highlight-current-row="true" row-key="id" lazy
|
||||
:load="loadRoleChild">
|
||||
<el-table-column
|
||||
label="菜单名称"
|
||||
header-align="center"
|
||||
prop="name"
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
align="left"
|
||||
></el-table-column>
|
||||
|
||||
<el-table-column label="URL" header-align="center" prop="href"
|
||||
:show-overflow-tooltip="true"></el-table-column>
|
||||
|
||||
<el-table-column label="资源类型" header-align="center" prop="type" :show-overflow-tooltip="true"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.type=='menu'" style="font-weight: bold">菜单</i>
|
||||
<i v-if="scope.row.type=='data'">数据</i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="权限标识" header-align="center" prop="permission"
|
||||
:show-overflow-tooltip="true"></el-table-column>
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="roleDialogVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog append-to-body :title="menuDialogTitle" :visible.sync="menuDialogVisible" :close-on-click-modal="false"
|
||||
width="70%">
|
||||
<!-- 搜索框 -->
|
||||
<!-- <el-row style="margin-bottom: 10px">-->
|
||||
<!-- <el-input-->
|
||||
<!-- v-model="searchText"-->
|
||||
<!-- placeholder="搜索11"-->
|
||||
<!-- size="small"-->
|
||||
<!-- clearable-->
|
||||
<!-- style="width: 300px"-->
|
||||
<!-- >-->
|
||||
<!-- <i slot="prefix" class="el-input__icon el-icon-search"></i>-->
|
||||
<!-- </el-input>-->
|
||||
<!-- </el-row>-->
|
||||
<el-row style="margin-bottom: 3px">
|
||||
<el-button size="small" @click="menuRoleSelAll">全选</el-button>
|
||||
<el-button size="small" @click="menuRoleSelClear">清空</el-button>
|
||||
</el-row>
|
||||
|
||||
<!-- :data="doMenuData"-->
|
||||
|
||||
<el-tree
|
||||
ref="doMenuTree"
|
||||
:data="filteredMenuData"
|
||||
:default-checked-keys="doMenuCheckedData"
|
||||
check-strictly
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
check-strictly
|
||||
:props="defaultProps"
|
||||
:filter-node-method="filterNode"
|
||||
>
|
||||
<span class="custom-tree-node" slot-scope="{ node, data }">
|
||||
<span v-html="getDisplayText(node, data)"></span>
|
||||
<span>
|
||||
<span v-if="data.type=='menu'" style="font-weight: bold; color: #409EFF;">菜单权限</span>
|
||||
<span v-if="data.type=='data'" style="color: #67C23A;">数据权限</span>
|
||||
</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="menuDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doMenu">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog append-to-body :title="userDialogTitle" :visible.sync="userDialogVisible" :close-on-click-modal="false"
|
||||
width="70%">
|
||||
<div class="block mb10">
|
||||
<el-select
|
||||
size="small"
|
||||
style="width: 60%"
|
||||
class="span_n"
|
||||
v-model="selUsers"
|
||||
multiple
|
||||
filterable
|
||||
remote
|
||||
default-first-option
|
||||
reserve-keyword
|
||||
:remote-method="remoteMethod"
|
||||
:loading="loading"
|
||||
placeholder="请输入用户名或姓名"
|
||||
>
|
||||
<el-option v-for="item in dbUsers" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
<el-button size="small" @click="userAddRole">将用户加入角色</el-button>
|
||||
<div class="pull-right offscreen-right">
|
||||
<el-button size="small" type="danger" @click="userDelRole">从角色中移除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table
|
||||
:data="userTableData"
|
||||
@sort-change="userPageOrder"
|
||||
size="small"
|
||||
header-align="center"
|
||||
style="width: 100%"
|
||||
@selection-change="userSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="35"></el-table-column>
|
||||
<el-table-column sortable prop="loginname" label="用户名" header-align="center"></el-table-column>
|
||||
<el-table-column prop="username" label="姓名" header-align="center"
|
||||
:show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column prop="unitname" label="所属单位" header-align="center" align="center"
|
||||
:show-overflow-tooltip="true"></el-table-column>
|
||||
<el-table-column sortable prop="disabled" label="帐号状态" header-align="center" align="center"
|
||||
:show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.disabled" class="fa fa-circle text-danger ml5"></i>
|
||||
<i v-if="!scope.row.disabled" class="fa fa-circle text-success ml5"></i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column sortable prop="useronline" label="在线状态" header-align="center" align="center"
|
||||
:show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<i v-if="scope.row.useronline" class="text-success ml5">在线</i>
|
||||
<i v-if="!scope.row.useronline" class="text-danger ml5">离线</i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="userPageSizeChange"
|
||||
@current-change="userPageNumberChange"
|
||||
:current-page="userForm.pageNumber"
|
||||
:page-sizes="[10, 20, 30, 50]"
|
||||
:page-size="userForm.pageSize"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="userForm.totalCount"
|
||||
></el-pagination>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="userDialogVisible = false">关 闭</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<sort ref="sortRef" @refresh="doSearch"></sort>
|
||||
|
||||
</div>
|
||||
<script nonce="${cspNonce!}">
|
||||
<!--#include("sort.js"){}#-->
|
||||
|
||||
const vue = new Vue({
|
||||
el: "#app",
|
||||
dicts: ["SYS_MENU_PLATFORM"],
|
||||
mixins: [initTableMixins],
|
||||
components: {
|
||||
sort: sort_component
|
||||
},
|
||||
data() {
|
||||
const self = this
|
||||
const validateName = function (rule, value, callback) {
|
||||
const regex = new RegExp("^[a-zA-Z][a-zA-Z0-9_]{1,100}$")
|
||||
if (!regex.test(value)) {
|
||||
callback(new Error("角色标识以字母开头2-100字,允许使用字母/数字/下划线"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validateUnit = function (rule, value, callback) {
|
||||
if (
|
||||
self.parentUnit.length < 1 ||
|
||||
self.parentUnit[self.parentUnit.length - 1] === "" ||
|
||||
self.parentUnit[self.parentUnit.length - 1] === "root"
|
||||
) {
|
||||
callback(new Error("请选择所属单位!"))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
addDialogVisible: false,
|
||||
editDialogVisible: false,
|
||||
roleDialogVisible: false,
|
||||
menuDialogVisible: false,
|
||||
userDialogVisible: false,
|
||||
treeData: {
|
||||
label: "name",
|
||||
children: "zones",
|
||||
id: "id",
|
||||
isLeaf: "leaf"
|
||||
},
|
||||
tableData: [],
|
||||
menuOptions: [],
|
||||
options: [],
|
||||
parentUnit: [],
|
||||
parentUnitSearch: [],
|
||||
pageForm: {
|
||||
searchUnit: "",
|
||||
searchName: "`name`",
|
||||
searchKeyword: "",
|
||||
searchName2: "username",
|
||||
searchKeyword2: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
pageOrderName: "",
|
||||
pageOrderBy: ""
|
||||
},
|
||||
formData: {
|
||||
id: "",
|
||||
unitid: "",
|
||||
disabled: false,
|
||||
menuIds: ""
|
||||
},
|
||||
formRules: {
|
||||
// parentUnit: [{ validator: validateUnit, trigger: ["blur", "change"] }],
|
||||
name: [{required: true, message: "角色名称", trigger: ["blur", "change"]}],
|
||||
code: [
|
||||
{required: true, message: "角色标识", trigger: ["blur", "change"]},
|
||||
{validator: validateName, trigger: ["blur", "change"]}
|
||||
]
|
||||
},
|
||||
editRules: {
|
||||
// parentUnit: [{ validator: validateUnit, trigger: ["blur", "change"] }],
|
||||
name: [{required: true, message: "角色名称", trigger: ["blur", "change"]}],
|
||||
code: [
|
||||
{required: true, message: "角色标识", trigger: ["blur", "change"]},
|
||||
{validator: validateName, trigger: ["blur", "change"]}
|
||||
]
|
||||
},
|
||||
roleDialogTitle: "查看角色权限",
|
||||
menuDialogTitle: "分配角色菜单",
|
||||
userDialogTitle: "分配用户",
|
||||
roleTableData: [], //treeTable后台取出的数据
|
||||
roleId: "", //当前角色ID
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label"
|
||||
},
|
||||
addMenuData: [],
|
||||
doMenuData: [],
|
||||
doMenuCheckedData: [], //已分配的权限选中状态
|
||||
doCmsData: [],
|
||||
doCmsCheckedData: [], //已分配的CMS权限
|
||||
doCmsForm: {},
|
||||
userForm: {
|
||||
roleId: "",
|
||||
pageNumber: 1,
|
||||
pageSize: 10,
|
||||
totalCount: 0,
|
||||
pageOrderName: "",
|
||||
pageOrderBy: ""
|
||||
},
|
||||
userTableData: [],
|
||||
loading: false,
|
||||
dbUsers: [], //分配用户
|
||||
selUsers: [], //分配选中的用户
|
||||
userSelection: [],
|
||||
props: {
|
||||
lazy: true,
|
||||
checkStrictly: true,
|
||||
multiple: false,
|
||||
lazyLoad: (node, resolve) => {
|
||||
this.$axios.post("/platform/sys/unit/tree", {pid: node.value}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
resolve(res.data)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
platform: "",
|
||||
|
||||
// 分配权限搜索
|
||||
searchText: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 根据第一级菜单名称过滤数据
|
||||
filteredMenuData() {
|
||||
if (!this.searchText.trim()) {
|
||||
return this.doMenuData;
|
||||
}
|
||||
|
||||
const searchText = this.searchText.toLowerCase();
|
||||
return this.doMenuData.filter(item => {
|
||||
return item.label.toLowerCase().includes(searchText);
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 搜索处理
|
||||
handleSearch(value) {
|
||||
this.$refs.doMenuTree.filter(value);
|
||||
},
|
||||
|
||||
// 过滤节点方法
|
||||
filterNode(value, data) {
|
||||
if (!value) return true;
|
||||
return data.label.toLowerCase().indexOf(value.toLowerCase()) !== -1;
|
||||
},
|
||||
|
||||
// 获取显示文本(只对第一级菜单高亮)
|
||||
getDisplayText(node, data) {
|
||||
const text = node.label;
|
||||
// 判断是否为第一级菜单(没有父节点或父节点是根节点)
|
||||
if (node.level === 1 && this.searchText) {
|
||||
return this.highlightText(text);
|
||||
}
|
||||
return text;
|
||||
},
|
||||
|
||||
// 高亮搜索文本
|
||||
highlightText(text) {
|
||||
if (!this.searchText || !text) {
|
||||
return text;
|
||||
}
|
||||
const searchRegex = new RegExp('(' + this.searchText + ')', 'gi');
|
||||
return text.replace(searchRegex, '<span class="highlight">$1</span>');
|
||||
},
|
||||
|
||||
exportRoles() {
|
||||
this.$downLoad.post(loc() + "/exportRoles?" + this.pageForm)
|
||||
},
|
||||
doPublic() {
|
||||
this.$confirm("确定要把所有用户加入公共角色吗?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(async () => {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: "正在提交...",
|
||||
spinner: "el-icon-loading"
|
||||
})
|
||||
const resp = await this.$axios.post(loc() + "/doPublic")
|
||||
loading.close()
|
||||
})
|
||||
},
|
||||
doSettingMemberRole() {
|
||||
this.$confirm("是否确定一键设置会员角色?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(async () => {
|
||||
const {code, msg} = await this.$axios.post("/platform/sys/role/doSettingMemberRole")
|
||||
if (code === 0) {
|
||||
this.$message.success(msg)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
},
|
||||
formatAt(val) {
|
||||
if (val > 0) return moment(val).format("YYYY-MM-DD HH:mm")
|
||||
return ""
|
||||
},
|
||||
doSearch() {
|
||||
let unit = this.parentUnitSearch[this.parentUnitSearch.length - 1]
|
||||
if ("root" === unit) {
|
||||
unit = ""
|
||||
}
|
||||
this.pageForm.searchUnit = unit
|
||||
this.pageForm.pageNumber = 1
|
||||
this.pageData()
|
||||
},
|
||||
addMenuLoad() {
|
||||
this.$axios.post("/platform/sys/role/menuAll/", {}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.addMenuData = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
doMenuLoad() {
|
||||
this.$axios.post("/platform/sys/role/menuRole/" + this.roleId + "/" + this.platform, {}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.doMenuData = res.data.menu
|
||||
this.doMenuCheckedData = res.data.cmenu
|
||||
}
|
||||
})
|
||||
},
|
||||
userSelectionChange(val) {
|
||||
this.userSelection = val
|
||||
},
|
||||
userPageOrder(column) {
|
||||
//按字段排序
|
||||
this.userForm.pageOrderName = column.prop
|
||||
this.userForm.pageOrderBy = column.order
|
||||
this.doUserLoad()
|
||||
},
|
||||
userPageNumberChange: function (val) {
|
||||
//页码更新操作
|
||||
this.userForm.pageNumber = val
|
||||
this.doUserLoad()
|
||||
},
|
||||
userPageSizeChange: function (val) {
|
||||
//分页大小更新操作
|
||||
this.userForm.pageSize = val
|
||||
this.doUserLoad()
|
||||
},
|
||||
remoteMethod(query) {
|
||||
if (query !== "") {
|
||||
this.loading = true
|
||||
this.$axios
|
||||
.post("/platform/sys/role/userSearch", {
|
||||
query: query,
|
||||
roleId: this.roleId
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.dbUsers = res.data.list
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
this.selUsers = []
|
||||
}
|
||||
},
|
||||
doUserLoad() {
|
||||
this.$axios.post("/platform/sys/role/user", this.userForm).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.userTableData = res.data.list
|
||||
this.userForm.totalCount = res.data.totalCount
|
||||
}
|
||||
})
|
||||
},
|
||||
openAdd() {
|
||||
this.addDialogVisible = true
|
||||
this.formData = {} //打开新增窗口,表单先清空
|
||||
if (this.$refs["addForm"]) this.$refs["addForm"].resetFields()
|
||||
this.addMenuLoad()
|
||||
},
|
||||
doAdd() {
|
||||
this.$refs["addForm"].validate((valid) => {
|
||||
if (valid) {
|
||||
// this.formData.menuIds = this.$refs["addMenuTree"].getCheckedKeys().toString()
|
||||
// this.formData.unitid = this.parentUnit[this.parentUnit.length - 1] || ""
|
||||
this.$axios.post("/platform/sys/role/addDo", this.formData).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.parentUnitSearch = []
|
||||
this.doSearch()
|
||||
this.addDialogVisible = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
doEdit() {
|
||||
this.$refs["editForm"].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$axios.post("/platform/sys/role/editDo", this.formData).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.doSearch()
|
||||
this.editDialogVisible = false
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
doMenu() {
|
||||
// if (this.searchText) {
|
||||
// this.$message.warning('请清空搜索条件后再提交')
|
||||
// return;
|
||||
// }
|
||||
|
||||
const ids = this.$refs["doMenuTree"].getCheckedKeys()
|
||||
if (!ids || ids.length === 0) {
|
||||
this.$message.warning("请选择菜单或数据权限")
|
||||
return
|
||||
}
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: "正在提交...",
|
||||
spinner: "el-icon-loading"
|
||||
})
|
||||
|
||||
this.$axios
|
||||
.post("/platform/sys/role/menuDo", {
|
||||
roleId: this.roleId,
|
||||
platform: this.platform,
|
||||
menuIds: ids.toString()
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.menuDialogVisible = false
|
||||
}
|
||||
loading.close()
|
||||
})
|
||||
},
|
||||
initRoleTreeTable() {
|
||||
this.$axios.post("/platform/sys/role/menu/" + this.roleId, {pid: ""}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.roleTableData = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
loadRoleChild(tree, treeNode, resolve) {
|
||||
this.$axios.post("/platform/sys/role/menu/" + this.roleId, {pid: tree.id}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
resolve(res.data)
|
||||
}
|
||||
})
|
||||
},
|
||||
dropdownCommand(command) {
|
||||
//监听下拉框事件
|
||||
if ("role" === command.type) {
|
||||
this.roleDialogVisible = true
|
||||
this.roleDialogTitle = "查看角色 【" + command.name + "】 的权限"
|
||||
this.roleId = command.id
|
||||
this.initRoleTreeTable()
|
||||
}
|
||||
if ("menu" === command.type) {
|
||||
this.menuDialogTitle = "分配角色 【" + command.name + "】 的PC端权限"
|
||||
this.menuDialogVisible = true
|
||||
this.platform = "PC"
|
||||
this.roleId = command.id
|
||||
this.doMenuLoad()
|
||||
}
|
||||
if ("h5_menu" === command.type) {
|
||||
this.menuDialogTitle = "分配角色 【" + command.name + "】 的H5端权限"
|
||||
this.menuDialogVisible = true
|
||||
this.platform = "H5"
|
||||
this.roleId = command.id
|
||||
this.doMenuLoad()
|
||||
}
|
||||
|
||||
if ("user" === command.type) {
|
||||
this.userDialogTitle = "分配角色 【" + command.name + "】 的用户"
|
||||
this.userDialogVisible = true
|
||||
this.roleId = command.id
|
||||
this.userForm.roleId = command.id
|
||||
this.doUserLoad()
|
||||
}
|
||||
if ("enable" === command.type || "disable" === command.type) {
|
||||
this.$axios.post("/platform/sys/role/" + command.type + "/" + command.id, {}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
if ("disabled" === command.type) {
|
||||
command.row.disabled = true
|
||||
}
|
||||
if ("enable" === command.type) {
|
||||
command.row.disabled = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
if ("edit" === command.type) {
|
||||
this.$axios.post("/platform/sys/role/edit/" + command.id, {}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.formData = res.data
|
||||
this.editDialogVisible = true
|
||||
}
|
||||
})
|
||||
}
|
||||
if ("delete" === command.type) {
|
||||
this.$confirm("此操作将删除 " + command.name, "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
this.$axios.post("/platform/sys/role/delete/" + command.id, {}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.doSearch()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
userAddRole() {
|
||||
if (this.selUsers.length === 0) {
|
||||
this.$message.warning("请选择用户")
|
||||
return
|
||||
}
|
||||
this.$axios
|
||||
.post("/platform/sys/role/usersAdd", {
|
||||
roleId: this.roleId,
|
||||
users: this.selUsers.toString()
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.selUsers = [] //清除已选择的用户
|
||||
this.dbUsers = [] //清除数据库查询的用户,已添加到角色的用户不应该还存在so..
|
||||
this.doUserLoad()
|
||||
}
|
||||
})
|
||||
},
|
||||
userDelRole() {
|
||||
if (this.userSelection.length === 0) {
|
||||
this.$message.warning("请选择用户")
|
||||
return
|
||||
}
|
||||
|
||||
const users = this.userSelection.map((user) => user.id)
|
||||
|
||||
this.$axios
|
||||
.post("/platform/sys/role/usersDel", {
|
||||
roleId: this.roleId,
|
||||
users: users.toString()
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.selUsers = [] //清除已选择的用户
|
||||
this.dbUsers = [] //清除数据库查询的用户,已添加到角色的用户不应该还存在so..
|
||||
this.doUserLoad()
|
||||
}
|
||||
})
|
||||
},
|
||||
getTreeAllIds(ids, obj) {
|
||||
const self = this
|
||||
if (obj && obj.length > 0) {
|
||||
obj.forEach(function (o) {
|
||||
ids.push(o.id)
|
||||
if (o.children) {
|
||||
self.getTreeAllIds(ids, o.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
addRoleSelAll() {
|
||||
const ids = []
|
||||
this.getTreeAllIds(ids, this.addMenuData)
|
||||
this.$refs["addMenuTree"].setCheckedKeys(ids)
|
||||
},
|
||||
addRoleSelClear() {
|
||||
this.$refs["addMenuTree"].setCheckedKeys([])
|
||||
},
|
||||
menuRoleSelAll() {
|
||||
const ids = []
|
||||
this.getTreeAllIds(ids, this.doMenuData)
|
||||
this.$refs["doMenuTree"].setCheckedKeys(ids)
|
||||
},
|
||||
menuRoleSelClear() {
|
||||
this.$refs["doMenuTree"].setCheckedKeys([])
|
||||
},
|
||||
clearButtons(list) {
|
||||
for (let o of list) {
|
||||
this.$set(o, "buttons", [])
|
||||
if (o.hasChildren) {
|
||||
this.clearButtons(o.children)
|
||||
}
|
||||
}
|
||||
},
|
||||
selParentChannel(list, pid, keys) {
|
||||
const self = this
|
||||
list.forEach(function (o) {
|
||||
if (pid === o.id) {
|
||||
keys.push(pid)
|
||||
}
|
||||
if (o.children) {
|
||||
self.selParentChannel(o.children, pid, keys)
|
||||
}
|
||||
})
|
||||
}
|
||||
// async getMenuOptions() {
|
||||
// const { data } = await $.get(loc() + "/getMenuOptions")
|
||||
// this.menuOptions = data
|
||||
// }
|
||||
},
|
||||
async created() {
|
||||
this.pageData()
|
||||
// await this.getMenuOptions()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style>
|
||||
.custom-tree-node {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
</style>
|
||||
<!--#
|
||||
}
|
||||
#-->
|
||||
@@ -0,0 +1,65 @@
|
||||
const sort_component = {
|
||||
template: `
|
||||
<el-dialog title="排序" :visible.sync="sortDialogVisible" width="50%">
|
||||
<el-tree ref="sortTreeRef" :data="sortData" draggable :allow-drop="sortAllowDrop" node-key="id"
|
||||
style="height: 60vh;overflow-y: auto"
|
||||
:props="defaultProps">
|
||||
<span class="custom-tree-node" slot-scope="scope">
|
||||
<span>{{ scope.node.label }}</span>
|
||||
</span>
|
||||
</el-tree>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="sortDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="doSort">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
`,
|
||||
data() {
|
||||
return {
|
||||
sortDialogVisible: false,
|
||||
sortData: [],
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "name"
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onOpen() {
|
||||
this.sortDialogVisible = true
|
||||
this.$axios.post("/platform/sys/role/sortData").then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.sortData = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
sortAllowDrop(moveNode, inNode, type) {
|
||||
return type !== "inner"
|
||||
},
|
||||
doSort() {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: "正在提交...",
|
||||
spinner: "el-icon-loading"
|
||||
})
|
||||
const afterSorts = this.sortData.map((v) => {
|
||||
return {
|
||||
id: v.id,
|
||||
name: v.name
|
||||
}
|
||||
})
|
||||
this.$axios
|
||||
.post("/platform/sys/role/doSort", { roles: JSON.stringify(afterSorts) })
|
||||
.then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.sortDialogVisible = false
|
||||
this.$emit("refresh", null)
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user