| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959 |
- @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>
- <el-select v-model="search_form.id_v1" placeholder="请选择一级分类" clearable @change="changeV1()">
- <el-option v-for="item in category_list" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_form.id_v2" placeholder="请选择二级分类" clearable @change="changeV2()">
- <el-option v-for="item in category_list_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-select v-model="search_form.id_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3">
- <el-option v-for="item in category_list_v3" :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.brand_id" placeholder="请选择品牌" clearable remote filterable :remote-method="getBrandData">
- <el-option v-for="item in brands_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="filtering">
- <el-input v-model="search_form.filtering_name" placeholder="请输入商品标签关键字"></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>
- <el-form-item label="利润率" prop="">
- <el-input v-model="search_form.min_ratio" placeholder="最低" style="width:150px;"></el-input>
- 至
- <el-input v-model="search_form.max_ratio" placeholder="最高" style="width:150px;"></el-input>
- </el-form-item>
- <el-form-item label="" prop="">
- <el-select v-model="search_form.page_size" placeholder="每页条数" clearable>
- <el-option v-for="item in page_size" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="商品类型" prop="leader_name">
- <el-checkbox v-model.number="search_form.is_new" :true-label="1" :false-label="0">新品</el-checkbox>
- <el-checkbox v-model.number="search_form.is_hot" :true-label="1" :false-label="0">热卖</el-checkbox>
- <el-checkbox v-model.number="search_form.is_recommand" :true-label="1" :false-label="0">推荐</el-checkbox>
- <el-checkbox v-model.number="search_form.is_discount" :true-label="1" :false-label="0">促销</el-checkbox>
- </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>
- <el-button size="small" @click="batchDestroy">批量删除</el-button>
- <el-button size="small" @click="batchUpdate">批量更新</el-button>
- <el-button size="small" @click="openCategory">批量修改分类</el-button>
- <el-button size="small" @click="UpdateJob">一键更新</el-button>
- </div>
- <div>
- @section('search')
- <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>
- <el-table-column prop="mid_id" label="中台ID" width="90" align="center">
- <template slot-scope="scope">
- [[scope.row.jd_goods_id]]
- </template>
- </el-table-column> <el-table-column prop="member_name" label="排序" max-width="70" align="center">
- <template slot-scope="scope">
- <el-popover class="item" placement="top" effect="light">
- <div style="text-align:center;">
- <el-input v-model="change_sort" size="small" style="width:100px;"></el-input>
- <el-button size="small" @click="confirmChangeSort(scope.row.id)">确定</el-button>
- </div>
- <a slot="reference" >
- <i class="el-icon-edit edit-i" title="点击编辑排序" @click="editTitle(scope.$index,'sort')"></i>
- </a>
- </el-popover>
- [[scope.row.display_order]]
- </template>
- </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">
- <el-popover class="item" placement="top" effect="light">
- <div style="text-align:center;">
- <div style="text-align:left;margin-bottom:10px;font-weight:900">修改商品标题</div>
- <el-input v-model="change_title" style="width:400px" size="small"></el-input>
- <el-button size="small" @click="confirmChange(scope.row.id,'title')">确定</el-button>
- </div>
- <a slot="reference">
- <i class="el-icon-edit edit-i" title="点击编辑" @click="editTitle(scope.$index,'title')"></i>
- </a>
- </el-popover>
- [[scope.row.title]]
- </template>
- </el-table-column>
- <el-table-column prop="member_num" label="价格" max-width="80" align="center">
- <template slot-scope="scope">
- <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
- <div style="text-align:center;">
- <el-input v-model="change_price" size="small" style="width:100px;"></el-input>
- <el-button size="small" @click="confirmChange(scope.row.id,'price')">确定</el-button>
- </div>
- <a slot="reference" >
- <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'price')"></i>
- </a>
- </el-popover>
- ¥[[scope.row.price]]
- </template>
- </el-table-column>
- <el-table-column prop="member_num" label="成本价" width="80" align="center">
- <template slot-scope="scope">
- ¥[[scope.row.cost_price]]
- </template>
- </el-table-column>
- <el-table-column prop="member_num" label="利润率" width="80" align="center">
- <template slot-scope="scope">
- [[((scope.row.price - scope.row.cost_price)* 100 /scope.row.cost_price).toFixed(2)]]%
- </template>
- </el-table-column>
- <el-table-column label="库存" align="center" max-width="80">
- <template slot-scope="scope">
- <el-popover class="item" placement="top" effect="light" :disabled="scope.row.has_option==1">
- <div style="text-align:center;">
- <el-input v-model="change_stock" size="small" style="width:100px;"></el-input>
- <el-button size="small" @click="confirmChange(scope.row.id,'stock')">确定</el-button>
- </div>
- <a slot="reference" >
- <i class="el-icon-edit edit-i" :title="scope.row.has_option==1?'多规格不支持快速修改':'点击编辑'" @click="editTitle(scope.$index,'stock')"></i>
- </a>
- </el-popover>
- [[scope.row.stock]]
- </template>
- </el-table-column>
- <el-table-column prop="real_sales" label="销量" width="70" align="center">
- <template slot-scope="scope">
- [[scope.row.show_sales]]
- </template>
- </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="300" 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="smallImg" alt=""
- style="margin:10px;width:150px;height:150px;">
- </div>
- <a slot="reference" @mouseover="SmallCode(scope.$index)" :href="'{{ yzWebFullUrl('goods.goods.generate-small-code', array('id' => '')) }}'+[[scope.row.id]]">小程序</a>
- </el-popover>
- <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 target="_blank" :href="'{{ yzWebFullUrl('plugin.jd-supply.admin.shop-goods.edit', array('id' => '')) }}'+[[scope.row.id]]" target="_blank">
- 编辑
- </a>
- <a @click="delOne(scope.row.id)">
- 删除
- </a>
- <a @click="copyList(scope.row.id)">
- 复制链接
- </a>
- <a :href="'{{ yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-jd-goods', array('id' => '')) }}'+[[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>
- <div>
- <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>
- <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>
- <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>
- <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>
- </div>
- </template>
- </el-table-column>
- </el-table>
- <!-- 表格end -->
- </template>
- @show
- </div>
- </div>
- </div>
- <el-dialog :visible.sync="category_show" width="60%" center title="选择分类">
- <div style="height:500px">
- <el-select v-model="batch_v1" placeholder="请选择一级分类" clearable @change="batchChangeV1($event)" :style="{width:catlevel==3?'33%':'48%'}">
- <el-option v-for="(item,index) in batch_category" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <el-select v-model="batch_v2" placeholder="请选择二级分类" clearable @change="batchChangeV2($event)" :style="{width:catlevel==3?'33%':'48%'}">
- <el-option v-for="item in batch_category_v2" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <el-select v-model="batch_v3" placeholder="请选择三级分类" clearable v-if="catlevel==3" style="width:33%">
- <el-option v-for="item in batch_category_v3" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="category_show = false">取 消</el-button>
- <el-button type="primary" @click="batchCategory">确 定 </el-button>
- </span>
- </el-dialog>
- <!-- 分页 -->
- <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:'上架'},
- ],
- page_size:[
- {id:'',name:''},
- {id:20,name:'20条'},
- {id:50,name:'50条'},
- {id:100,name:'100条'},
- ],
- sell_stock_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:{},
- //批量修改分类
- batch_category:[],
- batch_category_v2:[],
- batch_category_v3:[],
- batch_v1:'',
- batch_v2:'',
- batch_v3:'',
- category_show:false,
- }
- },
- created() {
- this.getData();
- },
- methods: {
- getData() {
- var that = this;
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.goods-list') !!}").then(response => {
- console.log(response);
- if(response.data.result==1){
- that.goods_list = response.data.data.list.data;
- let arr =[];
- 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.list.total;
- that.current_page = response.data.data.list.current_page;
- that.per_size = response.data.data.list.per_page;
- // that.brands_list = response.data.data.brands;
- that.category_list = response.data.data.catetory;
- that.catlevel = response.data.data.cat_level;
- console.log(that.goods_list);
- }
- 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('plugin.jd-supply.admin.shop-goods.get-parent-category') !!}",{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,
- min_ratio:that.search_form.min_ratio,
- max_ratio:that.search_form.max_ratio,
- product_attr:product_attr,//商品类型
- page_size:that.search_form.page_size,//商品类型
- filtering_name: that.search_form.filtering_name,
- },
- 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.jd-supply.admin.shop-goods.goods-search') !!}",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;
- };
- },
- openCategory() {
- this.category_show = true;
- if(this.batch_category.length==0) {
- this.getBatchCategory();
- }
- },
- getBatchCategory() {
- var that = this;
- that.$http.post("{!! yzWebFullUrl('goods.category.get-all-shop-category') !!}", {}).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- this.batch_category = response.data.data.list;
- } else {
- that.$message.error(response.data.msg);
- }
- }), function (res) {
- console.log(res);
- };
- },
- batchCategory() {
- let that = this;
- let json = {
- level_1:this.batch_v1,
- level_2:this.batch_v2,
- goods_id_arr:[],
- };
- if(!json.level_1) {
- this.$message.error('请选择一级分类')
- return;
- }
- if(!json.level_2) {
- this.$message.error('请选择二级分类')
- return;
- }
- that.goods_list.forEach((item, index) => {
- if (item.is_choose == 1) {
- json.goods_id_arr.push(item.id);
- }
- })
- if(this.catlevel == 3) {
- json.level_3 = this.batch_v3
- if(!json.level_3) {
- this.$message.error('请选择三级分类')
- return;
- }
- }
- that.$http.post("{!! yzWebFullUrl('goods.category.change-many-goods-category') !!}", json).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- that.$message.success('操作成功!');
- that.is_all_choose = 0;
- that.search(1);
- this.category_show = false;
- } else {
- that.$message.error(response.data.msg);
- }
- }), function (res) {
- console.log(res);
- };
- },
- batchChangeV1(val) {
- console.log(val)
- this.batch_category_v2 = [];
- this.batch_category_v3 = [];
- this.batch_v2 = '';
- this.batch_v3 = '';
- let obj = this.batch_category.find((item,index) => {
- return item.id == val
- })
- this.batch_category_v2 = obj?obj.has_many_children:[]
- },
- batchChangeV2(val) {
- if(this.catlevel!=3) {
- return
- }
- this.batch_category_v3 = [];
- this.batch_v3 = '';
- let obj = this.batch_category_v2.find((item,index) => {
- return item.id == val
- })
- this.batch_category_v3 = obj?obj.has_many_children:[]
- },
- // 批量上架、下架
- 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('plugin.jd-supply.admin.shop-goods.delete') !!}",{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: '已取消修改'});
- });
- },
- // 一键更新
- UpdateJob() {
- var that = this;
- let job_num = 0;
- that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-job-nums') !!}").then(response => {
- if(response.data.result==1){
- job_num = response.data.data.nums;
- let job = Math.ceil(this.total / 20);
- console.log(job);
- that.$confirm('一键更新所有聚合供应链商品。该操作将产生'+job+'条队列。可能造成商城其他队列延迟执行,队列堵塞等情况,建议开启多个队列运行,请谨慎操作(每条队列所需时间约等于批量更新20条商品所需时间,当前约有'+job_num +'条队列等待执行)', '提示', {confirmButtonText: '确定更新',cancelButtonText: '取消',type: 'warning'}).then(() => {
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.update-job') !!}").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;
- };
- }).catch(() => {
- this.$message({type: 'info',message: '已取消'});
- });
- }
- }),function(res){
- console.log(res);
- };
- },
- // 批量删除
- batchDestroy() {
- var that = this;
- that.$confirm('确定删除吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- that.table_loading = true;
- let ids = [];
- that.goods_list.forEach((item,index) => {
- if(item.is_choose == 1){
- ids.push(item.id);
- }
- })
- let json = {ids:ids}
- that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.batch-delete') !!}",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;
- };
- }).catch(() => {
- this.$message({type: 'info',message: '已取消修改'});
- });
- },
- // 批量更新
- batchUpdate() {
- var that = this;
- that.$confirm('确定更新吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- that.table_loading = true;
- let ids = [];
- that.goods_list.forEach((item,index) => {
- if(item.is_choose == 1){
- ids.push(item.id);
- }
- })
- let json = {ids:ids}
- that.$http.post("{!! yzWebFullUrl('plugin.jd-supply.admin.shop-goods.batchUpdate') !!}",json).then(response => {
- console.log(response);
- if(response.data.result==1){
- that.$message.success(response.data.msg);
- 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;
- };
- }).catch(() => {
- this.$message({type: 'info',message: '已取消修改'});
- });
- },
- // 新品、热卖、推荐、促销、
- setProperty(id,index,type) {
- var that = this;
- that.table_loading = true;
- console.log(that.goods_list[index][type])
- let data = that.goods_list[index][type];
- let json = {id:id,type:type,data:data};
- that.$http.post("{!! yzWebFullUrl('goods.goods.setProperty') !!}",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][type] == 1 ? 0 : 1;
- }
- that.table_loading = false;
- }),function(res){
- console.log(res);
- that.table_loading = false;
- };
- },
- // 编辑商品标题
- editTitle(index,type) {
- let that = this;
- if(type == 'title') {
- that.change_title = "";
- that.change_title = that.goods_list[index].title;
- }
- if(type == 'price') {
- if(that.goods_list[index].has_option == 1) {
- that.$message.error('多规格不支持快速修改');
- return false;
- }
- that.change_price = "";
- that.change_price = that.goods_list[index].price;
- }
- if(type == 'stock') {
- if(that.goods_list[index].has_option == 1) {
- that.$message.error('多规格不支持快速修改');
- return false;
- }
- that.change_stock = "";
- that.change_stock = that.goods_list[index].stock;
- }
- if(type == 'sort') {
- that.change_sort = "";
- that.change_sort = that.goods_list[index].display_order;
- }
- },
- // 确认修改标题、价格、库存
- confirmChange(id,type) {
- let that = this;
- let value = '';
- if(type == 'title'){
- value = that.change_title;
- if(that.change_title == ''){
- that.$message.error('标题不能为空');
- return false;
- }
- }
- if(type == 'price'){
- value = that.change_price;
- if(!(/^\d+(\.\d+)?$/.test(that.change_price))){
- that.$message.error('请输入正确价格');
- return false;
- }
- }
- if(type == 'stock'){
- value = that.change_stock;
- if(!(/^\d+$/.test(that.change_stock))){
- that.$message.error('请输入正确数字');
- return false;
- }
- }
- let json = {
- id:id,
- type:type,
- value:value,
- };
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('goods.goods.change') !!}",json).then(response => {
- console.log(response);
- if(response.data.result==1){
- that.$message.success('操作成功!');
- if (document.all) {
- document.getElementById('app').click();
- }
- else {// 其它浏览器
- var e = document.createEvent('MouseEvents')
- e.initEvent('click', true, true)
- document.getElementById('app').dispatchEvent(e)
- }
- that.search(1);
- }
- else{
- that.$message.error(response.data.msg);
- }
- that.table_loading = false;
- }),function(res){
- console.log(res);
- that.table_loading = false;
- };
- },
- // 确认修改排序
- confirmChangeSort(id) {
- let that = this;
- if(!(/^\d+$/.test(that.change_sort))){
- that.$message.error('请输入正确数字');
- return false;
- }
- that.table_loading = true;
- let json = {id:id,value:that.change_sort};
- that.$http.post("{!! yzWebFullUrl('goods.goods.displayorder') !!}",json).then(response => {
- console.log(response);
- if(response.data.result==1){
- that.$message.success('操作成功!');
- // that.$refs.search_form.click();
- if (document.all) {
- document.getElementById('app').click();
- }
- else {// 其它浏览器
- var e = document.createEvent('MouseEvents')
- e.initEvent('click', true, true)
- document.getElementById('app').dispatchEvent(e)
- }
- that.search(1);
- }
- else{
- that.$message.error(response.data.msg);
- }
- that.table_loading = false;
- }),function(res){
- console.log(res);
- that.table_loading = false;
- };
- },
- // 字符转义
- escapeHTML(a) {
- a = "" + a;
- return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");;
- },
- },
- })
- </script>
- @endsection
|