| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <style>
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- display: inline-block;
- width: 250px;
- margin: 0 0 20px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .table-body .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- .form-body {
- background-color: #fff;
- margin-bottom: 20px;
- }
- .el-tabs__header {
- background-color: #fff;
- }
- .el-tabs__item {
- width: 100px;
- text-align: center;
- }
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper,
- .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>广告设置</span>
- <div style="float: right">
- <el-button type="primary" size="small" style="padding: 9px 15px !important;" @click="add">创建广告
- </el-button>
- </div>
- </div>
- </div>
- <div class="table-body">
- <!-- <div class="input-item">
- <el-input @keyup.enter.native="search" size="small" placeholder="请输入广告名称" v-model="keyword" @clear="search">
- <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
- </el-input>
- </div> -->
- <!-- <div style="margin-bottom: 15px;" flex>
- <div flex>
- <div flex="cross:center" class="input-search">
- <div style="flex-shrink: 0;">课程名称:</div>
- <el-input @keyup.enter.native="search" size="small" placeholder="请输入课程名称" v-model="keyword" @clear="search"></el-input>
- </div>
- <div flex="cross:center" class="input-search">
- <div class="input-item-name">状态:</div>
- <div>
- <el-select v-model="searchData.status" placeholder="请选择" size="small">
- <el-option label="全部" :value="0"></el-option>
- <el-option v-for="(item,index) in status_text" :key="index" :label="item" :value="index">{{item}}
- </el-option>
- </el-select>
- </div>
- </div>
- </div>
- <div>
- <el-button type="primary" size="small" @click="search" style="padding: 9px 15px !important;">搜索</el-button>
- <el-button type="warning" @click="clereSearch" v-if="keyword" style="padding: 9px 15px !important;">清除搜索条件</el-button>
- </div>
- </div> -->
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <!-- <el-table-column label="ID" prop="id" width="80">
- <template slot-scope="scope">
- <div size="small">{{scope.row.id}}</div>
- </template>
- </el-table-column>
- <el-table-column label="商城ID" prop="mall_id">
- <template slot-scope="scope">
- <div size="small">{{scope.row.mall_id}}</div>
- </template>
- </el-table-column> -->
- <!-- <el-table-column label="分类ID" prop="id" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.id}}</div>
- </template>
- </el-table-column>
- <el-table-column label="分类 LOGO " prop="logo" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">
- <com-image width='80px' height='80px' :src=scope.row.logo></com-image>
- </div>
- </template>
- </el-table-column> -->
- <el-table-column label="排序" prop="sort" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.sort}}</div>
- </template>
- </el-table-column>
- <el-table-column label="名称" prop="title" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.title}}</div>
- </template>
- </el-table-column>
- <el-table-column label="图片" prop="pic_path" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">
- <com-image width='50px' height='50px' :src=scope.row.pic_path></com-image>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="是否启用" prop="content" min-width="100" align="center">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.is_show" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="不启用" @change="isUse($event, scope.row.id)"> </el-switch>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" prop="created_at" min-width="100" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="100" align="center">
- <template slot-scope="scope">
- <el-button circle type="text" size="mini" @click="bannarEdit(scope.row.id, scope.$index)"> 编辑 </el-button>
- <el-button circle type="text" size="mini" @click="bannarDelete(scope.row.id, scope.$index)"> 删除 </el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- status: 0,
- list: [],
- keyword: '',
- listLoading: false,
- page: 1,
- pageCount: 0,
- dialogFormVisible: false, //充值弹窗
- lableLoading: false,
- btnLoading: false,
- addStatus: 1, //默认是增加
- selectIndex: 0, //充值item的索引
- selectRow: {},
- form: {
- sort: null,
- title: '',
- created_at: null,
- }
- };
- },
- methods: {
- search() {
- this.page = 1;
- this.getList();
- },
- clereSearch() {
- this.keyword = '';
- this.page = 1;
- this.getList();
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- // 获取广告列表
- getList() {
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'course/default/bannars',
- page: self.page,
- keyword: this.keyword
- },
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- self.list = e.data.data.list;
- self.pageCount = e.data.data.page_count;
- }).catch(e => {
- console.log(e);
- });
- },
- // 新建
- add() {
- navigateTo({
- r: 'course/bannar/storage',
- });
- },
- // 编辑
- bannarEdit(id) {
- navigateTo({
- r: 'course/bannar/storage',
- id: id,
- });
- },
- // 屏蔽状态切换
- isUse($event, id) {
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'course/bannar/switch-status'
- },
- method: 'post',
- data: {
- id: id,
- val: $event
- }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- bannarDelete(id, index) {
- let self = this;
- self.$confirm('是否删除广告?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- self.listLoading = true;
- // console.log(id,'1111')
- request({
- params: {
- r: 'course/bannar/delete',
- },
- method: 'post',
- data: {
- id: id,
- }
- }).then(e => {
- self.listLoading = false;
- if (e.data.code === 0) {
- self.$message.success(e.data.msg);
- self.list.splice(index, 1);
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- }).catch(() => {
- // self.$message.info('已取消删除')
- });
- }
- },
- mounted: function() {
- this.getList();
- }
- });
- </script>
|