2022-10-09 16:17:15 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-10-17 16:04:39 +08:00
|
|
|
<Submenu activeName="repo" />
|
2022-10-09 16:17:15 +08:00
|
|
|
<el-card style="margin-top: 20px">
|
|
|
|
<ComplexTable :pagination-config="paginationConfig" v-model:selects="selects" :data="data" @search="search">
|
|
|
|
<template #toolbar>
|
2022-12-02 14:34:03 +08:00
|
|
|
<el-button icon="Plus" type="primary" @click="onOpenDialog('create')">
|
2022-10-09 16:17:15 +08:00
|
|
|
{{ $t('commons.button.create') }}
|
|
|
|
</el-button>
|
|
|
|
<el-button type="danger" plain :disabled="selects.length === 0" @click="onBatchDelete(null)">
|
|
|
|
{{ $t('commons.button.delete') }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
<el-table-column type="selection" fix></el-table-column>
|
|
|
|
<el-table-column :label="$t('commons.table.name')" prop="name" min-width="60" />
|
|
|
|
<el-table-column
|
|
|
|
:label="$t('container.downloadUrl')"
|
|
|
|
show-overflow-tooltip
|
|
|
|
prop="downloadUrl"
|
|
|
|
min-width="100"
|
|
|
|
fix
|
|
|
|
/>
|
2022-10-10 16:47:05 +08:00
|
|
|
<el-table-column :label="$t('container.protocol')" prop="protocol" min-width="60" fix />
|
2022-10-09 16:17:15 +08:00
|
|
|
<el-table-column :label="$t('commons.table.createdAt')" min-width="80" fix>
|
|
|
|
<template #default="{ row }">
|
|
|
|
{{ dateFromat(0, 0, row.createdAt) }}
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<fu-table-operations :buttons="buttons" :label="$t('commons.table.operate')" />
|
|
|
|
</ComplexTable>
|
|
|
|
</el-card>
|
|
|
|
<OperatorDialog @search="search" ref="dialogRef" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import ComplexTable from '@/components/complex-table/index.vue';
|
|
|
|
import OperatorDialog from '@/views/container/repo/operator/index.vue';
|
2022-10-17 16:04:39 +08:00
|
|
|
import Submenu from '@/views/container/index.vue';
|
2022-10-09 16:17:15 +08:00
|
|
|
import { reactive, onMounted, ref } from 'vue';
|
|
|
|
import { dateFromat } from '@/utils/util';
|
|
|
|
import { Container } from '@/api/interface/container';
|
2022-10-17 09:10:06 +08:00
|
|
|
import { deleteImageRepo, searchImageRepo } from '@/api/modules/container';
|
2022-10-09 16:17:15 +08:00
|
|
|
import { useDeleteData } from '@/hooks/use-delete-data';
|
|
|
|
import i18n from '@/lang';
|
|
|
|
|
|
|
|
const data = ref();
|
|
|
|
const selects = ref<any>([]);
|
|
|
|
const paginationConfig = reactive({
|
|
|
|
page: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
total: 0,
|
|
|
|
});
|
|
|
|
|
|
|
|
const search = async () => {
|
2022-10-17 09:10:06 +08:00
|
|
|
let params = {
|
|
|
|
page: paginationConfig.page,
|
|
|
|
pageSize: paginationConfig.pageSize,
|
|
|
|
};
|
|
|
|
await searchImageRepo(params).then((res) => {
|
2022-11-25 18:59:49 +08:00
|
|
|
data.value = res.data.items || [];
|
|
|
|
paginationConfig.total = res.data.total;
|
2022-10-09 16:17:15 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-10-17 09:10:06 +08:00
|
|
|
const dialogRef = ref();
|
2022-10-09 16:17:15 +08:00
|
|
|
const onOpenDialog = async (
|
|
|
|
title: string,
|
|
|
|
rowData: Partial<Container.RepoInfo> = {
|
|
|
|
auth: true,
|
2022-10-10 16:47:05 +08:00
|
|
|
protocol: 'http',
|
2022-10-09 16:17:15 +08:00
|
|
|
},
|
|
|
|
) => {
|
|
|
|
let params = {
|
|
|
|
title,
|
|
|
|
rowData: { ...rowData },
|
|
|
|
};
|
|
|
|
dialogRef.value!.acceptParams(params);
|
|
|
|
};
|
|
|
|
|
|
|
|
const onBatchDelete = async (row: Container.RepoInfo | null) => {
|
|
|
|
let ids: Array<number> = [];
|
|
|
|
if (row) {
|
|
|
|
ids.push(row.id);
|
|
|
|
} else {
|
|
|
|
selects.value.forEach((item: Container.RepoInfo) => {
|
|
|
|
ids.push(item.id);
|
|
|
|
});
|
|
|
|
}
|
2022-12-02 10:59:07 +08:00
|
|
|
await useDeleteData(deleteImageRepo, { ids: ids }, 'commons.msg.delete');
|
2022-10-09 16:17:15 +08:00
|
|
|
search();
|
|
|
|
};
|
|
|
|
|
|
|
|
const buttons = [
|
|
|
|
{
|
|
|
|
label: i18n.global.t('commons.button.edit'),
|
|
|
|
disabled: (row: Container.RepoInfo) => {
|
|
|
|
return row.downloadUrl === 'docker.io';
|
|
|
|
},
|
|
|
|
click: (row: Container.RepoInfo) => {
|
|
|
|
onOpenDialog('edit', row);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: i18n.global.t('commons.button.delete'),
|
|
|
|
disabled: (row: Container.RepoInfo) => {
|
|
|
|
return row.downloadUrl === 'docker.io';
|
|
|
|
},
|
|
|
|
click: (row: Container.RepoInfo) => {
|
|
|
|
onBatchDelete(row);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
search();
|
|
|
|
});
|
|
|
|
</script>
|