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 {
tableHeadItems: {
type: Array,
default: () => {
return this.tablecolumnList.map(item => item.label);
return ["门店名称", "门店地址", "门店商户号", "服务对接", "服务对接商户号"];
},
},
},
......
......@@ -148,7 +148,7 @@ export default {
justify-content: space-between;
background-color: #f5f6fa;
> .title {
line-height: 16px;
line-height: 32px;
}
.del-button {
border-style: dashed;
......
......@@ -39,7 +39,9 @@
:prop="`${propPrefix}.valueSource`">
<el-radio-group :value="item.valueSource"
@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 :label="enums.conditionVariableSourceTypeEnum.VALUE">
......@@ -230,8 +232,7 @@ export default {
// 只要切换一个, 子级全清
// valueType
const variable = this.options.conditionVariables.find(item => item.variableCode === val);
this.$emit("input", {
...this.item,
const value = {
variableCode: val,
valueType: variable?.variableType,
operator: undefined,
......@@ -241,6 +242,13 @@ export default {
numberValue: undefined,
enumValue: undefined,
dateValue: undefined,
};
if (!variable?.sopConditionVariableDTOList || variable?.sopConditionVariableDTOList?.length <= 0) {
value.valueSource = ConditionVariableSourceTypeEnum.VALUE;
}
this.$emit("input", {
...this.item,
...value,
});
},
handleOperatorChange(val) {
......@@ -273,7 +281,8 @@ export default {
this.updateItem("dateValue", 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 @@
<div style="margin-top:8px">
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_TEXT" class="type-item">
<VariableTextarea style="width:580px"
:max-length="1000"
:value="item.content"
:variable-list="messageVariables"
@input="handleContentChange" />
......@@ -37,12 +38,18 @@
@change="(urls, _currentUrl, _currentName, names, sizes) => handleMediasChange(urls, names, sizes, 2)" />
</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"
plain
@click="handleShowPageConfig">
编辑
</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>
<VenusDialog v-model="dialog.page.show"
......@@ -178,5 +185,18 @@ export default {
</script>
<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>
<template>
<div class="page-config-wrapper">
<div class="phone-preview-iframe">
<iframe ref="iframeRef"
<iframe v-if="iframeUrl"
ref="iframeRef"
class="iframe"
frameborder="0"
src="http://192.168.148.147:4173/sop-material-preview.html">
:src="iframeUrl">
</iframe>
</div>
<div class="config-from-wrapper">
......@@ -152,6 +153,7 @@
import VenusOssUpload from "@/components/venusOssUpload";
import { moveItem } from "@/libs/array.js";
import { isImageFile } from "@/libs/file.js";
import { baseConfig } from "@/main";
import { intervalPxOptions } from "@/views/marketingManagement/marketingPushStrategy/constant/index.js";
export default {
......@@ -179,6 +181,7 @@ export default {
return {
file: [],
materialList: [],
iframeUrl: "",
rules: {
pageTitle: [
{ required: true, message: "请输入网页标题", trigger: ["blur"] },
......@@ -224,6 +227,7 @@ export default {
window.removeEventListener("message", this.eventListenerIframeReady);
},
async mounted() {
this.iframeUrl = baseConfig.marketingManagement.marketingPushStrategy.pageConfigH5Addres;
window.addEventListener("message", this.eventListenerIframeReady);
},
......@@ -364,10 +368,13 @@ export default {
return hash ? `${finalUrl}#${hash}` : finalUrl;
},
async eventListenerIframeReady(e) {
console.log("message from iframe?", e.origin, e.data);
if (e.data.type === "SOP_MATERIAL_PREVIEW_READY" || e.type === "SOP_MATERIAL_PREVIEW_READY") {
await this.postIframeMessage();
if (!["http://single-pages.test.glsx.com.cn", "http://single-pages.glsx.com.cn"].includes(e.origin)) {
return;
}
if (e.data.type !== "SOP_MATERIAL_PREVIEW_READY") {
return;
}
await this.postIframeMessage();
},
async postIframeMessage() {
await this.$nextTick();
......
......@@ -15,26 +15,69 @@ function flattenConditions(conditionGroups) {
}, []);
}
function parseMaterials(materialJson) {
if (!materialJson)
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) {
function parseList(value) {
if (!value)
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 = {}) {
......@@ -52,21 +95,19 @@ export function getCustomerRows(info = {}) {
return [
{ label: "所属门店", value: getValue(customerInfo.storeName) },
{ label: "客户名称", value: getValue(customerInfo.customerName) },
{ label: "客户手机号", value: getValue(customerInfo.customerPhone) },
{ label: "客户手机号", value: maskPhone(customerInfo.customerPhone) },
];
}
export function getTriggerRows(info = {}) {
const triggerInfo = info.triggerInfo || {};
const conditionText = flattenConditions(triggerInfo.step2ConditionGroups).join(";");
const rows = [
{ label: "触发类型", value: getValue(triggerInfo.triggerTypeName) },
{ label: "日期时间变量", value: "客户新车交付日期" },
{ 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;
}
......@@ -78,27 +119,13 @@ export function getBranchBlocks(info = {}) {
return {
name: branch.branchName || `分支${branchIndex + 1}`,
conditionText,
actions: actions.map((action, actionIndex) => {
const actionTitle = action.actionTypeName === "发送消息" ? "向客户群发送消息" : getValue(action.actionTypeName);
// messageType:1-文本-content,2-图片-medals,3-视频-medals,4-网页-jumpUrl
const attrObj = {
1: "content",
2: "mediaIds",
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),
};
}),
actions: actions.map((action, actionIndex) => ({
name: `动作${actionIndex + 1}`,
title: getActionTitle(action),
rows: getActionRows(action),
mediaList: getActionMediaList(action),
link: getActionLink(action),
})),
};
});
}
<!-- 策略详情弹窗 -->
<template>
<div>
<d2-dialog btn-ok-label="确定"
<d2-dialog btn-ok-label="关闭"
class="detail"
width="70%"
:is-visible.sync="detailVisible"
:no-cancel="true"
:title="title"
@closeDialog="handleDetailClose"
@confirmDialog="handleDetailConfirm">
......@@ -51,7 +52,7 @@
<span>执行动作</span>
</div>
<div class="detail-section-body">
<div>动作执行确认:{{ info.triggerInfo.actionConfirmDesc }}</div>
<div>动作执行确认:{{ info.triggerInfo && info.triggerInfo.actionConfirmDesc }}</div>
<div>默认执行第一条满足条件规则的分支</div>
<template v-if="branchBlocks.length">
<div v-for="(branch, branchIndex) in branchBlocks"
......@@ -70,6 +71,42 @@
:key="row.label">
<span class="detail-label">{{ row.label }}:</span>{{ row.value }}
</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>
</template>
......@@ -144,6 +181,15 @@ export default {
},
methods: {
pauseOtherVideos(videos, currentVideo) {
if (!videos || !videos.length)
return;
videos.forEach((video) => {
if (video && video !== currentVideo && !video.paused) {
video.pause();
}
});
},
initInfo() {
const snapshotInfo = this.detailInfo && this.detailInfo.snapshotInfo;
if (!snapshotInfo) {
......@@ -151,7 +197,17 @@ export default {
return;
}
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() {
this.$emit("handleDetailConfirm");
......@@ -170,7 +226,9 @@ export default {
padding-right: 6px;
color: #303133;
font-size: 13px;
[class^="el-icon-"] {
color: #ffffff;
}
.detail-section {
margin-bottom: 18px;
......@@ -234,11 +292,54 @@ export default {
}
.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 {
display: inline;
.message-image,
.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>
<!-- 关联门店弹窗 -->
<template>
<div>
<d2-dialog btn-ok-label="确定"
<d2-dialog btn-ok-label="关闭"
class="record"
width="70%"
:is-visible.sync="recordVisible"
:no-cancel="true"
:title="title"
@closeDialog="handleRecordClose"
@confirmDialog="handleRecordConfirm">
......
......@@ -5,6 +5,8 @@
resize="none"
rows="8"
type="textarea"
show-word-limit
:maxlength="maxLength"
:value="value"
@input="handleInput">
</el-input>
......@@ -37,6 +39,10 @@
export default {
name: "VariableTextarea",
props: {
maxLength: {
type: Number,
default: 1000,
},
value: {
type: String,
required: true,
......@@ -93,12 +99,19 @@ export default {
.variable-textarea-wrapper {
border-radius: 4px;
border: 1px solid #e5e5e5;
::v-deep .el-textarea__inner {
border: none;
border-radius: 0;
box-shadow: none;
background-color: #f5f5f5;
color: #666;
::v-deep .el-textarea {
.el-textarea__inner {
border: none;
border-radius: 0;
box-shadow: none;
background-color: #f5f5f5;
color: #666;
}
.el-input__count {
right: 10px;
bottom: -42px;
background-color: transparent;
}
}
.foot-wrapper {
background-color: #f5f6fa;
......
......@@ -151,6 +151,7 @@
<script>
import { cloneDeep, isArray } from "lodash-es";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import { createStrategy, getMarketingPushStrategyDetailApi, getMetaOptionsApi, updateStrategy } from "@/views/marketingManagement/marketingPushStrategy/api/index.js";
import BranchGroup from "@/views/marketingManagement/marketingPushStrategy/components/branchGroup/index.vue";
import ConditionPanel from "@/views/marketingManagement/marketingPushStrategy/components/conditionPanel/index.vue";
......@@ -165,6 +166,7 @@ export default {
BranchGroup,
ConditionPanel,
},
mixins: [reportTrackFunMixin], // 导入混入
beforeRouteEnter(to, from, next) {
to.meta.title = to.query.editType === "edit" ? "修改策略" : "新增策略";
......@@ -356,6 +358,7 @@ export default {
const params = this.dealParams();
const api = this.$route.query.editType === "edit" ? updateStrategy : createStrategy;
api(params).then((res) => {
this.setReportTrackData(0, "sop_strategy_web_submit_change", {});
this.$message.success("操作成功");
this.handleCancel();
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!