category.blade.php 9.3 KB

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