ユーザードメインページを調整し、ユーザーがシステム管理者の場合、他のユーザーのユーザードメインを管理できるようにしました。
This commit is contained in:
@@ -1,17 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="q-pa-lg">
|
<div class="q-pa-lg">
|
||||||
<q-table grid grid-header title="Domain" selection="single" :rows="rows" :columns="columns"
|
<q-table grid grid-header title="Domain" selection="single" :rows="rows" :columns="columns" row-key="name"
|
||||||
v-model:selected="selected" row-key="name" :filter="filter" virtual-scroll v-model:pagination="pagination">
|
:filter="userDomainTableFilter" virtual-scroll v-model:pagination="pagination">
|
||||||
<template v-slot:top>
|
<template v-slot:top>
|
||||||
<div class="q-gutter-sm">
|
|
||||||
<q-btn class="q-mx-none" color="primary" label="追加" @click="newDomain()" />
|
<q-btn class="q-mx-none" color="primary" label="追加" @click="clickAddDomain()" />
|
||||||
</div>
|
|
||||||
<q-space />
|
<q-space />
|
||||||
<q-input borderless dense filled debounce="300" v-model="filter" placeholder="Search">
|
<div class="row q-gutter-md">
|
||||||
|
<q-item v-if="authStore.permissions === 'admin'" tag="label" dense @click="clickSwitchUser()">
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>オブジェクトユーザ : </q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section avatar>
|
||||||
|
{{ currentUserName }}
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-input borderless dense filled debounce="300" v-model="userDomainTableFilter" placeholder="Search">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon name="search" />
|
<q-icon name="search" />
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
@@ -46,7 +57,7 @@
|
|||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<q-btn v-if="isActive(props.row.id) !== 'Active'" flat
|
<q-btn v-if="isActive(props.row.id) !== 'Active'" flat
|
||||||
@click="activeDomain(props.row.id)">有効</q-btn>
|
@click="activeDomain(props.row.id)">有効</q-btn>
|
||||||
<q-btn flat @click="deleteConfirm(props.row)">削除</q-btn>
|
<q-btn flat @click="clickDeleteConfirm(props.row)">削除</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,11 +67,35 @@
|
|||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
|
|
||||||
<show-dialog v-model:visible="show" name="ドメイン" @close="closeDg">
|
<show-dialog v-model:visible="showAddDomainDg" name="ドメイン" @close="addUserDomainFinished">
|
||||||
<domain-select ref="domainDg" name="ドメイン" type="multiple"></domain-select>
|
<domain-select ref="addDomainRef" name="ドメイン" type="multiple"></domain-select>
|
||||||
</show-dialog>
|
</show-dialog>
|
||||||
|
|
||||||
<q-dialog v-model="confirm" persistent>
|
<show-dialog v-model:visible="showSwitchUserDd" name="ドメイン" minWidth="35vw" @close="switchUserFinished">
|
||||||
|
<template v-slot:toolbar>
|
||||||
|
<q-input dense placeholder="検索" v-model="switchUserFilter">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
<div class="q-gutter-md">
|
||||||
|
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>他のユーザーを選択する</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-toggle v-model="useOtherUser" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<div v-if="useOtherUser">
|
||||||
|
<user-list ref="switchUserRef" name="ドメイン" :filter="switchUserFilter" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</show-dialog>
|
||||||
|
|
||||||
|
<q-dialog v-model="showDeleteConfirm" persistent>
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section class="row items-center">
|
<q-card-section class="row items-center">
|
||||||
<div class="q-ma-sm q-mt-md">
|
<div class="q-ma-sm q-mt-md">
|
||||||
@@ -71,7 +106,7 @@
|
|||||||
|
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn flat label="Cancel" color="primary" v-close-popup />
|
<q-btn flat label="Cancel" color="primary" v-close-popup />
|
||||||
<q-btn flat label="OK" color="primary" v-close-popup @click="deleteDomain()" />
|
<q-btn flat label="OK" color="primary" v-close-popup @click="deleteDomainFinished()" />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
@@ -79,24 +114,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import ShowDialog from 'components/ShowDialog.vue';
|
import { api } from 'boot/axios';
|
||||||
import DomainSelect from 'components/DomainSelect.vue';
|
|
||||||
import { useAuthStore } from 'stores/useAuthStore';
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
|
|
||||||
|
import ShowDialog from 'components/ShowDialog.vue';
|
||||||
|
import DomainSelect from 'components/DomainSelect.vue';
|
||||||
|
import UserList from 'components/UserList.vue';
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
import { api } from 'boot/axios';
|
const pagination = ref({ sortBy: 'id', rowsPerPage: 0 });
|
||||||
const domainDg = ref();
|
const rows = ref([] as any[]);
|
||||||
const selected = ref([])
|
|
||||||
|
|
||||||
const show = ref(false);
|
|
||||||
const confirm = ref(false)
|
|
||||||
const filter = ref()
|
|
||||||
|
|
||||||
let editId = ref(0);
|
|
||||||
let activedomainid = ref(0);
|
|
||||||
|
|
||||||
const pagination = ref({ rowsPerPage: 0 });
|
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: 'id' },
|
{ name: 'id' },
|
||||||
@@ -106,63 +134,99 @@ const columns = [
|
|||||||
{ name: 'kintonepwd' },
|
{ name: 'kintonepwd' },
|
||||||
{ name: 'active', field: 'active' }
|
{ name: 'active', field: 'active' }
|
||||||
]
|
]
|
||||||
|
const userDomainTableFilter = ref()
|
||||||
|
|
||||||
const rows = ref([] as any[]);
|
const currentUserName = ref('')
|
||||||
|
const useOtherUser = ref(false);
|
||||||
|
const otherUserId = ref('')
|
||||||
|
|
||||||
const isActive = (id: number) => {
|
let editId = ref(0);
|
||||||
if (id == activedomainid.value)
|
|
||||||
return "Active";
|
|
||||||
else
|
|
||||||
return "Inactive";
|
|
||||||
}
|
|
||||||
|
|
||||||
const newDomain = () => {
|
const showAddDomainDg = ref(false);
|
||||||
|
const addDomainRef = ref();
|
||||||
|
|
||||||
|
const clickAddDomain = () => {
|
||||||
editId.value = 0;
|
editId.value = 0;
|
||||||
show.value = true;
|
showAddDomainDg.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addUserDomainFinished = (val: string) => {
|
||||||
const activeDomain = (id: number) => {
|
|
||||||
api.put(`api/activedomain/` + id).then(() => {
|
|
||||||
getDomain();
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteConfirm = (row: object) => {
|
|
||||||
confirm.value = true;
|
|
||||||
editId.value = row.id;
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteDomain = () => {
|
|
||||||
console.log(authStore.getCurrentDomain);
|
|
||||||
|
|
||||||
api.delete(`api/domain/${editId.value}/${authStore.userId}`).then(() => {
|
|
||||||
getDomain();
|
|
||||||
})
|
|
||||||
editId.value = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeDg = (val: string) => {
|
|
||||||
if (val == 'OK') {
|
if (val == 'OK') {
|
||||||
let dodmainids = [];
|
let dodmainids = [];
|
||||||
let domains = JSON.parse(JSON.stringify(domainDg.value.selected));
|
let domains = JSON.parse(JSON.stringify(addDomainRef.value.selected));
|
||||||
for (var key in domains) {
|
for (var key in domains) {
|
||||||
dodmainids.push(domains[key].id);
|
dodmainids.push(domains[key].id);
|
||||||
}
|
}
|
||||||
api.post(`api/domain/${authStore.userId}`, dodmainids).then(() => { getDomain(); });
|
api.post(`api/domain/${useOtherUser.value ? otherUserId.value : authStore.userId}`, dodmainids)
|
||||||
|
.then(() => { getDomain(useOtherUser.value ? otherUserId.value : undefined); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showDeleteConfirm = ref(false)
|
||||||
|
|
||||||
|
const clickDeleteConfirm = (row: any) => {
|
||||||
|
showDeleteConfirm.value = true;
|
||||||
|
editId.value = row.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteDomainFinished = () => {
|
||||||
|
api.delete(`api/domain/${editId.value}/${useOtherUser.value ? otherUserId.value : authStore.userId}`).then(() => {
|
||||||
|
getDomain(useOtherUser.value ? otherUserId.value : undefined);
|
||||||
|
})
|
||||||
|
editId.value = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const activeDomain = (id: number) => {
|
||||||
|
api.put(`api/activedomain/${id}${useOtherUser.value ? `?userId=${otherUserId.value}` : ''}`)
|
||||||
|
.then(() => { getDomain(useOtherUser.value ? otherUserId.value : undefined); })
|
||||||
|
};
|
||||||
|
|
||||||
|
let activeDomainId = ref(0);
|
||||||
|
|
||||||
|
const isActive = computed(() => (id: number) => {
|
||||||
|
if (id == activeDomainId.value)
|
||||||
|
return "Active";
|
||||||
|
else
|
||||||
|
return "Inactive";
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const showSwitchUserDd = ref(false);
|
||||||
|
const switchUserRef = ref();
|
||||||
|
const switchUserFilter = ref('')
|
||||||
|
|
||||||
|
const clickSwitchUser = () => {
|
||||||
|
showSwitchUserDd.value = true;
|
||||||
|
useOtherUser.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const switchUserFinished = async (val: string) => {
|
||||||
|
if (val == 'OK') {
|
||||||
|
if (useOtherUser.value) {
|
||||||
|
const user = switchUserRef.value.selected[0]
|
||||||
|
currentUserName.value = user.email;
|
||||||
|
otherUserId.value = user.id
|
||||||
|
await getDomain(user.id)
|
||||||
|
} else {
|
||||||
|
currentUserName.value = authStore.userInfo.email
|
||||||
|
await getDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const getDomain = async () => {
|
|
||||||
const resp = await api.get(`api/activedomain`);
|
const getDomain = async (userId? : string) => {
|
||||||
activedomainid.value = resp.data.id;
|
const resp = await api.get(`api/activedomain${useOtherUser.value ? `?userId=${otherUserId.value}` : ''}`);
|
||||||
const domainResult = await api.get(`api/domain`);
|
activeDomainId.value = resp?.data?.id;
|
||||||
|
const domainResult = userId ? await api.get(`api/domain?userId=${userId}`) : await api.get(`api/domain`);
|
||||||
const domains = domainResult.data as any[];
|
const domains = domainResult.data as any[];
|
||||||
rows.value = domains.map((item) => {
|
rows.value = domains.map((item) => {
|
||||||
return { id: item.id, name: item.name, url: item.url, kintoneuser: item.kintoneuser, kintonepwd: item.kintonepwd }
|
return { id: item.id, name: item.name, url: item.url, kintoneuser: item.kintoneuser, kintonepwd: item.kintonepwd }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
currentUserName.value = authStore.userInfo.email
|
||||||
await getDomain();
|
await getDomain();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user