|
@@ -0,0 +1,89 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" @click="goEdit({id:0})">添加</el-button>
|
|
|
+ <el-table :data="items">
|
|
|
+ <el-table-column label="标题" prop="title"></el-table-column>
|
|
|
+ <el-table-column label="宣传图" prop="icon"></el-table-column>
|
|
|
+ <el-table-column label="跳转地址" prop="url"></el-table-column>
|
|
|
+ <el-table-column label="状态">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <template v-if="scope.row.status === 1">
|
|
|
+ <p class="online">启用</p>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <p class="offline">禁用</p>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <template v-if="scope.row.status == 0">
|
|
|
+ <el-button type="success" @click="setStatus(scope.row)">启用</el-button>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-button type="danger" @click="setStatus(scope.row)">禁用</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <el-button type="text" size="small" @click="goEdit(scope.row)">编辑</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ items: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getItems: function() {
|
|
|
+ this.$http.bannerList({}, this).then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.items = res.obj
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ setStatus: function(row) {
|
|
|
+ var status = row.status === 1 ? 0 : 1
|
|
|
+ var msg = status === 1 ? '启用' : '禁用'
|
|
|
+ this.$confirm(
|
|
|
+ '您确定要将此Banner设置为 "' + msg + '" , 是否继续?',
|
|
|
+ '提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ this.$http
|
|
|
+ .bannerSetStatus({ id: row.id, status: status }, this)
|
|
|
+ .then(res => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ this.$message({
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ row.status = status
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ goEdit:function(row){
|
|
|
+ this.$router.push({ path: '/editBanner', query: { id: row.id } })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted: function() {
|
|
|
+ this.getItems()
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style>
|
|
|
+.online {
|
|
|
+ color: #67c23a;
|
|
|
+}
|
|
|
+.offline {
|
|
|
+ color: #f56c6c;
|
|
|
+}
|
|
|
+</style>
|