Commit ef50aee3 by lixiaomin

修改商品查看规格状态

parent c0901f18
...@@ -175,18 +175,19 @@ export function checkMachine(id) { ...@@ -175,18 +175,19 @@ export function checkMachine(id) {
}); });
} }
// 获取规格选项状态 // 获取规格选项
export function getSpecState(shopId,goodsId) { export function getSpecSku(shopId,goodsId) {
return request({ return request({
url: "/system/shop/getShopGoodsSpecs?shopId=" + shopId+"&goodsId="+goodsId, //url: "/system/shop/getShopGoodsSpecs?shopId=" + shopId+"&goodsId="+goodsId,
url: "/system/shop/selectSkuByShopGoods?shopId=" + shopId+"&goodsId="+goodsId,
method: "get", method: "get",
}); });
} }
// 修改规格选项状态 // 修改规格选项状态
export function updateSpecState(shopId,goodsId,ruleId,state) { export function updateSpecState(ids,state) {
return request({ return request({
url: "/system/shop/updateShopGoodsSpecState?shopId=" + shopId+"&goodsId="+goodsId+"&ruleId="+ruleId+"&state="+state, url: "/system/shop/updateShopGoodsSkuState?ids="+ids+"&state="+state,
method: "get", method: "get",
}); });
} }
...@@ -97,37 +97,48 @@ ...@@ -97,37 +97,48 @@
layout="total, sizes, prev, pager, next,jumper" layout="total, sizes, prev, pager, next,jumper"
:total="totalNum"> :total="totalNum">
</el-pagination> </el-pagination>
<el-dialog title="查看规格" :visible.sync="viewSpecDialog" width="1000px" append-to-body> <el-dialog title="查看规格" :visible.sync="viewSpecDialog" width="800px" append-to-body>
<div style="margin-bottom: 10px;"> <div style="margin-bottom: 10px;" >
<el-row> <el-row>
<el-col :span='2'>商品名称</el-col> <div>
<el-col :span='22'>{{goodsName}}</el-col> <el-col :span='2'>商品名称</el-col>
<el-col :span='4'>{{goodsName}}</el-col>
</div>
<div style="display: flex;justify-content:space-between">
<div></div>
<div></div>
<div>
<!-- <el-button size="small" type="primary">全选</el-button> -->
<el-button size="small" type="success" @click="changeMoreState('1')">上架</el-button>
<el-button size="small" type="danger" @click="changeMoreState('2')">下架</el-button>
</div>
</div>
</el-row> </el-row>
</div> </div>
<div style="display:flex;flex-direction:row;flex-wrap:wrap;width:1000px;margin-bottom: 10px;"> <el-table :data="specNameList" style="width: 100%" @selection-change="specNameStateChange" ref="multipleTable">
<div style="width:480px;" v-for="(item,index) in specList" :key="index"> <el-table-column
<el-row style="margin-bottom: 10px;"> type="selection"
<el-col :span='4'>规格组名</el-col> width="55">
<el-col :span='20'>{{item.name}}</el-col> </el-table-column>
</el-row> <el-table-column label="商品规格">
<el-row>
<el-col :span='4'> 选项值</el-col> <template slot-scope="scope">
<el-col :span='20'> <div style="white-space: pre-wrap;">
<el-table :data="item.specRules"> {{scope.row.strName}}
<el-table-column label="选项名称" prop="name"/> </div>
<el-table-column label="售罄" > </template>
<template slot-scope="scope">
<div @click="changeState(scope.row)" ><el-switch v-model="scope.row.state"/> </div> </el-table-column>
<span v-if="scope.row.state == false">售罄</span> <el-table-column label="状态" >
<span v-if="scope.row.state == true">在售</span> <template slot-scope="scope">
</template> <div @click="changeOneState(scope.row)" ><el-switch v-model="scope.row.state"/> </div>
</el-table-column> <span v-if="scope.row.state == false">下架</span>
</el-table> <span v-if="scope.row.state == true">上架</span>
</el-col> </template>
</el-row> </el-table-column>
</div>
</div> </el-table>
<div class="dialog-footer" style="text-align: center"> <div class="dialog-footer" style="text-align: center;margin-top: 10px;">
<el-button @click="cancel" type="primary">关闭</el-button> <el-button @click="cancel" type="primary">关闭</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -135,7 +146,7 @@ ...@@ -135,7 +146,7 @@
</template> </template>
<script> <script>
import { getCategoryGoods, addGoods ,offGoods,turnList,getSpecState,updateSpecState} from "@/api/system/shop"; import { getCategoryGoods, addGoods ,offGoods,turnList,getSpecSku,updateSpecState} from "@/api/system/shop";
import SelectGoods from '@/components/SelectGoods'; import SelectGoods from '@/components/SelectGoods';
import AddRecommend from './addRecommend.vue' import AddRecommend from './addRecommend.vue'
import Preferential from './preferential.vue'; import Preferential from './preferential.vue';
...@@ -164,48 +175,102 @@ export default { ...@@ -164,48 +175,102 @@ export default {
outIds: '', outIds: '',
total: null, total: null,
goodsList:[], goodsList:[],
viewSpecDialog:false, viewSpecDialog:false,
specList:[],
specState:true,
goodsId:null, goodsId:null,
goodsName:"" goodsName:"",
specNameList:[],
ids:"",
} }
}, },
mounted() { mounted() {
//this.getList() //this.getList()
}, },
methods: { methods: {
//新增接口1
cancel(){ cancel(){
this.viewSpecDialog=false; this.viewSpecDialog=false;
}, },
changeState(row){ specNameStateChange(val) {
this.ids="";
for(let i=0;i<val.length;i++){
this.ids +=val[i].id+","
}
this.ids=this.ids.substring(0,this.ids.length-1)
},
//新增接口2
changeOneState(row){
let tag=2; let tag=2;
if(row.state){ if(row.state){
tag=1; tag=1;
} }
updateSpecState(this.shopId,this.goodsId,row.id,tag).then((response) => { this.updateSpecState(row.id,tag);
if(response.code=="200"){ },
this.$modal.msgSuccess("修改状态成功!"); //新增接口3
changeMoreState(tag){
this.updateSpecState(this.ids,tag);
},
updateSpecState(ids,tag){
updateSpecState(ids,tag).then((response) => {
if(response.code=="200"){
let idsList=ids.split(",");
for(let i=0;i<idsList.length;i++){
let selectedId=idsList[i]
for(let j=0;j<this.specNameList.length;j++){
if(this.specNameList[j].id==selectedId){
this.specNameList[j].state=(tag == 1?true:false)
}
}
}
if(tag==1){
this.$modal.msgSuccess("上架成功!");
}else{
this.$modal.msgSuccess("下架成功!");
}
this.$refs.multipleTable.clearSelection();
}else{
if(tag==1){
this.$message.error("上架失败!");
}else{
this.$message.error("下架失败!");
}
} }
}) })
}, },
//新增接口3
clickView(row){ clickView(row){
this.specNameList=[];
this.viewSpecDialog=true; this.viewSpecDialog=true;
this.goodsId=row.id; this.goodsId=row.id;
this.goodsName=row.name; this.goodsName=row.name;
getSpecState(this.shopId,row.id).then((response) => { let specList=JSON.parse(row.spec);
getSpecSku(this.shopId,row.id).then((response) => {
if(response.code=="200"){ if(response.code=="200"){
for(let i=0;i<response.data.length;i++){ let list=response.data;
let itemI = response.data[i]; for(let i=0;i<list.length;i++){
for(let j=0;j<itemI.specRules.length;j++){ let ruleList=JSON.parse(list[i].ruleList);
let itemJ= itemI.specRules[j]; let strName = '';
itemJ.state = (itemJ.state == 1?true:false); for(let j=0;j<ruleList.length;j++){
ruleList[j].specName=this.findSpecNameById(specList,ruleList[j].specId);
strName +=ruleList[j].specName+":"+ruleList[j].name+"\n";
} }
} list[i].state=(list[i].state == 1?true:false)
this.specList=response.data this.specNameList.push({"id":list[i].id,"strName":strName,"state":list[i].state})
} }
}
}); });
}, },
//根据id找name
findSpecNameById(specList,p_specId){
let specName = '';
for(let i=0;i<specList.length;i++){
let specId = specList[i].id;
if(specId == p_specId){
specName = specList[i].name;
break;
}
}
return specName;
},
turnClick(row,tag){ turnClick(row,tag){
turnList({"shopId":this.shopId,"goodsId": row.id,"pointer":tag}).then((response) => { turnList({"shopId":this.shopId,"goodsId": row.id,"pointer":tag}).then((response) => {
if(response.code=="200"){ if(response.code=="200"){
...@@ -264,8 +329,7 @@ export default { ...@@ -264,8 +329,7 @@ export default {
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.outIds = selection.map((item) => item.id); this.outIds = selection.map((item) => item.id);
}, },
soldOutGoos(){ soldOutGoos(){
console.log("this.outIds",this.outIds)
if(this.outIds.length==0){ if(this.outIds.length==0){
this.$message.error('请选择所需下架的商品!'); this.$message.error('请选择所需下架的商品!');
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment