| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184 |
- @extends('layouts.base')
- @section('title', "商品列表")
- @section('content')
- <style>
- .sort_active{
- color: #29BA9C;
- }
- .el-icon-caret-top{
- cursor: pointer;
- }
- .el-icon-caret-bottom{
- cursor: pointer;
- }
- .el-icon-caret-top:hover{
- color: #29BA9C;
- }
- .el-icon-caret-bottom:hover{
- color: #29BA9C;
- }
- </style>
- <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()" filterable>
- <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()" filterable>
- <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" filterable>
- <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="">
- <el-select v-model="search_form.middleground_configuration_id" placeholder="请选择供应链" clearable remote filterable >
- <el-option v-for="item in middleground_configuration" :key="item.id" :label="item.title" :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_name">
- <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>
- <el-select v-model="search_form.is_hide" placeholder="请选择商品是否显示" clearable>
- <el-option label="显示" value="1"></el-option>
- <el-option label="隐藏" value="2"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="">
- <el-select v-model="search_form.source_id" placeholder="请选择商品来源" clearable v-if="is_source_open">
- <el-option v-for="item in source_list" :key="item.id" :label="item.source_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="UpdateJob">一键更新</el-button>
- <el-button size="small" @click="openCategory">批量修改分类</el-button>
- <el-button size="small" @click="setLocks(1)">批量锁定</el-button>
- <el-button size="small" @click="setLocks(2)">批量解锁</el-button>
- </div>
- <div style="color: red;margin:10px;">*如果锁定商品状态,第三方商品上下架,更新时触发风控都不会改变商品在商城的上下架状态</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="member_name" label="排序" max-width="80" 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="title" label="供应链名称" width="150" align="center">
- <template slot-scope="scope" v-if="scope.row.has_one_yz_goods">
- [[scope.row.has_one_yz_goods.has_one_middleground_configuration.title]]
- </template>
- </el-table-column>
- <el-table-column prop="member_num" label="价格" max-width="80" align="center">
- <template slot="header" slot-scope="scope">
- <div style="display: flex;align-items: center;justify-content:center">
- <span>价格</span>
- <div style="display: flex;flex-direction: column;margin-left: 5px;">
- <i class="el-icon-caret-top" :class="sort_price == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('price')" ></i>
- <i class="el-icon-caret-bottom" :class="sort_price == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('price')"></i>
- </div>
- </div>
- </template>
- <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" >
- <div v-if="scope.row.price != 0"> [[((scope.row.price - scope.row.cost_price)* 100 /scope.row.price).toFixed(2)]]% </div>
- <div v-else>0%</div>
- </template>
- </el-table-column>
- <el-table-column label="库存" align="center" max-width="80">
- <template slot="header" slot-scope="scope">
- <div style="display: flex;align-items: center;justify-content:center">
- <span>库存</span>
- <div style="display: flex;flex-direction: column;margin-left: 5px;">
- <i class="el-icon-caret-top" :class="sort_stock == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('stock')" ></i>
- <i class="el-icon-caret-bottom" :class="sort_stock == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('stock')"></i>
- </div>
- </div>
- </template>
- <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="销量" max-width="80" align="center">
- <template slot="header" slot-scope="scope">
- <div style="display: flex;align-items: center;justify-content:center">
- <span>销量</span>
- <div style="display: flex;flex-direction: column;margin-left: 5px;">
- <i class="el-icon-caret-top" :class="sort_sales == 'asc' ? 'sort_active' : '' " @click="btnPositiveSequence('sales')" ></i>
- <i class="el-icon-caret-bottom" :class="sort_sales == 'desc' ? 'sort_active' : '' " @click="btnReverseOrder('sales')"></i>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column class="goods_status" prop="stock" >
- <template slot="header" slot-scope="scope">
- <p>商品状态</p>
- <p>锁定状态</p>
- </template>
- <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>
- <p v-if="scope.row.has_one_yz_goods">
- [[scope.row.has_one_yz_goods.is_lock_status == 2?'未锁':'锁定']]
- <el-switch v-model="scope.row.has_one_yz_goods.is_lock_status" :active-value="1" :inactive-value="2" @change="setLock(scope.row.id,scope.$index)"></el-switch>
- </p>
- </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="smallImg" alt=""
- style="margin:10px;width:100px;height:100px;">
- </div>
- <a slot="reference" @mouseover="SmallCode(scope.$index)" :href="'{{ yzWebFullUrl('plugin.yz-supply.admin.shop-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 v-if="isUpdatePrice == 1" :href="'{{ yzWebFullUrl('plugin.yz-supply.admin.shop-goods.edit', array('id' => '')) }}'+[[scope.row.id]]">
- 编辑
- </a>
- <a @click="delOne(scope.row.id)">
- 删除
- </a>
- <a @click="copyList(scope.row.id)">
- 复制链接
- </a>
- <a :href="'{{ yzWebFullUrl('plugin.yz-supply.admin.shop-goods.update-yz-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() {
- let topic_id = '{!! $topic_id !!}';
- return{
- isUpdatePrice:2,
- //批量修改分类
- batch_category:[],
- batch_category_v2:[],
- batch_category_v3:[],
- batch_v1:'',
- batch_v2:'',
- batch_v3:'',
- category_show:false,
- middleground_configuration:[],
- middleground_configuration_id:0,
- 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:{
- topic_id:topic_id,
- id_v1:'',
- id_v2:'',
- id_v3:''
- },
- form:{},
- level_list:[],
- loading:false,
- table_loading:false,
- rules:{},
- //分页
- total:0,
- per_size:0,
- current_page:0,
- rules:{},
- sort_price:"",
- sort_stock:"",
- sort_sales:"",
- source_list:[],
- is_source_open:0,
- }
- },
- created() {
- this.getData();
- this.getMiddlegroundConfiguration();
- },
- methods: {
- btnPositiveSequence(val){
- switch (val) {
- case 'price'://价格
- this.sort_price = this.sort_price == 'asc'? '' : 'asc';
- break;
- case 'stock': //库存
- this.sort_stock = this.sort_stock == 'asc'? '' : 'asc';
- break;
- case 'sales': //销量
- this.sort_sales = this.sort_sales == 'asc'? '' : 'asc';
- break;
- default:
- break;
- }
- this.search(1);
- },
- btnReverseOrder(val){
- switch (val) {
- case 'price'://价格
- this.sort_price = this.sort_price == 'desc'? '' : 'desc';
- break;
- case 'stock': //库存
- this.sort_stock = this.sort_stock == 'desc'? '' : 'desc';
- break;
- case 'sales': //销量
- this.sort_sales = this.sort_sales == 'desc'? '' : 'desc';
- break;
- default:
- break;
- }
- this.search(1);
- },
- //一键解锁与锁定
- setLocks(status){
- var that = this;
- var msg = "解定";
- if(status == 1) {
- msg = "锁定"
- }
- let ids = [];
- that.goods_list.forEach((item,index) => {
- if(item.is_choose == 1){
- ids.push(item.id);
- }
- })
- that.$confirm('确定'+msg+'吗', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
- that.table_loading = true;
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-goods.set-locks') !!}",{status:status,ids:ids}).then(response => {
- console.log(response);
- if(response.data.result==1){
- that.$message.success(""+msg+"成功!");
- 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: '已取消'});
- });
- },
- /**
- * 锁定与解锁
- * @param item
- */
- setLock(id,index){
- var that = this;
- that.table_loading = true;
- let json = {id:id};
- // yzWebFullUrl('plugin.yz-supply.admin.shop-goods.goods-search')
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-goods.set-lock') !!}",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].has_one_yz_goods.is_lock_status == 1 ? 2 : 1;
- }
- that.table_loading = false;
- }),function(res){
- console.log(res);
- that.table_loading = false;
- };
- },
- getMiddlegroundConfiguration(){
- this.$http.post('{!! yzWebFullUrl('plugin.yz-supply.admin.middleground-configuration.get-middleground-configurations') !!}',{"is_all":1}).then(function (response) {
- if (response.data.result) {
- this.middleground_configuration = response.data.data;
- } else {
- this.$message({message: response.data.msg, type: 'error'});
- }
- }, function (response) {
- this.$message({message: response.data.msg, type: 'error'});
- })
- },
- getData() {
- var that = this;
- that.table_loading = true;
- let json = {
- search:{
- topic_id:that.search_form.topic_id,//商品专题
- },
- };
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-goods.goods-list') !!}",json).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.isUpdatePrice = response.data.data.isUpdatePrice;
- 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;
- that.catlevel = response.data.data.cat_level;
- that.catlevel = response.data.data.cat_level;
- that.source_list = response.data.data.source_list;
- that.is_source_open = response.data.data.is_source_open;
- 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(){
- if(this.search_form.id_v1 == ""){
- return true;
- }
- 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.yz-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(){
- if(this.search_form.id_v2 == ""){
- return true;
- }
- let that = this;
- this.search_form.id_v3 = "";
- this.category_list_v3 = [];
- if(this.catlevel==3) {
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.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 order_by = {};
- if (this.sort_price) {
- order_by.price = this.sort_price;
- }
- if (this.sort_stock) {
- order_by.stock = this.sort_stock;
- }
- if (this.sort_sales) {
- order_by.real_sales = this.sort_sales;
- }
- let json = {
- page:page,
- order_by:order_by,
- 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,
- is_hide:that.search_form.is_hide,
- filtering_name:that.search_form.filtering_name,
- product_attr:product_attr,//商品类型
- page_size:that.search_form.page_size,//商品类型
- middleground_configuration_id:that.search_form.middleground_configuration_id,
- topic_id:that.search_form.topic_id,//商品专题
- source_id:that.search_form.source_id,//商品来源
- },
- 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.yz-supply.admin.shop-goods.goods-search') !!}",json).then(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};
- // yzWebFullUrl('plugin.yz-supply.admin.shop-goods.goods-search')
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.shop-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('plugin.yz-supply.admin.shop-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.yz-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.msg);
- }
- 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.yz-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.yz-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.yz-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.yz-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('plugin.yz-supply.admin.shop-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('plugin.yz-supply.admin.shop-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;
- };
- },
- // 批量修改分类-打开分类选择框
- openCategory() {
- this.category_show = true;
- if(this.batch_category.length==0) {
- this.getBatchCategory();
- }
- },
- getBatchCategory() {
- var that = this;
- that.$http.post("{!! yzWebFullUrl('plugin.yz-supply.admin.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('plugin.yz-supply.admin.category.change-many-goods-category') !!}", json).then(response => {
- console.log(response);
- if (response.data.result == 1) {
- that.$message.success('操作成功!');
- that.is_all_choose = 0;
- this.category_show = false;
- that.search(1);
- } 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:[]
- },
- // 字符转义
- escapeHTML(a) {
- a = "" + a;
- return a.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");;
- },
- },
- })
- </script>
- @endsection
|