商品添加

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

View File

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

View File

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

View File

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

View File

@ -268,6 +268,7 @@ export default {
attributeValue: item.name,
salePrice: 0,
costPrice: 0,
marketPrice: 0,
stockNum: 0,
weight: 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: "库存",
field: "stockNum",
@ -456,6 +476,7 @@ export default {
} else {
stockNum = minStockNum + "~" + maxStockNum;
}
console.log(this.tableData);
this.$emit(
"getSpecs",