merchant-web/src/views/modules/marketing/points-mall/index.vue

325 lines
9.4 KiB
Vue
Raw Normal View History

2024-12-04 11:08:06 +00:00
<template>
2024-12-06 11:14:50 +00:00
<div style="height: calc(100vh - 200px)">
<obj-table-plus
ref="oTable"
style="height: 100%"
:tableCols="tableCols"
:tableProp="tableProp"
@query="queryList"
v-model="dataList"
:tableEvent="tableEvent"
:enableAutoQuery="false"
>
<template slot="tableTop">
<el-form :inline="true" :model="formInline" class="demo-form-inline">
2024-12-15 09:35:41 +00:00
<el-form-item v-if="storeList.length > 1" 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>
2024-12-06 11:14:50 +00:00
<el-form-item label="商品ID">
<el-input
placeholder="请输入商品ID"
2024-12-15 09:35:41 +00:00
v-model="formInline.productId"
2024-12-06 11:14:50 +00:00
></el-input>
</el-form-item>
<el-form-item label="商品名称">
<el-input
placeholder="请输入商品名称"
2024-12-15 09:35:41 +00:00
v-model="formInline.productName"
2024-12-06 11:14:50 +00:00
></el-input>
</el-form-item>
2024-12-15 09:35:41 +00:00
<el-form-item label="兑换状态">
<el-select v-model="formInline.redeemEnable" placeholder="请选择">
2024-12-06 11:14:50 +00:00
<el-option
2024-12-15 09:35:41 +00:00
v-for="item in [
{ value: true, label: '启用' },
{ value: false, label: '禁用' },
]"
2024-12-06 11:14:50 +00:00
:key="item.marketId"
:label="item.marketName"
:value="item.marketId"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="$refs.oTable.reload()"
>查询</el-button
>
2024-12-19 12:03:16 +00:00
<el-button type="primary" @click="reset">重置</el-button>
2024-12-06 11:14:50 +00:00
</el-form-item>
</el-form>
<div class="mb-2">
2024-12-16 13:00:34 +00:00
<el-button @click="add" type="primary" size="small">+添加</el-button>
2024-12-06 11:14:50 +00:00
</div>
</template>
</obj-table-plus>
<!-- 添加或编辑 -->
2024-12-16 13:00:34 +00:00
<add-or-update
2024-12-18 12:07:13 +00:00
:marketId="formInline.marketId"
:shopId="formInline.shopId"
2024-12-06 11:14:50 +00:00
@queryList="$refs.oTable.reload()"
ref="addOrUpdate"
2024-12-16 13:00:34 +00:00
></add-or-update>
2024-12-06 11:14:50 +00:00
<!-- 查看详情 -->
<!-- <viewDetails ref="viewDetails"></viewDetails> -->
2024-12-04 11:08:06 +00:00
</div>
</template>
<script>
2024-12-16 13:00:34 +00:00
import AddOrUpdate from "./popup/add-or-update.vue";
2024-12-06 11:14:50 +00:00
// import viewDetails from "./popup/view-details.vue";
import { mapState } from "vuex";
2024-12-04 11:08:06 +00:00
export default {
2024-12-16 13:00:34 +00:00
components: { AddOrUpdate },
2024-12-06 11:14:50 +00:00
data() {
return {
dataList: [],
formInline: {
marketId: "",
shopId: "",
unitType: "",
2024-12-19 12:03:16 +00:00
productId: "",
productName: "",
redeemEnable: "",
2024-12-06 11:14:50 +00:00
},
tableProp: {
"auto-resize": true,
border: true,
height: "auto",
"row-id": "id",
"show-overflow": false,
},
productFilterType: "SALE",
selectList: [],
value1: [],
};
},
created() {
this.formInline = {
unitType: JSON.parse(sessionStorage.getItem("userInfo")).unitType,
marketId: this.marketId,
2024-12-15 09:35:41 +00:00
shopId: this.shopId,
2024-12-06 11:14:50 +00:00
};
this.$nextTick(() => {
this.$refs.oTable.reload();
});
},
methods: {
queryList(pageNo, pageSize) {
this.$api.marketing
2024-12-15 09:35:41 +00:00
.PointsProductPage({
2024-12-06 11:14:50 +00:00
pageNumber: pageNo,
pageSize: pageSize,
...this.formInline,
})
.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-16 13:00:34 +00:00
add() {
this.$refs.addOrUpdate.toggle().add();
},
2024-12-19 12:03:16 +00:00
reset() {
this.formInline = {
unitType: JSON.parse(sessionStorage.getItem("userInfo")).unitType,
marketId: this.marketId,
shopId: this.shopId,
};
this.$refs.oTable.reload();
},
2024-12-06 11:14:50 +00:00
},
computed: {
tableCols() {
return [
{ type: "checkbox", width: "60px", fixed: "left" },
// { type: "seq", width: "60px", align: "center", title: "序号" },
{
title: "商品ID",
align: "center",
2024-12-15 09:35:41 +00:00
field: "productId",
2024-12-06 11:14:50 +00:00
},
{
title: "商品名称",
align: "center",
2024-12-19 12:03:16 +00:00
field: "productName",
2024-12-06 11:14:50 +00:00
},
{
title: "兑换积分",
align: "center",
2024-12-19 12:03:16 +00:00
field: "maxPoints",
type: "jsx",
render: ({ row }) => {
if (row.minPoints == row.maxPoints) {
return <span>{row.minPoints}</span>;
} else {
return (
<span>
{row.minPoints}-{row.maxPoints}
</span>
);
}
},
2024-12-06 11:14:50 +00:00
},
{
title: "剩余兑换库存",
align: "center",
2024-12-19 12:03:16 +00:00
field: "totalInventory",
2024-12-06 11:14:50 +00:00
},
{
title: "兑换状态",
align: "center",
2024-12-19 12:03:16 +00:00
field: "redeemEnable",
type: "jsx",
render: ({ row }) => {
let changStatus = () => {
if (row.redeemEnable) {
this.$confirm("是否开启积分商品兑换, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$api.marketing
.reverseEnablePointsProduct({
id: row.id,
})
.then((res) => {
this.$refs.oTable.reload();
})
.catch((err) => {
this.$refs.oTable.reload();
});
})
.catch(() => {
this.$refs.oTable.reload();
});
} else {
this.$confirm("是否关闭积分商品兑换, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$api.marketing
.reverseEnablePointsProduct({
id: row.id,
})
.then((res) => {
this.$refs.oTable.reload();
})
.catch((err) => {
this.$refs.oTable.reload();
});
})
.catch(() => {
this.$refs.oTable.reload();
});
}
};
return (
<el-switch
onChange={changStatus}
v-model={row.redeemEnable}
active-text="启用"
inactive-text="关闭"
></el-switch>
);
},
2024-12-06 11:14:50 +00:00
},
{
title: "已兑换数",
align: "center",
2024-12-19 12:03:16 +00:00
field: "totalRedeemQuantity",
2024-12-06 11:14:50 +00:00
},
{
title: "操作",
fixed: "right",
type: "jsx",
align: "center",
2024-12-19 12:03:16 +00:00
width: "200px",
render: ({ row }) => {
2024-12-06 11:14:50 +00:00
let edit = () => {
2024-12-19 12:03:16 +00:00
this.$api.marketing
.PointsProductDetail({
id: row.id,
})
.then((res) => {
this.$refs.addOrUpdate
.toggle({ ...res.data.data, productName: row.productName })
.update();
})
.catch((err) => {});
};
let deleteProduct = () => {
this.$api.marketing
.deletePointsProduct({ id: row.id })
.then((res) => {
this.$message.success("删除成功");
this.$refs.oTable.reload();
})
.catch((err) => {});
2024-12-06 11:14:50 +00:00
};
return (
<div>
2024-12-19 12:03:16 +00:00
<el-button
style="margin-right:10px"
size="mini"
type="primary"
onClick={edit}
>
2024-12-06 11:14:50 +00:00
编辑
</el-button>
2024-12-19 12:03:16 +00:00
<el-popconfirm
confirm-button-text="确定"
cancel-button-text="取消"
icon="el-icon-info"
icon-color="red"
onConfirm={deleteProduct}
title="确定删除吗?"
>
<el-button size="mini" slot="reference" type="danger">
删除
</el-button>
</el-popconfirm>
2024-12-06 11:14:50 +00:00
</div>
);
},
},
];
},
tableEvent() {
return {
"checkbox-all": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
"checkbox-change": ({ records, reserves }) => {
this.selectList = [...records, ...reserves];
},
};
},
...mapState("userData", [
"isMerchant",
"marketList",
"storeList",
"marketId",
"shopId",
]),
},
};
2024-12-04 11:08:06 +00:00
</script>
2024-12-06 11:14:50 +00:00
<style lang="scss" scoped></style>