2024-04-03 16:33:18 +08:00
|
|
|
<script setup lang="tsx">
|
2024-04-10 10:29:36 +08:00
|
|
|
import { NButton } from 'naive-ui';
|
2024-04-03 16:33:18 +08:00
|
|
|
import { fetchGetNamespaceList } from '@/service/api';
|
|
|
|
import { $t } from '@/locales';
|
|
|
|
import { useAppStore } from '@/store/modules/app';
|
|
|
|
import { useTable, useTableOperate } from '@/hooks/common/table';
|
|
|
|
import NamespaceOperateDrawer from './modules/namespace-operate-drawer.vue';
|
|
|
|
import NamespaceSearch from './modules/namespace-search.vue';
|
|
|
|
|
|
|
|
const appStore = useAppStore();
|
|
|
|
|
|
|
|
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
|
|
|
|
apiFn: fetchGetNamespaceList,
|
|
|
|
apiParams: {
|
|
|
|
page: 1,
|
|
|
|
size: 10,
|
2024-06-01 14:13:39 +08:00
|
|
|
keyword: null
|
2024-04-03 16:33:18 +08:00
|
|
|
},
|
|
|
|
columns: () => [
|
2024-06-01 14:13:39 +08:00
|
|
|
// {
|
|
|
|
// key: 'index',
|
|
|
|
// title: $t('common.index'),
|
|
|
|
// align: 'center',
|
|
|
|
// width: 64
|
|
|
|
// },
|
2024-04-03 16:33:18 +08:00
|
|
|
{
|
|
|
|
key: 'name',
|
|
|
|
title: $t('page.namespace.name'),
|
|
|
|
align: 'left',
|
2024-04-10 10:29:36 +08:00
|
|
|
width: 120
|
2024-04-03 16:33:18 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'uniqueId',
|
|
|
|
title: $t('page.namespace.uniqueId'),
|
|
|
|
align: 'left',
|
2024-04-10 10:29:36 +08:00
|
|
|
width: 180
|
2024-04-03 16:33:18 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'createDt',
|
|
|
|
title: $t('page.common.createTime'),
|
|
|
|
align: 'left',
|
2024-04-10 10:29:36 +08:00
|
|
|
width: 130
|
2024-04-03 16:33:18 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'updateDt',
|
|
|
|
title: $t('page.common.upadteTime'),
|
|
|
|
align: 'left',
|
2024-04-10 10:29:36 +08:00
|
|
|
width: 130
|
2024-04-03 16:33:18 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'operate',
|
|
|
|
title: $t('common.operate'),
|
|
|
|
align: 'center',
|
2024-04-10 10:29:36 +08:00
|
|
|
width: 64,
|
2024-04-03 16:33:18 +08:00
|
|
|
render: row => (
|
|
|
|
<div class="flex-center gap-8px">
|
2024-05-26 17:52:14 +08:00
|
|
|
<NButton type="primary" text ghost size="small" onClick={() => edit(row.id!)}>
|
2024-04-03 16:33:18 +08:00
|
|
|
{$t('common.edit')}
|
|
|
|
</NButton>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
const {
|
|
|
|
drawerVisible,
|
|
|
|
operateType,
|
|
|
|
editingData,
|
|
|
|
handleAdd,
|
|
|
|
handleEdit,
|
2024-04-10 10:29:36 +08:00
|
|
|
checkedRowKeys
|
2024-04-03 16:33:18 +08:00
|
|
|
// closeDrawer
|
|
|
|
} = useTableOperate(data, getData);
|
|
|
|
|
|
|
|
function edit(id: string) {
|
|
|
|
handleEdit(id);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
|
|
|
|
<NamespaceSearch v-model:model="searchParams" @reset="resetSearchParams" @search="getData" />
|
2024-04-10 10:29:36 +08:00
|
|
|
<NCard
|
|
|
|
:title="$t('page.namespace.title')"
|
|
|
|
:bordered="false"
|
|
|
|
size="small"
|
|
|
|
class="sm:flex-1-hidden card-wrapper"
|
|
|
|
header-class="view-card-header"
|
|
|
|
>
|
2024-04-03 16:33:18 +08:00
|
|
|
<template #header-extra>
|
|
|
|
<TableHeaderOperation
|
|
|
|
v-model:columns="columnChecks"
|
|
|
|
:disabled-delete="checkedRowKeys.length === 0"
|
|
|
|
:loading="loading"
|
2024-04-10 10:29:36 +08:00
|
|
|
:show-delete="false"
|
2024-04-03 16:33:18 +08:00
|
|
|
@add="handleAdd"
|
|
|
|
@refresh="getData"
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
<NDataTable
|
|
|
|
v-model:checked-row-keys="checkedRowKeys"
|
|
|
|
:columns="columns"
|
|
|
|
:data="data"
|
|
|
|
:flex-height="!appStore.isMobile"
|
|
|
|
:scroll-x="962"
|
|
|
|
:loading="loading"
|
|
|
|
remote
|
|
|
|
:row-key="row => row.id"
|
|
|
|
:pagination="mobilePagination"
|
|
|
|
class="sm:h-full"
|
|
|
|
/>
|
|
|
|
<NamespaceOperateDrawer
|
|
|
|
v-model:visible="drawerVisible"
|
|
|
|
:operate-type="operateType"
|
|
|
|
:row-data="editingData"
|
|
|
|
@submitted="getData"
|
|
|
|
/>
|
|
|
|
</NCard>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2024-04-10 10:29:36 +08:00
|
|
|
<style scoped></style>
|