support created at and delete
This commit is contained in:
1 parent
74f62354a2
commit
82e101fc86
5 files changed
+32
-3
No files matched your search
@@ -3,5 +3,10 @@ export default {
|
||||
edit: '编辑',
|
||||
login: '登录',
|
||||
logout: '退出登录',
|
||||
new: '新建'
|
||||
new: '新建',
|
||||
delete: '删除',
|
||||
confirm: '确定',
|
||||
cancel: '取消',
|
||||
alert: '警告',
|
||||
info: '提示'
|
||||
};
|
||||
@@ -5,5 +5,6 @@ export default {
|
||||
status: '状态',
|
||||
operation: '操作',
|
||||
description: '描述',
|
||||
createdAt: '创建时间',
|
||||
updatedAt: '更新时间'
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
copied: '复制成功'
|
||||
copied: '复制成功',
|
||||
confirmDelete: '确认删除吗?'
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface IArticle {
|
||||
id?: number;
|
||||
id?: string;
|
||||
title?: string | undefined;
|
||||
cover?: string | undefined;
|
||||
summary?: string | undefined;
|
||||
|
||||
Reference in new issue
Block a user