| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <style>
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>标签列表</span>
- <div style="float: right;margin-top: -5px">
- <el-button type="primary" @click="edit" size="small">添加标签</el-button>
- </div>
- </div>
- </div>
- <div class="table-body">
- <el-form :inline="true" size="small" class="demo-form-inline">
- <el-form-item>
- <el-input @keyup.enter.native="search" size="small" placeholder="请输入搜索内容" v-model="keyword" clearable @clear="getList">
- <el-button slot="append" icon="el-icon-search" @click="search"></el-button>
- </el-input>
- </el-form-item>
- </el-form>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column prop="id" label="ID" width="100">
- </el-table-column>
- <el-table-column label="标签名称" width="350px">
- <template slot-scope="scope">
- <com-ellipsis :line="1">{{scope.row.title}}</com-ellipsis>
- </template>
- </el-table-column>
- <el-table-column label="副标题">
- <template slot-scope="scope">
- <com-ellipsis :line="1">{{scope.row.sub_title}}</com-ellipsis>
- </template>
- </el-table-column>
- <el-table-column prop="sort" label="排序" width="150">
- <template slot-scope="scope">
- <div v-if="id != scope.row.id">
- <el-tooltip class="item" effect="dark" content="排序" placement="top">
- <span>{{scope.row.sort}}</span>
- </el-tooltip>
- <el-button class="edit-sort" type="text" @click="editSort(scope.row)">
- <img src="resources/img/mall/order/edit.png" alt="">
- </el-button>
- </div>
- <div style="display: flex;align-items: center" v-else>
- <el-input style="min-width: 70px" type="number" size="mini" class="change" v-model="sort" autocomplete="off"></el-input>
- <el-button class="change-quit" type="text" style="color: #F56C6C;padding: 0 5px" icon="el-icon-error" circle @click="quit()"></el-button>
- <el-button class="change-success" type="text" style="margin-left: 0;color: #67C23A;padding: 0 5px" icon="el-icon-success" circle @click="operate('sort',scope.row)">
- </el-button>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="created_at" width="220" label="添加日期">
- <template slot-scope="scope">
- <div>{{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="220">
- <template slot-scope="scope">
- <el-button type="text" @click="edit(scope.row.id)">编辑</el-button>
- <el-button type="text" @click="operate('destroy',scope.row)">删除</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: [],
- listLoading: false,
- page: 1,
- keyword: '',
- pageCount: 0,
- sort: 0,
- id: null,
- };
- },
- mounted: function() {
- this.getList();
- },
- methods: {
- search(){
- this.page = 1;
- this.getList();
- },
- editSort(row) {
- this.id = row.id;
- this.sort = row.sort;
- },
- quit() {
- this.id = null;
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- getList() {
- let self = this;
- self.listLoading = true;
- let keyword = this.keyword;
- let params = {
- r: 'mall/goods/label',
- page: self.page
- }
- if (keyword) params.keyword = keyword;
- request({
- params: params,
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.list = e.data.data.list;
- self.pageCount = e.data.data.page_count;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.listLoading = false;
- });
- },
- // 跳转编辑页
- edit(id) {
- id = parseInt(id);
- let params = {
- r: 'mall/goods/label-edit'
- };
- if (id) params = Object.assign(params, {
- id: id
- });
- navigateTo(params);
- },
- operate(type, data = null) {
- let param = { id: this.id, type: type };
- switch (type) {
- case 'sort':
- param.sort = this.sort;
- this.send(param);
- break;
- case 'destroy':
- this.$confirm('删除该条数据后不可以恢复, 是否继续?', '警告', {
- type: 'warning'
- }).then(() => {
- this.send(param)
- })
- break;
- }
- },
- send(params) {
- let self = this;
- request({
- params: {
- r: 'mall/goods/label',
- },
- method: 'post',
- data: params
- }).then(e => {
- if (e.data.code == 0) {
- self.$message.success(e.data.msg);
- self.getList();
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- }
- }
- });
- </script>
|