index.blade.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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?time='.time())}}" />
  5. <!-- 引入样式 -->
  6. <!-- 引入组件库 -->
  7. <link rel="stylesheet" href="{{static_url('../resources/views/goods/assets/css/common.css?time='.time())}}">
  8. <link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
  9. <style>
  10. .vue-main-set{
  11. background-color: red;
  12. }
  13. </style>
  14. <div class="all">
  15. <div id="app" v-cloak>
  16. <div class="vue-head goods-page_header">
  17. <div class="goods-page_header-buttons">
  18. <el-button type="text" :class="currentShowPage==1?'goods-page_header-current-button':''" @click="currentShowPage=1">商品标签列表</el-button>
  19. <el-button type="text" :class="currentShowPage==2?'goods-page_header-current-button':''" @click="currentShowPage=2">商品标签设置</el-button>
  20. </div>
  21. </div>
  22. <div v-if="currentShowPage==1">
  23. <div class="vue-main">
  24. <div class="vue-main-title" style="margin-bottom:20px">
  25. <div class="vue-main-title-left"></div>
  26. <div class="vue-main-title-content">商品标签组列表</div>
  27. <div class="vue-main-title-button">
  28. <el-button type="primary" plain icon="el-icon-plus" size="small" @click="addModal">添加标签组</el-button>
  29. </div>
  30. </div>
  31. <div class="vue-main-form">
  32. <el-table :data="list" style="width: 100%">
  33. <el-table-column label="ID" align="center" prop="id"></el-table-column>
  34. <el-table-column label="标签组名称" align="center" prop="name"></el-table-column>
  35. <el-table-column label="拥有标签个数" align="center" prop="filter_num"></el-table-column>
  36. <el-table-column label="是否启用" align="center">
  37. <template slot-scope="scope">
  38. <div>
  39. [[scope.row.is_show==1?'不启用':'启用']]
  40. </div>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="创建时间" align="center" prop="created_at"></el-table-column>
  44. <el-table-column prop="refund_time" label="操作" align="center" width="320">
  45. <template slot-scope="scope">
  46. <el-link title="查看标签" :underline="false" :href="'{{ yzWebUrl('filtering.filtering.filter-value', array('parent_id' => '')) }}'+[[scope.row.id]]" style="width:50px;">
  47. <i class="iconfont icon-ht_operation_tag"></i>
  48. </el-link>
  49. <el-link title="编辑标签" :underline="false" @click="gotoEdit(scope.row.id)" style="width:50px;">
  50. <i class="iconfont icon-ht_operation_edit"></i>
  51. </el-link>
  52. <el-link title="删除" :underline="false" @click="del(scope.row.id,scope.$index)" style="width:50px;">
  53. <i class="iconfont icon-ht_operation_delete"></i>
  54. </el-link>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. </div>
  59. </div>
  60. <!-- 分页 -->
  61. <div class="vue-page" v-if="total>0">
  62. <el-row>
  63. <el-col align="right">
  64. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  65. :page-size="per_page" :current-page="current_page" background
  66. ></el-pagination>
  67. </el-col>
  68. </el-row>
  69. </div>
  70. </div>
  71. <div v-if="currentShowPage==2">
  72. <div class="vue-main">
  73. <div class="vue-main-title" style="margin-bottom:20px">
  74. <div class="vue-main-title-left"></div>
  75. <div class="vue-main-title-content">商品标签设置</div>
  76. </div>
  77. <el-row :gutter="20">
  78. <el-col :span="10" :offset="5">
  79. <el-form ref="form">
  80. <el-form-item label="开启前端搜索标签">
  81. <el-switch v-model="set.is_search_show"
  82. active-color="#13ce66"
  83. :active-value="1"
  84. :inactive-value="0"
  85. ></el-switch>
  86. </el-form-item>
  87. <el-form-item size="large">
  88. <el-button type="primary" @click="saveSet()">保存</el-button>
  89. </el-form-item>
  90. </el-form>
  91. </el-col>
  92. </el-row>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <script>
  98. var app = new Vue({
  99. el: "#app",
  100. delimiters: ['[[', ']]'],
  101. name: 'test',
  102. data() {
  103. return {
  104. currentShowPage:1,
  105. list:[],
  106. change_sort:'',
  107. times:[],
  108. search_form:{
  109. },
  110. set:{
  111. is_search_show:0,
  112. },
  113. rules: {},
  114. current_page:1,
  115. total:1,
  116. per_page:1,
  117. }
  118. },
  119. created() {
  120. },
  121. mounted() {
  122. this.getData(1);
  123. this.getSet();
  124. },
  125. methods: {
  126. getData(page) {
  127. let that = this;
  128. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  129. this.$http.post('{!! yzWebFullUrl('filtering.filtering.filtering-data') !!}',{page:page}).then(function(response) {
  130. if (response.data.result) {
  131. this.list = response.data.data.data;
  132. this.current_page=response.data.data.current_page;
  133. this.total=response.data.data.total;
  134. this.per_page=response.data.data.per_page;
  135. loading.close();
  136. } else {
  137. this.$message({
  138. message: response.data.msg,
  139. type: 'error'
  140. });
  141. }
  142. loading.close();
  143. }, function(response) {
  144. this.$message({
  145. message: response.data.msg,
  146. type: 'error'
  147. });
  148. loading.close();
  149. });
  150. },
  151. search(val) {
  152. this.getData(val);
  153. },
  154. // 添加新品牌
  155. addModal() {
  156. let link = `{!! yzWebFullUrl('filtering.filtering.edit-view') !!}`+`&partent_id=0`;
  157. window.location.href = link;
  158. },
  159. gotoEdit(id) {
  160. let link = `{!! yzWebFullUrl('filtering.filtering.edit-view') !!}`+`&partent_id=0&id=`+id;
  161. window.location.href = link;
  162. },
  163. del(id,index) {
  164. console.log(id,index)
  165. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  166. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  167. this.$http.post('{!! yzWebFullUrl('filtering.filtering.del') !!}',{id:id}).then(function (response) {
  168. if (response.data.result) {
  169. this.list.splice(index,1);
  170. this.$message({type: 'success',message: '删除成功!'});
  171. }
  172. else{
  173. this.$message({type: 'error',message: response.data.msg});
  174. }
  175. loading.close();
  176. this.search(this.current_page)
  177. },function (response) {
  178. this.$message({type: 'error',message: response.data.msg});
  179. loading.close();
  180. }
  181. );
  182. }).catch(() => {
  183. this.$message({type: 'info',message: '已取消删除'});
  184. });
  185. },
  186. saveSet(){
  187. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  188. this.$http.post('{!! yzWebFullUrl('filtering.filtering.saveSet') !!}',this.set).then(function (response) {
  189. if (response.data.result) {
  190. this.$message({type: 'success',message: response.data.msg});
  191. }
  192. else{
  193. this.$message({type: 'error',message: response.data.msg});
  194. }
  195. loading.close();
  196. },function (response) {
  197. this.$message({type: 'error',message: response.data.msg});
  198. loading.close();
  199. }
  200. );
  201. },
  202. getSet(){
  203. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  204. this.$http.post('{!! yzWebFullUrl('filtering.filtering.getSet') !!}').then(function (response) {
  205. if (response.data.result) {
  206. this.set = response.data.data;
  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. },
  218. // 编辑排序
  219. editTitle(index) {
  220. let that = this;
  221. that.change_sort = "";
  222. that.change_sort = that.list[index].display_order;
  223. },
  224. confirmChangeSort(id) {
  225. let that = this;
  226. if (!(/^\d+$/.test(that.change_sort))) {
  227. that.$message.error('请输入正确数字');
  228. return false;
  229. }
  230. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  231. let json = {id: id, sort: that.change_sort};
  232. that.$http.post("{!! yzWebFullUrl('goods.dispatch.sort-v2') !!}", json).then(response => {
  233. console.log(response);
  234. if (response.data.result == 1) {
  235. that.$message.success('操作成功!');
  236. // that.$refs.search_form.click();
  237. if (document.all) {
  238. document.getElementById('app').click();
  239. } else {// 其它浏览器
  240. var e = document.createEvent('MouseEvents')
  241. e.initEvent('click', true, true)
  242. document.getElementById('app').dispatchEvent(e)
  243. }
  244. that.search(this.current_page);
  245. } else {
  246. that.$message.error(response.data.msg);
  247. }
  248. loading.close();
  249. }), function (res) {
  250. console.log(res);
  251. loading.close();
  252. };
  253. },
  254. // 快速修改
  255. changeStatus(id,index,type,value) {
  256. let that = this;
  257. let json = {id: id, type: type, status: value};
  258. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  259. that.$http.post("{!! yzWebFullUrl('goods.dispatch.quick-edit') !!}", json).then(response => {
  260. console.log(response);
  261. if (response.data.result == 1) {
  262. that.$message.success('操作成功!');
  263. } else {
  264. that.$message.error(response.data.msg);
  265. that.list[index][type] == 1 ? 0 : 1;
  266. }
  267. that.search(this.current_page);
  268. loading.close();
  269. }), function (res) {
  270. console.log(res);
  271. loading.close();
  272. };
  273. },
  274. // 字符转义
  275. escapeHTML(a) {
  276. a = "" + a;
  277. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  278. },
  279. },
  280. })
  281. </script>
  282. @endsection