merchant-web/src/views/modules/operation-management/commodity/index.vue

501 lines
15 KiB
Vue
Raw Normal View History

2024-08-07 09:55:31 +00:00
<template>
2024-10-20 09:00:39 +00:00
<div>
2024-12-05 11:57:56 +00:00
<div v-if="isMerchant" style="height: calc(100vh - 200px)">
2024-10-20 09:00:39 +00:00
<obj-table-plus
ref="oTable"
style="height: 100%"
:tableCols="tableCols"
:tableProp="tableProp"
@query="queryList"
v-model="dataList"
:tableEvent="tableEvent"
2024-11-17 10:00:35 +00:00
:enableAutoQuery="false"
2024-10-20 09:00:39 +00:00
>
<template slot="tableTop">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
2024-11-13 11:02:08 +00:00
<!-- <el-form-item label="平台分类">
2024-10-20 09:00:39 +00:00
<el-select v-model="formInline.region" placeholder="活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
2024-11-13 11:02:08 +00:00
</el-form-item> -->
<!-- <el-form-item label="商户分类">
2024-10-20 09:00:39 +00:00
<el-select v-model="formInline.region" placeholder="活动区域">
<el-option label="区域一" value="shanghai"></el-option>
<el-option label="区域二" value="beijing"></el-option>
</el-select>
2024-11-13 11:02:08 +00:00
</el-form-item> -->
2024-10-20 09:00:39 +00:00
<el-form-item label="商品搜索">
<el-input
2024-11-11 10:05:56 +00:00
v-model="formInline.name"
2024-10-20 09:00:39 +00:00
placeholder="商品搜索"
></el-input>
</el-form-item>
2024-11-18 10:22:16 +00:00
<el-form-item v-if="marketList.length > 0" label="菜市场">
2024-11-17 10:00:35 +00:00
<el-select
@change="getData"
v-model="formInline.marketId"
2024-11-18 10:22:16 +00:00
placeholder="请选择菜市场"
2024-11-17 10:00:35 +00:00
>
2024-11-13 11:02:08 +00:00
<el-option
v-for="item in marketList"
:key="item.marketId"
:label="item.marketName"
:value="item.marketId"
></el-option>
</el-select>
</el-form-item>
2024-11-18 10:22:16 +00:00
<el-form-item v-if="marketList.length > 0" label="店铺">
<el-select v-model="formInline.shopId" placeholder="请选择店铺">
2024-11-17 10:00:35 +00:00
<el-option
v-for="item in storeList"
:key="item.shopId"
:label="item.shopName"
:value="item.shopId"
></el-option>
</el-select>
</el-form-item>
2024-10-20 09:00:39 +00:00
<el-form-item>
<el-button type="primary" @click="$refs.oTable.reload()"
>查询</el-button
>
2024-11-11 10:05:56 +00:00
<el-button type="primary" @click="Reset">重置</el-button>
2024-10-20 09:00:39 +00:00
</el-form-item>
</el-form>
2024-12-26 10:08:11 +00:00
<div class="stat-list">
<div class="stat-item">
<i style="font-size: 22px" class="el-icon-s-goods"></i>
<div class="stat-right">
<div class="stat-title">总商品数量</div>
<div class="stat-value">
2025-01-20 09:42:33 +00:00
<span style="font-size: 20px">{{
overview.productCount
}}</span>
2024-12-26 10:08:11 +00:00
</div>
</div>
</div>
<div class="stat-item">
<i style="font-size: 22px" class="el-icon-s-shop"></i>
<div class="stat-right">
<div class="stat-title">上架中商品数量</div>
<div class="stat-value">
2025-01-20 09:42:33 +00:00
<span style="font-size: 20px">{{
overview.productOnSaleCount
}}</span>
2024-12-26 10:08:11 +00:00
</div>
</div>
</div>
<div class="stat-item">
<i style="font-size: 22px" class="el-icon-s-marketing"></i>
<div class="stat-right">
<div class="stat-title">折扣商品数量</div>
<div class="stat-value">
2025-01-20 09:42:33 +00:00
<span style="font-size: 20px">{{
overview.productDiscountCount
}}</span>
2024-12-26 10:08:11 +00:00
</div>
</div>
</div>
<div class="stat-item">
<i style="font-size: 22px" class="el-icon-s-promotion"></i>
<div class="stat-right">
<div class="stat-title">仓库中商品数量</div>
<div class="stat-value">
2025-01-20 09:42:33 +00:00
<span style="font-size: 20px">{{
overview.productWarehouseCount
}}</span>
2024-12-26 10:08:11 +00:00
</div>
</div>
</div>
</div>
2024-10-20 09:00:39 +00:00
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="在售" name="在售"></el-tab-pane>
<el-tab-pane label="仓库中" name="仓库中"></el-tab-pane>
<el-tab-pane label="折扣" name="折扣"></el-tab-pane>
</el-tabs>
<div class="mb-2">
<el-button type="primary" size="small" @click="addProduct"
>添加商品</el-button
>
<el-button
:disabled="selectList.length <= 0"
type="danger"
size="small"
@click="deleteProduct"
>批量删除</el-button
2024-08-09 10:04:10 +00:00
>
2024-10-20 09:00:39 +00:00
</div>
</template>
</obj-table-plus>
<!-- 添加或编辑 -->
<add-or-update
@queryList="$refs.oTable.reload()"
ref="addOrUpdate"
></add-or-update>
<!-- 改价格 -->
<AddPrice ref="AddPrice" @queryList="$refs.oTable.reload()"></AddPrice>
<!-- 改库存 -->
<addStock ref="addStock" @queryList="$refs.oTable.reload()"></addStock>
<!-- 打折扣 -->
<AddDiscount
ref="AddDiscount"
@queryList="$refs.oTable.reload()"
></AddDiscount>
</div>
<div style="height: calc(100vh - 200px)" v-else>
<el-empty :image-size="200" description="请先去完成商品哦"></el-empty>
</div>
2024-08-09 10:04:10 +00:00
</div>
2024-08-07 09:55:31 +00:00
</template>
<script>
2024-12-05 11:57:56 +00:00
import { mapState } from "vuex";
2024-08-14 09:52:12 +00:00
import AddDiscount from "./popup/add-discount.vue";
2024-08-13 10:03:15 +00:00
import AddPrice from "./popup/add-price.vue";
2024-08-09 10:04:10 +00:00
import AddOrUpdate from "./popup/add-or-update.vue";
2024-08-14 09:52:12 +00:00
import addStock from "./popup/add-stock.vue";
2024-08-07 09:55:31 +00:00
export default {
2024-08-14 09:52:12 +00:00
components: { AddOrUpdate, AddPrice, addStock, AddDiscount },
2024-08-09 10:04:10 +00:00
data() {
return {
2024-08-21 10:00:55 +00:00
activeName: "在售",
2024-08-09 10:04:10 +00:00
dataList: [],
formInline: {
2024-11-11 10:05:56 +00:00
name: "",
marketId: "",
2024-11-17 10:00:35 +00:00
shopId: "",
2024-08-09 10:04:10 +00:00
},
2024-08-13 10:03:15 +00:00
tableProp: {
"auto-resize": true,
border: true,
height: "auto",
"row-id": "id",
2024-08-20 10:00:08 +00:00
"show-overflow": false,
2024-08-13 10:03:15 +00:00
},
2024-08-13 02:47:05 +00:00
productFilterType: "SALE",
2024-08-13 10:03:15 +00:00
selectList: [],
2025-01-20 09:42:33 +00:00
overview: {},
2024-08-09 10:04:10 +00:00
};
},
2024-11-07 09:13:34 +00:00
created() {
2024-12-05 11:57:56 +00:00
this.formInline = {
name: "",
marketId: this.marketId,
shopId: this.shopId,
};
this.$nextTick(() => {
this.$refs.oTable.reload();
});
2024-11-07 09:13:34 +00:00
},
2024-08-09 10:04:10 +00:00
methods: {
2024-12-05 11:57:56 +00:00
//如果有多个菜市场调用
2024-11-17 10:00:35 +00:00
getData() {
2024-12-30 03:42:13 +00:00
// this.$api.mer_admin
// .storeList({ marketId: this.formInline.marketId })
// .then((res) => {
// this.formInline.shopId = res.data.data[0].shopId;
// this.$nextTick(() => {
// this.$refs.oTable.reload();
// });
// });
2024-11-17 10:00:35 +00:00
},
2024-08-09 10:04:10 +00:00
addProduct() {
2024-11-17 10:00:35 +00:00
this.$refs.addOrUpdate.toggle().add(this.formInline.shopId);
2024-08-07 09:55:31 +00:00
},
2024-08-13 10:03:15 +00:00
deleteProduct() {
console.log(this.selectList);
let integers = this.selectList.map((item) => {
return item.id;
});
this.$confirm("此操作将删除该商品, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
2024-08-20 10:00:08 +00:00
console.log("111");
2024-08-13 10:03:15 +00:00
this.$api.mer_admin.BatchDeleteProducts(integers).then((res) => {
this.$refs.oTable.reload();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
2024-08-09 10:04:10 +00:00
queryList(pageNo, pageSize) {
2024-12-05 11:57:56 +00:00
console.log(this.formInline);
2024-08-09 10:04:10 +00:00
this.$api.mer_admin
.getProductPage({
p: {
pageNumber: pageNo,
pageSize: pageSize,
},
2024-11-11 10:05:56 +00:00
...this.formInline,
2024-08-13 02:47:05 +00:00
productFilterType: this.productFilterType,
merchantId: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
productQuerySortParam: [],
2024-08-09 10:04:10 +00:00
})
.then((res) => {
console.log(res);
this.$refs.oTable.complete(
res.data.data.data,
Number(res.data.data.total)
);
})
.catch((err) => {
this.$refs.oTable.complete(false);
});
2024-12-30 03:42:13 +00:00
this.$api.mer_admin.getProductOverview(this.formInline).then((res) => {
2025-01-20 09:42:33 +00:00
console.log(res, "概况");
2024-12-30 03:42:13 +00:00
this.overview = res.data.data;
});
2024-08-07 09:55:31 +00:00
},
2024-11-11 10:05:56 +00:00
Reset() {
this.formInline = {
name: "",
2024-12-05 11:57:56 +00:00
marketId: this.marketId,
shopId: this.shopId,
2024-11-11 10:05:56 +00:00
};
this.$refs.oTable.reload();
},
2024-08-13 02:47:05 +00:00
handleClick() {
switch (this.activeName) {
case "在售":
this.productFilterType = "SALE";
break;
case "仓库中":
this.productFilterType = "WAREHOUSE";
break;
case "折扣":
this.productFilterType = "DISCOUNT";
break;
}
this.$refs.oTable.reload();
},
2024-08-09 10:04:10 +00:00
},
computed: {
tableCols() {
return [
2024-08-13 10:03:15 +00:00
{ type: "checkbox", width: "60px", fixed: "left" },
// { type: "seq", width: "60px", align: "center", title: "序号" },
2024-08-09 10:04:10 +00:00
{
title: "商品图",
2024-08-13 10:03:15 +00:00
field: "productPhotoList",
align: "center",
2024-08-21 10:00:55 +00:00
width: "80px",
2024-08-13 10:03:15 +00:00
type: "jsx",
render: ({ row }) => {
if (row.productPhotoList.length > 0) {
2024-08-21 10:00:55 +00:00
return (
<el-image
preview-src-list={row.productPhotoList.map((item) => {
return item.url;
})}
src={row.productPhotoList[0].url}
></el-image>
);
2024-08-13 10:03:15 +00:00
} else {
return <span>暂无商品图</span>;
}
},
2024-08-09 10:04:10 +00:00
},
{
title: "商品名称",
2024-08-13 10:03:15 +00:00
align: "center",
field: "name",
2024-08-09 10:04:10 +00:00
},
{
title: "商品售价",
2024-08-13 10:03:15 +00:00
align: "center",
field: "minSalePrice",
type: "jsx",
render: ({ row }) => {
if (row.minSalePrice == row.maxSalePrice) {
return <span>{row.minSalePrice}</span>;
} else {
return (
<span>
{row.minSalePrice}~{row.maxSalePrice}
</span>
);
}
},
2024-08-09 10:04:10 +00:00
},
2024-08-14 09:52:12 +00:00
{
title: "折扣",
align: "center",
field: "discountActivity",
type: "jsx",
render: ({ row }) => {
if (row.discountActivity) {
return <span>{row.discountActivity.ruleObject.discount}</span>;
}
},
},
2024-08-09 10:04:10 +00:00
{
title: "销量",
2024-08-13 10:03:15 +00:00
align: "center",
field: "saleNum",
2024-08-09 10:04:10 +00:00
},
{
title: "库存",
2024-08-13 10:03:15 +00:00
align: "center",
field: "stockNum",
2024-08-09 10:04:10 +00:00
},
{
title: "状态",
2024-08-13 10:03:15 +00:00
// fixed: "right",
type: "jsx",
align: "center",
"title-suffix": {
message: "点击上架/下架切换责任书状态",
icon: "vxe-icon-question-circle-fill",
},
render: ({ row }) => {
let Enable = () => {
let data = {
ids: [row.id],
status: "UP",
};
if (row.status == "UP") {
data.status = "DOWN";
} else {
data.status = "UP";
}
this.$api.mer_admin.putOnShelvesProducts(data).then((res) => {
console.log(res);
this.$refs.oTable.reload();
});
};
return (
<el-popconfirm
title={
row.status == "DOWN"
? "当前为下架状态,是否更改为上架状态?"
: "当前为上架状态,是否更改为下架状态?"
}
confirmButtonText={
row.status == "DOWN" ? "确认上架" : "确认下架"
}
onConfirm={Enable}
>
<el-button
slot="reference"
size="mini"
plain
type={row.status == "DOWN" ? "info" : "success"}
>
{row.status == "DOWN" ? "已下架" : "上架中"}
</el-button>
</el-popconfirm>
);
},
2024-08-09 10:04:10 +00:00
},
{
2025-01-20 09:42:33 +00:00
title: "操作 (提示:下架后可进行操作)",
2024-08-13 10:03:15 +00:00
fixed: "right",
type: "jsx",
align: "center",
width: "340px",
render: ({ row }) => {
2024-08-15 10:01:50 +00:00
let edit = () => {
this.$refs.addOrUpdate.toggle(row).update();
};
2024-08-13 10:03:15 +00:00
let priceAdjustment = () => {
console.log(row);
this.$refs.AddPrice.toggle(row).update();
};
2024-08-14 09:52:12 +00:00
let changeInventory = () => {
this.$refs.addStock.toggle(row).update();
};
let setDiscounts = () => {
this.$refs.AddDiscount.toggle(row).update();
};
2024-08-13 10:03:15 +00:00
return (
<div>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={edit}
>
编辑
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
onClick={priceAdjustment}
>
改价
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
2024-08-14 09:52:12 +00:00
onClick={changeInventory}
2024-08-13 10:03:15 +00:00
>
改库存
</el-button>
<el-button
size="mini"
disabled={row.status != "DOWN"}
type="primary"
2024-08-14 09:52:12 +00:00
onClick={setDiscounts}
2024-08-13 10:03:15 +00:00
>
设置折扣
</el-button>
</div>
);
},
2024-08-09 10:04:10 +00:00
},
];
2024-08-07 09:55:31 +00:00
},
2024-08-13 10:03:15 +00:00
tableEvent() {
return {
"checkbox-all": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
"checkbox-change": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
};
},
2024-12-05 11:57:56 +00:00
...mapState("userData", [
"isMerchant",
"marketList",
"storeList",
"marketId",
"shopId",
]),
2024-08-09 10:04:10 +00:00
},
};
2024-08-07 09:55:31 +00:00
</script>
2024-12-26 10:08:11 +00:00
<style lang="scss" scoped>
.stat-list {
display: flex;
align-items: center;
/* justify-content: space-between; */
// flex-wrap: wrap;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
}
.stat-item {
width: 20%;
margin: 20px 20px;
display: flex;
align-items: center;
}
.stat-right {
margin-left: 12px;
font-size: 18px;
}
.stat-title {
margin-bottom: 5px;
}
</style>