调整前端代码格式符合ESLint规范

This commit is contained in:
zer0Black
2023-02-28 22:43:03 +08:00
parent f5e5990a3b
commit 77b1ca8f0d
48 changed files with 3199 additions and 3179 deletions
+7 -7
View File
@@ -5,13 +5,13 @@
</template>
<script>
export default {
name: 'Page401',
data() {
return {}
},
methods: {}
}
export default {
name: 'Page401',
data () {
return {}
},
methods: {}
}
</script>
<style lang="scss" scoped>
+150 -152
View File
@@ -87,158 +87,158 @@
</template>
<script>
import {fileType} from "@/utils/fileType";
import { fileType } from '@/utils/fileType'
export default {
name: "MenuManager",
data() {
return {
form: {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0,
},
tableData: [],
dialogMenu: false,
mode: '',
pathList: [],
level: 0,
}
},
methods: {
init() {
this.sysMenuFindAllMenus();
this.getRouterPath();
},
// 菜单
sysMenuFindAllMenus() {
this.$api.menu.sysMenuFindAllMenus().then(({data}) => {
this.tableData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort;
});
})
},
// 新增弹窗
addMenu(row, level) {
this.mode = 'add';
this.level = level + 1;
this.form = {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0,
};
this.form.parentId = row ? row.id : '6f6fafb4a7';
this.dialogMenu = true;
},
// 新增 修改
postOrPutSysMenu() {
if (!this.form.name) {
return this.$message.warning('请输入菜单名称');
}
if (this.level === 0 || this.level === 2) {
// if (!this.form.icon) {
// return this.$message.warning('请上传菜单图标');
// }
}
if (this.mode === 'add') {
this.$api.menu.postSysMenu(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogMenu = false;
this.sysMenuFindAllMenus();
})
}
if (this.mode === 'modify') {
this.$api.menu.putSysMenu(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogMenu = false;
this.sysMenuFindAllMenus();
})
}
},
// 图标上传
uploadFile(params) {
let fd = new FormData();
fd.append('file', params.file);
this.$api.report.reportUploadPicFile(fd).then(({data}) => {
this.form.icon = data.key;
this.form.iconHref = data.value;
})
},
beforeUploadFile(file) {
const isType = (file.type === fileType.png || file.type === fileType.jpg);
const isSize = file.size / 1024 / 1024 < 2;
if (!isType) {
this.$message.error('仅能上传 pngjpg 格式文件');
}
if (!isSize) {
this.$message.error('您最大可上传2M文件');
}
return isType && isSize;
},
// 删除
deleteRow(row) {
this.$confirm('此操作将删除所选数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.menu.sysMenuDeleteId({ids: row.id}).then(_ => {
this.$message.success('操作成功');
this.sysMenuFindAllMenus();
})
})
},
// 编辑
modifyRow(row, level) {
this.level = level;
this.mode = 'modify';
this.form = JSON.parse(JSON.stringify(row));
this.dialogMenu = true;
},
// 获取存在路径
getRouterPath() {
let pathList = [];
let pathFun = (data, url) => {
data.forEach(item => {
if (item.children) {
pathFun(item.children, item.path);
} else {
pathList.push(`${url ? (url + '/') : ''}${item.path}`);
}
})
}
pathFun(this.$router.options.routes);
this.pathList = pathList;
},
},
computed: {
dialogTitle() {
switch (this.mode) {
case 'add':
return '新增';
case 'modify':
return '编辑';
case 'view':
return '查看';
}
}
},
created() {
this.init();
}
export default {
name: 'MenuManager',
data () {
return {
form: {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0
},
tableData: [],
dialogMenu: false,
mode: '',
pathList: [],
level: 0
}
},
methods: {
init () {
this.sysMenuFindAllMenus()
this.getRouterPath()
},
// 菜单
sysMenuFindAllMenus () {
this.$api.menu.sysMenuFindAllMenus().then(({ data }) => {
this.tableData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort
})
})
},
// 新增弹窗
addMenu (row, level) {
this.mode = 'add'
this.level = level + 1
this.form = {
name: '', // 名称
href: '', // 路径
icon: '', // 图标
iconHref: '', // 图标路径
sort: '', // 排序
remarks: '', // 描述
id: '',
parentId: '',
isUrl: 0
}
this.form.parentId = row ? row.id : '6f6fafb4a7'
this.dialogMenu = true
},
// 新增 修改
postOrPutSysMenu () {
if (!this.form.name) {
return this.$message.warning('请输入菜单名称')
}
if (this.level === 0 || this.level === 2) {
// if (!this.form.icon) {
// return this.$message.warning('请上传菜单图标');
// }
}
if (this.mode === 'add') {
this.$api.menu.postSysMenu(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogMenu = false
this.sysMenuFindAllMenus()
})
}
if (this.mode === 'modify') {
this.$api.menu.putSysMenu(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogMenu = false
this.sysMenuFindAllMenus()
})
}
},
// 图标上传
uploadFile (params) {
const fd = new FormData()
fd.append('file', params.file)
this.$api.report.reportUploadPicFile(fd).then(({ data }) => {
this.form.icon = data.key
this.form.iconHref = data.value
})
},
beforeUploadFile (file) {
const isType = (file.type === fileType.png || file.type === fileType.jpg)
const isSize = file.size / 1024 / 1024 < 2
if (!isType) {
this.$message.error('仅能上传 pngjpg 格式文件')
}
if (!isSize) {
this.$message.error('您最大可上传2M文件')
}
return isType && isSize
},
// 删除
deleteRow (row) {
this.$confirm('此操作将删除所选数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.menu.sysMenuDeleteId({ ids: row.id }).then(_ => {
this.$message.success('操作成功')
this.sysMenuFindAllMenus()
})
})
},
// 编辑
modifyRow (row, level) {
this.level = level
this.mode = 'modify'
this.form = JSON.parse(JSON.stringify(row))
this.dialogMenu = true
},
// 获取存在路径
getRouterPath () {
const pathList = []
const pathFun = (data, url) => {
data.forEach(item => {
if (item.children) {
pathFun(item.children, item.path)
} else {
pathList.push(`${url ? (url + '/') : ''}${item.path}`)
}
})
}
pathFun(this.$router.options.routes)
this.pathList = pathList
}
},
computed: {
dialogTitle () {
switch (this.mode) {
case 'add':
return '新增'
case 'modify':
return '编辑'
case 'view':
return '查看'
}
}
},
created () {
this.init()
}
}
</script>
<style lang="scss" scoped>
@@ -324,7 +324,6 @@
// margin-left: -1.5px;
// }
.menu-image {
display: flex;
align-items: center;
@@ -434,7 +433,6 @@
}
}
.icon-menu-text {
display: flex;
width: 36px;
+184 -184
View File
@@ -80,192 +80,192 @@
</template>
<script>
import {v4 as uuidv4} from 'uuid';
import { v4 as uuidv4 } from 'uuid'
export default {
name: "Role",
data() {
return {
tableData: [], // 角色列表
dialogRole: false,
mode: '',
form: {
rname: '',
rdesc: '',
rid: ''
},
dialogPermission: false,
treeData: [],
checkboxConfig: {
checkRowKeys: [],
checkStrictly: true
},
roleId: '',
tableKey: uuidv4(),
// isHomePage: null, // 配置首页 1首页 2权限
}
},
methods: {
init() {
this.getSysRole();
this.sysMenuFindAllMenus();
},
/* =============================================== 角色列表 =============================================== */
// 角色列表
getSysRole() {
this.$api.role.getSysRole().then(({data}) => {
this.tableData = data;
})
},
// 删除角色
delSysRole(row) {
this.$confirm('此操作将删除所选角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.role.delSysRole({id: row.rid}).then(({data}) => {
this.$message.success('操作成功');
this.getSysRole();
})
})
},
/* =============================================== 角色弹窗 =============================================== */
// 新增角色
addRole() {
this.mode = 'add';
this.form = {
rname: '',
rdesc: '',
rid: ''
}
this.dialogRole = true;
},
// 编辑角色
modifyRow(row) {
this.mode = 'modify';
this.form = {
rname: row.rname,
rdesc: row.rdesc,
rid: row.rid
}
this.dialogRole = true;
},
// 新增 修改
postOrPutSysRole() {
if (!this.form.rname) {
return this.$message.warning('请输入角色名称');
}
if (this.mode === 'add') {
this.$api.role.postSysRole(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogRole = false;
this.getSysRole();
})
}
if (this.mode === 'modify') {
this.$api.role.putSysRole(this.form).then(_ => {
this.$message.success('操作成功');
this.dialogRole = false;
this.getSysRole();
})
}
},
/* =============================================== 角色权限 =============================================== */
// 获取菜单
openPermission(row) {
this.roleId = row.rid;
// this.isHomePage = type;
// if(type === 2){
this.$api.menu.getSysMenu({roleId: row.rid}).then(({data}) => {
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
this.tableKey = uuidv4();
this.dialogPermission = true;
})
// }else if(type === 1) {
// this.$api.role.sysRoleGetRoleHome({roleId: row.rid}).then(({data}) => {
// if(data === null){
// data = []
// }
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
// this.tableKey = uuidv4();
// this.dialogPermission = true;
// })
// }
},
// 获取权限
getSysMenu(roleId){
this.$api.menu.getSysMenu({roleId}).then(({data}) => {
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
this.tableKey = uuidv4();
})
},
// 获取首页
// getSysHome(roleId){
// this.$api.role.sysRoleGetRoleHome({roleId}).then(({data}) => {
// if(data === null){
// data = []
// }
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
// this.tableKey = uuidv4();
// })
// },
// 添加权限
sysRoleSaveRoleMenu() {
// 获取全部选中和半选中的数据
let checkedData = this.$refs.rolePermission.getCheckboxRecords();
let indeterminateData = this.$refs.rolePermission.getCheckboxIndeterminateRecords();
let allCheckData = [];
allCheckData = checkedData.concat(indeterminateData);
let ids = allCheckData.map(item => item.id);
let params = {
rid: this.roleId,
menusstr: ids
}
this.$api.role.sysRoleSaveRoleMenu(params).then(_ => {
this.$message.success('操作成功');
this.dialogPermission = false;
})
},
// // 首页配置
// sysRoleSaveRoleHome(){
// let ids = this.$refs.rolePermission.getCheckboxRecords().map(item => item.id);
// let params = {
// rid: this.roleId,
// menusstr: ids
// }
// this.$api.role.sysRoleSaveRoleHome(params).then(_ => {
// this.$message.success('操作成功');
// this.dialogPermission = false;
// })
// },
// 菜单
sysMenuFindAllMenus() {
this.$api.menu.sysMenuFindAllMenus().then(({data}) => {
this.treeData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort;
});
})
},
},
computed: {
dialogTitle() {
switch (this.mode) {
case 'add':
return '新增';
case 'modify':
return '编辑';
case 'view':
return '查看';
}
}
},
created() {
this.init();
name: 'Role',
data () {
return {
tableData: [], // 角色列表
dialogRole: false,
mode: '',
form: {
rname: '',
rdesc: '',
rid: ''
},
dialogPermission: false,
treeData: [],
checkboxConfig: {
checkRowKeys: [],
checkStrictly: true
},
roleId: '',
tableKey: uuidv4()
// isHomePage: null, // 配置首页 1首页 2权限
}
},
methods: {
init () {
this.getSysRole()
this.sysMenuFindAllMenus()
},
/* =============================================== 角色列表 =============================================== */
// 角色列表
getSysRole () {
this.$api.role.getSysRole().then(({ data }) => {
this.tableData = data
})
},
// 删除角色
delSysRole (row) {
this.$confirm('此操作将删除所选角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.role.delSysRole({ id: row.rid }).then(({ data }) => {
this.$message.success('操作成功')
this.getSysRole()
})
})
},
/* =============================================== 角色弹窗 =============================================== */
// 新增角色
addRole () {
this.mode = 'add'
this.form = {
rname: '',
rdesc: '',
rid: ''
}
this.dialogRole = true
},
// 编辑角色
modifyRow (row) {
this.mode = 'modify'
this.form = {
rname: row.rname,
rdesc: row.rdesc,
rid: row.rid
}
this.dialogRole = true
},
// 新增 修改
postOrPutSysRole () {
if (!this.form.rname) {
return this.$message.warning('请输入角色名称')
}
if (this.mode === 'add') {
this.$api.role.postSysRole(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogRole = false
this.getSysRole()
})
}
if (this.mode === 'modify') {
this.$api.role.putSysRole(this.form).then(_ => {
this.$message.success('操作成功')
this.dialogRole = false
this.getSysRole()
})
}
},
/* =============================================== 角色权限 =============================================== */
// 获取菜单
openPermission (row) {
this.roleId = row.rid
// this.isHomePage = type;
// if(type === 2){
this.$api.menu.getSysMenu({ roleId: row.rid }).then(({ data }) => {
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id)
this.tableKey = uuidv4()
this.dialogPermission = true
})
// }else if(type === 1) {
// this.$api.role.sysRoleGetRoleHome({roleId: row.rid}).then(({data}) => {
// if(data === null){
// data = []
// }
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
// this.tableKey = uuidv4();
// this.dialogPermission = true;
// })
// }
},
// 获取权限
getSysMenu (roleId) {
this.$api.menu.getSysMenu({ roleId }).then(({ data }) => {
this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id)
this.tableKey = uuidv4()
})
},
// 获取首页
// getSysHome(roleId){
// this.$api.role.sysRoleGetRoleHome({roleId}).then(({data}) => {
// if(data === null){
// data = []
// }
// this.checkboxConfig.checkRowKeys = data.filter(item => item.belong === 1).map(item => item.id);
// this.tableKey = uuidv4();
// })
// },
// 添加权限
sysRoleSaveRoleMenu () {
// 获取全部选中和半选中的数据
const checkedData = this.$refs.rolePermission.getCheckboxRecords()
const indeterminateData = this.$refs.rolePermission.getCheckboxIndeterminateRecords()
let allCheckData = []
allCheckData = checkedData.concat(indeterminateData)
const ids = allCheckData.map(item => item.id)
const params = {
rid: this.roleId,
menusstr: ids
}
this.$api.role.sysRoleSaveRoleMenu(params).then(_ => {
this.$message.success('操作成功')
this.dialogPermission = false
})
},
// // 首页配置
// sysRoleSaveRoleHome(){
// let ids = this.$refs.rolePermission.getCheckboxRecords().map(item => item.id);
// let params = {
// rid: this.roleId,
// menusstr: ids
// }
// this.$api.role.sysRoleSaveRoleHome(params).then(_ => {
// this.$message.success('操作成功');
// this.dialogPermission = false;
// })
// },
// 菜单
sysMenuFindAllMenus () {
this.$api.menu.sysMenuFindAllMenus().then(({ data }) => {
this.treeData = data.filter(item => item.id !== '6f6fafb4a7').sort((a, b) => {
return a.sort - b.sort
})
})
}
},
computed: {
dialogTitle () {
switch (this.mode) {
case 'add':
return '新增'
case 'modify':
return '编辑'
case 'view':
return '查看'
}
}
},
created () {
this.init()
}
}
</script>
+231 -232
View File
@@ -123,244 +123,243 @@
</template>
<script>
import {Base64} from "js-base64";
import { Base64 } from 'js-base64'
export default {
name: "User",
data() {
return {
q: {
account: '', // 用户名
roleName: '', // 角色名称
pageNo: 1,
pageSize: 10,
},
total: 0,
tableData: [],
mode: '',
dialogUser: false,
form: {
account: '', // 用户名
cellPhoneNumber: '', // 手机号
department: '', // 部门
email: '', // 邮箱
password: '', // 密码
usid: '',
usname: '', // 姓名
roleIdList: [''], // 角色
},
repassword: '',
roleList: [],
}
},
methods: {
search(){
this.q.pageNo = 1;
this.sysUserList();
},
// 获取所有用户
sysUserList() {
this.$api.user.sysUserList(this.q).then(({data}) => {
this.tableData = data.records;
this.total = data.total;
this.q.pageNo = data.current;
this.q.pageSize = data.size;
if(!data.records.length && this.q.pageNo !== 1){
this.q.pageNo = 1;
this.sysUserList();
}
})
},
// 重置
reset() {
this.q = {
account: '', // 用户名
roleName: '', // 角色名称
pageNo: 1,
pageSize: 10,
};
this.total = 0;
this.tableData = [];
this.sysUserList();
},
// 单页数据量
handleSizeChange(val) {
this.q.pageSize = val;
this.q.pageNo = 1;
this.sysUserList();
},
// 第几页
handleCurrentChange(val) {
this.q.pageNo = val;
this.sysUserList();
},
// 新增
add() {
this.mode = 'add';
this.form = {
account: '', // 用户名
cellPhoneNumber: '', // 手机号
department: '', // 部门
email: '', // 邮箱
password: '', // 密码
usid: '',
usname: '', // 姓名
roleIdList: [''], // 角色
};
this.repassword = '';
this.dialogUser = true;
},
// 启用/禁用
sysUserIsUse(val, row) {
this.$confirm(val === '0' ? '此操作将禁用所选用户, 是否继续?' : '此操作将启用所选用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.user.sysUserIsUse({USID: row.USID, type: val}).then(_ => {
this.$message.success('操作成功');
this.sysUserList();
})
}).catch(() => {
row.ISUSE = val === '1' ? '0' : '1';
});
},
// 删除
deleteRow(row) {
this.deleteUser(row.USID);
},
// 验证
checkUserForm() {
if (this.mode === 'add') {
if (!this.form.account || !(/^[a-zA-Z0-9]*$/.test(this.form.account))) {
return this.$message.warning('用户名只能为纯数字、纯字母或字母数字组合') && false;
}
// // 密码
// if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/.test(this.form.password))) {
// return this.$message.warning('密码至少8个字符,至少1个大写字母,1个小写字母,1个数字') && false;
// }
// if (this.repassword !== this.form.password) {
// return this.$message.warning('请检查密码') && false;
// }
}
if(this.mode === 'modify'){
// if (this.form.password || this.repassword) {
// // 密码
// if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/.test(this.form.password))) {
// return this.$message.warning('密码至少8个字符,至少1个大写字母,1个小写字母,1个数字') && false;
// }
// if (this.repassword !== this.form.password) {
// return this.$message.warning('请检查密码') && false;
// }
// }
}
if (this.form.cellPhoneNumber && !(/^1[3|4|5|7|8|9][0-9]{9}$/.test(this.form.cellPhoneNumber))) {
return this.$message.warning('请检查手机号') && false;
}
if (this.form.email && !(/^[\w-.]+@[a-z\d-]+(\.[a-z\d-]+)*\.[a-z\d]{2,6}$/i.test(this.form.email))) {
return this.$message.warning('请检查邮箱') && false;
}
if (!this.form.roleIdList[0]) {
return this.$message.warning('请选择角色') && false;
}
if (!this.form.usname) {
return this.$message.warning('请输入姓名') && false;
}
return true;
},
// 新增用户
sysUserAddUser() {
if (!this.checkUserForm()) return;
let data = JSON.parse(JSON.stringify(this.form));
data.account = this.$JSEncrypt(data.account);
data.password = this.$JSEncrypt(data.password);
let jsonData = JSON.stringify(data);
this.$api.user.sysUserAddUser(Base64.encodeURI(jsonData)).then(_ => {
this.$message.success('操作成功');
this.dialogUser = false;
this.reset();
})
},
// 编辑查看用户
openRowData(mode, row) {
this.mode = mode;
this.form = {
account: row.ACCOUNT, // 用户名
cellPhoneNumber: row.CELLPHONE_NUMBER, // 手机号
department: row.DEPARTMENT, // 部门
email: row.EMAIL, // 邮箱
password: '', // 密码
usid: row.USID, // 用户ID
usname: row.USNAME, // 姓名
roleIdList: [row.ROLEID], // 角色
}
this.repassword = '';
this.dialogUser = true;
},
newAddFunc(){
},
uploadPDFSuccess(response, file, fileList) {
if (response.ok) {
this.$message.success('导入成功');
this.reset()
} else {
this.$message.error(response.message);
}
},
downloadTemp(){
window.open('/library/api/sys/user/template')
},
// 多选用户
getSelectUser() {
let users = this.$refs.userTable.getCheckboxRecords();
if (!users.length) {
return this.$message.warning('请选择数据后在进行操作');
}
let ids = users.map(item => item.USID).join(',');
this.deleteUser(ids);
},
// 删除用户
deleteUser(ids) {
this.$confirm('此操作将删除所选用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.user.sysUserDelete({ids}).then(_ => {
this.$message.success('操作成功');
this.sysUserList();
})
})
},
// 角色列表
getSysRole() {
this.$api.role.getSysRole().then(({data}) => {
this.roleList = data;
})
},
},
computed: {
dialogTitle() {
switch (this.mode) {
case 'add':
return '新增';
case 'modify':
return '编辑';
case 'view':
return '查看';
}
}
},
created() {
this.sysUserList();
this.getSysRole();
name: 'User',
data () {
return {
q: {
account: '', // 用户名
roleName: '', // 角色名称
pageNo: 1,
pageSize: 10
},
total: 0,
tableData: [],
mode: '',
dialogUser: false,
form: {
account: '', // 用户名
cellPhoneNumber: '', // 手机号
department: '', // 部门
email: '', // 邮箱
password: '', // 密码
usid: '',
usname: '', // 姓名
roleIdList: [''] // 角色
},
repassword: '',
roleList: []
}
},
methods: {
search () {
this.q.pageNo = 1
this.sysUserList()
},
// 获取所有用户
sysUserList () {
this.$api.user.sysUserList(this.q).then(({ data }) => {
this.tableData = data.records
this.total = data.total
this.q.pageNo = data.current
this.q.pageSize = data.size
if (!data.records.length && this.q.pageNo !== 1) {
this.q.pageNo = 1
this.sysUserList()
}
})
},
// 重置
reset () {
this.q = {
account: '', // 用户名
roleName: '', // 角色名称
pageNo: 1,
pageSize: 10
}
this.total = 0
this.tableData = []
this.sysUserList()
},
// 单页数据量
handleSizeChange (val) {
this.q.pageSize = val
this.q.pageNo = 1
this.sysUserList()
},
// 第几页
handleCurrentChange (val) {
this.q.pageNo = val
this.sysUserList()
},
// 新增
add () {
this.mode = 'add'
this.form = {
account: '', // 用户名
cellPhoneNumber: '', // 手机号
department: '', // 部门
email: '', // 邮箱
password: '', // 密码
usid: '',
usname: '', // 姓名
roleIdList: [''] // 角色
}
this.repassword = ''
this.dialogUser = true
},
// 启用/禁用
sysUserIsUse (val, row) {
this.$confirm(val === '0' ? '此操作将禁用所选用户, 是否继续?' : '此操作将启用所选用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.user.sysUserIsUse({ USID: row.USID, type: val }).then(_ => {
this.$message.success('操作成功')
this.sysUserList()
})
}).catch(() => {
row.ISUSE = val === '1' ? '0' : '1'
})
},
// 删除
deleteRow (row) {
this.deleteUser(row.USID)
},
// 验证
checkUserForm () {
if (this.mode === 'add') {
if (!this.form.account || !(/^[a-zA-Z0-9]*$/.test(this.form.account))) {
return this.$message.warning('用户名只能为纯数字、纯字母或字母数字组合') && false
}
// // 密码
// if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/.test(this.form.password))) {
// return this.$message.warning('密码至少8个字符,至少1个大写字母,1个小写字母,1个数字') && false;
// }
// if (this.repassword !== this.form.password) {
// return this.$message.warning('请检查密码') && false;
// }
}
if (this.mode === 'modify') {
// if (this.form.password || this.repassword) {
// // 密码
// if (!(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/.test(this.form.password))) {
// return this.$message.warning('密码至少8个字符,至少1个大写字母,1个小写字母,1个数字') && false;
// }
// if (this.repassword !== this.form.password) {
// return this.$message.warning('请检查密码') && false;
// }
// }
}
if (this.form.cellPhoneNumber && !(/^1[3|4|5|7|8|9][0-9]{9}$/.test(this.form.cellPhoneNumber))) {
return this.$message.warning('请检查手机号') && false
}
if (this.form.email && !(/^[\w-.]+@[a-z\d-]+(\.[a-z\d-]+)*\.[a-z\d]{2,6}$/i.test(this.form.email))) {
return this.$message.warning('请检查邮箱') && false
}
if (!this.form.roleIdList[0]) {
return this.$message.warning('请选择角色') && false
}
if (!this.form.usname) {
return this.$message.warning('请输入姓名') && false
}
return true
},
// 新增用户
sysUserAddUser () {
if (!this.checkUserForm()) return
const data = JSON.parse(JSON.stringify(this.form))
data.account = this.$JSEncrypt(data.account)
data.password = this.$JSEncrypt(data.password)
const jsonData = JSON.stringify(data)
this.$api.user.sysUserAddUser(Base64.encodeURI(jsonData)).then(_ => {
this.$message.success('操作成功')
this.dialogUser = false
this.reset()
})
},
// 编辑查看用户
openRowData (mode, row) {
this.mode = mode
this.form = {
account: row.ACCOUNT, // 用户名
cellPhoneNumber: row.CELLPHONE_NUMBER, // 手机号
department: row.DEPARTMENT, // 部门
email: row.EMAIL, // 邮箱
password: '', // 密码
usid: row.USID, // 用户ID
usname: row.USNAME, // 姓名
roleIdList: [row.ROLEID] // 角色
}
this.repassword = ''
this.dialogUser = true
},
newAddFunc () {
},
uploadPDFSuccess (response, file, fileList) {
if (response.ok) {
this.$message.success('导入成功')
this.reset()
} else {
this.$message.error(response.message)
}
},
downloadTemp () {
window.open('/library/api/sys/user/template')
},
// 多选用户
getSelectUser () {
const users = this.$refs.userTable.getCheckboxRecords()
if (!users.length) {
return this.$message.warning('请选择数据后在进行操作')
}
const ids = users.map(item => item.USID).join(',')
this.deleteUser(ids)
},
// 删除用户
deleteUser (ids) {
this.$confirm('此操作将删除所选用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$api.user.sysUserDelete({ ids }).then(_ => {
this.$message.success('操作成功')
this.sysUserList()
})
})
},
// 角色列表
getSysRole () {
this.$api.role.getSysRole().then(({ data }) => {
this.roleList = data
})
}
},
computed: {
dialogTitle () {
switch (this.mode) {
case 'add':
return '新增'
case 'modify':
return '编辑'
case 'view':
return '查看'
}
}
},
created () {
this.sysUserList()
this.getSysRole()
}
}
</script>
<style lang="scss" scoped>
.system-user {
.title {
+28 -29
View File
@@ -7,37 +7,37 @@
<script>
export default {
name: "MenuManager",
data() {
return {
url: ''
}
},
methods: {},
computed: {},
created() {
this.url = this.$store.state.pathUrl
},
mounted() {
/**
export default {
name: 'MenuManager',
data () {
return {
url: ''
}
},
methods: {},
computed: {},
created () {
this.url = this.$store.state.pathUrl
},
mounted () {
/**
* iframe-宽高自适应显示
*/
function changeMobsfIframe() {
const mobsf = document.getElementById('mobsf');
const deviceWidth = document.body.clientWidth;
const deviceHeight = document.body.clientHeight;
mobsf.style.width = '100%'; //数字是页面布局宽度差值
mobsf.style.height = (Number(deviceHeight) - 86) + 'px'; //数字是页面布局高度差
}
changeMobsfIframe()
window.onresize = function () {
changeMobsfIframe()
}
}
function changeMobsfIframe () {
const mobsf = document.getElementById('mobsf')
const deviceWidth = document.body.clientWidth
const deviceHeight = document.body.clientHeight
mobsf.style.width = '100%' // 数字是页面布局宽度差值
mobsf.style.height = (Number(deviceHeight) - 86) + 'px' // 数字是页面布局高度差
}
changeMobsfIframe()
window.onresize = function () {
changeMobsfIframe()
}
}
}
</script>
<style lang="scss" scoped>
@@ -225,7 +225,6 @@
}
}
.icon-menu-text {
display: flex;
width: 36px;