review:【antd/ele】【mall】商城相关的代码
This commit is contained in:
@@ -464,8 +464,6 @@ function handleRenameSuccess() {
|
|||||||
>
|
>
|
||||||
<div class="flex h-12 items-center">
|
<div class="flex h-12 items-center">
|
||||||
<!-- 头部:分类名 -->
|
<!-- 头部:分类名 -->
|
||||||
<!-- 2)拖动后,直接请求排序,不用有个【保存】;排序模型分类,和排序分类里的模型,交互有点不同哈。
|
|
||||||
@芋艿 好像 yudao-ui-admin-vue3 交互也是这样的,需要改吗? -->
|
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<Tooltip v-if="isCategorySorting" title="拖动排序">
|
<Tooltip v-if="isCategorySorting" title="拖动排序">
|
||||||
<!-- drag-handle 标识可以拖动,不能删掉 -->
|
<!-- drag-handle 标识可以拖动,不能删掉 -->
|
||||||
|
|||||||
@@ -168,10 +168,6 @@ async function initProcessInfo(row: any, formVariables?: any) {
|
|||||||
await router.push({
|
await router.push({
|
||||||
path: row.formCustomCreatePath,
|
path: row.formCustomCreatePath,
|
||||||
});
|
});
|
||||||
// 返回选择流程
|
|
||||||
// 这里为啥要有个 cancel 事件哈?目前看 vue3 + element-plus 貌似不需要呀;
|
|
||||||
// @芋艿 不加貌似会有点问题。
|
|
||||||
emit('cancel');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,36 +229,32 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验是否选择了商品
|
// 校验是否选择了商品
|
||||||
if (spuList.value.length === 0) {
|
if (spuList.value.length === 0) {
|
||||||
ElMessage.warning('请选择活动商品');
|
ElMessage.warning('请选择活动商品');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
try {
|
try {
|
||||||
// 获取折扣商品配置
|
// 获取折扣商品配置
|
||||||
const products = cloneDeep(
|
const products = cloneDeep(
|
||||||
spuAndSkuListRef.value?.getSkuConfigs('productConfig') || [],
|
spuAndSkuListRef.value?.getSkuConfigs('productConfig') || [],
|
||||||
) as MallDiscountActivityApi.DiscountProduct[];
|
) as MallDiscountActivityApi.DiscountProduct[];
|
||||||
|
|
||||||
// 转换金额为分
|
// 转换金额为分
|
||||||
products.forEach((item) => {
|
products.forEach((item) => {
|
||||||
item.discountPercent = convertToInteger(item.discountPercent);
|
item.discountPercent = convertToInteger(item.discountPercent);
|
||||||
item.discountPrice = convertToInteger(item.discountPrice);
|
item.discountPrice = convertToInteger(item.discountPrice);
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = cloneDeep(
|
const data = cloneDeep(
|
||||||
await formApi.getValues(),
|
await formApi.getValues(),
|
||||||
) as MallDiscountActivityApi.DiscountActivity;
|
) as MallDiscountActivityApi.DiscountActivity;
|
||||||
data.products = products;
|
data.products = products;
|
||||||
|
|
||||||
// 提交请求
|
// 提交请求
|
||||||
await (formData.value?.id
|
await (formData.value?.id
|
||||||
? updateDiscountActivity(data)
|
? updateDiscountActivity(data)
|
||||||
: createDiscountActivity(data));
|
: createDiscountActivity(data));
|
||||||
|
// 关闭并提示
|
||||||
await modalApi.close();
|
await modalApi.close();
|
||||||
emit('success');
|
emit('success');
|
||||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
@@ -271,18 +267,15 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
await resetForm();
|
await resetForm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
const data = modalApi.getData<MallDiscountActivityApi.DiscountActivity>();
|
const data = modalApi.getData<MallDiscountActivityApi.DiscountActivity>();
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
const activityData = await getDiscountActivity(data.id);
|
const activityData = await getDiscountActivity(data.id);
|
||||||
formData.value = activityData;
|
formData.value = activityData;
|
||||||
|
|
||||||
// 加载商品详情
|
// 加载商品详情
|
||||||
if (activityData.products && activityData.products.length > 0) {
|
if (activityData.products && activityData.products.length > 0) {
|
||||||
// 按 spuId 分组
|
// 按 spuId 分组
|
||||||
@@ -297,15 +290,13 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
}
|
}
|
||||||
spuProductsMap.get(spuId)!.push(product);
|
spuProductsMap.get(spuId)!.push(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载每个 SPU 的详情
|
// 加载每个 SPU 的详情
|
||||||
for (const [spuId, products] of spuProductsMap) {
|
for (const [spuId, products] of spuProductsMap) {
|
||||||
const skuIdArr = products.map((p) => p.skuId);
|
const skuIdArr = products.map((p) => p.skuId);
|
||||||
await getSpuDetails(spuId, skuIdArr, products, 'load');
|
await getSpuDetails(spuId, skuIdArr, products, 'load');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 设置到 values
|
||||||
// 设置表单值
|
|
||||||
await formApi.setValues(activityData);
|
await formApi.setValues(activityData);
|
||||||
} finally {
|
} finally {
|
||||||
modalApi.unlock();
|
modalApi.unlock();
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
const result = await getReward(data.id);
|
const result = await getReward(data.id);
|
||||||
// valueFormat: 'x' 配置下,直接使用时间戳字符串
|
|
||||||
result.startAndEndTime = [
|
result.startAndEndTime = [
|
||||||
result.startTime ? String(result.startTime) : undefined,
|
result.startTime ? String(result.startTime) : undefined,
|
||||||
result.endTime ? String(result.endTime) : undefined,
|
result.endTime ? String(result.endTime) : undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user