Some ts interface fix
This commit is contained in:
@@ -18,10 +18,10 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-name="p">
|
||||
<q-td :props="p">
|
||||
<q-td class="flex justify-between items-center" :props="p">
|
||||
{{ p.row.name }}
|
||||
<q-badge v-if="!p.row.domainActive" color="grey">未启用</q-badge>
|
||||
<q-badge v-if="p.row.id == tenantid" color="primary">現在</q-badge>
|
||||
<q-badge v-if="p.row.id == currendDomainId" color="primary">現在</q-badge>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
@@ -129,34 +129,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, reactive } from 'vue';
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { api } from 'boot/axios';
|
||||
import { useAuthStore } from 'stores/useAuthStore';
|
||||
|
||||
type IManagedDomain = {
|
||||
id: number;
|
||||
tenantid: string;
|
||||
name: string;
|
||||
url: string;
|
||||
kintoneuser: string,
|
||||
kintonepwd: string,
|
||||
create_time: string;
|
||||
update_time: string;
|
||||
is_active: boolean;
|
||||
owner: object
|
||||
}
|
||||
|
||||
type IDomainDisplay = {
|
||||
id: number;
|
||||
tenantid: string;
|
||||
name: string;
|
||||
url: string;
|
||||
user: string;
|
||||
password: string;
|
||||
domainActive: boolean;
|
||||
}
|
||||
import { useDomainStore } from 'stores/useDomainStore';
|
||||
import { IDomain, IDomainDisplay, IDomainSubmit } from '../types/DomainTypes';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const domainStore = useDomainStore();
|
||||
const inactiveRowClass = (row: IDomainDisplay) => row.domainActive ? '' : 'inactive-row';
|
||||
|
||||
const columns = [
|
||||
@@ -185,6 +165,7 @@ const show = ref(false);
|
||||
const confirm = ref(false);
|
||||
const resetPsw = ref(false);
|
||||
|
||||
const currendDomainId = computed(() => authStore.currentDomain.id);
|
||||
const tenantid = ref(authStore.currentDomain.id);
|
||||
const name = ref('');
|
||||
const url = ref('');
|
||||
@@ -195,11 +176,12 @@ const kintonepwdBK = ref('');
|
||||
const domainActive = ref(true);
|
||||
const isCreate = ref(true);
|
||||
let editId = ref(0);
|
||||
let ownerid = ref('');
|
||||
|
||||
const getDomain = async () => {
|
||||
loading.value = true;
|
||||
const userId = authStore.userId;
|
||||
const result = await api.get<IManagedDomain[]>(`api/domain?userId=${userId}`);
|
||||
const result = await api.get<IDomain[]>(`api/domain?userId=${userId}`);
|
||||
rows.value = result.data.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
@@ -208,7 +190,7 @@ const getDomain = async () => {
|
||||
name: item.name,
|
||||
url: item.url,
|
||||
user: item.kintoneuser,
|
||||
password: item.kintonepwd
|
||||
password: item.kintonepwd,
|
||||
}
|
||||
});
|
||||
loading.value = false;
|
||||
@@ -266,39 +248,23 @@ const closeDg = () => {
|
||||
}
|
||||
|
||||
const onSubmit = () => {
|
||||
if (!isCreate.value && editId.value !== 0) {
|
||||
api.put(`api/domain`, {
|
||||
'id': editId.value,
|
||||
'tenantid': tenantid.value,
|
||||
'name': name.value,
|
||||
'url': url.value,
|
||||
'kintoneuser': kintoneuser.value,
|
||||
'kintonepwd': isCreate.value || resetPsw.value ? kintonepwd.value : '',
|
||||
'is_active': domainActive.value,
|
||||
'ownerid': authStore.userId,
|
||||
}).then(() => {
|
||||
const method = editId.value !== 0 ? 'put' : 'post';
|
||||
const param: IDomainSubmit = {
|
||||
'id': editId.value,
|
||||
'tenantid': tenantid.value,
|
||||
'name': name.value,
|
||||
'url': url.value,
|
||||
'kintoneuser': kintoneuser.value,
|
||||
'kintonepwd': ((isCreate.value && editId.value == 0) || resetPsw.value) ? kintonepwd.value : '',
|
||||
'is_active': domainActive.value,
|
||||
'ownerid': authStore.userId || ''
|
||||
}
|
||||
api[method].apply(api, [`api/domain`, param]).then(() => {
|
||||
getDomain();
|
||||
domainStore.loadUserDomains();
|
||||
closeDg();
|
||||
onReset();
|
||||
})
|
||||
}
|
||||
else {
|
||||
api.post(`api/domain`, {
|
||||
'id': 0,
|
||||
'tenantid': tenantid.value,
|
||||
'name': name.value,
|
||||
'url': url.value,
|
||||
'kintoneuser': kintoneuser.value,
|
||||
'kintonepwd': kintonepwd.value,
|
||||
'is_active': domainActive.value,
|
||||
'ownerid': authStore.userId,
|
||||
}).then(() => {
|
||||
getDomain();
|
||||
closeDg();
|
||||
onReset();
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const onReset = () => {
|
||||
@@ -308,6 +274,7 @@ const onReset = () => {
|
||||
kintonepwd.value = '';
|
||||
isPwd.value = true;
|
||||
editId.value = 0;
|
||||
ownerid.value = '';
|
||||
isCreate.value = true;
|
||||
domainActive.value = true;
|
||||
resetPsw.value = false
|
||||
|
||||
Reference in New Issue
Block a user