Merge branch 'master' of https://gitee.com/y_project/RuoYi-Cloud
commit
ce2c714278
@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* v-dialogDrag 弹窗拖拽
|
||||||
|
* Copyright (c) 2019 ruoyi
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default {
|
||||||
|
bind(el, binding, vnode, oldVnode) {
|
||||||
|
const value = binding.value
|
||||||
|
if (value == false) return
|
||||||
|
// 获取拖拽内容头部
|
||||||
|
const dialogHeaderEl = el.querySelector('.el-dialog__header');
|
||||||
|
const dragDom = el.querySelector('.el-dialog');
|
||||||
|
dialogHeaderEl.style.cursor = 'move';
|
||||||
|
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
|
||||||
|
const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null);
|
||||||
|
dragDom.style.position = 'absolute';
|
||||||
|
dragDom.style.marginTop = 0;
|
||||||
|
let width = dragDom.style.width;
|
||||||
|
if (width.includes('%')) {
|
||||||
|
width = +document.body.clientWidth * (+width.replace(/\%/g, '') / 100);
|
||||||
|
} else {
|
||||||
|
width = +width.replace(/\px/g, '');
|
||||||
|
}
|
||||||
|
dragDom.style.left = `${(document.body.clientWidth - width) / 2}px`;
|
||||||
|
// 鼠标按下事件
|
||||||
|
dialogHeaderEl.onmousedown = (e) => {
|
||||||
|
// 鼠标按下,计算当前元素距离可视区的距离 (鼠标点击位置距离可视窗口的距离)
|
||||||
|
const disX = e.clientX - dialogHeaderEl.offsetLeft;
|
||||||
|
const disY = e.clientY - dialogHeaderEl.offsetTop;
|
||||||
|
|
||||||
|
// 获取到的值带px 正则匹配替换
|
||||||
|
let styL, styT;
|
||||||
|
|
||||||
|
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
|
||||||
|
if (sty.left.includes('%')) {
|
||||||
|
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100);
|
||||||
|
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100);
|
||||||
|
} else {
|
||||||
|
styL = +sty.left.replace(/\px/g, '');
|
||||||
|
styT = +sty.top.replace(/\px/g, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// 鼠标拖拽事件
|
||||||
|
document.onmousemove = function (e) {
|
||||||
|
// 通过事件委托,计算移动的距离 (开始拖拽至结束拖拽的距离)
|
||||||
|
const l = e.clientX - disX;
|
||||||
|
const t = e.clientY - disY;
|
||||||
|
|
||||||
|
let finallyL = l + styL
|
||||||
|
let finallyT = t + styT
|
||||||
|
|
||||||
|
// 移动当前元素
|
||||||
|
dragDom.style.left = `${finallyL}px`;
|
||||||
|
dragDom.style.top = `${finallyT}px`;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
document.onmouseup = function (e) {
|
||||||
|
document.onmousemove = null;
|
||||||
|
document.onmouseup = null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,18 @@
|
|||||||
|
import hasRole from './permission/hasRole'
|
||||||
|
import hasPermi from './permission/hasPermi'
|
||||||
|
import dialogDrag from './dialog/drag'
|
||||||
|
|
||||||
|
const install = function(Vue) {
|
||||||
|
Vue.directive('hasRole', hasRole)
|
||||||
|
Vue.directive('hasPermi', hasPermi)
|
||||||
|
Vue.directive('dialogDrag', dialogDrag)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.Vue) {
|
||||||
|
window['hasRole'] = hasRole
|
||||||
|
window['hasPermi'] = hasPermi
|
||||||
|
window['dialogDrag'] = dialogDrag
|
||||||
|
Vue.use(install); // eslint-disable-line
|
||||||
|
}
|
||||||
|
|
||||||
|
export default install
|
@ -0,0 +1,27 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const { $route: { meta: { link } }, } = this;
|
||||||
|
if ({ link }.link === "") {
|
||||||
|
return "404";
|
||||||
|
}
|
||||||
|
let url = { link }.link;
|
||||||
|
const height = document.documentElement.clientHeight - 94.5 + "px";
|
||||||
|
const style = { height: height };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={style}>
|
||||||
|
<iframe
|
||||||
|
src={url}
|
||||||
|
frameborder="no"
|
||||||
|
style="width: 100%; height: 100%"
|
||||||
|
scrolling="auto"
|
||||||
|
></iframe>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,213 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.phonenumber"
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="openSelectUser"
|
||||||
|
v-hasPermi="['system:role:add']"
|
||||||
|
>添加用户</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-circle-close"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="cancelAuthUserAll"
|
||||||
|
v-hasPermi="['system:role:remove']"
|
||||||
|
>批量取消授权</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-close"
|
||||||
|
size="mini"
|
||||||
|
@click="handleClose"
|
||||||
|
>关闭</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="statusOptions" :value="scope.row.status"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-circle-close"
|
||||||
|
@click="cancelAuthUser(scope.row)"
|
||||||
|
v-hasPermi="['system:role:remove']"
|
||||||
|
>取消授权</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
<select-user ref="select" :roleId="queryParams.roleId" @ok="handleQuery" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { allocatedUserList, authUserCancel, authUserCancelAll } from "@/api/system/role";
|
||||||
|
import selectUser from "./selectUser";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "AuthUser",
|
||||||
|
components: { selectUser },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中用户组
|
||||||
|
userIds: [],
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 用户表格数据
|
||||||
|
userList: [],
|
||||||
|
// 状态数据字典
|
||||||
|
statusOptions: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
roleId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
phonenumber: undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
const roleId = this.$route.params && this.$route.params.roleId;
|
||||||
|
if (roleId) {
|
||||||
|
this.queryParams.roleId = roleId;
|
||||||
|
this.getList();
|
||||||
|
this.getDicts("sys_normal_disable").then(response => {
|
||||||
|
this.statusOptions = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询授权用户列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
allocatedUserList(this.queryParams).then(response => {
|
||||||
|
this.userList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
// 返回按钮
|
||||||
|
handleClose() {
|
||||||
|
this.$store.dispatch("tagsView/delView", this.$route);
|
||||||
|
this.$router.push({ path: "/system/role" });
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.userIds = selection.map(item => item.userId)
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 打开授权用户表弹窗 */
|
||||||
|
openSelectUser() {
|
||||||
|
this.$refs.select.show();
|
||||||
|
},
|
||||||
|
/** 取消授权按钮操作 */
|
||||||
|
cancelAuthUser(row) {
|
||||||
|
const roleId = this.queryParams.roleId;
|
||||||
|
this.$confirm('确认要取消该用户"' + row.userName + '"角色吗?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return authUserCancel({ userId: row.userId, roleId: roleId });
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("取消授权成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 批量取消授权按钮操作 */
|
||||||
|
cancelAuthUserAll(row) {
|
||||||
|
const roleId = this.queryParams.roleId;
|
||||||
|
const userIds = this.userIds.join(",");
|
||||||
|
this.$confirm('是否取消选中用户授权数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(() => {
|
||||||
|
return authUserCancelAll({ roleId: roleId, userIds: userIds });
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("取消授权成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -0,0 +1,142 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 授权用户 -->
|
||||||
|
<el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body>
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true">
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.phonenumber"
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<el-row>
|
||||||
|
<el-table @row-click="clickRow" ref="table" :data="userList" @selection-change="handleSelectionChange" height="260px">
|
||||||
|
<el-table-column type="selection" width="55"></el-table-column>
|
||||||
|
<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<dict-tag :options="statusOptions" :value="scope.row.status"/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</el-row>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleSelectUser">确 定</el-button>
|
||||||
|
<el-button @click="visible = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { unallocatedUserList, authUserSelectAll } from "@/api/system/role";
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
// 角色编号
|
||||||
|
roleId: {
|
||||||
|
type: Number
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
visible: false,
|
||||||
|
// 选中数组值
|
||||||
|
userIds: [],
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 未授权用户数据
|
||||||
|
userList: [],
|
||||||
|
// 状态数据字典
|
||||||
|
statusOptions: [],
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
roleId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
phonenumber: undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getDicts("sys_normal_disable").then(response => {
|
||||||
|
this.statusOptions = response.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 显示弹框
|
||||||
|
show() {
|
||||||
|
this.queryParams.roleId = this.roleId;
|
||||||
|
this.getList();
|
||||||
|
this.visible = true;
|
||||||
|
},
|
||||||
|
clickRow(row) {
|
||||||
|
this.$refs.table.toggleRowSelection(row);
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.userIds = selection.map(item => item.userId);
|
||||||
|
},
|
||||||
|
// 查询表数据
|
||||||
|
getList() {
|
||||||
|
unallocatedUserList(this.queryParams).then(res => {
|
||||||
|
this.userList = res.rows;
|
||||||
|
this.total = res.total;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
/** 选择授权用户操作 */
|
||||||
|
handleSelectUser() {
|
||||||
|
const roleId = this.queryParams.roleId;
|
||||||
|
const userIds = this.userIds.join(",");
|
||||||
|
authUserSelectAll({ roleId: roleId, userIds: userIds }).then(res => {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.visible = false;
|
||||||
|
this.$emit("ok");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in new issue