category-list.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. @extends('layouts.base')
  2. @section('title', '案例分类管理')
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}"/>
  5. <div class="all">
  6. <div id="app" v-cloak>
  7. <div class="vue-crumbs">
  8. 案例库 > 案例分类
  9. </div>
  10. <div class="vue-head">
  11. <div class="vue-main-title" style="margin-bottom:20px">
  12. <div class="vue-main-title-left"></div>
  13. <div class="vue-main-title-content">案例分类</div>
  14. <div class="vue-main-title-button">
  15. <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addFirst">添加一级分类</el-button>
  16. </div>
  17. </div>
  18. <div class="vue-search">
  19. <el-input v-model="name" style="width:40%"></el-input>
  20. <el-button type="primary" @click="search(1)">搜索</el-button>
  21. <el-link class="el-link-assist" :underline="false" @click="openAll">
  22. 全部展开
  23. </el-link>
  24. <el-link class="el-link-assist" :underline="false" @click="closeAll" style="margin-left:20px;">
  25. 全部折叠
  26. </el-link>
  27. </div>
  28. </div>
  29. <div class="vue-main">
  30. <div class="vue-main-form">
  31. <el-table
  32. v-if="show_table"
  33. :data="list"
  34. row-key="id"
  35. ref="table"
  36. default-expand-all
  37. :tree-props="{children: 'sub_category'}"
  38. style="width: 100%"
  39. >
  40. <el-table-column prop="category_name" label="分类名称"></el-table-column>
  41. <el-table-column prop="refund_time" label="操作" align="left" width="400">
  42. <template slot-scope="scope">
  43. <div style="text-align:left">
  44. <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;">
  45. <i class="iconfont icon-ht_operation_add"></i>
  46. </el-link>
  47. <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;">
  48. <i class="iconfont icon-ht_operation_add"></i>
  49. </el-link>
  50. <el-link title="编辑分类" :underline="false" @click="editChild(scope.row)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
  51. <i class="iconfont icon-ht_operation_edit"></i>
  52. </el-link>
  53. <el-link title="删除分类" :underline="false" @click="del(scope.row.id,scope.$index)" style="text-align: left;display: inline-block;font-size:26px;width:50px;">
  54. <i class="iconfont icon-ht_operation_delete"></i>
  55. </el-link>
  56. </div>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. </div>
  62. <!-- 分页 -->
  63. <div class="vue-page">
  64. <el-row v-if="total>0">
  65. <el-col align="right">
  66. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  67. :page-size="per_page" :current-page="current_page" background
  68. ></el-pagination>
  69. </el-col>
  70. </el-row>
  71. </div>
  72. </div>
  73. </div>
  74. <script>
  75. var app = new Vue({
  76. el: "#app",
  77. delimiters: ['[[', ']]'],
  78. name: 'test',
  79. data() {
  80. return {
  81. list:[],
  82. name:'',
  83. rules: {},
  84. thirdShow:false,
  85. show_table:true,
  86. current_page:1,
  87. total:1,
  88. per_page:1,
  89. }
  90. },
  91. created() {
  92. },
  93. mounted() {
  94. this.getData(1);
  95. },
  96. methods: {
  97. getData(page) {
  98. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  99. this.show_table = false;
  100. let search = {
  101. name:this.name
  102. };
  103. this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-list') !!}',{page:page,search:search}).then(function(response) {
  104. if (response.data.result) {
  105. this.list = response.data.data.list.data;
  106. this.current_page=response.data.data.list.current_page;
  107. this.total=response.data.data.list.total;
  108. this.per_page=response.data.data.list.per_page;
  109. // this.thirdShow=response.data.data.thirdShow;
  110. loading.close();
  111. this.show_table = true;
  112. } else {
  113. this.$message({
  114. message: response.data.msg,
  115. type: 'error'
  116. });
  117. this.show_table = true;
  118. }
  119. loading.close();
  120. }, function(response) {
  121. this.$message({
  122. message: response.data.msg,
  123. type: 'error'
  124. });
  125. loading.close();
  126. this.show_table = true;
  127. });
  128. },
  129. search(val) {
  130. if(this.name == "") {
  131. this.getData(val);
  132. return;
  133. }
  134. this.show_table = false;
  135. let search = {
  136. category_name:this.name
  137. };
  138. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  139. this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-list') !!}',{page:val,search:search}).then(function(response) {
  140. if (response.data.result) {
  141. this.list = response.data.data.list.data;
  142. this.current_page=response.data.data.list.current_page;
  143. this.total=response.data.data.list.total;
  144. this.per_page=response.data.data.list.per_page;
  145. this.show_table = true;
  146. this.$forceUpdate()
  147. // this.thirdShow=response.data.thirdShow;
  148. loading.close();
  149. } else {
  150. this.$message({
  151. message: response.data.msg,
  152. type: 'error'
  153. });
  154. this.show_table = false;
  155. }
  156. loading.close();
  157. }, function(response) {
  158. this.$message({
  159. message: response.data.msg,
  160. type: 'error'
  161. });
  162. loading.close();
  163. this.show_table = false;
  164. });
  165. },
  166. openAll() {
  167. this.list.forEach((item,index) => {
  168. // this.$refs.table.toggleRowExpansion(item, true)
  169. if(this.list[index].sub_category && this.list[index].sub_category.length>0) {
  170. this.$refs.table.toggleRowExpansion(item, true)
  171. }
  172. })
  173. },
  174. closeAll() {
  175. this.list.forEach((item,index) => {
  176. if(this.list[index].sub_category && this.list[index].sub_category.length>0) {
  177. this.$refs.table.toggleRowExpansion(item, false)
  178. }
  179. })
  180. },
  181. // 添加一级分类
  182. addFirst() {
  183. let link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-add') !!}`+`&level=1`;
  184. window.location.href = link;
  185. },
  186. // 添加子分类
  187. addChild(item) {
  188. let link = '';
  189. link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-add') !!}`+`&pid=`+item.id+`&level=2`;
  190. window.location.href = link;
  191. },
  192. // 编辑子分类
  193. editChild(item) {
  194. let link = `{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-edit') !!}`+`&id=`+item.id;
  195. window.location.href = link;
  196. },
  197. del(id,index) {
  198. console.log(id,index)
  199. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  200. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  201. this.$http.post('{!! yzWebFullUrl('plugin.case-library.admin.case-category.category-del') !!}',{id:id}).then(function (response) {
  202. console.log(response.data);
  203. if (response.data.result) {
  204. // this.list.splice(index,1);
  205. this.$message({type: 'success',message: '删除成功!'});
  206. window.location.reload();
  207. }
  208. else{
  209. this.$message({type: 'error',message: response.data.msg});
  210. }
  211. loading.close();
  212. },function (response) {
  213. this.$message({type: 'error',message: response.data.msg});
  214. loading.close();
  215. }
  216. );
  217. }).catch(() => {
  218. this.$message({type: 'info',message: '已取消删除'});
  219. });
  220. },
  221. },
  222. })
  223. </script>
  224. @endsection