| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 |
- @extends('layouts.base')
- @section('title', "商品列表")
- @section('content')
- <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods.css')}}"/>
- <div id="qrcode" ref="qrcode" style="display:none;"></div>
- <div class="rightlist">
- <div id="app" v-cloak v-loading="all_loading">
- <template>
- <div class="second-list">
- <div class="third-list">
- <div class="form-list">
- <el-form :inline="true" :model="search_form" ref="search_form" style="margin-left:10px;">
- <el-row>
- <el-form-item label="" prop="">
- <el-select v-model="search_form.status" placeholder="请选择商品状态" clearable>
- <el-option v-for="item in status_list" :key="item.id" :label="item.name"
- :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="">
- <el-select v-model="search_form.sell_stock" placeholder="请选择售中库存" clearable>
- <el-option v-for="item in sell_stock_list" :key="item.id" :label="item.name"
- :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="keyword">
- <el-input v-model="search_form.keyword" placeholder="请输入商品ID或关键字"></el-input>
- </el-form-item>
- <el-form-item label="价格区间" prop="">
- <el-input v-model="search_form.min_price" placeholder="最低价"
- style="width:150px;"></el-input>
- 至
- <el-input v-model="search_form.max_price" placeholder="最高价"
- style="width:150px;"></el-input>
- </el-form-item>
- <a href="#">
- <el-button type="primary" icon="el-icon-search" @click="search(1)">搜索
- </el-button>
- </a>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div class="table-list">
- <div style="margin-left:10px;">
- <el-checkbox v-model.number="is_all_choose" :true-label="1" :false-label="0"
- @change="allChoose">[[is_all_choose==1?'全不选':'全选']]
- </el-checkbox>
- <el-button size="small" @click="batchPutAway(1)">批量上架</el-button>
- <el-button size="small" @click="batchPutAway(0)">批量下架</el-button>
- </div>
- <div>
- <template>
- <!-- 表格start -->
- <el-table :data="goods_list" style="width: 100%"
- :class="table_loading==true?'loading-height':''"
- v-loading="table_loading">
- <el-table-column prop="id" label="选择" width="60" align="center">
- <template slot-scope="scope">
- <el-checkbox v-model.number="scope.row.is_choose" :true-label="1"
- :false-label="0"
- @change="oneChange(scope.row)"></el-checkbox>
- </template>
- </el-table-column>
- <el-table-column prop="id" label="ID" width="70"
- align="center"></el-table-column>
- <el-table-column prop="equity_id" label="第三方ID" width="90"
- align="center"></el-table-column>
- </el-table-column>
- <el-table-column prop="total" label="商品" width="60" align="center">
- <template slot-scope="scope">
- <img :src="scope.row.thumb" style="width:50px;height:50px;">
- </template>
- </el-table-column>
- <el-table-column prop="down_time" label="" min-width="180" align="left"
- class="edit-cell">
- <template slot-scope="scope">
- [[scope.row.title]]
- </template>
- </el-table-column>
- <el-table-column prop="member_num" label="价格" max-width="80" align="center">
- <template slot-scope="scope">
- ¥[[scope.row.price]]
- </template>
- </el-table-column>
- <el-table-column label="库存" align="center" max-width="80">
- <template slot-scope="scope">
- [[scope.row.stock]]
- </template>
- </el-table-column>
- <el-table-column prop="real_sales" label="销量" width="70"
- align="center"></el-table-column>
- <el-table-column label="状态" prop="status_message" align="center">
- <template slot-scope="scope">
- [[scope.row.status?'上架':'下架']]
- <el-switch v-model="scope.row.status" :active-value="1"
- :inactive-value="0"
- @change="putAway(scope.row.id,scope.$index)"></el-switch>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="320" align="center">
- <template slot-scope="scope">
- <div class="table-option">
- <el-popover class="item" placement="left" effect="light"
- trigger="hover">
- <div style="text-align:center;">
- <img :src="img" alt=""
- style="margin:10px;width:100px;height:100px;">
- </div>
- <a slot="reference" @mouseover="listCode(scope.$index)">推广链接</a>
- </el-popover>
-
- <a :href="'{{ yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.edit', array('id' => '')) }}'+[[scope.row.id]]" target="_blank">
- 编辑
- </a>
- <a @click="copyList(scope.row.id)">
- 复制链接
- </a>
- <div>
- <input v-model="scope.row.link" :ref="'list'+scope.row.id"
- style="position:absolute;opacity:0;height:1px;"/>
- </div>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 表格end -->
- </template>
- </div>
- </div>
- </div>
- <!-- 分页 -->
- <div class="vue-page" v-show="total>1">
- <el-row>
- <el-col align="right">
- <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>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- </div>
- </div>
- <script src="{{resource_get('static/js/qrcode.min.js')}}"></script>
- <script>
- var app = new Vue({
- el: "#app",
- delimiters: ['[[', ']]'],
- data() {
- return {
- id: "",
- img: "",//二维码
- smallImg:"",//小程序二维码
- catlevel: 0,//是否显示三级分类
- is_all_choose: 0,//是否全选
- goods_list: [],//商品列表
- change_title: "",//修改标题弹框赋值
- change_price: "",//修改价格弹框赋值
- change_stock: "",//修改库存弹框赋值
- change_sort: "",//修改排序弹框赋值
- all_loading: false,
- status_list: [
- {id: '', name: '全部状态'},
- {id: 0, name: '下架'},
- {id: 1, name: '上架'},
- ],
- sell_stock_list: [
- {id: '', name: '全部'},
- {id: 0, name: '售罄'},
- {id: 1, name: '出售中'},
- ],
- spec_list: [
- {id: '', name: '全部'},
- {id: 0, name: '否'},
- {id: 1, name: '是'},
- ],
- brands_list: [],//品牌名称
- category_list: [],
- category_list_v2: [],
- category_list_v3: [],
- search_form: {
- id_v1: '',
- id_v2: '',
- id_v3: '',
- },
- form: {},
- level_list: [],
- loading: false,
- table_loading: false,
- rules: {},
- //分页
- total: 0,
- per_size: 0,
- current_page: 0,
- rules: {},
- }
- },
- created() {
- //this.getData();
- let that = this;
- document.onkeydown = function(){
- if(window.event.keyCode == 13)
- that.search(1);
- }
- },
- mounted() {
- let data = {!! $data !!};
- this.setData(data);
- console.log(data)
- },
- methods: {
- setData(data) {
- this.goods_list = data.list.data;
- let arr = [];
- this.goods_list.forEach((item, index) => {
- item.title = this.escapeHTML(item.title)
- arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
- });
- this.goods_list = arr;
- this.total = data.list.total;
- this.current_page = data.list.current_page;
- this.per_size = data.list.per_page;
- this.category_list = data.category;
- this.catlevel = data.cat_level;
- },
- getData() {
- var that = this;
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.get-data') !!}").then(response => {
- //console.log(response);
- if (response.data.result == 1) {
- this.setData(response.data.data);
- } else {
- that.$message.error(response.data.msg);
- }
- that.table_loading = false;
- }), function (res) {
- //console.log(res);
- that.table_loading = false;
- };
- },
- // 一级分类改变
- changeV1() {
- let that = this;
- this.search_form.id_v2 = "";
- this.search_form.id_v3 = "";
- this.category_list_v2 = [];
- this.category_list_v3 = [];
- that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:2,parent_id:this.search_form.id_v1}).then(response => {
- if (response.data.result == 1) {
- this.category_list_v2 = response.data.data;
- } else {
- that.$message.error(response.data.msg);
- }
- }), function (res) {
- //console.log(res);
- };
- this.category_list.find(item => {
- if (item.id == this.search_form.id_v1) {
- this.category_list_v2 = item.childrens;
- }
- });
- },
- // 二级分类改变
- changeV2() {
- let that = this;
- this.search_form.id_v3 = "";
- this.category_list_v3 = [];
- if (this.catlevel == 3) {
- that.$http.post("{!! yzWebFullUrl('goods.category.get-categorys-json') !!}",{level:3,parent_id:this.search_form.id_v2}).then(response => {
- if (response.data.result == 1) {
- this.category_list_v3 = response.data.data;
- } else {
- that.$message.error(response.data.msg);
- }
- }), function (res) {
- //console.log(res);
- };
- }
- },
- getBrandData(keyword) {
- if(keyword=="") {
- return;
- }
- let that = this;
- that.$http.post("{!! yzWebFullUrl('goods.brand.search-brand') !!}",{keyword:keyword}).then(response => {
- if (response.data.result == 1) {
- this.brands_list = response.data.data;
- } else {
- that.$message.error(response.data.msg);
- }
- }), function (res) {
- //console.log(res);
- };
- },
- // 搜索、分页
- search(page) {
- var that = this;
- console.log(that.search_form)
- // 商品类型
- let product_attr = [];
- if (that.search_form.is_new == 1) {
- product_attr.push('is_new')
- }
- if (that.search_form.is_hot == 1) {
- product_attr.push('is_hot')
- }
- if (that.search_form.is_recommand == 1) {
- product_attr.push('is_recommand')
- }
- if (that.search_form.is_discount == 1) {
- product_attr.push('is_discount')
- }
- let json = {
- page: page,
- search: {
- keyword: that.search_form.keyword,
- status: that.search_form.status,
- sell_stock: that.search_form.sell_stock,
- brand_id: that.search_form.brand_id,
- min_price: that.search_form.min_price,
- max_price: that.search_form.max_price,
- product_attr: product_attr,//商品类型
- is_spec: that.search_form.is_spec,
- },
- category: {
- parentid: that.search_form.id_v1,
- childid: that.search_form.id_v2,
- thirdid: that.search_form.id_v3,
- }
- };
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('plugin.aggregation-cps.admin.equity-goods.get-data') !!}", json).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- let arr = [];
- that.goods_list = response.data.data.data;
- that.goods_list.forEach((item, index) => {
- item.title = that.escapeHTML(item.title)
- arr.push(Object.assign({}, item, {is_choose: 0}))//是否选中
- });
- that.goods_list = arr;
- that.total = response.data.data.total;
- that.current_page = response.data.data.current_page;
- that.per_size = response.data.data.per_page;
- } else {
- that.$message.error(response.data.msg);
- }
- that.table_loading = false;
- }), function (res) {
- console.log(res);
- that.table_loading = false;
- };
- },
- qrcodeScan(url) {//生成二维码
- let qrcode = new QRCode('qrcode', {
- width: 100, // 二维码宽度
- height: 100, // 二维码高度
- render: 'image',
- text: url
- });
- var data = $("canvas")[$("canvas").length - 1].toDataURL().replace("image/png", "image/octet-stream;");
- console.log(data)
- this.img = data;
- },
- // 活动二维码
- listCode(index) {
- this.qrcodeScan(this.goods_list[index].link);
- },
- // 小程序二维码
- SmallCode(index) {
- this.smallImg = this.goods_list[index].small_link;
- },
- // 复制活动链接
- copyList(index) {
- that = this;
- let Url = that.$refs['list' + index];
- console.log(Url)
- Url.select(); // 选择对象
- document.execCommand("Copy", false);
- that.$message({message: "复制成功!", type: "success"});
- },
- // 单个选择
- oneChange(item) {
- let that = this;
- let is_all = 0;
- that.goods_list.some((item, index) => {
- if (item.is_choose == 1) {
- is_all = 1;
- } else {
- is_all = 0;
- return true;
- }
- })
- that.is_all_choose = is_all;
- },
- // 全选
- allChoose() {
- let that = this;
- let status = 0;
- if (that.is_all_choose == 1) {
- status = 1;
- } else {
- status = 0;
- }
- that.goods_list.forEach((item, index) => {
- item.is_choose = status;
- })
- },
- // 上架、下架
- putAway(id, index) {
- var that = this;
- that.table_loading = true;
- let data = that.goods_list[index].status;
- let json = {id: id, type: 'status', data: data};
- that.$http.post("{!! yzWebFullUrl('goods.goods.setPutaway') !!}", json).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- that.$message.success('操作成功!');
- } else {
- that.$message.error(response.data.msg);
- that.goods_list[index].is_choose == 1 ? 0 : 1;
- }
- that.table_loading = false;
- }), function (res) {
- console.log(res);
- that.table_loading = false;
- };
- },
- // 批量上架、下架
- batchPutAway(data) {
- var that = this;
- that.table_loading = true;
- let ids = [];
- that.goods_list.forEach((item, index) => {
- if (item.is_choose == 1) {
- ids.push(item.id);
- }
- })
- let json = {data: data, ids: ids}
- that.$http.post("{!! yzWebFullUrl('goods.goods.batchSetProperty') !!}", json).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- that.$message.success('操作成功!');
- that.is_all_choose = 0;
- that.search(1);
- } else {
- that.$message.error(response.data.msg);
- }
- that.table_loading = false;
- }), function (res) {
- console.log(res);
- that.table_loading = false;
- };
- },
- // 单个删除
- delOne(id) {
- var that = this;
- that.$confirm('确定删除吗', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('goods.goods.destroy') !!}", {id: id}).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- that.$message.success("删除成功!");
- that.search(1);
- } else {
- that.$message.error(response.data);
- }
- that.table_loading = false;
- }), function (res) {
- console.log(res);
- that.table_loading = false;
- };
- }).catch(() => {
- this.$message({type: 'info', message: '已取消修改'});
- });
- },
- // 字符转义
- escapeHTML(a) {
- a = "" + a;
- return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");
- ;
- },
- },
- })
- </script>
- @endsection
|