feat:add_global_tenant + delete_search_tenant (#1482)

Co-authored-by: 吹泡泡的团子 <baoxinyi_i@didiglobal.com>
pull/1483/head
GRL-bxy 1 year ago committed by GitHub
parent 5ff96ef2fb
commit f8832afa87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,33 @@
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
import * as user from '@/api/hippo4j-user';
export default {
name: 'App',
computed: {
...mapGetters(['tenantInfo'])
},
mounted() {
const userName = this.$cookie.get('userName');
user
.getCurrentUser(userName)
.then((response) => {
const { resources } = response;
if (response.role == 'ROLE_ADMIN') {
resources.unshift({
action: "rw",
resource: "所有租户",
username: userName
})
}
this.$store.dispatch('tenant/setTenantList', resources)
if (!this.tenantInfo.resource) {
this.$store.dispatch('tenant/setTenantInfo', resources[0])
console.log("ssss", this.tenantInfo)
}
})
.catch(() => {});
}
};
</script>

@ -18,6 +18,14 @@
<!-- </el-tooltip>-->
</template>
<el-select class="select-tenant" v-model="tenant.resource" filterable @change="changeTenant">
<el-option
v-for="(item, index) in tenantList"
:key="index"
:label="item.resource"
:value="index">
</el-option>
</el-select>
<langChange />
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
<div class="avatar-wrapper">
@ -41,13 +49,24 @@
</template>
<script>
import { mapGetters } from 'vuex'
import * as jobProjectApi from '@/api/hippo4j-tenant';
import * as user from '@/api/hippo4j-user';
import { mapGetters, mapState } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog'
import langChange from '@/locale/langChange'
export default {
data() {
return {
tenant: {
action: '',
resource: '',
username: ''
}
}
},
components: {
Breadcrumb,
Hamburger,
@ -58,7 +77,9 @@
...mapGetters([
'sidebar',
'avatar',
'device'
'device',
'tenantList',
'tenantInfo'
])
},
methods: {
@ -69,8 +90,45 @@
this.$cookie.delete('userName')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
},
async getTenantList() {
const userName = this.$cookie.get('userName')
await user
.getCurrentUser(userName)
.then((response) => {
const { resources } = response;
if (response.role == 'ROLE_ADMIN') {
resources.unshift({
action: "rw",
resource: "所有租户",
username: userName
})
}
this.$store.dispatch('tenant/setTenantList', resources)
this.$store.dispatch('tenant/setTenantInfo', this.tenantInfo || resources[0])
this.tenant = this.tenantInfo || resources[0]
})
.catch(() => {});
},
async changeTenant(index) {
let tenant = {
tenantId: this.tenantList[index].resource,
current: 1,
desc: true,
size: 10,
}
this.$store.dispatch('tenant/setTenantInfo', tenant)
tenant.tenantId = tenant.tenantId == '所有租户' ? '' : tenant.tenantId
await jobProjectApi.list(tenant).then((response) => {
console.log("isRes", response)
// this.$store.dispatch('tenant/setTenantList', resources)
});
}
}
},
async mounted() {
this.getTenantList()
},
}
</script>
@ -113,6 +171,17 @@
outline: none;
}
::v-deep .el-input__inner {
border: none;
box-shadow: none;
}
.select-tenant {
margin-right: 20px;
border: 0;
width: 150px;
}
.right-menu-item {
display: inline-block;
padding: 0 8px;

@ -10,6 +10,8 @@ const getters = {
introduction: state => state.user.introduction,
roles: state => state.user.roles,
permission_routes: state => state.permission.routes,
errorLogs: state => state.errorLog.logs
errorLogs: state => state.errorLog.logs,
tenantList: state => state.tenant.tenantList,
tenantInfo: state => state.tenant.tenantInfo,
}
export default getters

@ -0,0 +1,53 @@
import * as user from '@/api/hippo4j-user';
const state = {
tenantList: [],
tenantInfo: {}
}
const mutations = {
SET_TENANT_LIST: (state, log) => {
state.tenantList = log;
console.log("sssssss", state.tenantList)
},
SET_GLOBAL_TENANT: (state, log) => {
state.tenantInfo = log;
}
}
const actions = {
async getTenantList({commit}) {
debugger
const userName = this.$cookie.get('userName');
user
.getCurrentUser(userName)
.then((response) => {
const { resources } = response;
if (response.role == 'ROLE_ADMIN') {
resources.unshift({
action: "rw",
resource: "所有租户",
username: userName
})
}
commit('SET_TENANT_LIST', resources)
if (!state.tenantInfo) {
commit('SET_GLOBAL_TENANT', resources[0])
}
})
.catch(() => {});
},
setTenantList({commit}, log) {
commit('SET_TENANT_LIST', log)
},
setTenantInfo({commit}, log) {
commit('SET_GLOBAL_TENANT', log)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}

@ -1,36 +1,9 @@
<template>
<div class="app-container">
<div class="filter-container">
<el-input
v-model="listQuery.tenantId"
clearable
:placeholder="$t('tenantManage.tenant')"
style="width: 200px"
class="filter-item"
/>
<el-button
v-waves
class="filter-item"
type="primary"
icon="el-icon-search"
@click="fetchData"
>
{{ $t('common.query') }}
</el-button>
<el-button
:disabled="isEditDisabled"
class="filter-item"
style="margin-left: 10px"
type="primary"
icon="el-icon-edit"
@click="handleCreate"
>
{{ $t('common.insert') }}
</el-button>
</div>
<el-table
v-loading="listLoading"
:data="list"
:key="tableIsChange"
border
highlight-current-row
element-loading-text="Loading"
@ -134,6 +107,7 @@
import * as jobProjectApi from '@/api/hippo4j-tenant';
import waves from '@/directive/waves';
import Pagination from '@/components/Pagination';
import { mapGetters } from 'vuex';
export default {
name: 'JobProject',
@ -167,6 +141,7 @@ export default {
tenantId: '',
desc: true,
},
tableIsChange: false,
pluginTypeOptions: ['reader', 'writer'],
dialogPluginVisible: false,
pluginData: [],
@ -187,7 +162,16 @@ export default {
visible: true,
};
},
watch: {
tenantInfo(newVal, oldVal) {
this.listQuery = newVal;
this.fetchData()
}
},
computed:{
...mapGetters([
'tenantInfo'
]),
rules(){
return{
tenantId: [{ required: true, message: this.$t('message.requiredError'), trigger: 'blur' }],
@ -209,6 +193,10 @@ export default {
},
methods: {
fetchData() {
// debugger
this.listQuery = this?.tenantInfo || this.listQuery
console.log("Quary", this.tenantInfo)
this.listQuery.tenantId = this.listQuery.tenantId == '所有租户' ? '' : this.listQuery.tenantId
this.listLoading = true;
jobProjectApi.list(this.listQuery).then((response) => {
const { records } = response;

Loading…
Cancel
Save