list.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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-main">
  8. <div class="vue-main-title">
  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="addBrand">添加新品牌</el-button>
  13. </div>
  14. </div>
  15. <div class="form-list">
  16. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  17. <el-row>
  18. <el-form-item label="" prop="id">
  19. <el-input v-model="search_form.id" placeholder="请输入品牌ID"></el-input>
  20. </el-form-item>
  21. <el-form-item label="" prop="name">
  22. <el-input v-model="search_form.name" placeholder="请输入品牌名称"></el-input>
  23. </el-form-item>
  24. <a href="#">
  25. <el-button type="primary" icon="el-icon-search" @click="search()">搜索
  26. </el-button>
  27. </a>
  28. </el-col>
  29. </el-row>
  30. </el-form>
  31. </div>
  32. <div class="vue-main-form">
  33. <el-button size="mini" @click="patchRecommendBranch">批量开启</el-button>
  34. <el-button size="mini" @click="patchCancelRecommendBranch">批量关闭</el-button>
  35. <el-button size="mini" @click="patchCancelDelBranch">批量删除</el-button>
  36. <el-table :data="list" style="width: 100%" @selection-change="selectedBranch">
  37. <el-table-column type="selection" width="55"></el-table-column>
  38. <el-table-column prop="id" label="ID" align="center" width="120"></el-table-column>
  39. <el-table-column label="品牌">
  40. <template slot-scope="scope">
  41. <div>
  42. <img v-if="scope.row.logo_url" :src="scope.row.logo_url" onerror="this.src='/addons/yun_shop/static/resource/images/nopic.jpg'; this.title='图片未找到.'" style="width:50px;height:50px"></img>
  43. [[scope.row.name]]
  44. </div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="推荐">
  48. <template slot-scope="scope">
  49. <el-switch @change="recommendBranch(scope.row)" v-model="scope.row.is_recommend"></el-switch>
  50. </template>
  51. </el-table-column>
  52. <el-table-column prop="refund_time" label="操作" align="center" width="320">
  53. <template slot-scope="scope">
  54. <!-- <el-link type="warning" :underline="false" :href="'{{ yzWebUrl('goods.brand.edit-viwe', array('id' => '')) }}'+[[scope.row.id]]" class="el-link-edit el-link-edit-middle">
  55. 修改
  56. </el-link>
  57. <el-link type="warning" :underline="false" @click="del(scope.row.id,scope.$index)" class="el-link-edit el-link-edit-end">
  58. 删除
  59. </el-link> -->
  60. <el-link title="编辑品牌" :underline="false" :href="'{{ yzWebUrl('goods.brand.edit-viwe', array('id' => '')) }}'+[[scope.row.id]]" style="width:50px;">
  61. <i class="iconfont icon-ht_operation_edit"></i>
  62. </el-link>
  63. <el-link title="删除品牌" :underline="false" @click="del(scope.row.id,scope.$index)" style="width:50px;">
  64. <i class="iconfont icon-ht_operation_delete"></i>
  65. </el-link>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. </div>
  70. </div>
  71. <!-- 分页 -->
  72. <div class="vue-page" v-if="total>0">
  73. <el-row>
  74. <el-col align="right">
  75. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  76. :page-size="per_page" :current-page="current_page" background
  77. ></el-pagination>
  78. </el-col>
  79. </el-row>
  80. </div>
  81. </div>
  82. </div>
  83. <script>
  84. var app = new Vue({
  85. el: "#app",
  86. delimiters: ['[[', ']]'],
  87. name: 'test',
  88. data() {
  89. return {
  90. list:[],
  91. rules: {},
  92. current_page:1,
  93. total:1,
  94. per_page:1,
  95. id:'',
  96. name:'',
  97. search_form:{},
  98. selectedBranchs:[]
  99. }
  100. },
  101. created() {
  102. },
  103. mounted() {
  104. this.getData(1);
  105. },
  106. methods: {
  107. selectedBranch(branchs){
  108. this.selectedBranchs=branchs;
  109. },
  110. patchRecommendBranch(){
  111. let ids=[];
  112. for (const item of this.selectedBranchs) {
  113. ids.push(item.id);
  114. }
  115. this.$http.post("{!! yzWebFullUrl('goods.brand.batch-recommend') !!}",{
  116. ids,
  117. is_recommend:1
  118. }).then(res=>{
  119. if(res.result==0){
  120. this.$toast(res.msg);
  121. return;
  122. }
  123. this.selectedBranchs.forEach(item=>{
  124. item['is_recommend']=true;
  125. })
  126. });
  127. },
  128. recommendBranch(branchItem){
  129. this.$http.post("{!! yzWebFullUrl('goods.brand.batch-recommend') !!}",{
  130. ids:[branchItem.id],
  131. is_recommend:branchItem.is_recommend?1:0
  132. }).then(res=>{
  133. if(res.result==0){
  134. branchItem.is_recommend=branchItem.is_recommend==1?0:1;
  135. this.$message(res.msg);
  136. return;
  137. }
  138. });
  139. },
  140. patchCancelRecommendBranch(){
  141. let ids=[];
  142. for (const item of this.selectedBranchs) {
  143. ids.push(item.id);
  144. }
  145. this.$http.post("{!! yzWebFullUrl('goods.brand.batch-recommend') !!}",{
  146. ids,
  147. is_recommend:0
  148. }).then(res=>{
  149. if(res.result==0){
  150. this.$toast(res.msg);
  151. return;
  152. }
  153. this.selectedBranchs.forEach(item=>{
  154. item['is_recommend']=false;
  155. })
  156. });
  157. },
  158. patchCancelDelBranch(){
  159. let ids=[];
  160. for (const item of this.selectedBranchs) {
  161. ids.push(item.id);
  162. }
  163. this.$confirm('确定批量删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  164. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  165. this.$http.post('{!! yzWebFullUrl('goods.brand.deleted-brand') !!}',{ids:ids}).then(function (response) {
  166. console.log(response.data);
  167. if (response.data.result) {
  168. this.$message({type: 'success',message: '删除成功!'});
  169. location.reload();
  170. }
  171. else{
  172. this.$message({type: 'error',message: response.data.msg});
  173. }
  174. loading.close();
  175. },function (response) {
  176. this.$message({type: 'error',message: response.data.msg});
  177. loading.close();
  178. }
  179. );
  180. }).catch(() => {
  181. this.$message({type: 'info',message: '已取消删除'});
  182. });
  183. },
  184. getData(page,json) {
  185. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  186. this.$http.post('{!! yzWebFullUrl('goods.brand.brand-data') !!}',{page:page,search:json}).then(function(response) {
  187. if (response.data.result) {
  188. for (const item of response.data.data.data) {
  189. item['is_recommend']=Boolean(item['is_recommend']);
  190. }
  191. this.list = response.data.data.data;
  192. this.current_page=response.data.data.current_page;
  193. this.total=response.data.data.total;
  194. this.per_page=response.data.data.per_page;
  195. loading.close();
  196. } else {
  197. this.$message({
  198. message: response.data.msg,
  199. type: 'error'
  200. });
  201. }
  202. loading.close();
  203. }, function(response) {
  204. this.$message({
  205. message: response.data.msg,
  206. type: 'error'
  207. });
  208. loading.close();
  209. });
  210. },
  211. search(val) {
  212. var that = this;
  213. let json = {
  214. id: that.search_form.id,
  215. name: that.search_form.name,
  216. };
  217. console.log(json)
  218. this.getData(val,json);
  219. },
  220. // 添加新品牌
  221. addBrand() {
  222. let link = `{!! yzWebFullUrl('goods.brand.edit-viwe') !!}`;
  223. console.log(link);
  224. window.location.href = link;
  225. },
  226. del(id,index) {
  227. console.log(id,index)
  228. this.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  229. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  230. this.$http.post('{!! yzWebFullUrl('goods.brand.deleted-brand') !!}',{id:id}).then(function (response) {
  231. console.log(response.data);
  232. if (response.data.result) {
  233. this.list.splice(index,1);
  234. this.$message({type: 'success',message: '删除成功!'});
  235. }
  236. else{
  237. this.$message({type: 'error',message: response.data.msg});
  238. }
  239. loading.close();
  240. },function (response) {
  241. this.$message({type: 'error',message: response.data.msg});
  242. loading.close();
  243. }
  244. );
  245. }).catch(() => {
  246. this.$message({type: 'info',message: '已取消删除'});
  247. });
  248. },
  249. },
  250. })
  251. </script>
  252. @endsection