equity_goods.blade.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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"
  17. :value="item.id"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="" prop="">
  21. <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
  22. <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name"
  23. :value="item.id"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item label="" prop="keyword">
  27. <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
  28. </el-form-item>
  29. <el-form-item label="价格区间" prop="">
  30. <el-input v-model="search_form.min_price" placeholder="最低价"
  31. style="width:150px;"></el-input>
  32. <el-input v-model="search_form.max_price" placeholder="最高价"
  33. style="width:150px;"></el-input>
  34. </el-form-item>
  35. <a href="#">
  36. <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索
  37. </el-button>
  38. </a>
  39. </el-col>
  40. </el-row>
  41. </el-form>
  42. </div>
  43. <div class="table-list">
  44. <div style="margin-left:10px;">
  45. <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0"
  46. @change="allChoose">[[is_all_choose==1?'全不选':'全选']]
  47. </el-checkbox>
  48. <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
  49. <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
  50. </div>
  51. <div>
  52. <template>
  53. <!-- 表格start -->
  54. <el-table :data="goods_list" style="width: 100%"
  55. :class="table_loading==true?'loading-height':''"
  56. v-loading="table_loading">
  57. <el-table-column prop="id" label="选择" width="60" align="center">
  58. <template slot-scope="scope">
  59. <el-checkbox v-model.number="scope.row.is_choose" :true-label="1"
  60. :false-label="0"
  61. @change="oneChange(scope.row)"></el-checkbox>
  62. </template>
  63. </el-table-column>
  64. <el-table-column prop="id" label="ID" width="70"
  65. align="center"></el-table-column>
  66. <el-table-column prop="equity_id" label="第三方ID" width="90"
  67. align="center"></el-table-column>
  68. </el-table-column>
  69. <el-table-column prop="total" label="商品" width="60" align="center">
  70. <template slot-scope="scope">
  71. <img :src="scope.row.thumb" style="width:50px;height:50px;">
  72. </template>
  73. </el-table-column>
  74. <el-table-column prop="down_time" label="" min-width="180" align="left"
  75. class="edit-cell">
  76. <template slot-scope="scope">
  77. [[scope.row.title]]
  78. </template>
  79. </el-table-column>
  80. <el-table-column prop="member_num" label="价格" max-width="80" align="center">
  81. <template slot-scope="scope">
  82. ¥[[scope.row.price]]
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="库存" align="center" max-width="80">
  86. <template slot-scope="scope">
  87. [[scope.row.stock]]
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="real_sales" label="销量" width="70"
  91. align="center"></el-table-column>
  92. <el-table-column label="状态" prop="status_message" align="center">
  93. <template slot-scope="scope">
  94. [[scope.row.status?'上架':'下架']]
  95. <el-switch v-model="scope.row.status" :active-value="1"
  96. :inactive-value="0"
  97. @change="putAway(scope.row.id,scope.$index)"></el-switch>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="操作" width="320" align="center">
  101. <template slot-scope="scope">
  102. <div class="table-option">
  103. <el-popover class="item" placement="left" effect="light"
  104. trigger="hover">
  105. <div style="text-align:center;">
  106. <img :src="img" alt=""
  107. style="margin:10px;width:100px;height:100px;">
  108. </div>
  109. <a slot="reference" @mouseover="listCode(scope.$index)">推广链接</a>
  110. </el-popover>
  111. &nbsp;&nbsp;
  112. <a :href="'{{ yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.edit', array('id' => '')) }}'+[[scope.row.id]]" target="_blank">
  113. 编辑
  114. </a>&nbsp;&nbsp;
  115. <a @click="copyList(scope.row.id)">
  116. 复制链接
  117. </a>
  118. <div>
  119. <input v-model="scope.row.link" :ref="'list'+scope.row.id"
  120. style="position:absolute;opacity:0;height:1px;"/>
  121. </div>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <!-- 表格end -->
  127. </template>
  128. </div>
  129. </div>
  130. </div>
  131. <!-- 分页 -->
  132. <div class="vue-page" v-show="total>1">
  133. <el-row>
  134. <el-col align="right">
  135. <el-pagination layout="prev, pager, next,jumper" @current-change="search" :total="total"
  136. :page-size="per_size" :current-page="current_page" background
  137. v-loading="loading"></el-pagination>
  138. </el-col>
  139. </el-row>
  140. </div>
  141. </div>
  142. </template>
  143. </div>
  144. </div>
  145. <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
  146. <script>
  147. var app = new Vue({
  148. el: "#app",
  149. delimiters: ['[[', ']]'],
  150. data() {
  151. return {
  152. id: "",
  153. img: "",//二维码
  154. smallImg:"",//小程序二维码
  155. catlevel: 0,//是否显示三级分类
  156. is_all_choose: 0,//是否全选
  157. goods_list: [],//商品列表
  158. change_title: "",//修改标题弹框赋值
  159. change_price: "",//修改价格弹框赋值
  160. change_stock: "",//修改库存弹框赋值
  161. change_sort: "",//修改排序弹框赋值
  162. all_loading: false,
  163. status_list: [
  164. {id: '', name: '全部状态'},
  165. {id: 0, name: '下架'},
  166. {id: 1, name: '上架'},
  167. ],
  168. sell_stock_list: [
  169. {id: '', name: '全部'},
  170. {id: 0, name: '售罄'},
  171. {id: 1, name: '出售中'},
  172. ],
  173. spec_list: [
  174. {id: '', name: '全部'},
  175. {id: 0, name: '否'},
  176. {id: 1, name: '是'},
  177. ],
  178. brands_list: [],//品牌名称
  179. category_list: [],
  180. category_list_v2: [],
  181. category_list_v3: [],
  182. search_form: {
  183. id_v1: '',
  184. id_v2: '',
  185. id_v3: '',
  186. },
  187. form: {},
  188. level_list: [],
  189. loading: false,
  190. table_loading: false,
  191. rules: {},
  192. //分页
  193. total: 0,
  194. per_size: 0,
  195. current_page: 0,
  196. rules: {},
  197. }
  198. },
  199. created() {
  200. //this.getData();
  201. let that = this;
  202. document.onkeydown = function(){
  203. if(window.event.keyCode == 13)
  204. that.search(1);
  205. }
  206. },
  207. mounted() {
  208. let data = {!! $data !!};
  209. this.setData(data);
  210. console.log(data)
  211. },
  212. methods: {
  213. setData(data) {
  214. this.goods_list = data.list.data;
  215. let arr = [];
  216. this.goods_list.forEach((item, index) => {
  217. item.title = this.escapeHTML(item.title)
  218. arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
  219. });
  220. this.goods_list = arr;
  221. this.total = data.list.total;
  222. this.current_page = data.list.current_page;
  223. this.per_size = data.list.per_page;
  224. this.category_list = data.category;
  225. this.catlevel = data.cat_level;
  226. },
  227. getData() {
  228. var that = this;
  229. that.table_loading = true;
  230. that.$http.post("{!! yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.get-data') !!}").then(response => {
  231. //console.log(response);
  232. if (response.data.result == 1) {
  233. this.setData(response.data.data);
  234. } else {
  235. that.$message.error(response.data.msg);
  236. }
  237. that.table_loading = false;
  238. }), function (res) {
  239. //console.log(res);
  240. that.table_loading = false;
  241. };
  242. },
  243. // 一级分类改变
  244. changeV1() {
  245. let that = this;
  246. this.search_form.id_v2 = "";
  247. this.search_form.id_v3 = "";
  248. this.category_list_v2 = [];
  249. this.category_list_v3 = [];
  250. that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:2,parent_id:this.search_form.id_v1}).then(response => {
  251. if (response.data.result == 1) {
  252. this.category_list_v2 = response.data.data;
  253. } else {
  254. that.$message.error(response.data.msg);
  255. }
  256. }), function (res) {
  257. //console.log(res);
  258. };
  259. this.category_list.find(item => {
  260. if (item.id == this.search_form.id_v1) {
  261. this.category_list_v2 = item.childrens;
  262. }
  263. });
  264. },
  265. // 二级分类改变
  266. changeV2() {
  267. let that = this;
  268. this.search_form.id_v3 = "";
  269. this.category_list_v3 = [];
  270. if (this.catlevel == 3) {
  271. that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:3,parent_id:this.search_form.id_v2}).then(response => {
  272. if (response.data.result == 1) {
  273. this.category_list_v3 = response.data.data;
  274. } else {
  275. that.$message.error(response.data.msg);
  276. }
  277. }), function (res) {
  278. //console.log(res);
  279. };
  280. }
  281. },
  282. getBrandData(keyword) {
  283. if(keyword=="") {
  284. return;
  285. }
  286. let that = this;
  287. that.$http.post("{!! yzWebFullUrl('goods.brand.search-brand') !!}",{keyword:keyword}).then(response => {
  288. if (response.data.result == 1) {
  289. this.brands_list = response.data.data;
  290. } else {
  291. that.$message.error(response.data.msg);
  292. }
  293. }), function (res) {
  294. //console.log(res);
  295. };
  296. },
  297. // 搜索、分页
  298. search(page) {
  299. var that = this;
  300. console.log(that.search_form)
  301. // 商品类型
  302. let product_attr = [];
  303. if (that.search_form.is_new == 1) {
  304. product_attr.push('is_new')
  305. }
  306. if (that.search_form.is_hot == 1) {
  307. product_attr.push('is_hot')
  308. }
  309. if (that.search_form.is_recommand == 1) {
  310. product_attr.push('is_recommand')
  311. }
  312. if (that.search_form.is_discount == 1) {
  313. product_attr.push('is_discount')
  314. }
  315. let json = {
  316. page: page,
  317. search: {
  318. keyword: that.search_form.keyword,
  319. status: that.search_form.status,
  320. sell_stock: that.search_form.sell_stock,
  321. brand_id: that.search_form.brand_id,
  322. min_price: that.search_form.min_price,
  323. max_price: that.search_form.max_price,
  324. product_attr: product_attr,//商品类型
  325. is_spec: that.search_form.is_spec,
  326. },
  327. category: {
  328. parentid: that.search_form.id_v1,
  329. childid: that.search_form.id_v2,
  330. thirdid: that.search_form.id_v3,
  331. }
  332. };
  333. that.table_loading = true;
  334. that.$http.post("{!! yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.get-data') !!}", json).then(response => {
  335. console.log(response);
  336. if (response.data.result == 1) {
  337. let arr = [];
  338. that.goods_list = response.data.data.data;
  339. that.goods_list.forEach((item, index) => {
  340. item.title = that.escapeHTML(item.title)
  341. arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
  342. });
  343. that.goods_list = arr;
  344. that.total = response.data.data.total;
  345. that.current_page = response.data.data.current_page;
  346. that.per_size = response.data.data.per_page;
  347. } else {
  348. that.$message.error(response.data.msg);
  349. }
  350. that.table_loading = false;
  351. }), function (res) {
  352. console.log(res);
  353. that.table_loading = false;
  354. };
  355. },
  356. qrcodeScan(url) {//生成二维码
  357. let qrcode = new QRCode('qrcode', {
  358. width: 100, // 二维码宽度
  359. height: 100, // 二维码高度
  360. render: 'image',
  361. text: url
  362. });
  363. var data = $("canvas")[$("canvas").length - 1].toDataURL().replace("image/png", "image/octet-stream;");
  364. console.log(data)
  365. this.img = data;
  366. },
  367. // 活动二维码
  368. listCode(index) {
  369. this.qrcodeScan(this.goods_list[index].link);
  370. },
  371. // 小程序二维码
  372. SmallCode(index) {
  373. this.smallImg = this.goods_list[index].small_link;
  374. },
  375. // 复制活动链接
  376. copyList(index) {
  377. that = this;
  378. let Url = that.$refs['list' + index];
  379. console.log(Url)
  380. Url.select(); // 选择对象
  381. document.execCommand("Copy", false);
  382. that.$message({message: "复制成功!", type: "success"});
  383. },
  384. // 单个选择
  385. oneChange(item) {
  386. let that = this;
  387. let is_all = 0;
  388. that.goods_list.some((item, index) => {
  389. if (item.is_choose == 1) {
  390. is_all = 1;
  391. } else {
  392. is_all = 0;
  393. return true;
  394. }
  395. })
  396. that.is_all_choose = is_all;
  397. },
  398. // 全选
  399. allChoose() {
  400. let that = this;
  401. let status = 0;
  402. if (that.is_all_choose == 1) {
  403. status = 1;
  404. } else {
  405. status = 0;
  406. }
  407. that.goods_list.forEach((item, index) => {
  408. item.is_choose = status;
  409. })
  410. },
  411. // 上架、下架
  412. putAway(id, index) {
  413. var that = this;
  414. that.table_loading = true;
  415. let data = that.goods_list[index].status;
  416. let json = {id: id, type: 'status', data: data};
  417. that.$http.post("{!! yzWebFullUrl('goods.goods.setPutaway') !!}", json).then(response => {
  418. console.log(response);
  419. if (response.data.result == 1) {
  420. that.$message.success('操作成功!');
  421. } else {
  422. that.$message.error(response.data.msg);
  423. that.goods_list[index].is_choose == 1 ? 0 : 1;
  424. }
  425. that.table_loading = false;
  426. }), function (res) {
  427. console.log(res);
  428. that.table_loading = false;
  429. };
  430. },
  431. // 批量上架、下架
  432. batchPutAway(data) {
  433. var that = this;
  434. that.table_loading = true;
  435. let ids = [];
  436. that.goods_list.forEach((item, index) => {
  437. if (item.is_choose == 1) {
  438. ids.push(item.id);
  439. }
  440. })
  441. let json = {data: data, ids: ids}
  442. that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}", json).then(response => {
  443. console.log(response);
  444. if (response.data.result == 1) {
  445. that.$message.success('操作成功!');
  446. that.is_all_choose = 0;
  447. that.search(1);
  448. } else {
  449. that.$message.error(response.data.msg);
  450. }
  451. that.table_loading = false;
  452. }), function (res) {
  453. console.log(res);
  454. that.table_loading = false;
  455. };
  456. },
  457. // 单个删除
  458. delOne(id) {
  459. var that = this;
  460. that.$confirm('确定删除吗', '提示', {
  461. confirmButtonText: '确定',
  462. cancelButtonText: '取消',
  463. type: 'warning'
  464. }).then(() => {
  465. that.table_loading = true;
  466. that.$http.post("{!! yzWebFullUrl('goods.goods.destroy') !!}", {id: id}).then(response => {
  467. console.log(response);
  468. if (response.data.result == 1) {
  469. that.$message.success("删除成功!");
  470. that.search(1);
  471. } else {
  472. that.$message.error(response.data);
  473. }
  474. that.table_loading = false;
  475. }), function (res) {
  476. console.log(res);
  477. that.table_loading = false;
  478. };
  479. }).catch(() => {
  480. this.$message({type: 'info', message: '已取消修改'});
  481. });
  482. },
  483. // 字符转义
  484. escapeHTML(a) {
  485. a = "" + a;
  486. return a.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&apos;/g, "'");
  487. ;
  488. },
  489. },
  490. })
  491. </script>
  492. @endsection