support created at and delete

This commit is contained in:
AceDataCloud committed 2021-09-19 22:53:21 +08:00
1 parent 74f62354a2
commit 82e101fc86
5 files changed
+32 -3

No files matched your search

+22
View File
@@ -11,6 +11,11 @@
>
<el-table :data="items" v-loading="loading">
<el-table-column prop="title" :label="$t('common.entity.title')"> </el-table-column>
<el-table-column prop="created_at" :label="$t('common.entity.createdAt')">
<template #default="scope">
{{ $dayjs.format(scope.row.created_at) }}
</template>
</el-table-column>
<el-table-column prop="updated_at" :label="$t('common.entity.updatedAt')">
<template #default="scope">
{{ $dayjs.format(scope.row.updated_at) }}
@@ -21,6 +26,9 @@
<el-button @click="onEdit(scope.row)" round type="primary" size="mini">
{{ $t('common.button.edit') }}
</el-button>
<el-button @click="onDelete(scope.row)" round type="danger" size="mini">
{{ $t('common.button.delete') }}
</el-button>
</template>
</el-table-column>
</el-table>
@@ -90,6 +98,20 @@ export default defineComponent({
}
});
},
onDelete(row: IArticle) {
this.$confirm(this.$t('common.message.confirmDelete'), this.$t('common.button.info'), {
confirmButtonText: this.$t('common.button.confirm'),
cancelButtonText: this.$t('common.button.cancel'),
type: 'warning'
}).then(() => {
if (!row.id) {
return;
}
ArticleService.delete(row.id).then((): void => {
this.items = this.items.filter((item) => item.id !== row.id);
});
});
},
onCreate() {
ArticleService.create({}).then(({ data: data }: { data: IArticleDetailResponse }): void => {
console.log('data', data);