mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
refactor: 推广记录 platform 字段改为外键关联 ec_platform 表,平台下拉动态加载
This commit is contained in:
@@ -292,8 +292,8 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司ID',
|
||||
`shop_id` bigint UNSIGNED NOT NULL COMMENT '店铺ID',
|
||||
`fee_type_id` bigint UNSIGNED NOT NULL COMMENT '推广费类型ID',
|
||||
`platform_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '平台ID',
|
||||
`fee_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '推广费名称',
|
||||
`platform` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '平台(淘宝、京东、拼多多等)',
|
||||
`campaign_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '推广活动名称',
|
||||
`fee_amount` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '推广费金额',
|
||||
`base_amount` decimal(10, 2) NULL DEFAULT NULL COMMENT '基础金额(用于按比例计算)',
|
||||
@@ -312,12 +312,13 @@ CREATE TABLE `ec_promotion_fee` (
|
||||
INDEX `idx_shop_id`(`shop_id` ASC) USING BTREE,
|
||||
INDEX `idx_fee_type_id`(`fee_type_id` ASC) USING BTREE,
|
||||
INDEX `idx_fee_date`(`fee_date` ASC) USING BTREE,
|
||||
INDEX `idx_platform`(`platform` ASC) USING BTREE,
|
||||
INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
|
||||
INDEX `fk_ec_promotion_fee_creator`(`create_by` ASC) USING BTREE,
|
||||
INDEX `fk_ec_promotion_fee_updater`(`update_by` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_shop` FOREIGN KEY (`shop_id`) REFERENCES `ec_shop` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_platform` FOREIGN KEY (`platform_id`) REFERENCES `ec_platform` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_type` FOREIGN KEY (`fee_type_id`) REFERENCES `ec_promotion_fee_type` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_ec_promotion_fee_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '电商-推广费记录表' ;
|
||||
|
||||
+4
-4
@@ -37,10 +37,10 @@ public class CreatePromotionFeeDTO {
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -97,4 +97,4 @@ public class CreatePromotionFeeDTO {
|
||||
*/
|
||||
@Schema(description = "备注", example = "双十一期间推广费用")
|
||||
private String remark;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,10 +25,10 @@ public class PromotionFeeFilterDTO {
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广费发生日期开始
|
||||
@@ -41,4 +41,4 @@ public class PromotionFeeFilterDTO {
|
||||
*/
|
||||
@Schema(description = "推广费发生日期结束", example = "2024-01-31")
|
||||
private LocalDate feeDateEnd;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -44,10 +44,10 @@ public class UpdatePromotionFeeDTO {
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台", example = "淘宝")
|
||||
private String platform;
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
@@ -104,4 +104,4 @@ public class UpdatePromotionFeeDTO {
|
||||
*/
|
||||
@Schema(description = "备注", example = "双十一期间推广费用")
|
||||
private String remark;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -40,18 +40,18 @@ public class PromotionFeePO {
|
||||
@TableField("fee_type_id")
|
||||
private Long feeTypeId;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@TableField("platform_id")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
@TableField("fee_name")
|
||||
private String feeName;
|
||||
|
||||
/**
|
||||
* 平台(淘宝、京东、拼多多等)
|
||||
*/
|
||||
@TableField("platform")
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 推广活动名称
|
||||
*/
|
||||
|
||||
+12
@@ -50,6 +50,18 @@ public class PromotionFeeVO {
|
||||
@Schema(description = "推广费类型名称", example = "直通车")
|
||||
private String feeTypeName;
|
||||
|
||||
/**
|
||||
* 平台ID
|
||||
*/
|
||||
@Schema(description = "平台ID", example = "1")
|
||||
private Long platformId;
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
*/
|
||||
@Schema(description = "平台名称", example = "淘宝")
|
||||
private String platformName;
|
||||
|
||||
/**
|
||||
* 推广费名称
|
||||
*/
|
||||
|
||||
+18
-14
@@ -17,8 +17,9 @@ import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.dto.UpdatePromotio
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.po.PromotionFeePO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.model.vo.PromotionFeeVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.service.PromotionFeeService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.promotion.service.PromotionFeeTypeService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.platform.service.PlatformService;
|
||||
import top.xyquan.ecomdmbbackend.modules.ecom.shop.service.ShopService;
|
||||
import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,6 +36,7 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
private final CurrentUserContext currentUserContext;
|
||||
private final ShopService shopService;
|
||||
private final PromotionFeeTypeService promotionFeeTypeService;
|
||||
private final PlatformService platformService;
|
||||
|
||||
/**
|
||||
* 创建推广费记录
|
||||
@@ -49,7 +51,7 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
po.setCompanyId(currentUserContext.getCurrentCompanyId());
|
||||
po.setCreateBy(currentUserContext.getCurrentUserId());
|
||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
|
||||
|
||||
promotionFeeMapper.insert(po);
|
||||
return po.getId();
|
||||
}
|
||||
@@ -110,17 +112,13 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<PromotionFeeVO> getPromotionFeePage(PageQueryDTO<PromotionFeeFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
|
||||
// 创建分页对象
|
||||
Page<PromotionFeePO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PromotionFeePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PromotionFeePO::getCompanyId, companyId);
|
||||
|
||||
// 添加过滤条件
|
||||
PromotionFeeFilterDTO filter = pageQueryDTO.getFilters();
|
||||
if (filter != null) {
|
||||
if (filter.getShopId() != null) {
|
||||
@@ -129,8 +127,8 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
if (filter.getFeeTypeId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getFeeTypeId, filter.getFeeTypeId());
|
||||
}
|
||||
if (filter.getPlatform() != null && !filter.getPlatform().trim().isEmpty()) {
|
||||
wrapper.like(PromotionFeePO::getPlatform, filter.getPlatform());
|
||||
if (filter.getPlatformId() != null) {
|
||||
wrapper.eq(PromotionFeePO::getPlatformId, filter.getPlatformId());
|
||||
}
|
||||
if (filter.getFeeDateStart() != null) {
|
||||
wrapper.ge(PromotionFeePO::getFeeDate, filter.getFeeDateStart());
|
||||
@@ -140,19 +138,15 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
}
|
||||
}
|
||||
|
||||
// 排序
|
||||
wrapper.orderByDesc(PromotionFeePO::getFeeDate)
|
||||
.orderByDesc(PromotionFeePO::getCreateTime);
|
||||
|
||||
// 执行分页查询
|
||||
IPage<PromotionFeePO> pageResult = promotionFeeMapper.selectPage(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<PromotionFeeVO> voList = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建分页结果
|
||||
return PageResultVO.create(voList, pageResult.getTotal(), pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
}
|
||||
|
||||
@@ -182,10 +176,20 @@ public class PromotionFeeServiceImpl implements PromotionFeeService {
|
||||
vo.setFeeTypeName(feeTypeVO.getTypeName());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 查询失败不影响主流程
|
||||
}
|
||||
}
|
||||
|
||||
// 填充平台名称
|
||||
if (po.getPlatformId() != null) {
|
||||
try {
|
||||
var platform = platformService.getById(po.getPlatformId());
|
||||
if (platform != null) {
|
||||
vo.setPlatformName(platform.getPlatformName());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ export namespace PromotionFeeDTO {
|
||||
shopId?: number;
|
||||
/** 推广费类型ID */
|
||||
feeTypeId?: number;
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 推广费发生日期开始 */
|
||||
feeDateStart?: string;
|
||||
/** 推广费发生日期结束 */
|
||||
@@ -25,8 +25,8 @@ export namespace PromotionFeeDTO {
|
||||
feeTypeId: number;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台(淘宝、京东、拼多多等) */
|
||||
platform?: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
@@ -57,8 +57,8 @@ export namespace PromotionFeeDTO {
|
||||
feeTypeId: number;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台(淘宝、京东、拼多多等) */
|
||||
platform?: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
@@ -78,4 +78,4 @@ export namespace PromotionFeeDTO {
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,10 @@ export namespace PromotionFeeVO {
|
||||
feeTypeName?: string;
|
||||
/** 推广费名称 */
|
||||
feeName: string;
|
||||
/** 平台(淘宝、京东、拼多多等) */
|
||||
platform?: string;
|
||||
/** 平台ID */
|
||||
platformId?: number;
|
||||
/** 平台名称 */
|
||||
platformName?: string;
|
||||
/** 推广活动名称 */
|
||||
campaignName?: string;
|
||||
/** 推广费金额 */
|
||||
@@ -48,4 +50,4 @@ export namespace PromotionFeeVO {
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-30
@@ -26,6 +26,7 @@ import {
|
||||
updatePromotionFeeApi,
|
||||
} from '#/api/ecommerce/promotion-fee';
|
||||
import { getActivePromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'PromotionFeeFormModal' });
|
||||
@@ -47,7 +48,6 @@ interface Emits {
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 与父组件 v-model:open 同步:遮罩/右上角关闭时也要 emit false,否则父级一直为 true 无法二次打开
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
@@ -66,16 +66,14 @@ const [Modal, modalApi] = useVbenModal({
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<PromotionFeeDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
feeTypeId: undefined as any,
|
||||
feeName: '',
|
||||
platform: undefined,
|
||||
platformId: undefined,
|
||||
campaignName: '',
|
||||
feeAmount: undefined as any,
|
||||
baseAmount: undefined,
|
||||
@@ -87,7 +85,6 @@ const formData = ref<PromotionFeeDTO.Create>({
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
feeTypeId: [
|
||||
@@ -98,16 +95,9 @@ const rules = {
|
||||
feeDate: [{ required: true, message: '请选择发生日期', trigger: 'change' }],
|
||||
} as any;
|
||||
|
||||
// 平台选项
|
||||
const platformOptions = [
|
||||
{ label: '淘宝', value: '淘宝' },
|
||||
{ label: '京东', value: '京东' },
|
||||
{ label: '拼多多', value: '拼多多' },
|
||||
{ label: '天猫', value: '天猫' },
|
||||
{ label: '抖音', value: '抖音' },
|
||||
{ label: '快手', value: '快手' },
|
||||
{ label: '其他', value: '其他' },
|
||||
];
|
||||
// 平台选项(动态加载)
|
||||
const platformList = ref<{ label: string; value: number }[]>([]);
|
||||
const platformListLoading = ref(false);
|
||||
|
||||
// 店铺列表
|
||||
const shopList = ref<ShopVO.Info[]>([]);
|
||||
@@ -117,7 +107,6 @@ const shopListLoading = ref(false);
|
||||
const feeTypeList = ref<PromotionFeeTypeVO.Info[]>([]);
|
||||
const feeTypeListLoading = ref(false);
|
||||
|
||||
// 监听 props.open:先准备好表单再 open,关闭时同步 modalApi
|
||||
watch(
|
||||
() => props.open,
|
||||
async (newVal) => {
|
||||
@@ -131,7 +120,7 @@ watch(
|
||||
shopId: props.promotionFeeData.shopId,
|
||||
feeTypeId: props.promotionFeeData.feeTypeId,
|
||||
feeName: props.promotionFeeData.feeName,
|
||||
platform: props.promotionFeeData.platform,
|
||||
platformId: props.promotionFeeData.platformId,
|
||||
campaignName: props.promotionFeeData.campaignName || '',
|
||||
feeAmount: props.promotionFeeData.feeAmount,
|
||||
baseAmount: props.promotionFeeData.baseAmount,
|
||||
@@ -154,7 +143,6 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
// 加载店铺列表
|
||||
const loadShopList = async () => {
|
||||
shopListLoading.value = true;
|
||||
try {
|
||||
@@ -171,7 +159,6 @@ const loadShopList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 加载推广费类型列表
|
||||
const loadFeeTypeList = async () => {
|
||||
feeTypeListLoading.value = true;
|
||||
try {
|
||||
@@ -184,13 +171,27 @@ const loadFeeTypeList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 重置表单数据
|
||||
const loadPlatformList = async () => {
|
||||
platformListLoading.value = true;
|
||||
try {
|
||||
const list = await getActivePlatformsApi();
|
||||
platformList.value = list.map((p) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('加载平台列表失败:', error);
|
||||
} finally {
|
||||
platformListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
feeTypeId: undefined as any,
|
||||
feeName: '',
|
||||
platform: undefined,
|
||||
platformId: undefined,
|
||||
campaignName: '',
|
||||
feeAmount: undefined as any,
|
||||
baseAmount: undefined,
|
||||
@@ -203,13 +204,11 @@ const resetFormData = () => {
|
||||
};
|
||||
};
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && props.promotionFeeData) {
|
||||
// 更新推广费记录
|
||||
const updateData: PromotionFeeDTO.Update = {
|
||||
id: props.promotionFeeData.id,
|
||||
...formData.value,
|
||||
@@ -217,7 +216,6 @@ const handleOk = async () => {
|
||||
await updatePromotionFeeApi(updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
// 创建推广费记录
|
||||
await createPromotionFeeApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
@@ -230,16 +228,15 @@ const handleOk = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 取消:关闭与重置由 onOpenChange 统一处理
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopList();
|
||||
loadFeeTypeList();
|
||||
loadPlatformList();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -291,14 +288,15 @@ onMounted(() => {
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台" name="platform">
|
||||
<Form.Item label="平台" name="platformId">
|
||||
<Select
|
||||
v-model:value="formData.platform"
|
||||
v-model:value="formData.platformId"
|
||||
placeholder="请选择平台"
|
||||
:loading="platformListLoading"
|
||||
allow-clear
|
||||
>
|
||||
<Select.Option
|
||||
v-for="option in platformOptions"
|
||||
v-for="option in platformList"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
@@ -389,4 +387,4 @@ onMounted(() => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
</template>
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
getPromotionFeePageApi,
|
||||
} from '#/api/ecommerce/promotion-fee';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop/apis';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform/apis';
|
||||
import { getAllPromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type/apis';
|
||||
|
||||
import PromotionFeeFormModal from './components/PromotionFeeFormModal.vue';
|
||||
@@ -83,21 +84,25 @@ async function fetchFeeTypeOptions() {
|
||||
const searchForm = ref({
|
||||
shopId: undefined as number | undefined,
|
||||
feeTypeId: undefined as number | undefined,
|
||||
platform: '',
|
||||
platformId: undefined as number | undefined,
|
||||
feeDateStart: undefined as string | undefined,
|
||||
feeDateEnd: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 平台选项
|
||||
const platformOptions = [
|
||||
{ label: '淘宝', value: '淘宝' },
|
||||
{ label: '京东', value: '京东' },
|
||||
{ label: '拼多多', value: '拼多多' },
|
||||
{ label: '天猫', value: '天猫' },
|
||||
{ label: '抖音', value: '抖音' },
|
||||
{ label: '快手', value: '快手' },
|
||||
{ label: '其他', value: '其他' },
|
||||
];
|
||||
// 平台选项(动态加载)
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
const loadPlatformOptions = async () => {
|
||||
try {
|
||||
const list = await getActivePlatformsApi();
|
||||
platformOptions.value = list.map((p) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
}));
|
||||
} catch (e) {
|
||||
console.error('加载平台列表失败', e);
|
||||
}
|
||||
};
|
||||
loadPlatformOptions();
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
@@ -200,7 +205,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
filters: {
|
||||
shopId: searchForm.value.shopId || undefined,
|
||||
feeTypeId: searchForm.value.feeTypeId || undefined,
|
||||
platform: searchForm.value.platform || undefined,
|
||||
platformId: searchForm.value.platformId || undefined,
|
||||
feeDateStart: searchForm.value.feeDateStart || undefined,
|
||||
feeDateEnd: searchForm.value.feeDateEnd || undefined,
|
||||
},
|
||||
@@ -273,7 +278,7 @@ const formOptions = computed(() => ({
|
||||
allowClear: true,
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platform',
|
||||
fieldName: 'platformId',
|
||||
label: '平台',
|
||||
},
|
||||
{
|
||||
@@ -352,8 +357,8 @@ const formatAmount = (amount: number) => {
|
||||
};
|
||||
|
||||
// 获取平台标签颜色
|
||||
const getPlatformColor = (platform: string | undefined) => {
|
||||
switch (platform) {
|
||||
const getPlatformColor = (platformName: string | undefined) => {
|
||||
switch (platformName) {
|
||||
case '京东': {
|
||||
return 'red';
|
||||
}
|
||||
@@ -409,8 +414,8 @@ const getPlatformColor = (platform: string | undefined) => {
|
||||
|
||||
<!-- 平台列 -->
|
||||
<template #platform="{ row }: { row: any }">
|
||||
<Tag v-if="row.platform" :color="getPlatformColor(row.platform)">
|
||||
{{ row.platform }}
|
||||
<Tag v-if="row.platformName" :color="getPlatformColor(row.platformName)">
|
||||
{{ row.platformName }}
|
||||
</Tag>
|
||||
<span v-else class="text-gray-400">-</span>
|
||||
</template>
|
||||
|
||||
+23
-8
@@ -4,7 +4,7 @@ import type { PromotionFeeDTO, PromotionFeeVO } from '#/api/ecommerce/promotion-
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { Button, DatePicker, Input, Popconfirm, Space } from 'ant-design-vue';
|
||||
import { Button, DatePicker, Popconfirm, Select, Space } from 'ant-design-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
deletePromotionFeeApi,
|
||||
getPromotionFeePageApi,
|
||||
} from '#/api/ecommerce/promotion-fee';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
|
||||
import PromotionFeeFormModal from '#/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue';
|
||||
|
||||
@@ -30,11 +31,24 @@ const kpi = computed(() => props.data);
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const searchForm = ref({
|
||||
platform: undefined as string | undefined,
|
||||
platformId: undefined as number | undefined,
|
||||
feeDateStart: undefined as string | undefined,
|
||||
feeDateEnd: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 平台选项(动态加载)
|
||||
const platformList = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
const loadPlatformList = async () => {
|
||||
try {
|
||||
const list = await getActivePlatformsApi();
|
||||
platformList.value = list.map((p) => ({ label: p.platformName, value: p.id }));
|
||||
} catch (e) {
|
||||
console.error('加载平台列表失败', e);
|
||||
}
|
||||
};
|
||||
loadPlatformList();
|
||||
|
||||
const modalVisible = ref(false);
|
||||
const editingData = ref<PromotionFeeVO.Info | undefined>();
|
||||
|
||||
@@ -42,8 +56,8 @@ const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{ type: 'seq', title: '序号', width: 60 },
|
||||
{ field: 'feeName', title: '费用名称', width: 110 },
|
||||
{ field: 'platformName', title: '平台', width: 90 },
|
||||
{ field: 'campaignName', title: '活动名称', minWidth: 140 },
|
||||
{ field: 'platform', title: '平台', width: 90 },
|
||||
{
|
||||
field: 'feeAmount', title: '费用金额', width: 130,
|
||||
formatter: ({ cellValue }) => `¥${Number(cellValue || 0).toLocaleString()}`,
|
||||
@@ -71,7 +85,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: props.shopId || undefined,
|
||||
platform: searchForm.value.platform,
|
||||
platformId: searchForm.value.platformId,
|
||||
feeDateStart: searchForm.value.feeDateStart,
|
||||
feeDateEnd: searchForm.value.feeDateEnd,
|
||||
},
|
||||
@@ -115,11 +129,12 @@ async function handleDelete(id: number) {
|
||||
<span>推广费</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<Input
|
||||
v-model:value="searchForm.platform"
|
||||
<Select
|
||||
v-model:value="searchForm.platformId"
|
||||
placeholder="平台"
|
||||
class="!w-24"
|
||||
class="!w-28"
|
||||
allow-clear
|
||||
:options="platformList"
|
||||
@change="() => gridReloadRef?.()"
|
||||
/>
|
||||
<DatePicker
|
||||
@@ -179,4 +194,4 @@ async function handleDelete(id: number) {
|
||||
@success="gridReloadRef?.()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
Reference in New Issue
Block a user