| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <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(0)">添加分类
- </el-button>
- </div>
- </div>
- </div>
- <div class="table-body">
- <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="searchData.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="searchData.keyword || searchData.start_time || searchData.end_time" 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="分类名称" prop="cname" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.cname}}</div>
- </template>
- </el-table-column>
- <el-table-column label="分类 LOGO " prop="logo" min-width="80" align="center">
- <template slot-scope="scope">
- <div size="small">
- <!-- <img :src=scope.row.logo alt=""> -->
- <com-image width='50px' height='50px' :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="是否导航" width="120" align="center">
- <template slot-scope="scope">
- <el-switch :active-value="1" :inactive-value="0" @change="switchNavicat(scope.row)" v-model="scope.row.is_navicat">
- </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 type="text" size="mini" @click="storage(scope.row.id)" style="width:56px;height: 24px;">编辑</el-button>
- <el-button circle type="text" size="mini" @click="cateDelete(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 {
- list: [],
- searchData: {
- keyword: '',
- },
- listLoading: false,
- page: 1,
- pageCount: 0,
- };
- },
- methods: {
- search() {
- this.page = 1;
- this.getList();
- },
- clereSearch() {
- this.searchData.keyword = '';
- this.getList();
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- getList() {
- let self = this;
- self.listLoading = true;
- request({
- params: {
- r: 'course/default/categorys',
- page: self.page,
- ...this.searchData
- },
- 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);
- });
- },
- // 编辑/新建
- storage(id) {
- navigateTo({
- r: 'course/category/edit',
- id: id,
- });
- },
- cateDelete(id, index) {
- let self = this;
- self.$confirm('是否删除课程分类?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- self.listLoading = true;
- // console.log(id,'1111')
- request({
- params: {
- r: 'course/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('已取消删除')
- });
- },
- switchNavicat(row_data) {
- // console.log(is_navicat, row_data.is_navicat);
- this.listLoading = true;
- request({
- method: 'post',
- params: {
- r: 'course/category/switch-navicat',
- },
- data: {
- id: row_data.id,
- is_navicat: row_data.is_navicat,
- },
- }).then(e => {
- this.listLoading = false;
- if (e.data.code === 0) {
- this.$message.success(e.data.msg);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {});
- }
- },
- mounted: function() {
- this.getList();
- }
- });
- </script>
|