<template>
|
<TableLayout :permissions="['business:ywh5banner:query']">
|
<el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="88px" inline>
|
<el-form-item label="标题" prop="title">
|
<el-input v-model="searchForm.title" placeholder="请输入标题" clearable @keypress.enter.native="search" />
|
</el-form-item>
|
<el-form-item label="状态" prop="status">
|
<el-select v-model="searchForm.status" clearable placeholder="全部">
|
<el-option :value="0" label="启用" />
|
<el-option :value="1" label="禁用" />
|
</el-select>
|
</el-form-item>
|
<section>
|
<el-button type="primary" icon="el-icon-search" @click="search">查询</el-button>
|
<el-button icon="el-icon-refresh" @click="reset">重置</el-button>
|
</section>
|
</el-form>
|
|
<template v-slot:table-wrap>
|
<ul class="toolbar">
|
<li>
|
<el-button
|
type="primary"
|
icon="el-icon-plus"
|
@click="$refs.editWindow.open('新建轮播图')"
|
v-permissions="['business:ywh5banner:create']"
|
>新建</el-button>
|
</li>
|
<li>
|
<el-button
|
icon="el-icon-delete"
|
@click="deleteByIdInBatch"
|
v-permissions="['business:ywh5banner:delete']"
|
>批量删除</el-button>
|
</li>
|
</ul>
|
|
<el-table
|
v-loading="isWorking.search"
|
:data="tableData.list"
|
stripe
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="48" />
|
<el-table-column label="预览" width="160" align="center">
|
<template slot-scope="{ row }">
|
<el-image
|
v-if="row.imageUrl"
|
:src="row.imageUrl"
|
:preview-src-list="[row.imageUrl]"
|
fit="cover"
|
class="banner-thumb"
|
/>
|
<span v-else>-</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="title" label="标题" min-width="140" show-overflow-tooltip />
|
<el-table-column prop="sortnum" label="排序" width="80" align="center" />
|
<el-table-column label="状态" width="100" align="center">
|
<template slot-scope="{ row }">
|
<el-switch
|
v-model="row.status"
|
:active-value="0"
|
:inactive-value="1"
|
:disabled="!containPermissions(['business:ywh5banner:update'])"
|
@change="changeStatus(row)"
|
/>
|
</template>
|
</el-table-column>
|
<el-table-column prop="linkUrl" label="跳转链接" min-width="160" show-overflow-tooltip />
|
<el-table-column prop="editDate" label="更新时间" width="168" align="center" />
|
<el-table-column label="操作" width="140" align="center" fixed="right">
|
<template slot-scope="{ row }">
|
<el-button
|
type="text"
|
@click="$refs.editWindow.open('编辑轮播图', row)"
|
v-permissions="['business:ywh5banner:update']"
|
>编辑</el-button>
|
<el-button
|
type="text"
|
class="red"
|
@click="deleteById(row)"
|
v-permissions="['business:ywh5banner:delete']"
|
>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
@size-change="handleSizeChange"
|
@current-change="handlePageChange"
|
:pagination="tableData.pagination"
|
/>
|
</template>
|
|
<YwH5BannerEdit ref="editWindow" @success="handlePageChange" />
|
</TableLayout>
|
</template>
|
|
<script>
|
import BaseTable from '@/components/base/BaseTable'
|
import TableLayout from '@/layouts/TableLayout'
|
import Pagination from '@/components/common/Pagination'
|
import YwH5BannerEdit from './components/YwH5BannerEdit'
|
import { updateById } from '@/api/business/ywh5banner'
|
import { Message } from 'element-ui'
|
|
export default {
|
name: 'YwH5Banner',
|
extends: BaseTable,
|
components: { TableLayout, Pagination, YwH5BannerEdit },
|
data () {
|
return {
|
searchForm: {
|
title: '',
|
status: null
|
}
|
}
|
},
|
created () {
|
this.config({
|
module: 'H5轮播图',
|
api: '/business/ywh5banner',
|
'field.id': 'id',
|
'field.main': 'title'
|
})
|
this.search()
|
},
|
methods: {
|
buildSearchModel () {
|
const model = {}
|
if (this.searchForm.title) model.title = this.searchForm.title
|
if (this.searchForm.status !== null && this.searchForm.status !== '') {
|
model.status = this.searchForm.status
|
}
|
return model
|
},
|
reset () {
|
this.searchForm = { title: '', status: null }
|
this.search()
|
},
|
handlePageChange (pageIndex) {
|
this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
|
this.isWorking.search = true
|
this.api.fetchList({
|
page: this.tableData.pagination.pageIndex,
|
capacity: this.tableData.pagination.pageSize,
|
model: this.buildSearchModel(),
|
sorts: this.tableData.sorts
|
})
|
.then(data => {
|
this.tableData.list = data.records
|
this.tableData.pagination.total = data.total
|
})
|
.catch(() => {})
|
.finally(() => { this.isWorking.search = false })
|
},
|
changeStatus (row) {
|
updateById({ id: row.id, status: row.status })
|
.then(() => {
|
Message.success('状态已更新')
|
})
|
.catch(() => {
|
row.status = row.status === 0 ? 1 : 0
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.banner-thumb {
|
width: 128px;
|
height: 56px;
|
border-radius: 4px;
|
border: 1px solid #ebeef5;
|
}
|
|
.red {
|
color: #f56c6c;
|
}
|
</style>
|