mirror of
https://github.com/chillzhuang/Saber.git
synced 2024-11-22 10:29:28 +08:00
⚡ 增加多租户模块
This commit is contained in:
parent
145f8ad072
commit
f3d6f63f95
@ -46,10 +46,13 @@ export const getDept = (id) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
export const getDeptTree = () => {
|
||||
export const getDeptTree = (tenantCode) => {
|
||||
return request({
|
||||
url: '/api/blade-system/dept/tree',
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: {
|
||||
tenantCode,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,12 @@ export const getRole = (roleIds) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const getRoleTree = () => {
|
||||
export const getRoleTree = (tenantCode) => {
|
||||
return request({
|
||||
url: '/api/blade-system/role/tree',
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
params: {
|
||||
tenantCode,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
38
src/api/system/tenant.js
Normal file
38
src/api/system/tenant.js
Normal file
@ -0,0 +1,38 @@
|
||||
import request from '@/router/axios';
|
||||
|
||||
export const getList = (current, size, params) => {
|
||||
return request({
|
||||
url: '/api/blade-system/tenant/list',
|
||||
method: 'get',
|
||||
params: {
|
||||
...params,
|
||||
current,
|
||||
size,
|
||||
}
|
||||
})
|
||||
}
|
||||
export const remove = (ids) => {
|
||||
return request({
|
||||
url: '/api/blade-system/tenant/remove',
|
||||
method: 'post',
|
||||
params: {
|
||||
ids,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const add = (row) => {
|
||||
return request({
|
||||
url: '/api/blade-system/tenant/submit',
|
||||
method: 'post',
|
||||
data: row
|
||||
})
|
||||
}
|
||||
|
||||
export const update = (row) => {
|
||||
return request({
|
||||
url: '/api/blade-system/tenant/submit',
|
||||
method: 'post',
|
||||
data: row
|
||||
})
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
import request from '@/router/axios';
|
||||
import {baseUrl} from '@/config/env';
|
||||
|
||||
export const loginByUsername = (account, password, type) => request({
|
||||
export const loginByUsername = (tenantCode, account, password, type) => request({
|
||||
url: '/api/blade-auth/token',
|
||||
method: 'post',
|
||||
params: {
|
||||
tenantCode,
|
||||
account,
|
||||
password,
|
||||
type
|
||||
|
@ -66,6 +66,7 @@ export default {
|
||||
login: {
|
||||
title: 'Login ',
|
||||
info: 'Enterprise Development Platform',
|
||||
tenantCode: 'Please input tenantCode',
|
||||
username: 'Please input username',
|
||||
password: 'Please input a password',
|
||||
wechat: 'Wechat',
|
||||
|
@ -66,6 +66,7 @@ export default {
|
||||
login: {
|
||||
title: '登录 ',
|
||||
info: '企业级开发平台',
|
||||
tenantCode: '请输入租户编号',
|
||||
username: '请输入账号',
|
||||
password: '请输入密码',
|
||||
wechat: '微信',
|
||||
|
@ -5,6 +5,16 @@
|
||||
ref="loginForm"
|
||||
:model="loginForm"
|
||||
label-width="0">
|
||||
<el-form-item prop="tenantCode">
|
||||
<el-input size="small"
|
||||
@keyup.enter.native="handleLogin"
|
||||
v-model="loginForm.tenantCode"
|
||||
auto-complete="off"
|
||||
:placeholder="$t('login.tenantCode')">
|
||||
<i slot="prefix"
|
||||
class="icon-quanxian"></i>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="username">
|
||||
<el-input size="small"
|
||||
@keyup.enter.native="handleLogin"
|
||||
@ -45,11 +55,15 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
loginForm: {
|
||||
tenantCode: "000000",
|
||||
username: "admin",
|
||||
password: "admin",
|
||||
type: "account"
|
||||
},
|
||||
loginRules: {
|
||||
tenantCode: [
|
||||
{ required: true, message: "请输入租户编号", trigger: "blur" }
|
||||
],
|
||||
username: [
|
||||
{ required: true, message: "请输入用户名", trigger: "blur" }
|
||||
],
|
||||
|
@ -28,7 +28,6 @@ function addPath(ele, first) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const user = {
|
||||
state: {
|
||||
userInfo: getStore({ name: 'userInfo' }) || [],
|
||||
@ -42,7 +41,7 @@ const user = {
|
||||
//根据用户名登录
|
||||
LoginByUsername({ commit }, userInfo) {
|
||||
return new Promise((resolve) => {
|
||||
loginByUsername(userInfo.username, userInfo.password, userInfo.type).then(res => {
|
||||
loginByUsername(userInfo.tenantCode, userInfo.username, userInfo.password, userInfo.type).then(res => {
|
||||
const data = res.data.data;
|
||||
commit('SET_TOKEN', data.accessToken);
|
||||
commit('SET_USERIFNO', data);
|
||||
@ -170,7 +169,6 @@ const user = {
|
||||
},
|
||||
SET_PERMISSION: (state, permission) => {
|
||||
let result = [];
|
||||
|
||||
function getCode(list) {
|
||||
list.forEach(ele => {
|
||||
if (typeof (ele) === 'object') {
|
||||
@ -185,7 +183,6 @@ const user = {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
getCode(permission);
|
||||
state.permission = {};
|
||||
result.forEach(ele => {
|
||||
|
@ -73,6 +73,18 @@
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "租户编号",
|
||||
prop: "tenantCode",
|
||||
search: true,
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入租户编号",
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "部门全称",
|
||||
prop: "fullName",
|
||||
|
@ -92,11 +92,14 @@ export default {
|
||||
index: true,
|
||||
selection: true,
|
||||
viewBtn: true,
|
||||
dialogWidth: 300,
|
||||
dialogHeight: 400,
|
||||
column: [
|
||||
{
|
||||
label: "角色名称",
|
||||
prop: "roleName",
|
||||
search: true,
|
||||
span: 24,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
@ -105,10 +108,42 @@ export default {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "租户编号",
|
||||
prop: "tenantCode",
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
span: 24,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入租户编号",
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "所属租户",
|
||||
prop: "tenantCode",
|
||||
type: "tree",
|
||||
dicUrl: "/api/blade-system/tenant/select",
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
span: 24,
|
||||
props: {
|
||||
label: "tenantName",
|
||||
value: "tenantCode"
|
||||
},
|
||||
search: true,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入所属租户",
|
||||
trigger: "click"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "角色别名",
|
||||
prop: "roleAlias",
|
||||
search: true,
|
||||
span: 24,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
@ -123,6 +158,7 @@ export default {
|
||||
dicData: [],
|
||||
type: "tree",
|
||||
hide: true,
|
||||
span: 24,
|
||||
props: {
|
||||
label: "title"
|
||||
},
|
||||
@ -138,6 +174,7 @@ export default {
|
||||
label: "角色排序",
|
||||
prop: "sort",
|
||||
type: "number",
|
||||
span: 24,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
|
210
src/views/system/tenant.vue
Normal file
210
src/views/system/tenant.vue
Normal file
@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<basic-container>
|
||||
<avue-crud :option="option"
|
||||
:data="data"
|
||||
ref="crud"
|
||||
v-model="form"
|
||||
:page="page"
|
||||
:permission="permissionList"
|
||||
@row-del="rowDel"
|
||||
@row-update="rowUpdate"
|
||||
@row-save="rowSave"
|
||||
@search-change="searchChange"
|
||||
@search-reset="searchReset"
|
||||
@selection-change="selectionChange"
|
||||
@on-load="onLoad">
|
||||
<template slot="menuLeft">
|
||||
<el-button type="danger"
|
||||
size="small"
|
||||
icon="el-icon-delete"
|
||||
v-if="permission.tenant_delete"
|
||||
plain
|
||||
@click="handleDelete">删 除
|
||||
</el-button>
|
||||
</template>
|
||||
<template slot-scope="{row}"
|
||||
slot="roleId">
|
||||
<el-tag>{{row.roleName}}</el-tag>
|
||||
</template>
|
||||
<template slot-scope="{row}"
|
||||
slot="deptId">
|
||||
<el-tag>{{row.deptName}}</el-tag>
|
||||
</template>
|
||||
</avue-crud>
|
||||
</basic-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getList, remove, update, add} from "@/api/system/tenant";
|
||||
import {mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
selectionList: [],
|
||||
page: {
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
},
|
||||
option: {
|
||||
tip: false,
|
||||
border: true,
|
||||
index: true,
|
||||
selection: true,
|
||||
viewBtn: true,
|
||||
dialogWidth: 300,
|
||||
dialogHeight: 400,
|
||||
column: [
|
||||
{
|
||||
label: "租户编号",
|
||||
prop: "tenantCode",
|
||||
search: true,
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
span: 24,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入租户编号",
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "租户名称",
|
||||
prop: "tenantName",
|
||||
search: true,
|
||||
span: 24,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入参数名称",
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "联系人",
|
||||
prop: "linkman",
|
||||
search: true,
|
||||
span: 24,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入联系人",
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "联系电话",
|
||||
prop: "contactNumber",
|
||||
span: 24,
|
||||
},
|
||||
{
|
||||
label: "联系地址",
|
||||
prop: "address",
|
||||
span: 24,
|
||||
minRows: 6,
|
||||
type: "textarea",
|
||||
}
|
||||
]
|
||||
},
|
||||
data: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.vaildData(this.permission.tenant_add, false),
|
||||
viewBtn: this.vaildData(this.permission.tenant_view, false),
|
||||
delBtn: this.vaildData(this.permission.tenant_delete, false),
|
||||
editBtn: this.vaildData(this.permission.tenant_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
let ids = [];
|
||||
this.selectionList.forEach(ele => {
|
||||
ids.push(ele.id);
|
||||
});
|
||||
return ids.join(",");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
rowSave(row, loading) {
|
||||
add(row).then(() => {
|
||||
loading();
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowUpdate(row, index, loading) {
|
||||
update(row).then(() => {
|
||||
loading();
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowDel(row) {
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
searchReset() {
|
||||
this.onLoad(this.page);
|
||||
},
|
||||
searchChange(params) {
|
||||
this.onLoad(this.page, params);
|
||||
},
|
||||
selectionChange(list) {
|
||||
this.selectionList = list;
|
||||
},
|
||||
handleDelete() {
|
||||
if (this.selectionList.length === 0) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(this.ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.$refs.crud.toggleSelection();
|
||||
});
|
||||
},
|
||||
onLoad(page, params = {}) {
|
||||
getList(page.currentPage, page.pageSize, params).then(res => {
|
||||
const data = res.data.data;
|
||||
this.page.total = data.total;
|
||||
this.data = data.records;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
@ -51,6 +51,8 @@
|
||||
add,
|
||||
resetPassword
|
||||
} from "@/api/system/user";
|
||||
import {getDeptTree} from "@/api/system/dept";
|
||||
import {getRoleTree} from "@/api/system/role";
|
||||
import {mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
@ -80,6 +82,10 @@
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
},
|
||||
init: {
|
||||
roleTree: [],
|
||||
deptTree: [],
|
||||
},
|
||||
option: {
|
||||
tip: false,
|
||||
border: true,
|
||||
@ -91,7 +97,6 @@
|
||||
{
|
||||
label: "登录账号",
|
||||
prop: "account",
|
||||
span: 24,
|
||||
search: true,
|
||||
rules: [{
|
||||
required: true,
|
||||
@ -99,6 +104,29 @@
|
||||
trigger: "blur"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: "租户编号",
|
||||
prop: "tenantCode",
|
||||
addDisplay: false,
|
||||
editDisplay: false,
|
||||
viewDisplay: false,
|
||||
},
|
||||
{
|
||||
label: "所属租户",
|
||||
prop: "tenantCode",
|
||||
type: "tree",
|
||||
dicUrl: "/api/blade-system/tenant/select",
|
||||
props: {
|
||||
label: "tenantName",
|
||||
value: "tenantCode"
|
||||
},
|
||||
search: true,
|
||||
rules: [{
|
||||
required: true,
|
||||
message: "请输入所属租户",
|
||||
trigger: "click"
|
||||
}]
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
prop: 'password',
|
||||
@ -139,7 +167,7 @@
|
||||
prop: "roleId",
|
||||
multiple: true,
|
||||
type: "tree",
|
||||
dicUrl: "/api/blade-system/role/tree",
|
||||
dicData: [],
|
||||
props: {
|
||||
label: "title"
|
||||
},
|
||||
@ -155,7 +183,7 @@
|
||||
prop: "deptId",
|
||||
type: "tree",
|
||||
multiple: true,
|
||||
dicUrl: "/api/blade-system/dept/tree",
|
||||
dicData: [],
|
||||
props: {
|
||||
label: "title"
|
||||
},
|
||||
@ -174,6 +202,7 @@
|
||||
{
|
||||
label: "电子邮箱",
|
||||
prop: "email",
|
||||
hide: true,
|
||||
overHidden: true
|
||||
},
|
||||
{
|
||||
@ -201,11 +230,13 @@
|
||||
type: "date",
|
||||
prop: "birthday",
|
||||
format: "yyyy-MM-dd hh:mm:ss",
|
||||
valueFormat: "yyyy-MM-dd hh:mm:ss"
|
||||
valueFormat: "yyyy-MM-dd hh:mm:ss",
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
label: "账号状态",
|
||||
prop: "statusName",
|
||||
hide: true,
|
||||
display: false
|
||||
}
|
||||
]
|
||||
@ -213,6 +244,20 @@
|
||||
data: []
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
'form.tenantCode'() {
|
||||
if (this.form.tenantCode !== '') {
|
||||
getDeptTree(this.form.tenantCode).then(res => {
|
||||
const index = this.$refs.crud.findColumnIndex("deptId");
|
||||
this.option.column[index].dicData = res.data.data;
|
||||
});
|
||||
getRoleTree(this.form.tenantCode).then(res => {
|
||||
const index = this.$refs.crud.findColumnIndex("roleId");
|
||||
this.option.column[index].dicData = res.data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
@ -347,6 +392,14 @@
|
||||
this.page.total = data.total;
|
||||
this.data = data.records;
|
||||
});
|
||||
getDeptTree(this.form.tenantCode).then(res => {
|
||||
const index = this.$refs.crud.findColumnIndex("deptId");
|
||||
this.option.column[index].dicData = res.data.data;
|
||||
});
|
||||
getRoleTree(this.form.tenantCode).then(res => {
|
||||
const index = this.$refs.crud.findColumnIndex("roleId");
|
||||
this.option.column[index].dicData = res.data.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user