Files
lilishop-ui/manager/src/components/lili-dialog/index.vue
pikachu1995@126.com 0f08807f00 feat(coupon): 重构优惠券类型为满减、满折、立减三种分类
- 新增立减优惠券类型,支持无门槛直接抵扣
- 优惠券列表页统一使用行对象判断类型并显示完整类型名称
- 发布页增加优惠券类型选择组件,切换时自动联动字段显隐
- 买家端购物车满减门槛为零时显示"无门槛使用"
- 卖家端发布页新增券面实时预览面板
- 卖家端发布页重构为分步布局并优化表单交互样式
- 面额与消费门槛校验增加大于零的数值约束
- 移除列表页冗余的标签颜色映射函数,简化展示逻辑
2026-11-05 22:36:21 +08:00

225 lines
4.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-dialog
v-if="goodsFlag"
v-model="flag"
title="选择商品"
width="85%"
top="5vh"
:z-index="10000"
:close-on-click-modal="false"
append-to-body
destroy-on-close
class="goods-selector-dialog"
@close="clickClose"
>
<goodsDialog
v-if="flag"
ref="goodsDialogRef"
:selectedWay="goodsData"
:goods-loader="goodsLoader"
:query-params="queryParams"
@selected="
(val) => {
goodsData = val;
}
"
/>
<template #footer>
<div class="goods-dialog-footer">
<span class="selected-count-tip">
已选择 <strong class="text-primary">{{ goodsData.length }}</strong> 件商品
</span>
<div class="footer-actions">
<el-button @click="clickClose">取消</el-button>
<el-button type="primary" @click="clickOK">确定</el-button>
</div>
</div>
</template>
</el-dialog>
<el-dialog
v-else
v-model="flag"
width="1160px"
top="80px"
:z-index="10000"
:close-on-click-modal="false"
append-to-body
destroy-on-close
class="link-selector-dialog"
@close="clickClose"
>
<linkDialog
v-if="flag"
class="linkDialog"
@selectedLink="
(val) => {
linkData = val;
}
"
/>
<template #footer>
<el-button @click="clickClose">取消</el-button>
<el-button type="primary" @click="clickOK">确定</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { ref } from "vue";
import goodsDialog from "./goods-dialog";
import linkDialog from "./link-dialog";
const emit = defineEmits(["closeFlag", "selectedGoodsData", "selectedLink"]);
defineProps({ goodsLoader: { type: Function, default: null }, queryParams: { type: Object, default: () => ({}) } });
const goodsFlag = ref(false); // 是否商品选择器
const goodsData = ref([]); // 选择的商品
const linkData = ref(""); // 选择的链接
const flag = ref(false); // modal显隐
// 模板 ref:原 ref="goodsDialog" 与 import 的组件同名,改名避免互相覆盖
const goodsDialogRef = ref(null);
function clearGoodsSelected() {
goodsData.value = [];
}
// 关闭弹窗
function clickClose() {
flag.value = false;
goodsFlag.value = false;
emit("closeFlag", false);
}
// 单选商品
function singleGoods() {
var timer = setInterval(() => {
if (goodsDialogRef.value) {
goodsDialogRef.value.type = "single";
clearInterval(timer);
}
}, 100);
}
// 点击确认
function clickOK() {
if (goodsFlag.value) {
emit("selectedGoodsData", goodsData.value);
} else {
emit("selectedLink", linkData.value);
}
clickClose();
}
// 打开组件方法
function open(type, mutiple) {
flag.value = true;
if (type == "goods") {
goodsFlag.value = true;
if (mutiple) {
singleGoods();
}
} else {
goodsFlag.value = false;
}
}
// 关闭组件
function close() {
flag.value = false;
}
// 外部通过 ref 访问的成员:
defineExpose({
open,
close,
singleGoods,
clearGoodsSelected,
goodsData,
goodsFlag,
flag,
});
</script>
<style scoped lang="scss">
:deep(.el-dialog__body) {
width: 100%;
height: 500px;
overflow: hidden;
}
.goods-dialog-footer {
display: flex;
justify-content: space-between;
align-items: center;
.selected-count-tip {
font-size: 13px;
color: #606266;
.text-primary {
color: #409eff;
font-weight: 600;
font-size: 15px;
margin: 0 2px;
}
}
.footer-actions {
display: flex;
gap: 10px;
}
}
</style>
<style lang="scss">
/* 商品选择器弹窗全局尺寸与布局增强 */
.goods-selector-dialog {
max-width: 1360px;
min-width: 900px;
border-radius: 8px;
.el-dialog__header {
padding: 16px 20px;
margin-right: 0;
border-bottom: 1px solid #ebeef5;
.el-dialog__title {
font-size: 16px;
font-weight: 600;
color: #303133;
}
}
.el-dialog__body {
width: 100% !important;
height: calc(84vh - 120px) !important;
min-height: 520px !important;
max-height: 760px !important;
padding: 16px 20px !important;
box-sizing: border-box !important;
overflow: hidden !important;
}
.el-dialog__footer {
padding: 12px 20px;
border-top: 1px solid #ebeef5;
}
}
// 抽屉 append-to-body 后不在当前组件 DOM 内,不能使用 scoped 样式
.link-selector-drawer {
max-width: 96vw;
.el-drawer__body {
overflow: hidden;
}
.goods-select-table,
.shops-select-table,
.articles-select-table,
.specials-select-table {
height: calc(100vh - 240px) !important;
}
}
// 商品分类下拉挂载到 body,需要高于抽屉的 10000 层级
.goods-dialog-cascader-popper,
.goods-dialog-pagination-popper {
z-index: 10001 !important;
}
</style>