list.blade.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. @extends('layouts.base')
  2. @section('title', "商品列表")
  3. @section('content')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods.css')}}"/>
  5. <!-- <div id="qrcode" ref="qrcode" style="display:none;"></div> -->
  6. <div class="rightlist">
  7. <div id="app" v-cloak v-loading="all_loading">
  8. <template>
  9. <div class="second-list">
  10. <div class="third-list">
  11. <div class="form-list">
  12. <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
  13. <el-row>
  14. <el-form-item label="" prop="">
  15. <el-select v-model="search_form.status" placeholder="请选择商品状态" clearable>
  16. <el-option v-for="item in status_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="" prop="">
  20. <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
  21. <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-select v-model="search_form.id_v1" placeholder="请选择一级分类" clearable @change="changeV1()">
  26. <el-option v-for="item in category_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-select v-model="search_form.id_v2" placeholder="请选择二级分类" clearable>
  31. <el-option v-for="item in category_list_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="" prop="">
  35. <el-select v-model="search_form.brand_id" placeholder="请选择品牌" clearable>
  36. <el-option v-for="item in brands_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="" prop="keyword">
  40. <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
  41. </el-form-item>
  42. <el-form-item label="" prop="hotel_id">
  43. <el-input v-model="search_form.hotel_id" placeholder="请输入酒店ID"></el-input>
  44. </el-form-item>
  45. <el-form-item label="价格区间" prop="">
  46. <el-input v-model="search_form.min_price" placeholder="最低价" style="width:150px;"></el-input>
  47. <el-input v-model="search_form.max_price" placeholder="最高价" style="width:150px;"></el-input>
  48. </el-form-item>
  49. <el-form-item label="商品类型" prop="leader_name">
  50. <el-checkbox v-model.number="search_form.is_new" :true-label="1" :false-label="0">新品</el-checkbox>
  51. <el-checkbox v-model.number="search_form.is_hot" :true-label="1" :false-label="0">热卖</el-checkbox>
  52. <el-checkbox v-model.number="search_form.is_recommand" :true-label="1" :false-label="0">推荐</el-checkbox>
  53. <el-checkbox v-model.number="search_form.is_discount" :true-label="1" :false-label="0">促销</el-checkbox>
  54. </el-form-item>
  55. <a href="#">
  56. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索</el-button>
  57. </a>
  58. </el-row>
  59. </el-form>
  60. </div>
  61. <div class="table-list">
  62. <div style="margin-left:10px;">
  63. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0" @change="allChoose">[[is_all_choose==1?'全不选':'全选']]</el-checkbox>
  64. <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
  65. <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
  66. <!-- <el-button size="small" type="danger" @click="batchDestroy">批量删除</el-button> -->
  67. </div>
  68. <div>
  69. <template>
  70. <!-- 表格start -->
  71. <el-table :data="goods_list" style="width: 100%" :class="table_loading==true?'loading-height':''" v-loading="table_loading">
  72. <el-table-column prop="id" label="选择" width="60" align="center">
  73. <template slot-scope="scope">
  74. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1" :false-label="0" @change="oneChange(scope.row)"></el-checkbox>
  75. </template>
  76. </el-table-column>
  77. <el-table-column prop="id" label="ID" width="70" align="center"></el-table-column>
  78. </el-table-column>
  79. <el-table-column prop="member_name" label="排序" max-width="80" align="center">
  80. <template slot-scope="scope">
  81. <el-popover class="item" placement="top" effect="light">
  82. <div style="text-align:center;">
  83. <el-input v-model="change_sort" size="small" style="width:100px;"></el-input>
  84. <el-button size="small" @click="confirmChangeSort(scope.row.id)">确定</el-button>
  85. </div>
  86. <a slot="reference" >
  87. <i class="el-icon-edit edit-i" title="点击编辑排序" @click="editTitle(scope.$index,'sort')"></i>
  88. </a>
  89. </el-popover>
  90. [[scope.row.display_order]]
  91. </template>
  92. </el-table-column>
  93. <el-table-column prop="total" label="商品" width="60" align="center">
  94. <template slot-scope="scope">
  95. <img :src="scope.row.thumb" style="width:50px;height:50px;">
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="down_time" label="" min-width="180" align="left" class="edit-cell">
  99. <template slot-scope="scope">
  100. <el-popover class="item" placement="top" effect="light">
  101. <div style="text-align:center;">
  102. <div style="text-align:left;margin-bottom:10px;font-weight:900">修改商品标题</div>
  103. <el-input v-model="change_title" style="width:400px" size="small"></el-input>
  104. <el-button size="small" @click="confirmChange(scope.row.id,'title')">确定</el-button>
  105. </div>
  106. <a slot="reference">
  107. <i class="el-icon-edit edit-i" title="点击编辑" @click="editTitle(scope.$index,'title')"></i>
  108. </a>
  109. </el-popover>
  110. [[scope.row.title]]
  111. </template>
  112. </el-table-column>
  113. <el-table-column prop="member_num" label="价格" max-width="80" align="center">
  114. <template slot-scope="scope">
  115. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  116. <div style="text-align:center;">
  117. <el-input v-model="change_price" size="small" style="width:100px;"></el-input>
  118. <el-button size="small" @click="confirmChange(scope.row.id,'price')">确定</el-button>
  119. </div>
  120. <a slot="reference" >
  121. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'price')"></i>
  122. </a>
  123. </el-popover>
  124. ¥[[scope.row.price]]
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="库存" align="center" max-width="80">
  128. <template slot-scope="scope">
  129. <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
  130. <div style="text-align:center;">
  131. <el-input v-model="change_stock" size="small" style="width:100px;"></el-input>
  132. <el-button size="small" @click="confirmChange(scope.row.id,'stock')">确定</el-button>
  133. </div>
  134. <a slot="reference" >
  135. <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'stock')"></i>
  136. </a>
  137. </el-popover>
  138. [[scope.row.stock]]
  139. </template>
  140. </el-table-column>
  141. <el-table-column prop="real_sales" label="销量" width="70" align="center"></el-table-column>
  142. <el-table-column label="酒店" max-width="80" align="center">
  143. <template slot-scope="scope">
  144. 酒店:[[scope.row.hotel_name]]<br>
  145. ID:[[scope.row.hotel_id]]
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="状态" prop="status_message" align="center">
  149. <template slot-scope="scope">
  150. [[scope.row.status?'上架':'下架']]
  151. <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="putAway(scope.row.id,scope.$index)"></el-switch>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="操作" width="300" align="center">
  155. <template slot-scope="scope">
  156. <div class="table-option">
  157. <el-popover class="item" placement="left" effect="light" trigger="hover">
  158. <div style="text-align:center;">
  159. <img :src="scope.row.download_url" alt="" style="margin:10px;width:100px;height:100px;">
  160. </div>
  161. <a slot="reference">推广链接</a>
  162. </el-popover>&nbsp;&nbsp;
  163. <a :href="'{{ yzWebFullUrl('plugin.hotel.admin.goods.edit', array('id' => '')) }}'+[[scope.row.id]]" target="_blank">
  164. 编辑
  165. </a>&nbsp;&nbsp;
  166. <!-- <a @click="delOne(scope.row.id)">
  167. 删除
  168. </a>&nbsp;&nbsp; -->
  169. <a :href="scope.row.download_url" target="_blank" download="">
  170. 下载二维码
  171. </a>
  172. <div>
  173. <input v-model="scope.row.link" :ref="'list'+scope.row.id" style="position:absolute;opacity:0;height:1px;" />
  174. </div>
  175. </div>
  176. <div>
  177. <el-checkbox border size="mini" v-model.number="scope.row.is_new" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_new')">新品</el-checkbox>
  178. <el-checkbox border size="mini" v-model.number="scope.row.is_hot" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_hot')">热卖</el-checkbox>
  179. <el-checkbox border size="mini" v-model.number="scope.row.is_recommand" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_recommand')">推荐</el-checkbox>
  180. <el-checkbox border size="mini" v-model.number="scope.row.is_discount" :true-label="1" :false-label="0" @change="setProperty(scope.row.id,scope.$index,'is_discount')">促销</el-checkbox>
  181. </div>
  182. </template>
  183. </el-table-column>
  184. </el-table>
  185. <!-- 表格end -->
  186. </template>
  187. </div>
  188. </div>
  189. </div>
  190. <!-- 分页 -->
  191. <div class="vue-page" v-show="total>1">
  192. <el-row>
  193. <el-col align="right">
  194. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total" :page-size="per_size" :current-page="current_page" background v-loading="loading"></el-pagination>
  195. </el-col>
  196. </el-row>
  197. </div>
  198. </div>
  199. </template>
  200. </div>
  201. <!-- <script src="{{resource_get('static/js/qrcode.min.js')}}"></script> -->
  202. <script>
  203. var app = new Vue({
  204. el:"#app",
  205. delimiters: ['[[', ']]'],
  206. data() {
  207. return{
  208. id:"",
  209. img:"",//二维码
  210. // catlevel:0,//是否显示三级分类
  211. is_all_choose:0,//是否全选
  212. goods_list:[],//商品列表
  213. change_title:"",//修改标题弹框赋值
  214. change_price:"",//修改价格弹框赋值
  215. change_stock:"",//修改库存弹框赋值
  216. change_sort:"",//修改排序弹框赋值
  217. all_loading:false,
  218. status_list:[
  219. {id:'',name:'全部状态'},
  220. {id:0,name:'下架'},
  221. {id:1,name:'上架'},
  222. ],
  223. sell_stock_list:[
  224. {id:'',name:'全部'},
  225. {id:0,name:'售罄'},
  226. {id:1,name:'出售中'},
  227. ],
  228. brands_list:[],//品牌名称
  229. category_list:[],
  230. category_list_v2:[],
  231. search_form:{
  232. id_v1:'',
  233. id_v2:'',
  234. },
  235. form:{},
  236. level_list:[],
  237. loading:false,
  238. table_loading:false,
  239. rules:{},
  240. //分页
  241. total:0,
  242. per_size:0,
  243. current_page:0,
  244. rules:{},
  245. }
  246. },
  247. created() {
  248. let that = this;
  249. this.getData();
  250. document.onkeydown = function(){
  251. if(window.event.keyCode == 13)
  252. that.search(1);
  253. }
  254. },
  255. methods: {
  256. getData() {
  257. var that = this;
  258. that.table_loading = true;
  259. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.goods-list') !!}").then(response => {
  260. console.log(response);
  261. if(response.data.result==1){
  262. that.goods_list = response.data.data.list.data;
  263. let arr =[];
  264. that.goods_list.forEach((item,index) => {
  265. item.title = that.escapeHTML(item.title)
  266. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  267. });
  268. that.goods_list=arr;
  269. that.total = response.data.data.list.total;
  270. that.current_page = response.data.data.list.current_page;
  271. that.per_size = response.data.data.list.per_page;
  272. that.brands_list = response.data.data.brands;
  273. that.category_list = response.data.data.catetory_menus.ids;
  274. // that.catlevel = response.data.data.catetory_menus.catlevel;
  275. console.log(that.goods_list);
  276. }
  277. else{
  278. that.$message.error(response.data.msg);
  279. }
  280. that.table_loading = false;
  281. }),function(res){
  282. console.log(res);
  283. that.table_loading = false;
  284. };
  285. },
  286. // 一级分类改变
  287. changeV1(){
  288. this.search_form.id_v2 = "";
  289. this.category_list_v2 = [];
  290. this.category_list.find(item => {
  291. if(item.id == this.search_form.id_v1) {
  292. this.category_list_v2 = item.childrens;
  293. }
  294. });
  295. },
  296. // 搜索、分页
  297. search(page) {
  298. var that = this;
  299. console.log(that.search_form)
  300. // 商品类型
  301. let product_attr = [];
  302. if(that.search_form.is_new == 1){
  303. product_attr.push('is_new')
  304. }
  305. if(that.search_form.is_hot == 1){
  306. product_attr.push('is_hot')
  307. }
  308. if(that.search_form.is_recommand == 1){
  309. product_attr.push('is_recommand')
  310. }
  311. if(that.search_form.is_discount == 1){
  312. product_attr.push('is_discount')
  313. }
  314. let json = {
  315. page:page,
  316. search:{
  317. keyword:that.search_form.keyword,
  318. status:that.search_form.status,
  319. sell_stock:that.search_form.sell_stock,
  320. brand_id:that.search_form.brand_id,
  321. min_price:that.search_form.min_price,
  322. max_price:that.search_form.max_price,
  323. hotel_id:that.search_form.hotel_id,
  324. product_attr:product_attr,//商品类型
  325. },
  326. category:{
  327. parentid:that.search_form.id_v1,
  328. childid:that.search_form.id_v2,
  329. }
  330. };
  331. that.table_loading = true;
  332. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.goods-search') !!}",json).then(response => {
  333. console.log(response);
  334. if(response.data.result==1){
  335. let arr = [];
  336. that.goods_list = response.data.data.list.data;
  337. that.goods_list.forEach((item,index) => {
  338. item.title = that.escapeHTML(item.title)
  339. arr.push(Object.assign({},item,{is_choose:0}))//是否选中
  340. });
  341. that.goods_list=arr;
  342. that.total = response.data.data.list.total;
  343. that.current_page = response.data.data.list.current_page;
  344. that.per_size = response.data.data.list.per_page;
  345. }
  346. else{
  347. that.$message.error(response.data.msg);
  348. }
  349. that.table_loading = false;
  350. }),function(res){
  351. console.log(res);
  352. that.table_loading = false;
  353. };
  354. },
  355. // 单个选择
  356. oneChange(item) {
  357. let that = this;
  358. let is_all = 0;
  359. that.goods_list.some((item,index) => {
  360. if(item.is_choose == 1) {
  361. is_all = 1;
  362. }
  363. else {
  364. is_all = 0;
  365. return true;
  366. }
  367. })
  368. that.is_all_choose = is_all;
  369. },
  370. // 全选
  371. allChoose() {
  372. let that = this;
  373. let status = 0;
  374. if(that.is_all_choose == 1){
  375. status = 1;
  376. }
  377. else{
  378. status = 0;
  379. }
  380. that.goods_list.forEach((item,index) => {
  381. item.is_choose = status;
  382. })
  383. },
  384. // 上架、下架
  385. putAway(id,index) {
  386. var that = this;
  387. that.table_loading = true;
  388. let data = that.goods_list[index].status;
  389. let json = {id:id,type:'status',data:data};
  390. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.setProperty') !!}",json).then(response => {
  391. console.log(response);
  392. if(response.data.result==1){
  393. that.$message.success('操作成功!');
  394. }
  395. else{
  396. that.$message.error(response.data.msg);
  397. that.goods_list[index].is_choose == 1 ? 0 : 1;
  398. }
  399. that.table_loading = false;
  400. }),function(res){
  401. console.log(res);
  402. that.table_loading = false;
  403. };
  404. },
  405. // 批量上架、下架
  406. batchPutAway(data) {
  407. var that = this;
  408. that.table_loading = true;
  409. let ids = [];
  410. that.goods_list.forEach((item,index) => {
  411. if(item.is_choose == 1){
  412. ids.push(item.id);
  413. }
  414. })
  415. let json = {data:data,ids:ids}
  416. that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}",json).then(response => {
  417. console.log(response);
  418. if(response.data.result==1){
  419. that.$message.success('操作成功!');
  420. that.is_all_choose = 0;
  421. that.search(1);
  422. }
  423. else{
  424. that.$message.error(response.data.msg);
  425. }
  426. that.table_loading = false;
  427. }),function(res){
  428. console.log(res);
  429. that.table_loading = false;
  430. };
  431. },
  432. // 新品、热卖、推荐、促销、
  433. setProperty(id,index,type) {
  434. var that = this;
  435. that.table_loading = true;
  436. console.log(that.goods_list[index][type])
  437. let data = that.goods_list[index][type];
  438. let json = {id:id,type:type,data:data};
  439. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.setProperty') !!}",json).then(response => {
  440. console.log(response);
  441. if(response.data.result==1){
  442. that.$message.success('操作成功!');
  443. }
  444. else{
  445. that.$message.error(response.data.msg);
  446. that.goods_list[index][type] == 1 ? 0 : 1;
  447. }
  448. that.table_loading = false;
  449. }),function(res){
  450. console.log(res);
  451. that.table_loading = false;
  452. };
  453. },
  454. // 编辑商品标题
  455. editTitle(index,type) {
  456. let that = this;
  457. if(type == 'title') {
  458. that.change_title = "";
  459. that.change_title = that.goods_list[index].title;
  460. }
  461. if(type == 'price') {
  462. if(that.goods_list[index].has_option == 1) {
  463. that.$message.error('多规格不支持快速修改');
  464. return false;
  465. }
  466. that.change_price = "";
  467. that.change_price = that.goods_list[index].price;
  468. }
  469. if(type == 'stock') {
  470. if(that.goods_list[index].has_option == 1) {
  471. that.$message.error('多规格不支持快速修改');
  472. return false;
  473. }
  474. that.change_stock = "";
  475. that.change_stock = that.goods_list[index].stock;
  476. }
  477. if(type == 'sort') {
  478. that.change_sort = "";
  479. that.change_sort = that.goods_list[index].display_order;
  480. }
  481. },
  482. // 确认修改标题、价格、库存
  483. confirmChange(id,type) {
  484. let that = this;
  485. let value = '';
  486. if(type == 'title'){
  487. value = that.change_title;
  488. if(that.change_title == ''){
  489. that.$message.error('标题不能为空');
  490. return false;
  491. }
  492. }
  493. if(type == 'price'){
  494. value = that.change_price;
  495. if(!(/^\d+(\.\d+)?$/.test(that.change_price))){
  496. that.$message.error('请输入正确价格');
  497. return false;
  498. }
  499. }
  500. if(type == 'stock'){
  501. value = that.change_stock;
  502. if(!(/^\d+$/.test(that.change_stock))){
  503. that.$message.error('请输入正确数字');
  504. return false;
  505. }
  506. }
  507. let json = {
  508. id:id,
  509. type:type,
  510. value:value,
  511. };
  512. that.table_loading = true;
  513. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.change') !!}",json).then(response => {
  514. console.log(response);
  515. if(response.data.result==1){
  516. that.$message.success('操作成功!');
  517. if (document.all) {
  518. document.getElementById('app').click();
  519. }
  520. else {// 其它浏览器
  521. var e = document.createEvent('MouseEvents')
  522. e.initEvent('click', true, true)
  523. document.getElementById('app').dispatchEvent(e)
  524. }
  525. that.search(1);
  526. }
  527. else{
  528. that.$message.error(response.data.msg);
  529. }
  530. that.table_loading = false;
  531. }),function(res){
  532. console.log(res);
  533. that.table_loading = false;
  534. };
  535. },
  536. // 确认修改排序
  537. confirmChangeSort(id) {
  538. let that = this;
  539. if(!(/^\d+$/.test(that.change_sort))){
  540. that.$message.error('请输入正确数字');
  541. return false;
  542. }
  543. that.table_loading = true;
  544. let json = {id:id,value:that.change_sort};
  545. that.$http.post("{!! yzWebFullUrl('plugin.hotel.admin.goods.displayorder') !!}",json).then(response => {
  546. console.log(response);
  547. if(response.data.result==1){
  548. that.$message.success('操作成功!');
  549. // that.$refs.search_form.click();
  550. if (document.all) {
  551. document.getElementById('app').click();
  552. }
  553. else {// 其它浏览器
  554. var e = document.createEvent('MouseEvents')
  555. e.initEvent('click', true, true)
  556. document.getElementById('app').dispatchEvent(e)
  557. }
  558. that.search(1);
  559. }
  560. else{
  561. that.$message.error(response.data.msg);
  562. }
  563. that.table_loading = false;
  564. }),function(res){
  565. console.log(res);
  566. that.table_loading = false;
  567. };
  568. },
  569. // 字符转义
  570. escapeHTML(a) {
  571. a = "" + a;
  572. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");;
  573. },
  574. },
  575. })
  576. </script>
  577. @endsection