| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <template>
- <el-container>
- <el-header height="220">
- <el-row style="margin-top: 10px">
- <el-button type="plain" icon="el-icon-plus" @click="createAlbumDiaglog = true">创建相册</el-button>
- </el-row>
- </el-header>
- <el-main>
- <el-table
- :data="dataList"
- style="width: 100%"
- >
- <el-table-column
- type="index"
- />
- <el-table-column
- prop="coverUrl"
- label="相册封面"
- width="90"
- >
- <template slot-scope="scope">
- <el-image
- lazy
- fit="cover"
- class="coverImg"
- :src="scope.row.coverUrl"
- />
- </template>
- </el-table-column>
- <el-table-column
- prop="createdAt"
- label="发布时间"
- />
- <el-table-column
- prop="albumName"
- label="相册名字"
- width="180"
- >
- <template slot-scope="scope">
- <router-link style="text-decoration-line: none" target="_blank" :to="`/image/album/${scope.row.albumId}`">
- <span>{{ scope.row.albumName }}</span>
- </router-link>
- </template>
- </el-table-column>
- <el-table-column
- prop="total"
- label="图片数量"
- />
- <el-table-column
- prop="scope"
- label="可见范围"
- >
- <template slot-scope="scope">
- <el-tooltip class="item" effect="dark" content="点击修改可见范围" placement="top-end">
- <el-button
- v-if="scope.row.scope === 1"
- size="mini"
- @click="handleScope(scope.$index, scope.row)"
- >本人可见</el-button>
- <el-button
- v-else-if="scope.row.scope === 2"
- size="mini"
- type="success"
- @click="handleScope(scope.$index, scope.row)"
- >所有人可见</el-button>
- <el-button
- v-else-if="scope.row.scope === 3"
- size="mini"
- type="warning"
- @click="handleScope(scope.$index, scope.row)"
- >VIP 可见</el-button>
- <el-button
- v-else
- size="mini"
- type="danger"
- @click="handleScope(scope.$index, scope.row)"
- >验证码可见</el-button>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column label="操作">
- <template slot-scope="scope">
- <el-button
- size="mini"
- @click="handleEdit(scope.$index, scope.row)"
- >编辑</el-button>
- <el-button
- size="mini"
- type="danger"
- @click="handleDelete(scope.$index, scope.row)"
- >删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- background
- :small="screenWidth <= 768"
- layout="prev, pager, next"
- :page-size="pageSize"
- :current-page="currentPage"
- :total="totalSize"
- @current-change="handleCurrentChange"
- @prev-click="handleCurrentChange"
- @next-click="handleCurrentChange"
- />
- </el-main>
- <!-- 创建相册对话框 -->
- <el-dialog
- append-to-body
- :visible.sync="createAlbumDiaglog"
- width="30%"
- center
- >
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <span>创建相册</span>
- <el-button style="float: right; padding: 3px 0" type="text" @click="onCreateAlbum">确定</el-button>
- </div>
- <div class="text item">
- <el-form ref="form" :model="form" label-width="80px">
- <el-form-item label="相册名">
- <el-input v-model="form.albumName" style="width: 70%; padding-right: 2px" placeholder="相册名不能超过 50 个字符" />
- </el-form-item>
- <el-form-item label="可见范围">
- <el-select v-model="form.scope" placeholder="选择可见范围">
- <el-option label="本人可见" value="1" />
- <el-option label="所有人可见" value="2" />
- <el-option label="VIP 可见" value="3" />
- <el-option label="验证码可见" value="4" />
- </el-select>
- </el-form-item>
- </el-form>
- </div>
- </el-card>
- </el-dialog>
- <!-- 修改可见范围对话框 -->
- <el-dialog
- append-to-body
- :visible.sync="showEditScopeDialog"
- width="30%"
- center
- >
- <el-card class="box-card">
- <div slot="header" class="clearfix">
- <span>修改相册可见范围</span>
- <el-button style="float: right; padding: 3px 0" type="text" @click="onUpdateScope">更新</el-button>
- </div>
- <div class="text item">
- <el-select v-model="form.scope" placeholder="选择可见范围">
- <el-option label="本人可见" value="1" />
- <el-option label="所有人可见" value="2" />
- <el-option label="VIP 可见" value="3" />
- <el-option label="验证码可见" value="4" />
- </el-select>
- </div>
- </el-card>
- </el-dialog>
- </el-container>
- </template>
- <script>
- import { updateAlbumScope, deleteAlbum, getUserAlbums, submitAlbum } from '@/api/image'
- export default {
- name: 'ImagePost',
- data() {
- return {
- // 屏幕宽度, 为了控制分页条的大小
- screenWidth: document.body.clientWidth,
- currentPage: 1,
- pageSize: 12,
- totalSize: 0,
- dataList: [],
- // **********************************************************************
- showEditScopeDialog: false,
- form: {
- albumId: null,
- scope: '1'
- },
- createAlbumDiaglog: false
- }
- },
- created() {
- document.title = '相册稿件'
- this.getData()
- },
- methods: {
- handleCurrentChange(pageNumber) {
- this.currentPage = pageNumber
- this.getData()
- // 回到顶部
- scrollTo(0, 0)
- },
- getData() {
- this.dataList = []
- getUserAlbums(this.currentPage).then(resp => {
- if (resp.code === 0) {
- this.dataList = resp.data.list
- this.totalSize = resp.data.totalSize
- } else {
- this.$notify({
- title: '提示',
- message: resp.msg,
- type: 'warning',
- duration: 3000
- })
- }
- })
- },
- handleScope(index, row) {
- this.form.albumId = row.albumId
- this.form.scope = '' + row.scope
- this.showEditScopeDialog = true
- },
- handleEdit(index, row) {
- const path = '/post/edit/album/' + row.albumId
- this.$router.push(path)
- },
- handleDelete(index, row) {
- this.$confirm('确定要删除 ' + row.albumName + ' 相册?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deleteAlbum(row.albumId).then(res => {
- if (res.code === 0) {
- this.$notify({
- title: '相册稿件已删除',
- type: 'warning',
- duration: 3000
- })
- // this.$router.go(0)
- }
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- })
- })
- },
- onCreateAlbum() {
- this.createAlbumDiaglog = false
- submitAlbum(this.form).then(res => {
- if (res.code === 0) {
- this.$message.info('相册已创建')
- } else {
- this.$notify({
- title: '提示',
- message: res.msg,
- type: 'warning',
- duration: 3000
- })
- }
- }).catch(error => {
- this.$notify({
- title: '提示',
- message: error.message,
- type: 'warning',
- duration: 3000
- })
- })
- },
- onUpdateScope() {
- this.showEditScopeDialog = false
- updateAlbumScope(this.form).then(res => {
- if (res.code === 0) {
- this.$notify({
- title: '提示',
- message: res.msg,
- type: 'warning',
- duration: 3000
- })
- } else {
- this.$notify({
- title: '提示',
- message: res.msg,
- type: 'warning',
- duration: 3000
- })
- }
- }).catch(error => {
- this.$notify({
- title: '提示',
- message: error.message,
- type: 'warning',
- duration: 3000
- })
- })
- }
- }
- }
- </script>
- <style>
- /*处于手机屏幕时*/
- @media screen and (max-width: 768px) {
- .tit {
- font-weight: 600;
- font-size: 12px;
- height: 32px;
- }
- .time {
- font-size: 10px;
- color: #999;
- }
- .num {
- font-size: 9px;
- padding-top: 3px;
- }
- .bottom {
- margin-top: 2px;
- line-height: 7px;
- }
- .coverImg {
- height: 120px !important;
- }
- }
- .coverImg {
- width: 100%;
- height: 90px;
- display: block;
- }
- </style>
|