Refactor JournalList.vue.

pull/40/head
ruibaby 2019-09-06 12:27:44 +08:00
parent a2935dadd9
commit f375c9ed3e
1 changed files with 56 additions and 50 deletions

View File

@ -2,7 +2,10 @@
<div class="page-header-index-wide"> <div class="page-header-index-wide">
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<a-card :bordered="false" :bodyStyle="{ padding: '16px' }"> <a-card
:bordered="false"
:bodyStyle="{ padding: '16px' }"
>
<div class="table-page-search-wrapper"> <div class="table-page-search-wrapper">
<a-form layout="inline"> <a-form layout="inline">
<a-row :gutter="48"> <a-row :gutter="48">
@ -22,6 +25,7 @@
<a-select <a-select
placeholder="请选择状态" placeholder="请选择状态"
v-model="queryParam.type" v-model="queryParam.type"
@change="loadJournals(true)"
> >
<a-select-option <a-select-option
v-for="type in Object.keys(journalType)" v-for="type in Object.keys(journalType)"
@ -80,7 +84,7 @@
<img alt="example" :src="photo.thumbnail" slot="cover"> <img alt="example" :src="photo.thumbnail" slot="cover">
</a-card> --> </a-card> -->
<a-modal <!-- <a-modal
:visible="previewVisible" :visible="previewVisible"
:footer="null" :footer="null"
@cancel="handleCancelPreview" @cancel="handleCancelPreview"
@ -90,7 +94,7 @@
style="width: 100%" style="width: 100%"
:src="previewPhoto.url" :src="previewPhoto.url"
> >
</a-modal> </a-modal> -->
<template slot="actions"> <template slot="actions">
<span> <span>
@ -114,6 +118,16 @@
{{ item.commentCount }} {{ item.commentCount }}
</a> </a>
</span> </span>
<span v-if="item.type=='PRIVATE'">
<a href="javascript:void(0);" disabled>
<a-icon type="lock" />
</a>
</span>
<span v-else>
<a href="javascript:void(0);">
<a-icon type="unlock" />
</a>
</span>
<!-- <span> <!-- <span>
From 微信 From 微信
</span>--> </span>-->
@ -282,9 +296,9 @@
<script> <script>
import JournalCommentTree from './components/JournalCommentTree' import JournalCommentTree from './components/JournalCommentTree'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { mapGetters } from 'vuex'
import journalApi from '@/api/journal' import journalApi from '@/api/journal'
import journalCommentApi from '@/api/journalComment' import journalCommentApi from '@/api/journalComment'
import userApi from '@/api/user'
import UploadPhoto from '@/components/Upload/UploadPhoto.vue' import UploadPhoto from '@/components/Upload/UploadPhoto.vue'
export default { export default {
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -292,9 +306,9 @@ export default {
data() { data() {
return { return {
journalType: journalApi.journalType, journalType: journalApi.journalType,
plusPhotoVisible: true, // plusPhotoVisible: true,
photoList: [], // // photoList: [], //
previewVisible: false, // previewVisible: false,
showMoreOptions: false, showMoreOptions: false,
previewPhoto: { previewPhoto: {
// //
@ -321,47 +335,44 @@ export default {
}, },
journals: [], journals: [],
comments: [], comments: [],
journal: { journal: {},
id: undefined,
content: '',
photos: []
},
isPublic: true, isPublic: true,
journalPhotos: [], // journalPhotos: [], //
selectComment: null, selectComment: null,
replyComment: {}, replyComment: {}
user: {}
} }
}, },
created() { created() {
this.loadJournals() this.loadJournals()
this.loadUser() },
computed: {
...mapGetters(['user'])
}, },
methods: { methods: {
handleCancelPreview() { // handleCancelPreview() {
this.previewVisible = false // this.previewVisible = false
}, // },
handlerPhotoPreview(photo) { // handlerPhotoPreview(photo) {
// // //
this.previewVisible = true // this.previewVisible = true
this.previewPhoto = photo // this.previewPhoto = photo
}, // },
handlerPhotoUploadSuccess(response, file) { // handlerPhotoUploadSuccess(response, file) {
var callData = response.data.data // var callData = response.data.data
var photo = { // var photo = {
name: callData.name, // name: callData.name,
url: callData.path, // url: callData.path,
thumbnail: callData.thumbPath, // thumbnail: callData.thumbPath,
suffix: callData.suffix, // suffix: callData.suffix,
width: callData.width, // width: callData.width,
height: callData.height // height: callData.height
} // }
this.journalPhotos.push(photo) // this.journalPhotos.push(photo)
}, // },
handleUploadPhotoWallClick() { // handleUploadPhotoWallClick() {
// // //
this.showMoreOptions = !this.showMoreOptions // this.showMoreOptions = !this.showMoreOptions
}, // },
loadJournals(isSearch) { loadJournals(isSearch) {
this.queryParam.page = this.pagination.page - 1 this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size this.queryParam.size = this.pagination.size
@ -376,28 +387,23 @@ export default {
this.listLoading = false this.listLoading = false
}) })
}, },
loadUser() {
userApi.getProfile().then(response => {
this.user = response.data.data
})
},
handleNew() { handleNew() {
this.title = '新建' this.title = '新建'
this.visible = true this.visible = true
this.journal = {} this.journal = {}
// //
this.plusPhotoVisible = true // this.plusPhotoVisible = true
this.photoList = [] // this.photoList = []
}, },
handleEdit(item) { handleEdit(item) {
this.title = '编辑' this.title = '编辑'
this.journal = item this.journal = item
this.isPublic = item.type !== 'PRIVATE'
this.visible = true this.visible = true
// , // ,
this.plusPhotoVisible = false // this.plusPhotoVisible = false
this.photoList = item.photos // this.photoList = item.photos
}, },
handleDelete(id) { handleDelete(id) {
journalApi.delete(id).then(response => { journalApi.delete(id).then(response => {
@ -448,7 +454,7 @@ export default {
journalApi.create(this.journal).then(response => { journalApi.create(this.journal).then(response => {
this.$message.success('发表成功!') this.$message.success('发表成功!')
this.loadJournals() this.loadJournals()
this.photoList = [] // this.photoList = []
this.isPublic = true this.isPublic = true
}) })
} }