商品添加

This commit is contained in:
余同学 2024-11-17 18:00:35 +08:00
parent 94a1e831c4
commit 066eb8004e
5 changed files with 121 additions and 39 deletions

View File

@ -49,12 +49,12 @@ export const mer_admin = {
return $http.post(`/merchant-api/product/page`, data); return $http.post(`/merchant-api/product/page`, data);
}, },
//商户商品分类 //商户商品分类
getProductCategory: () => { getProductCategory: (data) => {
return $http.get( return $http.request({
`/merchant-api/product/category/list?shopId=${ url: `/merchant-api/product/category/list`,
JSON.parse(sessionStorage.getItem("userInfo")).shopId method: "get",
}` params: data,
); });
}, },
//上架或下架 //上架或下架
putOnShelvesProducts: (data) => { putOnShelvesProducts: (data) => {
@ -154,6 +154,14 @@ export const mer_admin = {
params: { id }, params: { id },
}); });
}, },
//市场下的店铺列表
storeList: (data) => {
return $http.request({
method: "get",
url: `/merchant-api/market/shop_list`,
params: data,
});
},
//获取品牌信息 //获取品牌信息
getBrandInfo: () => { getBrandInfo: () => {
return $http.request({ return $http.request({

View File

@ -133,7 +133,7 @@ export default {
{ {
title: "银行卡号", title: "银行卡号",
align: "center", align: "center",
field: "cardId", field: "cardNo",
}, },
{ {
title: "手机号", title: "手机号",

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<div v-if="shopId" style="height: calc(100vh - 200px)"> <div v-if="isShopId" style="height: calc(100vh - 200px)">
<obj-table-plus <obj-table-plus
ref="oTable" ref="oTable"
style="height: 100%" style="height: 100%"
@ -9,6 +9,7 @@
@query="queryList" @query="queryList"
v-model="dataList" v-model="dataList"
:tableEvent="tableEvent" :tableEvent="tableEvent"
:enableAutoQuery="false"
> >
<template slot="tableTop"> <template slot="tableTop">
<el-form :inline="true" :model="formInline" class="demo-form-inline"> <el-form :inline="true" :model="formInline" class="demo-form-inline">
@ -31,7 +32,11 @@
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item v-if="marketList.length > 0" label="摊铺"> <el-form-item v-if="marketList.length > 0" label="摊铺">
<el-select v-model="formInline.marketId" placeholder="请选择摊铺"> <el-select
@change="getData"
v-model="formInline.marketId"
placeholder="请选择摊铺"
>
<el-option <el-option
v-for="item in marketList" v-for="item in marketList"
:key="item.marketId" :key="item.marketId"
@ -40,6 +45,16 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="marketList.length > 0" label="商店">
<el-select v-model="formInline.shopId" placeholder="请选择商店">
<el-option
v-for="item in storeList"
:key="item.shopId"
:label="item.shopName"
:value="item.shopId"
></el-option>
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="$refs.oTable.reload()" <el-button type="primary" @click="$refs.oTable.reload()"
>查询</el-button >查询</el-button
@ -101,6 +116,7 @@ export default {
formInline: { formInline: {
name: "", name: "",
marketId: "", marketId: "",
shopId: "",
}, },
marketList: [], marketList: [],
tableProp: { tableProp: {
@ -112,26 +128,45 @@ export default {
}, },
productFilterType: "SALE", productFilterType: "SALE",
selectList: [], selectList: [],
shopId: "", isShopId: "",
storeList: [],
}; };
}, },
created() { created() {
if (JSON.parse(sessionStorage.getItem("userInfo")).markets.length > 0) { if (JSON.parse(sessionStorage.getItem("userInfo")).markets.length > 0) {
this.shopId = true; this.isShopId = true;
this.formInline.marketId = JSON.parse( this.formInline.marketId = JSON.parse(
sessionStorage.getItem("userInfo") sessionStorage.getItem("userInfo")
).markets[0].marketId; ).markets[0].marketId;
this.marketList = JSON.parse(sessionStorage.getItem("userInfo")).markets; this.marketList = JSON.parse(sessionStorage.getItem("userInfo")).markets;
console.log(this.marketList); console.log(this.marketList);
this.getData();
} else if (JSON.parse(sessionStorage.getItem("userInfo")).shopId) { } else if (JSON.parse(sessionStorage.getItem("userInfo")).shopId) {
this.shopId = true; (this.formInline.shopId = JSON.parse(
sessionStorage.getItem("userInfo")
).shopId),
(this.isShopId = true);
this.$nextTick(() => {
this.$refs.oTable.reload();
});
} else { } else {
this.shopId = false; this.isShopId = false;
} }
}, },
methods: { methods: {
getData() {
this.$api.mer_admin
.storeList({ marketId: this.formInline.marketId })
.then((res) => {
this.storeList = res.data.data;
this.formInline.shopId = res.data.data[0].shopId;
this.$nextTick(() => {
this.$refs.oTable.reload();
});
});
},
addProduct() { addProduct() {
this.$refs.addOrUpdate.toggle().add(); this.$refs.addOrUpdate.toggle().add(this.formInline.shopId);
}, },
deleteProduct() { deleteProduct() {
console.log(this.selectList); console.log(this.selectList);
@ -166,7 +201,6 @@ export default {
...this.formInline, ...this.formInline,
productFilterType: this.productFilterType, productFilterType: this.productFilterType,
merchantId: JSON.parse(sessionStorage.getItem("userInfo")).merchantId, merchantId: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
productQuerySortParam: [], productQuerySortParam: [],
}) })
.then((res) => { .then((res) => {

View File

@ -150,6 +150,9 @@ export default {
fileListTwo: [], // fileListTwo: [], //
place: "", // place: "", //
passCheck: [], // passCheck: [], //
shopId: "",
getProductCategory: [],
getSaleUnit: [],
}; };
}, },
mounted() {}, mounted() {},
@ -174,7 +177,10 @@ export default {
this.init(cloneDeep(e)); this.init(cloneDeep(e));
} }
return { return {
add: () => { add: (shopId) => {
this.shopId = shopId;
this.getData();
console.log(this.shopId);
this.$nextTick(() => { this.$nextTick(() => {
this.modalConfig.title = "添加商品"; this.modalConfig.title = "添加商品";
this.modalData = { this.modalData = {
@ -195,14 +201,13 @@ export default {
singlePrice: "", singlePrice: "",
singleStock: "", singleStock: "",
specType: 0, specType: 0,
minCostPrice:"",
status: "UP", status: "UP",
}; };
this.modalData.merchantId = JSON.parse( this.modalData.merchantId = JSON.parse(
sessionStorage.getItem("userInfo") sessionStorage.getItem("userInfo")
).merchantId; ).merchantId;
this.modalData.shopId = JSON.parse( this.modalData.shopId = shopId;
sessionStorage.getItem("userInfo")
).shopId;
this.passCheck = []; this.passCheck = [];
this.place = []; this.place = [];
}); });
@ -218,6 +223,8 @@ export default {
}, },
init(row) { init(row) {
console.log(row); console.log(row);
this.shopId = row.shopId;
this.getData();
this.fileList = row.productPhotoList.map((item) => { this.fileList = row.productPhotoList.map((item) => {
return { return {
name: "", name: "",
@ -335,6 +342,18 @@ export default {
}); });
return state; return state;
}, },
getData() {
this.$api.mer_admin
.getProductCategory({ shopId: this.shopId })
.then((res) => {
this.getProductCategory = res.data.data;
console.log(res);
});
this.$api.mer_admin.getSaleUnit({ shopId: this.shopId }).then((res) => {
this.getSaleUnit = res.data.data;
console.log(res);
});
},
}, },
computed: { computed: {
modalCols() { modalCols() {
@ -547,14 +566,14 @@ export default {
}, },
{ {
label: "成本", label: "成本",
prop: "minCostPrice", prop: "costPrice",
type: "jsx", type: "jsx",
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={this.modalData.specType != 0} readonly={this.modalData.specType != 0}
placeholder="请输入价格" placeholder="请输入价格"
v-model={this.modalData.minCostPrice} v-model={this.modalData.costPrice}
> >
<template slot="append">单位</template> <template slot="append">单位</template>
</el-input> </el-input>
@ -562,15 +581,15 @@ export default {
}, },
}, },
{ {
label: "", label: "市场价",
prop: "singlePrice", prop: "marketPrice",
type: "jsx", type: "jsx",
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={this.modalData.specType != 0} readonly={this.modalData.specType != 0}
placeholder="请输入" placeholder="请输入市场价"
v-model={this.modalData.singlePrice} v-model={this.modalData.marketPrice}
> >
<template slot="append">单位</template> <template slot="append">单位</template>
</el-input> </el-input>
@ -818,11 +837,12 @@ export default {
this.modalData.productSpecificationList = [ this.modalData.productSpecificationList = [
{ {
attributeValue: "默认", attributeValue: "默认",
costPrice: this.modalData.minCostPrice, costPrice: this.modalData.costPrice,
salePrice: this.modalData.singlePrice, salePrice: this.modalData.singlePrice,
stockNum: this.modalData.singleStock, stockNum: this.modalData.singleStock,
weight: this.modalData.weight, weight: this.modalData.weight,
volume: this.modalData.volume, volume: this.modalData.volume,
marketPrice: this.modalData.marketPrice,
}, },
]; ];
} }
@ -852,7 +872,7 @@ export default {
this.modalData.productSpecificationList = [ this.modalData.productSpecificationList = [
{ {
attributeValue: "默认", attributeValue: "默认",
costPrice: this.modalData.minCostPrice, costPrice: this.modalData.costPrice,
salePrice: this.modalData.singlePrice, salePrice: this.modalData.singlePrice,
stockNum: this.modalData.singleStock, stockNum: this.modalData.singleStock,
weight: this.modalData.weight, weight: this.modalData.weight,
@ -872,18 +892,17 @@ export default {
}, },
}, },
asyncComputed: { asyncComputed: {
async getProductCategory() { // async getProductCategory() {
let res = await this.$api.mer_admin.getProductCategory(); // let res = await this.$api.mer_admin.getProductCategory();
return res.data.data; // return res.data.data;
}, // },
async getSaleUnit() { // async getSaleUnit() {
let res = await this.$api.mer_admin.getSaleUnit({ // let res = await this.$api.mer_admin.getSaleUnit({
shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId, // shopId: JSON.parse(sessionStorage.getItem("userInfo")).shopId,
}); // });
console.log(res); // console.log(res);
// return res.data.data;
return res.data.data; // },
},
}, },
}; };
</script> </script>

View File

@ -268,6 +268,7 @@ export default {
attributeValue: item.name, attributeValue: item.name,
salePrice: 0, salePrice: 0,
costPrice: 0, costPrice: 0,
marketPrice: 0,
stockNum: 0, stockNum: 0,
weight: 0, weight: 0,
volume: 0, volume: 0,
@ -325,6 +326,25 @@ export default {
); );
}, },
}, },
{
title: "市场价(元)",
field: "marketPrice",
align: "center",
"min-width": "160px",
type: "jsx",
render: ({ row }) => {
return (
<div>
<el-input-number
min={0}
size="small"
v-model={row.marketPrice}
placeholder="请输入成本"
></el-input-number>
</div>
);
},
},
{ {
title: "库存", title: "库存",
field: "stockNum", field: "stockNum",
@ -456,6 +476,7 @@ export default {
} else { } else {
stockNum = minStockNum + "~" + maxStockNum; stockNum = minStockNum + "~" + maxStockNum;
} }
console.log(this.tableData);
this.$emit( this.$emit(
"getSpecs", "getSpecs",