2019-04-25 14:45:28 +00:00
|
|
|
|
<template>
|
|
|
|
|
<div class="page-header-index-wide">
|
|
|
|
|
<a-row
|
|
|
|
|
:gutter="12"
|
|
|
|
|
type="flex"
|
|
|
|
|
align="middle"
|
|
|
|
|
>
|
|
|
|
|
<a-col
|
|
|
|
|
:span="24"
|
|
|
|
|
class="search-box"
|
|
|
|
|
>
|
2019-08-31 15:18:07 +00:00
|
|
|
|
<a-card :bordered="false" :bodyStyle="{ padding: '16px' }">
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<div class="table-page-search-wrapper">
|
|
|
|
|
<a-form layout="inline">
|
|
|
|
|
<a-row :gutter="48">
|
|
|
|
|
<a-col
|
|
|
|
|
:md="6"
|
|
|
|
|
:sm="24"
|
|
|
|
|
>
|
|
|
|
|
<a-form-item label="关键词">
|
|
|
|
|
<a-input v-model="queryParam.keyword" />
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col
|
|
|
|
|
:md="6"
|
|
|
|
|
:sm="24"
|
|
|
|
|
>
|
|
|
|
|
<a-form-item label="分组">
|
|
|
|
|
<a-select>
|
|
|
|
|
<a-select-option value="11">11</a-select-option>
|
|
|
|
|
<a-select-option value="22">22</a-select-option>
|
|
|
|
|
</a-select>
|
|
|
|
|
</a-form-item>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col
|
|
|
|
|
:md="6"
|
|
|
|
|
:sm="24"
|
|
|
|
|
>
|
|
|
|
|
<span class="table-page-search-submitButtons">
|
|
|
|
|
<a-button
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="loadPhotos(true)"
|
|
|
|
|
>查询</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
style="margin-left: 8px;"
|
|
|
|
|
@click="resetParam"
|
|
|
|
|
>重置</a-button>
|
|
|
|
|
</span>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
|
|
|
|
</a-form>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="table-operator">
|
|
|
|
|
<a-button
|
|
|
|
|
type="primary"
|
|
|
|
|
icon="plus"
|
2019-04-25 15:27:58 +00:00
|
|
|
|
@click="handleAddClick"
|
2019-04-25 14:45:28 +00:00
|
|
|
|
>添加</a-button>
|
|
|
|
|
</div>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-col :span="24">
|
|
|
|
|
<a-list
|
|
|
|
|
:grid="{ gutter: 12, xs: 1, sm: 2, md: 4, lg: 6, xl: 6, xxl: 6 }"
|
|
|
|
|
:dataSource="photos"
|
|
|
|
|
:loading="listLoading"
|
|
|
|
|
>
|
|
|
|
|
<a-list-item
|
|
|
|
|
slot="renderItem"
|
|
|
|
|
slot-scope="item, index"
|
|
|
|
|
:key="index"
|
|
|
|
|
>
|
|
|
|
|
<a-card
|
|
|
|
|
:bodyStyle="{ padding: 0 }"
|
|
|
|
|
hoverable
|
|
|
|
|
@click="showDrawer(item)"
|
|
|
|
|
>
|
2019-04-25 15:27:58 +00:00
|
|
|
|
<div class="photo-thumb">
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<img :src="item.thumbnail">
|
|
|
|
|
</div>
|
|
|
|
|
<a-card-meta>
|
|
|
|
|
<ellipsis
|
|
|
|
|
:length="isMobile()?36:18"
|
|
|
|
|
tooltip
|
|
|
|
|
slot="description"
|
|
|
|
|
>{{ item.name }}</ellipsis>
|
|
|
|
|
</a-card-meta>
|
|
|
|
|
</a-card>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
</a-list>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
2019-04-26 14:46:20 +00:00
|
|
|
|
<div class="page-wrapper">
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<a-pagination
|
|
|
|
|
:total="pagination.total"
|
|
|
|
|
:defaultPageSize="pagination.size"
|
|
|
|
|
:pageSizeOptions="['18', '36', '54','72','90','108']"
|
|
|
|
|
showSizeChanger
|
|
|
|
|
@change="handlePaginationChange"
|
|
|
|
|
@showSizeChange="handlePaginationChange"
|
|
|
|
|
/>
|
2019-04-26 14:46:20 +00:00
|
|
|
|
</div>
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<a-drawer
|
|
|
|
|
title="图片详情"
|
|
|
|
|
:width="isMobile()?'100%':'460'"
|
|
|
|
|
closable
|
2019-08-27 14:48:56 +00:00
|
|
|
|
:visible="drawerVisible"
|
2019-04-25 14:45:28 +00:00
|
|
|
|
destroyOnClose
|
|
|
|
|
@close="onDrawerClose"
|
|
|
|
|
>
|
|
|
|
|
<a-row
|
|
|
|
|
type="flex"
|
|
|
|
|
align="middle"
|
|
|
|
|
>
|
|
|
|
|
<a-col :span="24">
|
|
|
|
|
<a-skeleton
|
|
|
|
|
active
|
|
|
|
|
:loading="drawerLoading"
|
|
|
|
|
:paragraph="{rows: 8}"
|
|
|
|
|
>
|
2019-04-25 15:27:58 +00:00
|
|
|
|
<div class="photo-detail-img">
|
|
|
|
|
<img
|
2019-05-05 15:29:26 +00:00
|
|
|
|
:src="photo.url || '//i.loli.net/2019/05/05/5ccf007c0a01d.png'"
|
2019-04-25 15:27:58 +00:00
|
|
|
|
@click="showThumbDrawer"
|
|
|
|
|
>
|
2019-04-25 14:45:28 +00:00
|
|
|
|
</div>
|
|
|
|
|
</a-skeleton>
|
|
|
|
|
</a-col>
|
|
|
|
|
<a-divider />
|
|
|
|
|
<a-col :span="24">
|
|
|
|
|
<a-skeleton
|
|
|
|
|
active
|
|
|
|
|
:loading="drawerLoading"
|
|
|
|
|
:paragraph="{rows: 8}"
|
|
|
|
|
>
|
|
|
|
|
<a-list itemLayout="horizontal">
|
2019-04-25 15:27:58 +00:00
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
|
|
|
|
<a-input v-model="photo.thumbnail" />
|
|
|
|
|
</template>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.thumbnail }}</template>
|
|
|
|
|
<span slot="title">
|
|
|
|
|
缩略图地址:
|
|
|
|
|
</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
|
|
|
|
<a-input v-model="photo.name" />
|
|
|
|
|
</template>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.name }}</template>
|
|
|
|
|
<span slot="title">
|
|
|
|
|
图片名称:
|
|
|
|
|
</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
2019-05-31 16:23:23 +00:00
|
|
|
|
<a-date-picker
|
|
|
|
|
v-model="photo.takeTime"
|
|
|
|
|
style="width:100%"
|
|
|
|
|
/>
|
2019-04-25 14:45:28 +00:00
|
|
|
|
</template>
|
|
|
|
|
<span
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.takeTime | moment }}</span>
|
|
|
|
|
<span slot="title">拍摄日期:</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
|
|
|
|
<a-input v-model="photo.location" />
|
|
|
|
|
</template>
|
|
|
|
|
<span
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.location || '无' }}</span>
|
|
|
|
|
<span slot="title">拍摄地点:</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
|
|
|
|
<a-input v-model="photo.team" />
|
|
|
|
|
</template>
|
|
|
|
|
<span
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.team || '无' }}</span>
|
|
|
|
|
<span slot="title">分组:</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
<a-list-item>
|
|
|
|
|
<a-list-item-meta>
|
|
|
|
|
<template
|
|
|
|
|
slot="description"
|
|
|
|
|
v-if="editable"
|
|
|
|
|
>
|
|
|
|
|
<a-input
|
|
|
|
|
v-model="photo.description"
|
|
|
|
|
type="textarea"
|
|
|
|
|
:autosize="{ minRows: 5 }"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
<span
|
|
|
|
|
slot="description"
|
|
|
|
|
v-else
|
|
|
|
|
>{{ photo.description || '无' }}</span>
|
|
|
|
|
<span slot="title">描述:</span>
|
|
|
|
|
</a-list-item-meta>
|
|
|
|
|
</a-list-item>
|
|
|
|
|
</a-list>
|
|
|
|
|
</a-skeleton>
|
|
|
|
|
</a-col>
|
|
|
|
|
</a-row>
|
2019-04-25 15:27:58 +00:00
|
|
|
|
<AttachmentSelectDrawer
|
|
|
|
|
v-model="thumDrawerVisible"
|
|
|
|
|
@listenToSelect="selectPhotoThumb"
|
|
|
|
|
:drawerWidth="460"
|
|
|
|
|
/>
|
2019-05-31 16:23:23 +00:00
|
|
|
|
<a-divider class="divider-transparent" />
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<div class="bottom-control">
|
2019-04-25 15:27:58 +00:00
|
|
|
|
<a-button
|
|
|
|
|
type="dashed"
|
|
|
|
|
style="marginRight: 8px"
|
|
|
|
|
@click="handleEditClick"
|
|
|
|
|
v-if="!editable"
|
|
|
|
|
>编辑</a-button>
|
|
|
|
|
<a-button
|
|
|
|
|
type="primary"
|
|
|
|
|
style="marginRight: 8px"
|
|
|
|
|
@click="handleCreateOrUpdate"
|
|
|
|
|
v-else
|
|
|
|
|
>保存</a-button>
|
2019-04-25 14:45:28 +00:00
|
|
|
|
<a-popconfirm
|
|
|
|
|
title="你确定要删除该图片?"
|
|
|
|
|
okText="确定"
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
@confirm="handleDeletePhoto"
|
|
|
|
|
>
|
|
|
|
|
<a-button type="danger">删除</a-button>
|
|
|
|
|
</a-popconfirm>
|
|
|
|
|
</div>
|
|
|
|
|
</a-drawer>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-04-25 15:27:58 +00:00
|
|
|
|
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
|
2019-04-25 14:45:28 +00:00
|
|
|
|
import { mixin, mixinDevice } from '@/utils/mixin.js'
|
|
|
|
|
import photoApi from '@/api/photo'
|
|
|
|
|
|
|
|
|
|
export default {
|
2019-04-25 15:27:58 +00:00
|
|
|
|
components: {
|
|
|
|
|
AttachmentSelectDrawer
|
|
|
|
|
},
|
2019-04-25 14:45:28 +00:00
|
|
|
|
mixins: [mixin, mixinDevice],
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2019-08-27 14:48:56 +00:00
|
|
|
|
drawerVisible: false,
|
2019-04-25 14:45:28 +00:00
|
|
|
|
drawerLoading: false,
|
|
|
|
|
listLoading: true,
|
2019-04-25 15:27:58 +00:00
|
|
|
|
thumDrawerVisible: false,
|
2019-04-25 14:45:28 +00:00
|
|
|
|
photo: {},
|
|
|
|
|
photos: [],
|
|
|
|
|
editable: false,
|
|
|
|
|
pagination: {
|
|
|
|
|
page: 1,
|
|
|
|
|
size: 18,
|
|
|
|
|
sort: null
|
|
|
|
|
},
|
|
|
|
|
queryParam: {
|
|
|
|
|
page: 0,
|
|
|
|
|
size: 18,
|
|
|
|
|
sort: null,
|
2019-04-25 15:27:58 +00:00
|
|
|
|
keyword: null
|
2019-04-25 14:45:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.loadPhotos()
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
loadPhotos(isSearch) {
|
|
|
|
|
this.queryParam.page = this.pagination.page - 1
|
|
|
|
|
this.queryParam.size = this.pagination.size
|
|
|
|
|
this.queryParam.sort = this.pagination.sort
|
|
|
|
|
if (isSearch) {
|
|
|
|
|
this.queryParam.page = 0
|
|
|
|
|
}
|
|
|
|
|
this.listLoading = true
|
|
|
|
|
photoApi.query(this.queryParam).then(response => {
|
|
|
|
|
this.photos = response.data.data.content
|
|
|
|
|
this.pagination.total = response.data.data.total
|
|
|
|
|
this.listLoading = false
|
|
|
|
|
})
|
|
|
|
|
},
|
2019-04-25 15:27:58 +00:00
|
|
|
|
handleCreateOrUpdate() {
|
|
|
|
|
if (this.photo.id) {
|
|
|
|
|
photoApi.update(this.photo.id, this.photo).then(response => {
|
2019-05-31 14:35:09 +00:00
|
|
|
|
this.$message.success('照片更新成功!')
|
2019-05-09 13:15:27 +00:00
|
|
|
|
this.loadPhotos()
|
2019-04-25 15:27:58 +00:00
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
photoApi.create(this.photo).then(response => {
|
2019-05-31 14:35:09 +00:00
|
|
|
|
this.$message.success('照片添加成功!')
|
2019-05-09 13:15:27 +00:00
|
|
|
|
this.loadPhotos()
|
2019-04-25 15:27:58 +00:00
|
|
|
|
this.photo = response.data.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
this.editable = false
|
|
|
|
|
},
|
2019-04-25 14:45:28 +00:00
|
|
|
|
showDrawer(photo) {
|
|
|
|
|
this.photo = photo
|
2019-08-27 14:48:56 +00:00
|
|
|
|
this.drawerVisible = true
|
2019-04-25 14:45:28 +00:00
|
|
|
|
},
|
|
|
|
|
handlePaginationChange(page, size) {
|
|
|
|
|
this.$log.debug(`Current: ${page}, PageSize: ${size}`)
|
|
|
|
|
this.pagination.page = page
|
|
|
|
|
this.pagination.size = size
|
|
|
|
|
this.loadPhotos()
|
|
|
|
|
},
|
2019-04-25 15:27:58 +00:00
|
|
|
|
handleAddClick() {
|
|
|
|
|
this.editable = true
|
2019-08-27 14:48:56 +00:00
|
|
|
|
this.drawerVisible = true
|
2019-04-25 15:27:58 +00:00
|
|
|
|
},
|
2019-04-25 14:45:28 +00:00
|
|
|
|
handleEditClick() {
|
|
|
|
|
this.editable = true
|
|
|
|
|
},
|
|
|
|
|
handleDeletePhoto() {
|
|
|
|
|
photoApi.delete(this.photo.id).then(response => {
|
|
|
|
|
this.$message.success('删除成功!')
|
2019-04-25 15:27:58 +00:00
|
|
|
|
this.onDrawerClose()
|
|
|
|
|
this.loadPhotos()
|
2019-04-25 14:45:28 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
2019-04-25 15:27:58 +00:00
|
|
|
|
showThumbDrawer() {
|
|
|
|
|
this.thumDrawerVisible = true
|
|
|
|
|
},
|
|
|
|
|
selectPhotoThumb(data) {
|
2019-07-16 13:43:20 +00:00
|
|
|
|
this.photo.url = encodeURI(data.path)
|
2019-04-25 15:27:58 +00:00
|
|
|
|
this.thumDrawerVisible = false
|
|
|
|
|
},
|
2019-04-25 14:45:28 +00:00
|
|
|
|
resetParam() {
|
|
|
|
|
this.queryParam.keyword = null
|
|
|
|
|
this.loadPhotos()
|
|
|
|
|
},
|
|
|
|
|
onDrawerClose() {
|
2019-08-27 14:48:56 +00:00
|
|
|
|
this.drawerVisible = false
|
2019-04-25 15:27:58 +00:00
|
|
|
|
this.photo = {}
|
|
|
|
|
this.editable = false
|
2019-04-25 14:45:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.ant-divider-horizontal {
|
|
|
|
|
margin: 24px 0 12px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-box {
|
|
|
|
|
padding-bottom: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 15:27:58 +00:00
|
|
|
|
.photo-thumb {
|
2019-04-25 14:45:28 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
position: relative;
|
|
|
|
|
padding-bottom: 56%;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
img {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ant-card-meta {
|
|
|
|
|
padding: 0.8rem;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-25 15:27:58 +00:00
|
|
|
|
.photo-detail-img img {
|
2019-04-25 14:45:28 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.table-operator {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|