add detail edit

This commit is contained in:
AceDataCloud committed 2021-08-29 01:14:54 +08:00
1 parent 83b9afcd33
commit 15631b6b6a
11 files changed
+197 -21

No files matched your search

+89
View File
@@ -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>
+66
View File
@@ -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>
+7 -5
View File
@@ -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>