Commit 89c3d4e6 by Jaxon

Merge branch 'feature/marketing-sop-push-strategy' into 'SAAS+V5.8.3'

Feature/marketing sop push strategy

See merge request !769
2 parents 765e5482 68569930
...@@ -111,7 +111,7 @@ export default { ...@@ -111,7 +111,7 @@ export default {
tableHeadItems: { tableHeadItems: {
type: Array, type: Array,
default: () => { default: () => {
return this.tablecolumnList.map(item => item.label); return ["门店名称", "门店地址", "门店商户号", "服务对接", "服务对接商户号"];
}, },
}, },
}, },
......
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
justify-content: space-between; justify-content: space-between;
background-color: #f5f6fa; background-color: #f5f6fa;
> .title { > .title {
line-height: 16px; line-height: 32px;
} }
.del-button { .del-button {
border-style: dashed; border-style: dashed;
......
...@@ -39,7 +39,9 @@ ...@@ -39,7 +39,9 @@
:prop="`${propPrefix}.valueSource`"> :prop="`${propPrefix}.valueSource`">
<el-radio-group :value="item.valueSource" <el-radio-group :value="item.valueSource"
@input="handleValueSource"> @input="handleValueSource">
<el-radio-button :label="enums.conditionVariableSourceTypeEnum.VARIABLE"> <el-radio-button :disabled="getVariableRefCodeOptions.length === 0"
:label="enums.conditionVariableSourceTypeEnum.VARIABLE"
:title="getVariableRefCodeOptions.length === 0 ? '所选变量没有支持的子变量' : ''">
变量 变量
</el-radio-button> </el-radio-button>
<el-radio-button :label="enums.conditionVariableSourceTypeEnum.VALUE"> <el-radio-button :label="enums.conditionVariableSourceTypeEnum.VALUE">
...@@ -230,8 +232,7 @@ export default { ...@@ -230,8 +232,7 @@ export default {
// 只要切换一个, 子级全清 // 只要切换一个, 子级全清
// valueType // valueType
const variable = this.options.conditionVariables.find(item => item.variableCode === val); const variable = this.options.conditionVariables.find(item => item.variableCode === val);
this.$emit("input", { const value = {
...this.item,
variableCode: val, variableCode: val,
valueType: variable?.variableType, valueType: variable?.variableType,
operator: undefined, operator: undefined,
...@@ -241,6 +242,13 @@ export default { ...@@ -241,6 +242,13 @@ export default {
numberValue: undefined, numberValue: undefined,
enumValue: undefined, enumValue: undefined,
dateValue: undefined, dateValue: undefined,
};
if (!variable?.sopConditionVariableDTOList || variable?.sopConditionVariableDTOList?.length <= 0) {
value.valueSource = ConditionVariableSourceTypeEnum.VALUE;
}
this.$emit("input", {
...this.item,
...value,
}); });
}, },
handleOperatorChange(val) { handleOperatorChange(val) {
...@@ -273,7 +281,8 @@ export default { ...@@ -273,7 +281,8 @@ export default {
this.updateItem("dateValue", val); this.updateItem("dateValue", val);
}, },
handleEnumChange(val) { handleEnumChange(val) {
this.updateItem("enumValue", val); const enumItem = this.getVariableEnumOptions.find(item => item.enumCode === val);
this.$emit("input", { ...this.item, enumValue: val, enumValueName: enumItem?.enumName || "" });
}, },
}, },
}; };
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<div style="margin-top:8px"> <div style="margin-top:8px">
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_TEXT" class="type-item"> <div v-if="item.messageType === MessageTypeEnum.VARIABLE_TEXT" class="type-item">
<VariableTextarea style="width:580px" <VariableTextarea style="width:580px"
:max-length="1000"
:value="item.content" :value="item.content"
:variable-list="messageVariables" :variable-list="messageVariables"
@input="handleContentChange" /> @input="handleContentChange" />
...@@ -37,12 +38,18 @@ ...@@ -37,12 +38,18 @@
@change="(urls, _currentUrl, _currentName, names, sizes) => handleMediasChange(urls, names, sizes, 2)" /> @change="(urls, _currentUrl, _currentName, names, sizes) => handleMediasChange(urls, names, sizes, 2)" />
</div> </div>
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_WEBPAGE" class="type-item"> <div v-if="item.messageType === MessageTypeEnum.VARIABLE_WEBPAGE" class="type-item page-config">
<el-button size="mini" <el-button size="mini"
plain plain
@click="handleShowPageConfig"> @click="handleShowPageConfig">
编辑 编辑
</el-button> </el-button>
<span v-if="item.pageTitle && item.pageDesc && item.bgColor" class="validate-tips success">
<i class="el-icon-check"> </i>
网页已设置
</span>
<span v-else class="validate-tips">网页未设置</span>
</div> </div>
</div> </div>
<VenusDialog v-model="dialog.page.show" <VenusDialog v-model="dialog.page.show"
...@@ -178,5 +185,18 @@ export default { ...@@ -178,5 +185,18 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.type-item {
&.page-config {
display: flex;
align-items: center;
.validate-tips {
font-size: 13px;
color: rgba(0, 0, 0, 0.45);
margin-left: 8px;
&.success {
color: rgba(0, 128, 0, 0.45);
}
}
}
}
</style> </style>
<template> <template>
<div class="page-config-wrapper"> <div class="page-config-wrapper">
<div class="phone-preview-iframe"> <div class="phone-preview-iframe">
<iframe ref="iframeRef" <iframe v-if="iframeUrl"
ref="iframeRef"
class="iframe" class="iframe"
frameborder="0" frameborder="0"
src="http://192.168.148.147:4173/sop-material-preview.html"> :src="iframeUrl">
</iframe> </iframe>
</div> </div>
<div class="config-from-wrapper"> <div class="config-from-wrapper">
...@@ -152,6 +153,7 @@ ...@@ -152,6 +153,7 @@
import VenusOssUpload from "@/components/venusOssUpload"; import VenusOssUpload from "@/components/venusOssUpload";
import { moveItem } from "@/libs/array.js"; import { moveItem } from "@/libs/array.js";
import { isImageFile } from "@/libs/file.js"; import { isImageFile } from "@/libs/file.js";
import { baseConfig } from "@/main";
import { intervalPxOptions } from "@/views/marketingManagement/marketingPushStrategy/constant/index.js"; import { intervalPxOptions } from "@/views/marketingManagement/marketingPushStrategy/constant/index.js";
export default { export default {
...@@ -179,6 +181,7 @@ export default { ...@@ -179,6 +181,7 @@ export default {
return { return {
file: [], file: [],
materialList: [], materialList: [],
iframeUrl: "",
rules: { rules: {
pageTitle: [ pageTitle: [
{ required: true, message: "请输入网页标题", trigger: ["blur"] }, { required: true, message: "请输入网页标题", trigger: ["blur"] },
...@@ -224,6 +227,7 @@ export default { ...@@ -224,6 +227,7 @@ export default {
window.removeEventListener("message", this.eventListenerIframeReady); window.removeEventListener("message", this.eventListenerIframeReady);
}, },
async mounted() { async mounted() {
this.iframeUrl = baseConfig.marketingManagement.marketingPushStrategy.pageConfigH5Addres;
window.addEventListener("message", this.eventListenerIframeReady); window.addEventListener("message", this.eventListenerIframeReady);
}, },
...@@ -364,10 +368,13 @@ export default { ...@@ -364,10 +368,13 @@ export default {
return hash ? `${finalUrl}#${hash}` : finalUrl; return hash ? `${finalUrl}#${hash}` : finalUrl;
}, },
async eventListenerIframeReady(e) { async eventListenerIframeReady(e) {
console.log("message from iframe?", e.origin, e.data); if (!["http://single-pages.test.glsx.com.cn", "http://single-pages.glsx.com.cn"].includes(e.origin)) {
if (e.data.type === "SOP_MATERIAL_PREVIEW_READY" || e.type === "SOP_MATERIAL_PREVIEW_READY") { return;
await this.postIframeMessage(); }
if (e.data.type !== "SOP_MATERIAL_PREVIEW_READY") {
return;
} }
await this.postIframeMessage();
}, },
async postIframeMessage() { async postIframeMessage() {
await this.$nextTick(); await this.$nextTick();
......
...@@ -15,26 +15,69 @@ function flattenConditions(conditionGroups) { ...@@ -15,26 +15,69 @@ 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),
};
}
function maskPhone(phone) {
if (!phone)
return "-";
const str = String(phone);
return str.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
} }
export function getBasicRows(info = {}) { export function getBasicRows(info = {}) {
...@@ -52,21 +95,19 @@ export function getCustomerRows(info = {}) { ...@@ -52,21 +95,19 @@ export function getCustomerRows(info = {}) {
return [ return [
{ label: "所属门店", value: getValue(customerInfo.storeName) }, { label: "所属门店", value: getValue(customerInfo.storeName) },
{ label: "客户名称", value: getValue(customerInfo.customerName) }, { label: "客户名称", value: getValue(customerInfo.customerName) },
{ label: "客户手机号", value: getValue(customerInfo.customerPhone) }, { label: "客户手机号", value: maskPhone(customerInfo.customerPhone) },
]; ];
} }
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 +119,13 @@ export function getBranchBlocks(info = {}) { ...@@ -78,27 +119,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),
};
}),
}; };
}); });
} }
<!-- 策略详情弹窗 --> <!-- 策略详情弹窗 -->
<template> <template>
<div> <div>
<d2-dialog btn-ok-label="确定" <d2-dialog btn-ok-label="关闭"
class="detail" class="detail"
width="70%" width="70%"
:is-visible.sync="detailVisible" :is-visible.sync="detailVisible"
:no-cancel="true"
:title="title" :title="title"
@closeDialog="handleDetailClose" @closeDialog="handleDetailClose"
@confirmDialog="handleDetailConfirm"> @confirmDialog="handleDetailConfirm">
...@@ -51,7 +52,7 @@ ...@@ -51,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"
...@@ -70,6 +71,42 @@ ...@@ -70,6 +71,42 @@
: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"
@play="handleVideoPlay">
</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>
...@@ -144,6 +181,15 @@ export default { ...@@ -144,6 +181,15 @@ export default {
}, },
methods: { methods: {
pauseOtherVideos(videos, currentVideo) {
if (!videos || !videos.length)
return;
videos.forEach((video) => {
if (video && video !== currentVideo && !video.paused) {
video.pause();
}
});
},
initInfo() { initInfo() {
const snapshotInfo = this.detailInfo && this.detailInfo.snapshotInfo; const snapshotInfo = this.detailInfo && this.detailInfo.snapshotInfo;
if (!snapshotInfo) { if (!snapshotInfo) {
...@@ -151,7 +197,17 @@ export default { ...@@ -151,7 +197,17 @@ 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);
},
handleVideoPlay(event) {
const wrapper = this.$el && this.$el.querySelector(".strategy-detail-dialog");
const videos = wrapper ? wrapper.querySelectorAll("video") : [];
this.pauseOtherVideos(Array.prototype.slice.call(videos), event.target);
}, },
handleDetailConfirm() { handleDetailConfirm() {
this.$emit("handleDetailConfirm"); this.$emit("handleDetailConfirm");
...@@ -170,7 +226,9 @@ export default { ...@@ -170,7 +226,9 @@ export default {
padding-right: 6px; padding-right: 6px;
color: #303133; color: #303133;
font-size: 13px; font-size: 13px;
[class^="el-icon-"] {
color: #ffffff;
}
.detail-section { .detail-section {
margin-bottom: 18px; margin-bottom: 18px;
...@@ -234,11 +292,54 @@ export default { ...@@ -234,11 +292,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;
}
.message-media-list {
display: flex;
flex-wrap: wrap;
gap: 10px;
flex: 1;
}
.message-media-item {
width: 180px;
} }
.material-text { .message-image,
display: inline; .message-video {
width: 180px;
height: 120px;
border-radius: 4px;
background: #fff;
border: 1px solid #ebeef5;
object-fit: contain;
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>
<!-- 关联门店弹窗 --> <!-- 关联门店弹窗 -->
<template> <template>
<div> <div>
<d2-dialog btn-ok-label="确定" <d2-dialog btn-ok-label="关闭"
class="record" class="record"
width="70%" width="70%"
:is-visible.sync="recordVisible" :is-visible.sync="recordVisible"
:no-cancel="true"
:title="title" :title="title"
@closeDialog="handleRecordClose" @closeDialog="handleRecordClose"
@confirmDialog="handleRecordConfirm"> @confirmDialog="handleRecordConfirm">
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
resize="none" resize="none"
rows="8" rows="8"
type="textarea" type="textarea"
show-word-limit
:maxlength="maxLength"
:value="value" :value="value"
@input="handleInput"> @input="handleInput">
</el-input> </el-input>
...@@ -37,6 +39,10 @@ ...@@ -37,6 +39,10 @@
export default { export default {
name: "VariableTextarea", name: "VariableTextarea",
props: { props: {
maxLength: {
type: Number,
default: 1000,
},
value: { value: {
type: String, type: String,
required: true, required: true,
...@@ -93,12 +99,19 @@ export default { ...@@ -93,12 +99,19 @@ export default {
.variable-textarea-wrapper { .variable-textarea-wrapper {
border-radius: 4px; border-radius: 4px;
border: 1px solid #e5e5e5; border: 1px solid #e5e5e5;
::v-deep .el-textarea__inner { ::v-deep .el-textarea {
border: none; .el-textarea__inner {
border-radius: 0; border: none;
box-shadow: none; border-radius: 0;
background-color: #f5f5f5; box-shadow: none;
color: #666; background-color: #f5f5f5;
color: #666;
}
.el-input__count {
right: 10px;
bottom: -42px;
background-color: transparent;
}
} }
.foot-wrapper { .foot-wrapper {
background-color: #f5f6fa; background-color: #f5f6fa;
......
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
<script> <script>
import { cloneDeep, isArray } from "lodash-es"; import { cloneDeep, isArray } from "lodash-es";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import { createStrategy, getMarketingPushStrategyDetailApi, getMetaOptionsApi, updateStrategy } from "@/views/marketingManagement/marketingPushStrategy/api/index.js"; import { createStrategy, getMarketingPushStrategyDetailApi, getMetaOptionsApi, updateStrategy } from "@/views/marketingManagement/marketingPushStrategy/api/index.js";
import BranchGroup from "@/views/marketingManagement/marketingPushStrategy/components/branchGroup/index.vue"; import BranchGroup from "@/views/marketingManagement/marketingPushStrategy/components/branchGroup/index.vue";
import ConditionPanel from "@/views/marketingManagement/marketingPushStrategy/components/conditionPanel/index.vue"; import ConditionPanel from "@/views/marketingManagement/marketingPushStrategy/components/conditionPanel/index.vue";
...@@ -165,6 +166,7 @@ export default { ...@@ -165,6 +166,7 @@ export default {
BranchGroup, BranchGroup,
ConditionPanel, ConditionPanel,
}, },
mixins: [reportTrackFunMixin], // 导入混入
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
to.meta.title = to.query.editType === "edit" ? "修改策略" : "新增策略"; to.meta.title = to.query.editType === "edit" ? "修改策略" : "新增策略";
...@@ -356,6 +358,7 @@ export default { ...@@ -356,6 +358,7 @@ export default {
const params = this.dealParams(); const params = this.dealParams();
const api = this.$route.query.editType === "edit" ? updateStrategy : createStrategy; const api = this.$route.query.editType === "edit" ? updateStrategy : createStrategy;
api(params).then((res) => { api(params).then((res) => {
this.setReportTrackData(0, "sop_strategy_web_submit_change", {});
this.$message.success("操作成功"); this.$message.success("操作成功");
this.handleCancel(); this.handleCancel();
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!