content.blade.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. @extends('layouts.base')
  2. @section('title', '商学院管理')
  3. @section('content')
  4. <link rel="stylesheet" href="{{resource_get('plugins/aggregation-cps/static/index.css')}}">
  5. <style>
  6. .edit-i{display:none;}
  7. .el-table_1_column_2:hover .edit-i{font-weight:900;padding:0;margin:0;display:inline-block;}
  8. .el-tabs__item,.is-top{font-size:16px}
  9. .el-tabs__active-bar { height: 3px;}
  10. </style>
  11. <div class="all">
  12. <div id="app" v-cloak>
  13. <div class="vue-crumbs">
  14. {!! (defined('CPS_PLUGIN_NAME') ? CPS_PLUGIN_NAME : '聚合CPS') !!} > 商学院管理
  15. </div>
  16. <div class="vue-main">
  17. <div class="vue-main-form">
  18. <div class="vue-main-title" style="margin-bottom:20px">
  19. <div class="vue-main-title-left"></div>
  20. <div class="vue-main-title-content" style="flex:0 0 400px">栏目:[[column_title]]</div>
  21. <div class="" style="text-align:left;font-size:12px;color:#999">
  22. <span>内容数量:[[total]]</span>&nbsp;&nbsp;&nbsp;
  23. </div>
  24. <div class="vue-main-title-button">
  25. <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addModal">添加内容</el-button>
  26. </div>
  27. </div>
  28. <el-table :data="list" style="width: 100%">
  29. <el-table-column label="排序" align="center" prop="sort" width="70">
  30. </el-table-column>
  31. <el-table-column label="内容主图" align="center">
  32. <template slot-scope="scope">
  33. <img :src="scope.row.img_url" style="width:50px;height:50px;">
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="内容名称" align="center" prop="title" >
  37. </el-table-column>
  38. <el-table-column label="是否显示" align="center" width="80">
  39. <template slot-scope="scope">
  40. <div>
  41. <el-tooltip placement="top">
  42. <div slot="content">[[scope.row.is_show==1?'显示':'隐藏']]</div>
  43. <el-switch v-model="scope.row.is_show" @change="changeHide(scope.row.id,scope.row.is_show)" :active-value="1" :inactive-value="0"></el-switch>
  44. </el-tooltip>
  45. </div>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" align="center" >
  49. <template slot-scope="scope">
  50. <div>
  51. <el-button type="primary" @click="editChild(scope.row)">编辑</el-button>
  52. <el-button type="primary" @click="del(scope.row.id,scope.row)">删除</el-button>
  53. </div>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </div>
  58. </div>
  59. <!-- 分页 -->
  60. <div class="vue-page" v-if="total>0">
  61. <el-row>
  62. <el-col align="right">
  63. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  64. :page-size="per_page" :current-page="current_page" background
  65. ></el-pagination>
  66. </el-col>
  67. </el-row>
  68. </div>
  69. </div>
  70. </div>
  71. <script>
  72. let academy_id = {!! $academy_id?:0 !!};
  73. let column_title = '{!! $column_title?:0 !!}';
  74. var app = new Vue({
  75. el: "#app",
  76. delimiters: ['[[', ']]'],
  77. name: 'test',
  78. data() {
  79. return {
  80. list:[],
  81. column_title:column_title,
  82. search_form:{
  83. title:'',
  84. },
  85. // 统计
  86. academy_id : academy_id ,
  87. total: 0,
  88. rules: {},
  89. current_page:1,
  90. per_page:1,
  91. }
  92. },
  93. created() {
  94. },
  95. mounted() {
  96. this.getData(1);
  97. },
  98. methods: {
  99. getData(page) {
  100. let json = {
  101. academy_id:academy_id,
  102. page:page,
  103. title:this.search_form.title,
  104. };
  105. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  106. this.$http.post('{!! yzWebFullUrl('plugin.aggregation-cps.admin.commerce-academy.get-content') !!}',json).then(function(response) {
  107. if (response.data.result) {
  108. this.list = response.data.data.data;
  109. this.current_page=response.data.data.current_page;
  110. this.total=response.data.data.total;
  111. this.per_page=response.data.data.per_page;
  112. loading.close();
  113. } else {
  114. this.$message({
  115. message: response.data.msg,
  116. type: 'error'
  117. });
  118. }
  119. loading.close();
  120. }, function(response) {
  121. this.$message({
  122. message: response.data.msg,
  123. type: 'error'
  124. });
  125. loading.close();
  126. });
  127. },
  128. search(val) {
  129. this.getData(val);
  130. },
  131. // 编辑
  132. editChild(item) {
  133. let link = `{!! yzWebFullUrl('plugin.aggregation-cps.admin.commerce-academy.add-content') !!}`+`&id=`+item.id;
  134. window.location.href = link;
  135. },
  136. del(id,index) {
  137. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  138. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  139. this.$http.post('{!! yzWebFullUrl('plugin.aggregation-cps.admin.commerce-academy.delete-column') !!}',{id:id}).then(function (response) {
  140. if (response.data.result) {
  141. this.list.splice(index,1);
  142. this.$message({type: 'success',message: '删除成功!'});
  143. }
  144. else{
  145. this.$message({type: 'error',message: response.data.msg});
  146. }
  147. loading.close();
  148. this.search(this.current_page)
  149. },function (response) {
  150. this.$message({type: 'error',message: response.data.msg});
  151. loading.close();
  152. }
  153. );
  154. }).catch(() => {
  155. this.$message({type: 'info',message: '已取消删除'});
  156. });
  157. },
  158. // 设置显不显示
  159. changeHide(id,is_show) {
  160. let json = {
  161. id:id,
  162. is_show:is_show,
  163. }
  164. let url = `{!! yzWebFullUrl('plugin.aggregation-cps.admin.commerce-academy.is-show') !!}`;
  165. console.log(json);
  166. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  167. this.$http.post(url,json).then(function (response) {
  168. if (response.data.result) {
  169. this.$message({type: 'success',message: '操作成功!'});
  170. }
  171. else{
  172. this.$message({type: 'error',message: response.data.msg});
  173. }
  174. loading.close();
  175. this.search(this.current_page);
  176. },function (response) {
  177. this.$message({type: 'error',message: response.data.msg});
  178. loading.close();
  179. })
  180. },
  181. // 添加
  182. addModal() {
  183. let link = `{!! yzWebFullUrl('plugin.aggregation-cps.admin.commerce-academy.add-content',['academy_id' =>$academy_id]) !!}`;
  184. console.log(link);
  185. window.location.href = link;
  186. },
  187. },
  188. })
  189. </script>
  190. @endsection