add detail edit
This commit is contained in:
1 parent
83b9afcd33
commit
15631b6b6a
11 files changed
+197
-21
No files matched your search
@@ -6,7 +6,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
items: this.$route.matched
|
||||
@@ -15,7 +17,7 @@ export default {
|
||||
mounted() {
|
||||
console.log('this', this.$route);
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<el-menu class="h-full" router :default-active="$route.name">
|
||||
<el-menu-item index="article" @select="onSelect">
|
||||
<el-menu-item index="article-index" @select="onSelect">
|
||||
<el-icon class="mr-2">
|
||||
<document />
|
||||
</el-icon>
|
||||
<template #title>{{ $t('content.nav.article') }}</template>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="platform">
|
||||
<el-menu-item index="platform-index">
|
||||
<el-icon class="mr-2">
|
||||
<box />
|
||||
</el-icon>
|
||||
@@ -18,8 +18,9 @@
|
||||
<script lang="ts">
|
||||
import { Document, Box } from '@element-plus/icons';
|
||||
import routes from '@/router/content';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
export default {
|
||||
export default defineComponent({
|
||||
components: {
|
||||
Document,
|
||||
Box
|
||||
@@ -33,11 +34,11 @@ export default {
|
||||
console.log(this.$route);
|
||||
},
|
||||
methods: {
|
||||
onSelect(val) {
|
||||
onSelect(val: string) {
|
||||
this.$router.push({
|
||||
name: val
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
@@ -1,3 +1,4 @@
|
||||
export default {
|
||||
setup: '配置'
|
||||
setup: '配置',
|
||||
edit: '编辑'
|
||||
};
|
||||
@@ -1,7 +1,9 @@
|
||||
export default {
|
||||
platform: '平台',
|
||||
title: '标题',
|
||||
icon: '图标',
|
||||
status: '状态',
|
||||
operation: '操作',
|
||||
description: '描述'
|
||||
description: '描述',
|
||||
updatedAt: '更新时间'
|
||||
};
|
||||
@@ -2,5 +2,6 @@ export default {
|
||||
editor: '编辑器',
|
||||
home: '首页',
|
||||
content: '内容',
|
||||
platform: '平台'
|
||||
platform: '平台',
|
||||
article: '文章'
|
||||
};
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<div class="px-4 pt-4">
|
||||
<el-card shadow="hover">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<div id="vditor" class="vditor" />
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vditor from 'vditor';
|
||||
import { Breadcrumb } from '@/components/common/index';
|
||||
import { defaultOptions } from '@/settings/editor';
|
||||
import 'vditor/src/assets/scss/index.scss';
|
||||
import { defineComponent } from 'vue';
|
||||
import { ArticleService } from '@/services';
|
||||
import { IArticle, IArticleDetailResponse } from '@/services/article/types';
|
||||
|
||||
interface IData {
|
||||
id: string | string[];
|
||||
vditor: null | Vditor;
|
||||
item: null | IArticle;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
Breadcrumb
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
id: this.$route.params.id,
|
||||
vditor: null,
|
||||
item: null,
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
ArticleService.get(this.id).then(({ data: data }: { data: IArticleDetailResponse }): void => {
|
||||
console.log('data', data);
|
||||
this.item = data;
|
||||
this.loading = false;
|
||||
if (this.vditor && this.item) {
|
||||
this.vditor.setValue(this.item.content);
|
||||
}
|
||||
});
|
||||
this.initVditor();
|
||||
},
|
||||
computed: {},
|
||||
methods: {
|
||||
initVditor() {
|
||||
const options = {
|
||||
width: '100%',
|
||||
height: '0',
|
||||
tab: '\t',
|
||||
mode: 'ir',
|
||||
icon: 'material',
|
||||
debugger: false,
|
||||
after: () => {
|
||||
if (this.vditor?.getValue) {
|
||||
return;
|
||||
}
|
||||
if (this.item?.content) {
|
||||
this.vditor?.setValue(this.item.content);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.vditor = new Vditor('vditor', {
|
||||
...defaultOptions,
|
||||
...options
|
||||
});
|
||||
// this.vditor.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.vditor {
|
||||
// margin: 50px auto;
|
||||
height: calc(100vh - 200px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="24">
|
||||
<div class="px-4 pt-4">
|
||||
<el-card shadow="hover">
|
||||
<div class="mb-5">
|
||||
<breadcrumb />
|
||||
</div>
|
||||
<el-table :data="items" v-loading="loading">
|
||||
<el-table-column prop="title" :label="$t('common.entity.title')"> </el-table-column>
|
||||
<el-table-column prop="updated_at" :label="$t('common.entity.updatedAt')"> </el-table-column>
|
||||
<el-table-column :label="$t('common.entity.operation')">
|
||||
<template #default="scope">
|
||||
<el-button @click="onEdit(scope.row)" round type="primary" size="small">
|
||||
{{ $t('common.button.edit') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Breadcrumb } from '@/components/common/index';
|
||||
import ArticleService from '@/services/article/service';
|
||||
import { IArticle, IArticleListResponse } from '@/services/article/types';
|
||||
import { defineComponent } from 'vue';
|
||||
|
||||
interface IData {
|
||||
items: IArticle[];
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
Breadcrumb
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
items: [],
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
async mounted() {
|
||||
this.loading = true;
|
||||
ArticleService.getAll().then(({ data: data }: { data: IArticleListResponse }): void => {
|
||||
console.log('data', data);
|
||||
this.items = data.results;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onEdit(row: IArticle) {
|
||||
this.$router.push({
|
||||
name: 'article-edit',
|
||||
params: {
|
||||
id: row.id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -16,9 +16,11 @@
|
||||
<el-table-column prop="description" :label="$t('common.entity.description')"> </el-table-column>
|
||||
<el-table-column :label="$t('common.entity.status')"> </el-table-column>
|
||||
<el-table-column :label="$t('common.entity.operation')">
|
||||
<el-button @click="onSetup" round type="primary" size="small">
|
||||
{{ $t('common.button.setup') }}
|
||||
</el-button>
|
||||
<template #default="scope">
|
||||
<el-button @click="onSetup(scope.row)" round type="primary" size="small">
|
||||
{{ $t('common.button.setup') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
@@ -57,9 +59,9 @@ export default defineComponent({
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
onSetup() {
|
||||
onSetup(row) {
|
||||
console.log('333');
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
+11
-3
@@ -18,15 +18,23 @@ export default {
|
||||
},
|
||||
{
|
||||
path: 'article',
|
||||
name: 'article',
|
||||
name: 'article-index',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/content/Article.vue')
|
||||
component: () => import('@/pages/content/article/Index.vue')
|
||||
},
|
||||
{
|
||||
path: 'article/:id',
|
||||
name: 'article-edit',
|
||||
meta: {
|
||||
title: t('common.nav.article')
|
||||
},
|
||||
component: () => import('@/pages/content/article/Detail.vue')
|
||||
},
|
||||
{
|
||||
path: 'platform',
|
||||
name: 'platform',
|
||||
name: 'platform-index',
|
||||
meta: {
|
||||
title: t('common.nav.platform')
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ class ArticleService {
|
||||
return await httpClient.get(`/${this.key}`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
async get(id: string | string[]): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ class ArticleService {
|
||||
return httpClient.post(`/${this.key}`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
async update(id: string | string[], data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
async delete(id: string | string[]): Promise<AxiosResponse<null>> {
|
||||
return httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
export interface IArticle {
|
||||
id: number;
|
||||
title: string;
|
||||
cover: string;
|
||||
summary: string;
|
||||
content: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface IArticleListResponse {
|
||||
|
||||
Reference in new issue
Block a user