Commit bb2f7fe0 by chenwq

feat: 优化动作执行确认和媒体内容展示逻辑

1 parent 13a50cbe
...@@ -15,26 +15,62 @@ function flattenConditions(conditionGroups) { ...@@ -15,26 +15,62 @@ function flattenConditions(conditionGroups) {
}, []); }, []);
} }
function parseMaterials(materialJson) { function parseList(value) {
if (!materialJson) if (!value)
return [];
try {
const list = JSON.parse(materialJson);
if (!Array.isArray(list))
return [];
const typeMap = {
image: "图片",
video: "视频",
};
return list
.filter(item => item && item.url)
.map(item => ({
typeName: typeMap[item.type] || item.type || "素材",
url: item.url,
}));
} catch (e) {
return []; return [];
return String(value)
.split(",")
.map(item => item.trim())
.filter(Boolean);
}
function normalizeMediaIds(mediaIds, type) {
return parseList(mediaIds)
.map((item) => {
return {
type,
url: item,
name: "",
};
})
.filter(item => item.url)
.slice(0, 9);
}
function getActionTitle(action) {
return action.actionTypeName === "发送消息" ? "向客户群发送消息" : getValue(action.actionTypeName);
}
function getActionRows(action) {
const rows = [
{ label: "目标群", value: "目标客户所在群" },
{ label: "消息类型", value: getValue(action.messageTypeName) },
];
if (Number(action.messageType) === 1) {
rows.push({ label: "消息内容", value: getValue(action.content) });
} }
return rows;
}
function getActionMediaList(action) {
if (Number(action.messageType) === 2) {
return normalizeMediaIds(action.mediaIds, "image");
}
if (Number(action.messageType) === 3) {
return normalizeMediaIds(action.mediaIds, "video");
}
return [];
}
function getActionLink(action) {
if (Number(action.messageType) !== 4)
return null;
return {
label: "消息内容",
value: getValue(action.jumpUrl),
};
} }
export function getBasicRows(info = {}) { export function getBasicRows(info = {}) {
...@@ -58,15 +94,13 @@ export function getCustomerRows(info = {}) { ...@@ -58,15 +94,13 @@ export function getCustomerRows(info = {}) {
export function getTriggerRows(info = {}) { export function getTriggerRows(info = {}) {
const triggerInfo = info.triggerInfo || {}; const triggerInfo = info.triggerInfo || {};
const conditionText = flattenConditions(triggerInfo.step2ConditionGroups).join(";");
const rows = [ const rows = [
{ label: "触发类型", value: getValue(triggerInfo.triggerTypeName) }, { label: "触发类型", value: getValue(triggerInfo.triggerTypeName) },
{ label: "日期时间变量", value: "客户新车交付日期" },
{ label: "实际触发时间", value: getValue(triggerInfo.triggerTimeDesc) }, { label: "实际触发时间", value: getValue(triggerInfo.triggerTimeDesc) },
{ label: "同时满足以下条件", value: conditionText },
]; ];
const conditionText = flattenConditions(triggerInfo.step2ConditionGroups).join(";");
if (conditionText) {
rows.push({ label: "同时满足以下条件", value: conditionText });
}
rows.push({ label: "动作执行确认", value: getValue(triggerInfo.actionConfirmDesc) });
return rows; return rows;
} }
...@@ -78,27 +112,13 @@ export function getBranchBlocks(info = {}) { ...@@ -78,27 +112,13 @@ export function getBranchBlocks(info = {}) {
return { return {
name: branch.branchName || `分支${branchIndex + 1}`, name: branch.branchName || `分支${branchIndex + 1}`,
conditionText, conditionText,
actions: actions.map((action, actionIndex) => { actions: actions.map((action, actionIndex) => ({
const actionTitle = action.actionTypeName === "发送消息" ? "向客户群发送消息" : getValue(action.actionTypeName); name: `动作${actionIndex + 1}`,
// messageType:1-文本-content,2-图片-medals,3-视频-medals,4-网页-jumpUrl title: getActionTitle(action),
const attrObj = { rows: getActionRows(action),
1: "content", mediaList: getActionMediaList(action),
2: "mediaIds", link: getActionLink(action),
3: "mediaIds", })),
4: "jumpUrl",
};
const rows = [
{ label: "目标群", value: "目标客户所在群" },
{ label: "消息类型", value: getValue(action.messageTypeName) },
{ label: "消息内容", value: getValue(action[attrObj[action.messageType]]) },
];
return {
name: `动作${actionIndex + 1}`,
title: actionTitle,
rows,
materials: parseMaterials(action.materialJson),
};
}),
}; };
}); });
} }
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
<span>执行动作</span> <span>执行动作</span>
</div> </div>
<div class="detail-section-body"> <div class="detail-section-body">
<div>动作执行确认:{{ info.triggerInfo.actionConfirmDesc }}</div> <div>动作执行确认:{{ info.triggerInfo && info.triggerInfo.actionConfirmDesc }}</div>
<div>默认执行第一条满足条件规则的分支</div> <div>默认执行第一条满足条件规则的分支</div>
<template v-if="branchBlocks.length"> <template v-if="branchBlocks.length">
<div v-for="(branch, branchIndex) in branchBlocks" <div v-for="(branch, branchIndex) in branchBlocks"
...@@ -71,6 +71,41 @@ ...@@ -71,6 +71,41 @@
:key="row.label"> :key="row.label">
<span class="detail-label">{{ row.label }}:</span>{{ row.value }} <span class="detail-label">{{ row.label }}:</span>{{ row.value }}
</p> </p>
<div v-if="action.mediaList.length"
class="message-media-wrapper">
<span class="detail-label">消息内容:</span>
<div class="message-media-list">
<div v-for="media in action.mediaList"
:key="media.url"
class="message-media-item">
<el-image v-if="media.type === 'image'"
class="message-image"
fit="cover"
:preview-src-list="getImagePreviewList(action.mediaList)"
:src="media.url">
</el-image>
<video v-else
class="message-video"
controls
:src="media.url">
</video>
<div v-if="media.name"
class="media-name"
:title="media.name">
{{ media.name }}
</div>
</div>
</div>
</div>
<p v-if="action.link">
<span class="detail-label">{{ action.link.label }}:</span>
<a class="detail-link"
rel="noopener noreferrer"
target="_blank"
:href="action.link.value">
{{ action.link.value }}
</a>
</p>
</div> </div>
</div> </div>
</template> </template>
...@@ -152,7 +187,12 @@ export default { ...@@ -152,7 +187,12 @@ export default {
return; return;
} }
this.info = JSON.parse(snapshotInfo); this.info = JSON.parse(snapshotInfo);
console.log(this.info); console.log(this.info, "this.info");
},
getImagePreviewList(mediaList) {
return mediaList
.filter(item => item.type === "image")
.map(item => item.url);
}, },
handleDetailConfirm() { handleDetailConfirm() {
this.$emit("handleDetailConfirm"); this.$emit("handleDetailConfirm");
...@@ -235,11 +275,54 @@ export default { ...@@ -235,11 +275,54 @@ export default {
} }
.action-block:last-child { .action-block:last-child {
margin-bottom: 0px; margin-bottom: 0;
}
.message-media-wrapper {
display: flex;
align-items: flex-start;
margin-top: 4px;
} }
.material-text { .message-media-list {
display: inline; display: flex;
flex-wrap: wrap;
gap: 10px;
flex: 1;
}
.message-media-item {
width: 240px;
}
.message-image,
.message-video {
width: 240px;
height: 180px;
border-radius: 4px;
background: #fff;
border: 1px solid #ebeef5;
object-fit: cover;
display: block;
}
.media-name {
margin-top: 4px;
color: #606266;
font-size: 12px;
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-link {
color: #409eff;
text-decoration: none;
&:hover {
text-decoration: underline;
}
} }
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!