添加商品库存批量编辑
This commit is contained in:
parent
61cf19f1f8
commit
98688dc658
16
src/api/skuStock.js
Normal file
16
src/api/skuStock.js
Normal file
@ -0,0 +1,16 @@
|
||||
import request from '@/utils/request'
|
||||
export function fetchList(pid,params) {
|
||||
return request({
|
||||
url:'/sku/'+pid,
|
||||
method:'get',
|
||||
params:params
|
||||
})
|
||||
}
|
||||
|
||||
export function update(pid,data) {
|
||||
return request({
|
||||
url:'/sku/update/'+pid,
|
||||
method:'post',
|
||||
data:data
|
||||
})
|
||||
}
|
@ -95,6 +95,11 @@
|
||||
style="margin-top: 20px"
|
||||
@click="handleRefreshProductSkuList">刷新列表
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
style="margin-top: 20px"
|
||||
@click="handleSyncProductSkuPrice">同步价格
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="属性图片:" v-if="hasAttrPic">
|
||||
<el-card shadow="never" class="cardBg">
|
||||
@ -403,6 +408,20 @@
|
||||
this.refreshProductSkuList();
|
||||
});
|
||||
},
|
||||
handleSyncProductSkuPrice(){
|
||||
this.$confirm('将同步第一个sku的价格到所有sku,是否继续', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
if(this.value.skuStockList!==null&&this.value.skuStockList.length>0){
|
||||
let price=this.value.skuStockList[0].price;
|
||||
for(let i=0;i<this.value.skuStockList.length;i++){
|
||||
this.value.skuStockList[i].price=price;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
refreshProductSkuList() {
|
||||
this.value.skuStockList = [];
|
||||
let skuList = this.value.skuStockList;
|
||||
|
@ -119,6 +119,13 @@
|
||||
showStatus: [true, false, false, false]
|
||||
}
|
||||
},
|
||||
created(){
|
||||
if(this.isEdit){
|
||||
getProduct(this.$route.query.id).then(response=>{
|
||||
this.productParam=response.data;
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
hideAll() {
|
||||
for (let i = 0; i < this.showStatus.length; i++) {
|
||||
|
@ -52,6 +52,9 @@
|
||||
<el-input v-model="value.weight" style="width: 300px"></el-input>
|
||||
<span style="margin-left: 20px">克</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序">
|
||||
<el-input v-model="value.sort"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item style="text-align: center">
|
||||
<el-button type="primary" size="medium" @click="handleNext('productInfoForm')">下一步,填写商品促销</el-button>
|
||||
</el-form-item>
|
||||
@ -75,6 +78,7 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
hasEditCreated:false,
|
||||
//选中商品分类的值
|
||||
selectProductCateValue: [],
|
||||
productCateOptions: [],
|
||||
@ -93,13 +97,22 @@
|
||||
};
|
||||
},
|
||||
created() {
|
||||
if(this.isEdit){
|
||||
this.handleEditCreated();
|
||||
}
|
||||
this.getProductCateList();
|
||||
this.getBrandList();
|
||||
},
|
||||
computed:{
|
||||
//商品的编号
|
||||
productId(){
|
||||
return this.value.id;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
productId:function(newValue){
|
||||
if(!this.isEdit)return;
|
||||
if(this.hasEditCreated)return;
|
||||
if(newValue===undefined||newValue==null||newValue===0)return;
|
||||
this.handleEditCreated();
|
||||
},
|
||||
selectProductCateValue: function (newValue) {
|
||||
if (newValue != null && newValue.length === 2) {
|
||||
this.value.productCategoryId = newValue[1];
|
||||
@ -111,13 +124,11 @@
|
||||
methods: {
|
||||
//处理编辑逻辑
|
||||
handleEditCreated(){
|
||||
getProduct(this.$route.query.id).then(response=>{
|
||||
if(response.data.productCategoryId!=null){
|
||||
this.selectProductCateValue.push(response.data.cateParentId);
|
||||
this.selectProductCateValue.push(response.data.productCategoryId);
|
||||
}
|
||||
this.$emit('input',response.data);
|
||||
});
|
||||
if(this.value.productCategoryId!=null){
|
||||
this.selectProductCateValue.push(this.value.cateParentId);
|
||||
this.selectProductCateValue.push(this.value.productCategoryId);
|
||||
}
|
||||
this.hasEditCreated=true;
|
||||
},
|
||||
getProductCateList() {
|
||||
fetchListWithChildren().then(response => {
|
||||
|
@ -33,7 +33,7 @@
|
||||
</el-switch>
|
||||
<span style="margin-left: 10px;margin-right: 10px">推荐</span>
|
||||
<el-switch
|
||||
v-model="value.recommendStatus"
|
||||
v-model="value.recommandStatus"
|
||||
:active-value="1"
|
||||
:inactive-value="0">
|
||||
</el-switch>
|
||||
|
@ -135,7 +135,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="SKU库存" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="primary" icon="el-icon-edit" circle></el-button>
|
||||
<el-button type="primary" icon="el-icon-edit" @click="handleShowSkuEditDialog(scope.$index, scope.row)" circle></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="销量" width="100" align="center">
|
||||
@ -211,6 +211,64 @@
|
||||
:total="total">
|
||||
</el-pagination>
|
||||
</div>
|
||||
<el-dialog
|
||||
title="编辑货品信息"
|
||||
:visible.sync="editSkuInfo.dialogVisible"
|
||||
width="40%">
|
||||
<span>商品货号:</span>
|
||||
<span>{{editSkuInfo.productName}}</span>
|
||||
<el-input placeholder="按sku编号搜索" v-model="editSkuInfo.keyword" size="small" style="width: 50%;margin-left: 20px">
|
||||
<el-button slot="append" icon="el-icon-search" @click="handleSearchEditSku"></el-button>
|
||||
</el-input>
|
||||
<el-table style="width: 100%;margin-top: 20px"
|
||||
:data="editSkuInfo.stockList"
|
||||
border>
|
||||
<el-table-column
|
||||
label="SKU编号"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.skuCode"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-for="(item,index) in editSkuInfo.productAttr"
|
||||
:label="item.name"
|
||||
:key="item.id"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
{{getProductSkuSp(scope.row,index)}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="销售价格"
|
||||
width="80"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.price"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="商品库存"
|
||||
width="80"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.stock"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="库存预警值"
|
||||
width="100"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.lowStock"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="editSkuInfo.dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleEditSkuConfirm">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
@ -221,6 +279,8 @@
|
||||
updateRecommendStatus,
|
||||
updatePublishStatus
|
||||
} from '@/api/product'
|
||||
import {fetchList as fetchSkuStockList,update as updateSkuStockList} from '@/api/skuStock'
|
||||
import {fetchList as fetchProductAttrList} from '@/api/productAttr'
|
||||
import {fetchList as fetchBrandList} from '@/api/brand'
|
||||
import {fetchListWithChildren} from '@/api/productCate'
|
||||
|
||||
@ -238,6 +298,15 @@
|
||||
name: "productList",
|
||||
data() {
|
||||
return {
|
||||
editSkuInfo:{
|
||||
dialogVisible:false,
|
||||
productId:null,
|
||||
productName:'',
|
||||
productAttributeCategoryId:null,
|
||||
stockList:[],
|
||||
productAttr:[],
|
||||
keyword:null
|
||||
},
|
||||
operates: [
|
||||
{
|
||||
label: "商品上架",
|
||||
@ -322,6 +391,15 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getProductSkuSp(row, index) {
|
||||
if (index === 0) {
|
||||
return row.sp1;
|
||||
} else if (index === 1) {
|
||||
return row.sp2;
|
||||
} else {
|
||||
return row.sp3;
|
||||
}
|
||||
},
|
||||
getList() {
|
||||
this.listLoading = true;
|
||||
fetchList(this.listQuery).then(response => {
|
||||
@ -354,6 +432,48 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
handleShowSkuEditDialog(index,row){
|
||||
this.editSkuInfo.dialogVisible=true;
|
||||
this.editSkuInfo.productId=row.id;
|
||||
this.editSkuInfo.productName=row.name;
|
||||
this.editSkuInfo.productAttributeCategoryId = row.productAttributeCategoryId;
|
||||
this.editSkuInfo.keyword=null;
|
||||
fetchSkuStockList(row.id,{keyword:this.editSkuInfo.keyword}).then(response=>{
|
||||
this.editSkuInfo.stockList=response.data;
|
||||
});
|
||||
fetchProductAttrList(row.productAttributeCategoryId,{type:0}).then(response=>{
|
||||
this.editSkuInfo.productAttr=response.data.list;
|
||||
});
|
||||
},
|
||||
handleSearchEditSku(){
|
||||
fetchSkuStockList(this.editSkuInfo.productId,{keyword:this.editSkuInfo.keyword}).then(response=>{
|
||||
this.editSkuInfo.stockList=response.data;
|
||||
});
|
||||
},
|
||||
handleEditSkuConfirm(){
|
||||
if(this.editSkuInfo.stockList==null||this.editSkuInfo.stockList.length<=0){
|
||||
this.$message({
|
||||
message: '暂无sku信息',
|
||||
type: 'warning',
|
||||
duration: 1000
|
||||
});
|
||||
return
|
||||
}
|
||||
this.$confirm('是否要进行修改', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(()=>{
|
||||
updateSkuStockList(this.editSkuInfo.productId,this.editSkuInfo.stockList).then(response=>{
|
||||
this.$message({
|
||||
message: '修改成功',
|
||||
type: 'success',
|
||||
duration: 1000
|
||||
});
|
||||
this.editSkuInfo.dialogVisible=false;
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSearchList() {
|
||||
this.listQuery.pageNum = 1;
|
||||
this.getList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user