添加商品库存批量编辑
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"
|
style="margin-top: 20px"
|
||||||
@click="handleRefreshProductSkuList">刷新列表
|
@click="handleRefreshProductSkuList">刷新列表
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
style="margin-top: 20px"
|
||||||
|
@click="handleSyncProductSkuPrice">同步价格
|
||||||
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="属性图片:" v-if="hasAttrPic">
|
<el-form-item label="属性图片:" v-if="hasAttrPic">
|
||||||
<el-card shadow="never" class="cardBg">
|
<el-card shadow="never" class="cardBg">
|
||||||
@ -403,6 +408,20 @@
|
|||||||
this.refreshProductSkuList();
|
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() {
|
refreshProductSkuList() {
|
||||||
this.value.skuStockList = [];
|
this.value.skuStockList = [];
|
||||||
let skuList = this.value.skuStockList;
|
let skuList = this.value.skuStockList;
|
||||||
|
@ -119,6 +119,13 @@
|
|||||||
showStatus: [true, false, false, false]
|
showStatus: [true, false, false, false]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created(){
|
||||||
|
if(this.isEdit){
|
||||||
|
getProduct(this.$route.query.id).then(response=>{
|
||||||
|
this.productParam=response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hideAll() {
|
hideAll() {
|
||||||
for (let i = 0; i < this.showStatus.length; i++) {
|
for (let i = 0; i < this.showStatus.length; i++) {
|
||||||
|
@ -52,6 +52,9 @@
|
|||||||
<el-input v-model="value.weight" style="width: 300px"></el-input>
|
<el-input v-model="value.weight" style="width: 300px"></el-input>
|
||||||
<span style="margin-left: 20px">克</span>
|
<span style="margin-left: 20px">克</span>
|
||||||
</el-form-item>
|
</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-form-item style="text-align: center">
|
||||||
<el-button type="primary" size="medium" @click="handleNext('productInfoForm')">下一步,填写商品促销</el-button>
|
<el-button type="primary" size="medium" @click="handleNext('productInfoForm')">下一步,填写商品促销</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -75,6 +78,7 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
hasEditCreated:false,
|
||||||
//选中商品分类的值
|
//选中商品分类的值
|
||||||
selectProductCateValue: [],
|
selectProductCateValue: [],
|
||||||
productCateOptions: [],
|
productCateOptions: [],
|
||||||
@ -93,13 +97,22 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if(this.isEdit){
|
|
||||||
this.handleEditCreated();
|
|
||||||
}
|
|
||||||
this.getProductCateList();
|
this.getProductCateList();
|
||||||
this.getBrandList();
|
this.getBrandList();
|
||||||
},
|
},
|
||||||
|
computed:{
|
||||||
|
//商品的编号
|
||||||
|
productId(){
|
||||||
|
return this.value.id;
|
||||||
|
}
|
||||||
|
},
|
||||||
watch: {
|
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) {
|
selectProductCateValue: function (newValue) {
|
||||||
if (newValue != null && newValue.length === 2) {
|
if (newValue != null && newValue.length === 2) {
|
||||||
this.value.productCategoryId = newValue[1];
|
this.value.productCategoryId = newValue[1];
|
||||||
@ -111,13 +124,11 @@
|
|||||||
methods: {
|
methods: {
|
||||||
//处理编辑逻辑
|
//处理编辑逻辑
|
||||||
handleEditCreated(){
|
handleEditCreated(){
|
||||||
getProduct(this.$route.query.id).then(response=>{
|
if(this.value.productCategoryId!=null){
|
||||||
if(response.data.productCategoryId!=null){
|
this.selectProductCateValue.push(this.value.cateParentId);
|
||||||
this.selectProductCateValue.push(response.data.cateParentId);
|
this.selectProductCateValue.push(this.value.productCategoryId);
|
||||||
this.selectProductCateValue.push(response.data.productCategoryId);
|
|
||||||
}
|
}
|
||||||
this.$emit('input',response.data);
|
this.hasEditCreated=true;
|
||||||
});
|
|
||||||
},
|
},
|
||||||
getProductCateList() {
|
getProductCateList() {
|
||||||
fetchListWithChildren().then(response => {
|
fetchListWithChildren().then(response => {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
</el-switch>
|
</el-switch>
|
||||||
<span style="margin-left: 10px;margin-right: 10px">推荐</span>
|
<span style="margin-left: 10px;margin-right: 10px">推荐</span>
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="value.recommendStatus"
|
v-model="value.recommandStatus"
|
||||||
:active-value="1"
|
:active-value="1"
|
||||||
:inactive-value="0">
|
:inactive-value="0">
|
||||||
</el-switch>
|
</el-switch>
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="SKU库存" width="100" align="center">
|
<el-table-column label="SKU库存" width="100" align="center">
|
||||||
<template slot-scope="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="销量" width="100" align="center">
|
<el-table-column label="销量" width="100" align="center">
|
||||||
@ -211,6 +211,64 @@
|
|||||||
:total="total">
|
:total="total">
|
||||||
</el-pagination>
|
</el-pagination>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -221,6 +279,8 @@
|
|||||||
updateRecommendStatus,
|
updateRecommendStatus,
|
||||||
updatePublishStatus
|
updatePublishStatus
|
||||||
} from '@/api/product'
|
} 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 {fetchList as fetchBrandList} from '@/api/brand'
|
||||||
import {fetchListWithChildren} from '@/api/productCate'
|
import {fetchListWithChildren} from '@/api/productCate'
|
||||||
|
|
||||||
@ -238,6 +298,15 @@
|
|||||||
name: "productList",
|
name: "productList",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
editSkuInfo:{
|
||||||
|
dialogVisible:false,
|
||||||
|
productId:null,
|
||||||
|
productName:'',
|
||||||
|
productAttributeCategoryId:null,
|
||||||
|
stockList:[],
|
||||||
|
productAttr:[],
|
||||||
|
keyword:null
|
||||||
|
},
|
||||||
operates: [
|
operates: [
|
||||||
{
|
{
|
||||||
label: "商品上架",
|
label: "商品上架",
|
||||||
@ -322,6 +391,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getProductSkuSp(row, index) {
|
||||||
|
if (index === 0) {
|
||||||
|
return row.sp1;
|
||||||
|
} else if (index === 1) {
|
||||||
|
return row.sp2;
|
||||||
|
} else {
|
||||||
|
return row.sp3;
|
||||||
|
}
|
||||||
|
},
|
||||||
getList() {
|
getList() {
|
||||||
this.listLoading = true;
|
this.listLoading = true;
|
||||||
fetchList(this.listQuery).then(response => {
|
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() {
|
handleSearchList() {
|
||||||
this.listQuery.pageNum = 1;
|
this.listQuery.pageNum = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user