This commit is contained in:
LiYang 2016-08-02 19:56:59 +08:00
parent 1e045d073c
commit e98437b02e
8 changed files with 71 additions and 34 deletions

View File

@ -14,7 +14,7 @@ class CreateAnnouncementSerializer(serializers.Serializer):
class AnnouncementSerializer(serializers.ModelSerializer):
create_time = DateTimeTZField()
last_update_time = DateTimeTZField
last_update_time = DateTimeTZField()
class UserSerializer(serializers.ModelSerializer):
class Meta:

View File

@ -31,7 +31,7 @@
<td>{{ user.email }}</td>
<td>{{ $t(adminType[user.admin_type]) }}</td>
<td>
<button class="btn-sm btn-info" v-on:click="edit(user.id)">{{ $t("user.edit") }}</button>
<button class="btn-sm btn-info" v-on:click="edit(user.id)">{{ $t("adminUtils.edit") }}</button>
<a target="_blank" href="/submissions/?user_id={{ user.id }}">
{{ $t("user.submission") }}
</a>

View File

@ -3,12 +3,12 @@
<table class="table table-striped">
<tr>
<th>ID</th>
<th>{{ $t("announcement.title") }}</th>
<th>{{ $t("announcement.createTime") }}</th>
<th>{{ $t("announcement.lastUpdateTime") }}</th>
<th>{{ $t("announcement.createdBy") }}</th>
<th>{{ $t("announcement.isVisible") }}</th>
<th>{{ $t("announcement.management") }}</th>
<th>{{ $t("adminUtils.title") }}</th>
<th>{{ $t("adminUtils.createTime") }}</th>
<th>{{ $t("adminUtils.lastUpdateTime") }}</th>
<th>{{ $t("adminUtils.createdBy") }}</th>
<th>{{ $t("adminUtils.isVisible") }}</th>
<th>{{ $t("adminUtils.management") }}</th>
</tr>
<tr v-for="announcement in announcementList">
<td>{{ announcement.id }}</td>
@ -18,7 +18,7 @@
<td>{{ announcement.created_by.username }}</td>
<td>{{ $t(announcementStatus[announcement.visible?1:0]) }}</td>
<td>
<button class="btn-sm btn-info" v-on:click="edit(announcement.id)">{{ $t("announcement.edit") }}</button>
<button class="btn-sm btn-info" v-on:click="edit(announcement.id)">{{ $t("adminUtils.edit") }}</button>
</td>
</tr>
</table>
@ -34,7 +34,7 @@
export default({
data() {
return {
announcementStatus: ["announcement.visible", "announcement.invisible"],
announcementStatus: ["adminUtils.visible", "adminUtils.invisible"],
announcementList: [],
pagination: {
currentPage: 1,

View File

@ -5,11 +5,12 @@
<form v-on:submit="submit">
<div class="row">
<div class="form-group col-md-12">
<label>{{ $t("announcement.title") }}</label>
<label>{{ $t("adminUtils.title") }}</label>
<input type="text" class="form-control">
</div>
<div class="form-group col-md-12">
<simditor editorid="createAnnouncement"></simditor>
<label>{{ $t("adminUtils.content") }}</label>
<simditor editorid="createAnnouncement" v-ref:editor></simditor>
</div>
</div>
<div class="form-group">
@ -30,6 +31,8 @@
}
},
route: {
},
components: {
simditor
}

View File

@ -6,11 +6,12 @@
<form v-on:submit="submit">
<div class="row">
<div class="form-group col-md-12">
<label>{{ $t("announcement.title") }}</label>
<label>{{ $t("adminUtils.title") }}</label>
<input type="text" class="form-control">
</div>
<div class="form-group col-md-12">
<simditor editorid="editAnnouncement"></simditor>
<label>{{ $t("adminUtils.content") }}</label>
<simditor editorid="editAnnouncement" :content="content" v-ref:editor></simditor>
</div>
</div>
<div class="form-group">
@ -25,7 +26,10 @@
export default({
data() {
return {}
return {
announcement: {},
content: ""
}
},
methods: {
submit() {

View File

@ -3,7 +3,7 @@
<ul class="pagination pagination-lg">
<li class="{{ pagination.currentPage > 1 ? '' : 'disabled' }}">
<a href="#" aria-label="Previous" @click.prevent="changePage(1)">
<span aria-hidden="true">上一页</span>
<span aria-hidden="true">{{ $t("pagination.firstPage") }}</span>
</a>
</li>
<li class="{{ pagination.currentPage > 1 ? '' : 'disabled' }}">
@ -31,7 +31,7 @@
</li>
<li class="{{ pagination.currentPage < pagination.totalPages ? '' : 'disabled' }}">
<a href="#" aria-label="Next" @click.prevent="changePage(pagination.totalPages)">
<span aria-hidden="true">最后一页</span>
<span aria-hidden="true">{{ $t("pagination.lastPage") }}</span>
</a>
</li>
</ul>
@ -82,9 +82,11 @@
},
methods: {
changePage(page) {
this.$set('pagination.currentPage', page);
this.$router.go({name: this.$route.name, params: {page: page}});
this.callback();
if (page > 0 && page <= this.pagination.totalPages) {
this.$set('pagination.currentPage', page);
this.$router.go({name: this.$route.name, params: {page: page}});
this.callback();
}
}
}
};

View File

@ -6,10 +6,30 @@
import SimditorMakrdown from "simditor-markdown"
export default{
props: ["editorid"],
data() {
return {
editor: {}
}
},
props: {
editorid: {
required: true
},
content: {
required: true
}
},
methods: {
setContent(content){
this.editor.setValue(content);
},
getContent() {
return this.editor.getValue();
}
},
attached() {
var self = this;
var editor = new Simditor({
self.editor = new Simditor({
textarea: document.getElementById(self.editorid),
upload: {url: "/", fileKey: "file"},
toolbar: ['bold', 'italic', 'underline', 'color', 'image', 'ol', 'ul', 'markdown']

View File

@ -9,8 +9,8 @@ export default {
announcementManagement: "公告管理"
},
pagination: {
first: "首页",
last: "末页"
firstPage: "首页",
lastPage: "末页"
},
request: {
error: "请求失败",
@ -25,7 +25,7 @@ export default {
adminType: "用户类型",
createTime: "注册时间",
management: "管理",
edit: "编辑",
submission: "提交",
newPassword: "新密码",
leaveBlankIfDoNotChangePassword: "不需要修改密码请留空",
@ -48,20 +48,28 @@ export default {
announcementList: "公告列表",
editAnnouncement: "编辑公告",
createAnnouncement: "创建公告",
title: "标题",
createTime: "创建时间",
lastUpdateTime: "最后更新",
createdBy: "创建人",
isVisible: "是否可见",
visible: "可见",
invisible: "隐藏",
management: "管理",
edit: "编辑",
},
adminUtils: {
search: "搜索",
inputKeyword: "输入关键词",
submit: "提交",
edit: "编辑",
title: "标题",
createTime: "创建时间",
lastUpdateTime: "最后更新",
createdBy: "创建人",
isVisible: "是否可见",
visible: "可见",
invisible: "隐藏",
management: "管理",
content: "内容",
back: "返回",
saveChanges: "保存修改",