| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- @extends('layouts.base')
- @section('title', '案例分类管理')
- @section('content')
- <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
- <div class="all">
- <div id="app" v-cloak>
- <div class="vue-crumbs">
- 案例库 > 案例分类
- </div>
- <div class="vue-head">
- <div class="vue-main-title" style="margin-bottom:20px">
- <div class="vue-main-title-left"></div>
- <div class="vue-main-title-content">案例分类</div>
- <div class="vue-main-title-button">
- <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addFirst">添加一级分类</el-button>
- </div>
- </div>
- <div class="vue-search">
- <el-input v-model="name" style="width:40%"></el-input>
- <el-button type="primary" @click="search(1)">搜索</el-button>
- <el-link class="el-link-assist" :underline="false" @click="openAll">
- 全部展开
- </el-link>
- <el-link class="el-link-assist" :underline="false" @click="closeAll" style="margin-left:20px;">
- 全部折叠
- </el-link>
- </div>
- </div>
-
- <div class="vue-main">
-
-
- <div class="vue-main-form">
- <el-table
- v-if="show_table"
- :data="list"
- row-key="id"
- ref="table"
- default-expand-all
- :tree-props="{children: 'sub_category'}"
- style="width: 100%"
- >
- <el-table-column prop="category_name" label="分类名称"></el-table-column>
- <el-table-column prop="refund_time" label="操作" align="left" width="400">
- <template slot-scope="scope">
- <div style="text-align:left">
- <el-link title="创建子分类" :underline="false" v-if="scope.row.sub_category && thirdShow" @click="addChild(scope.row)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
- <i class="iconfont icon-ht_operation_add"></i>
- </el-link>
- <el-link title="创建子分类" :underline="false" v-else-if="!thirdShow &&scope.row.pid==0" @click="addChild(scope.row)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
- <i class="iconfont icon-ht_operation_add"></i>
- </el-link>
- <el-link title="编辑分类" :underline="false" @click="editChild(scope.row)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
- <i class="iconfont icon-ht_operation_edit"></i>
- </el-link>
- <el-link title="删除分类" :underline="false" @click="del(scope.row.id,scope.$index)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
- <i class="iconfont icon-ht_operation_delete"></i>
- </el-link>
- </div>
-
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <!-- 分页 -->
- <div class="vue-page">
- <el-row v-if="total>0">
- <el-col align="right">
- <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
- :page-size="per_page" :current-page="current_page" background
- ></el-pagination>
- </el-col>
- </el-row>
- </div>
- </div>
- </div>
- <script>
- var app = new Vue({
- el: "#app",
- delimiters: ['[[', ']]'],
- name: 'test',
- data() {
- return {
- list:[],
- name:'',
- rules: {},
- thirdShow:false,
- show_table:true,
- current_page:1,
- total:1,
- per_page:1,
- }
- },
- created() {
- },
- mounted() {
- this.getData(1);
- },
- methods: {
- getData(page) {
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.show_table = false;
- let search = {
- name:this.name
- };
- this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-list') !!}',{page:page,search:search}).then(function(response) {
- if (response.data.result) {
- this.list = response.data.data.list.data;
- this.current_page=response.data.data.list.current_page;
- this.total=response.data.data.list.total;
- this.per_page=response.data.data.list.per_page;
- // this.thirdShow=response.data.data.thirdShow;
- loading.close();
- this.show_table = true;
- } else {
- this.$message({
- message: response.data.msg,
- type: 'error'
- });
- this.show_table = true;
- }
- loading.close();
- }, function(response) {
- this.$message({
- message: response.data.msg,
- type: 'error'
- });
- loading.close();
- this.show_table = true;
- });
- },
-
- search(val) {
- if(this.name == "") {
- this.getData(val);
- return;
- }
- this.show_table = false;
- let search = {
- category_name:this.name
- };
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-list') !!}',{page:val,search:search}).then(function(response) {
- if (response.data.result) {
- this.list = response.data.data.list.data;
- this.current_page=response.data.data.list.current_page;
- this.total=response.data.data.list.total;
- this.per_page=response.data.data.list.per_page;
- this.show_table = true;
- this.$forceUpdate()
- // this.thirdShow=response.data.thirdShow;
- loading.close();
- } else {
- this.$message({
- message: response.data.msg,
- type: 'error'
- });
- this.show_table = false;
- }
- loading.close();
- }, function(response) {
- this.$message({
- message: response.data.msg,
- type: 'error'
- });
- loading.close();
- this.show_table = false;
- });
- },
- openAll() {
- this.list.forEach((item,index) => {
- // this.$refs.table.toggleRowExpansion(item, true)
- if(this.list[index].sub_category && this.list[index].sub_category.length>0) {
- this.$refs.table.toggleRowExpansion(item, true)
- }
- })
-
- },
- closeAll() {
- this.list.forEach((item,index) => {
- if(this.list[index].sub_category && this.list[index].sub_category.length>0) {
- this.$refs.table.toggleRowExpansion(item, false)
- }
- })
- },
- // 添加一级分类
- addFirst() {
- let link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-add') !!}`+`&level=1`;
- window.location.href = link;
- },
- // 添加子分类
- addChild(item) {
- let link = '';
- link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-add') !!}`+`&pid=`+item.id+`&level=2`;
- window.location.href = link;
- },
- // 编辑子分类
- editChild(item) {
- let link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-edit') !!}`+`&id=`+item.id;
- window.location.href = link;
- },
- del(id,index) {
- console.log(id,index)
- this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
- this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-del') !!}',{id:id}).then(function (response) {
- console.log(response.data);
- if (response.data.result) {
- // this.list.splice(index,1);
- this.$message({type: 'success',message: '删除成功!'});
- window.location.reload();
- }
- else{
- this.$message({type: 'error',message: response.data.msg});
- }
- loading.close();
- },function (response) {
- this.$message({type: 'error',message: response.data.msg});
- loading.close();
- }
- );
- }).catch(() => {
- this.$message({type: 'info',message: '已取消删除'});
- });
- },
-
- },
- })
- </script>
- @endsection
|