| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- <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="storage">创建分类
- </el-button>
- </div>
- </div>
- </div>
- <div class="table-body">
- <!-- <template>
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="轮播图" name="carousel">轮播图</el-tab-pane>
- <el-tab-pane label="分类栏" name="category">分类栏</el-tab-pane>
- </el-tabs>
- </template>
- <div class="input-item">
- <el-input @keyup.enter.native="search" size="small"
- placeholder="请输入广告名称"
- v-model="keyword"
- clearable
- @clear="search">
- <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
- </el-input>
- </div>
- -->
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column label="ID" prop="id" min-width="80" align="center"></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" align="center">
- <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.status" :active-value="1" :inactive-value="0" active-text="启用" inactive-text="不启用" @change="isUse(scope.row.status, 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="storage(scope.row.id)">编辑</el-button>
- <el-button circle type="text" size="mini" @click="categoryDelete(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 {
- activeName: 'category',
- status: 0,
- list: [],
- keyword: '',
- listLoading: false,
- page: 1,
- pageCount: 0,
- form: {
- sort: null,
- title: '',
- created_at: null,
- }
- };
- },
- methods: {
- handleClick(tab, event) {
- console.log(tab.name, 111111111111);
- if (tab.name === 'carousel') {
- let request_url = {
- r: 'lucky-group/banner/index'
- };
- } else if (tab.name === 'category') {
- let request_url = {
- r: 'lucky-group/category/index'
- };
- }
- navigateTo(this.path);
- },
- search() {
- 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: 'lucky-group/group-category/index',
- 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);
- });
- },
- // 新建 or 编辑
- storage(id = null) {
- if (!id) {
- navigateTo({
- r: 'lucky-group/group-category/storage',
- });
- } else {
- navigateTo({
- r: 'lucky-group/group-category/storage',
- id: id,
- });
- }
- },
- // 屏蔽状态切换
- isUse(event, id) {
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'lucky-group/group-category/switch-status'
- },
- method: 'post',
- data: {
- id: id,
- status: 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);
- });
- },
- categoryDelete(id, index) {
- let self = this;
- self.$confirm('是否删除广告?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- self.listLoading = true;
- // console.log(id,'1111')
- request({
- params: {
- r: 'lucky-group/group-category/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>
|