2024-12-16 13:00:34 +00:00
|
|
|
|
<template>
|
|
|
|
|
<obj-modal
|
|
|
|
|
ref="modal"
|
|
|
|
|
labelWidth="150px"
|
|
|
|
|
:modalConfig="modalConfig"
|
|
|
|
|
:modalData="modalData"
|
|
|
|
|
:modalHandles="modalHandles"
|
|
|
|
|
>
|
|
|
|
|
<template slot="dialog__content">
|
|
|
|
|
<el-form :inline="true" :model="formInline" class="demo-form-inline">
|
|
|
|
|
<el-form-item label="商品搜索">
|
|
|
|
|
<el-input v-model="formList.name" placeholder="商品搜索"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" @click="queryList">查询</el-button>
|
|
|
|
|
<el-button type="primary" @click="Reset">重置</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-table
|
|
|
|
|
border
|
|
|
|
|
ref="multipleTable"
|
|
|
|
|
:data="dataList"
|
2025-04-08 02:39:22 +00:00
|
|
|
|
height="40vh"
|
2024-12-16 13:00:34 +00:00
|
|
|
|
tooltip-effect="dark"
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
@select="select"
|
|
|
|
|
@select-all="selectAll"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="selection" width="55"> </el-table-column>
|
|
|
|
|
<el-table-column label="商品图" width="100">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-image
|
|
|
|
|
:preview-src-list="[scope.row.productPhotoList[0].url]"
|
|
|
|
|
:src="scope.row.productPhotoList[0].url"
|
|
|
|
|
></el-image
|
|
|
|
|
></template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="name" label="商品名称" />
|
|
|
|
|
<el-table-column prop="name" label="商品售价">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span>¥{{ getSalePrice(scope.row) }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="address" label="折扣">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<span>{{ scope.row.discountActivity?.ruleObject.discount }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column prop="saleNum" label="销量" />
|
|
|
|
|
<el-table-column prop="stockNum" label="库存" />
|
|
|
|
|
</el-table>
|
|
|
|
|
<div class="pagination-container">
|
|
|
|
|
<el-pagination
|
|
|
|
|
:current-page="query.pageNumber"
|
|
|
|
|
:page-sizes="[10, 20, 30, 50]"
|
|
|
|
|
:page-size="query.pageSize"
|
|
|
|
|
:total="total"
|
|
|
|
|
background
|
|
|
|
|
layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</obj-modal>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { debounce, cloneDeep } from "lodash";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
isAdd: true,
|
|
|
|
|
//表格属性
|
|
|
|
|
modalConfig: {
|
|
|
|
|
title: "请点击选择商品 (提示:最多选择5个商品)",
|
|
|
|
|
show: false,
|
2025-08-11 15:15:49 +00:00
|
|
|
|
width: "1000px"
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
query: {
|
|
|
|
|
pageNumber: 1,
|
2025-08-11 15:15:49 +00:00
|
|
|
|
pageSize: 10
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
total: 0,
|
|
|
|
|
modalData: {},
|
|
|
|
|
dataList: [], //表格数据
|
|
|
|
|
selectList: [],
|
|
|
|
|
formInline: {},
|
|
|
|
|
formList: {
|
2025-08-11 15:15:49 +00:00
|
|
|
|
name: ""
|
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
queryList() {
|
|
|
|
|
this.$api.mer_admin
|
|
|
|
|
.getProductPage({
|
|
|
|
|
p: {
|
|
|
|
|
pageNumber: this.query.pageNumber,
|
2025-08-11 15:15:49 +00:00
|
|
|
|
pageSize: this.query.pageSize
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
...this.formInline,
|
|
|
|
|
...this.formList,
|
|
|
|
|
productFilterType: "SALE",
|
|
|
|
|
merchantId: JSON.parse(sessionStorage.getItem("userInfo")).merchantId,
|
2025-08-11 15:15:49 +00:00
|
|
|
|
productQuerySortParam: []
|
2024-12-16 13:00:34 +00:00
|
|
|
|
})
|
2025-08-11 15:15:49 +00:00
|
|
|
|
.then(res => {
|
2024-12-16 13:00:34 +00:00
|
|
|
|
console.log(res);
|
2025-08-11 15:15:49 +00:00
|
|
|
|
this.dataList = res.data.data;
|
2024-12-16 13:00:34 +00:00
|
|
|
|
this.total = Number(res.data.data.total);
|
|
|
|
|
})
|
2025-08-11 15:15:49 +00:00
|
|
|
|
.catch(err => {
|
2024-12-16 13:00:34 +00:00
|
|
|
|
this.dataList = [];
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
toggle(e) {
|
|
|
|
|
if (this.modalConfig.show == false) {
|
|
|
|
|
this.modalConfig.show = true;
|
|
|
|
|
} else {
|
|
|
|
|
this.modalConfig.show = false;
|
|
|
|
|
}
|
|
|
|
|
if (e) {
|
|
|
|
|
this.init(cloneDeep(e));
|
|
|
|
|
}
|
|
|
|
|
return {
|
2025-08-11 15:15:49 +00:00
|
|
|
|
add: row => {
|
2024-12-16 13:00:34 +00:00
|
|
|
|
console.log(row);
|
|
|
|
|
this.formInline = row;
|
|
|
|
|
this.isAdd = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.queryList();
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
update: () => {
|
|
|
|
|
this.isAdd = false;
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
init(row) {},
|
|
|
|
|
toggleSelection(rows) {
|
|
|
|
|
if (rows) {
|
2025-08-11 15:15:49 +00:00
|
|
|
|
rows.forEach(row => {
|
2024-12-16 13:00:34 +00:00
|
|
|
|
this.$refs.multipleTable.toggleRowSelection(row);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs.multipleTable.clearSelection();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
select(selection, row) {
|
|
|
|
|
if (selection.length > 5) {
|
|
|
|
|
this.$message.error("最多选择5个商品");
|
|
|
|
|
this.$refs.multipleTable.toggleRowSelection(row, false);
|
|
|
|
|
} else {
|
|
|
|
|
this.selectList = selection;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
selectAll(selection) {
|
|
|
|
|
if (selection.length > 5) {
|
|
|
|
|
this.$message.error("最多选择5个商品");
|
|
|
|
|
selection.length = 5;
|
|
|
|
|
this.selectList = selection;
|
|
|
|
|
console.log(selection);
|
|
|
|
|
} else {
|
|
|
|
|
this.selectList = selection;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getSalePrice(row) {
|
|
|
|
|
if (row.minSalePrice == row.maxSalePrice) {
|
|
|
|
|
return row.minSalePrice;
|
|
|
|
|
} else {
|
|
|
|
|
return `${row.minSalePrice}~${row.maxSalePrice}`;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
handleSizeChange(val) {
|
|
|
|
|
this.query.pageSize = val;
|
2025-07-08 16:09:10 +00:00
|
|
|
|
this.queryList();
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
handleCurrentChange(val) {
|
|
|
|
|
this.query.pageNumber = val;
|
2025-07-08 16:09:10 +00:00
|
|
|
|
this.queryList();
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
Reset() {
|
|
|
|
|
this.formList = {};
|
|
|
|
|
this.queryList();
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
modalHandles() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
label: "取消",
|
|
|
|
|
handle: () => {
|
|
|
|
|
this.toggle();
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: "确认",
|
|
|
|
|
type: "primary",
|
|
|
|
|
handle: () => {
|
|
|
|
|
this.$emit("getProduct", this.selectList);
|
|
|
|
|
this.toggle();
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
tableEvent() {
|
|
|
|
|
return {
|
|
|
|
|
"checkbox-all": ({ records, reserves }) => {
|
|
|
|
|
console.log(records, reserves);
|
|
|
|
|
this.selectList = [...records, ...reserves];
|
|
|
|
|
},
|
|
|
|
|
"checkbox-change": ({ records, reserves }) => {
|
|
|
|
|
console.log(records, reserves);
|
|
|
|
|
if (records.length > 5) {
|
|
|
|
|
this.$message.error("最多选择5个商品");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.selectList = [...records, ...reserves];
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
};
|
2025-08-11 15:15:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-16 13:00:34 +00:00
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
::v-deep .selectAllbtnDis .cell .el-checkbox__inner {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2025-04-08 02:39:22 +00:00
|
|
|
|
</style>
|