Commit 68bf0df9 by 张立顺

Merge branch 'SAAS+V5.8.3' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.8.3
2 parents bc783954 367d20da
Showing 62 changed files with 4324 additions and 396 deletions
{
"mcpServers": {
"codegraph": {
"type": "stdio",
"command": "codegraph",
"args": [
"serve",
"--mcp"
]
}
}
}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"vetur.validation.template": false, "vetur.validation.template": false,
"vetur.validation.script": false, "vetur.validation.script": false,
"vetur.validation.style": true, "vetur.validation.style": true,
"vetur.useWorkspaceDependencies": true,
"vetur.ignoreProjectWarning": false, "vetur.ignoreProjectWarning": false,
"vetur.experimental.templateInterpolationService": false, "vetur.experimental.templateInterpolationService": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint", "editor.defaultFormatter": "dbaeumer.vscode-eslint",
......
...@@ -6,37 +6,53 @@ ENV DEBIAN_FRONTEND=noninteractive ...@@ -6,37 +6,53 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
curl \ curl \
git \ git \
nano \ nano \
ca-certificates \ ca-certificates \
bash \ bash \
unzip \ unzip \
jq \ jq \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 创建用户(uid=1000)
RUN useradd -m -u 1000 -s /bin/bash claude
# 切换到 claude 用户
USER claude
ENV HOME=/home/claude
# Volta # Volta
ENV VOLTA_HOME=/root/.volta ENV VOLTA_HOME=/home/claude/.volta
ENV PATH=$VOLTA_HOME/bin:$PATH ENV PATH=${VOLTA_HOME}/bin:${PATH}
# 安装 Volta
RUN curl https://get.volta.sh | bash RUN curl https://get.volta.sh | bash
# 安装 Node
# 安装 Node14
RUN volta install node@14 RUN volta install node@14
# 默认 Node22
RUN volta install node@22 RUN volta install node@22
# 安装 Claude Code
# Claude Code
RUN npm install -g @anthropic-ai/claude-code RUN npm install -g @anthropic-ai/claude-code
# 触发一次 claude 命令让它生成初始的 ~/.claude.json(如果它还没生成的话) # 初始化 Claude 配置
# 并使用 jq 安全地注入 hasCompletedOnboarding 字段,不破坏原有内容 RUN mkdir -p /home/claude/.claude && \
RUN mkdir -p /root && \ echo '{}' > /home/claude/.claude.json && \
touch /root/.claude.json && \ jq '. + {"hasCompletedOnboarding": true}' \
(echo '{}' > /root/.claude.json) && \ /home/claude/.claude.json \
jq '. + {"hasCompletedOnboarding": true}' /root/.claude.json > /root/.claude.json.tmp && \ > /home/claude/.claude.json.tmp && \
mv /root/.claude.json.tmp /root/.claude.json mv /home/claude/.claude.json.tmp /home/claude/.claude.json
# ==========================
# 最后统一修正权限
# ==========================
USER root
RUN chown -R 1000:1000 /home/claude
# 恢复默认运行用户
USER claude
WORKDIR /workspace WORKDIR /workspace
CMD ["/bin/bash"] CMD ["/bin/bash"]
services: services:
ai-worker: ai-worker:
# user: "1000:1000"
build: build:
context: . context: .
dockerfile: ../build/Dockerfile.unit.test dockerfile: ../build/Dockerfile.unit.test
container_name: ai-worker container_name: ai-worker
working_dir: /workspace working_dir: /workspace
volumes: volumes:
- ./workspace:/workspace - npm-cache:/home/jdkapp/.npm
# npm 缓存
- npm-cache:/home/claude/.npm
# Claude 登录状态
- claude-cache:/home/claude/.claude/projects
# Volta 缓存(node、npm)
- volta-cache:/home/claude/.volta
environment: environment:
- ANTHROPIC_AUTH_TOKEN - ANTHROPIC_AUTH_TOKEN
- GIT_AUTHOR_NAME=AI-BOT
- GIT_AUTHOR_EMAIL=ai-bot@didihu.com.cn
- GIT_COMMITTER_NAME=AI-BOT
- GIT_COMMITTER_EMAIL=ai-bot@didihu.com.cn
- AI_GITLAB_TOKEN
- ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/apps/anthropic - ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/apps/anthropic
- ANTHROPIC_MODEL=qwen3.5-plus - ANTHROPIC_MODEL=qwen3.5-plus
- ANTHROPIC_SMALL_FAST_MODEL=qwen3.5-flash - ANTHROPIC_SMALL_FAST_MODEL=qwen3.5-flash
...@@ -17,6 +29,15 @@ services: ...@@ -17,6 +29,15 @@ services:
- ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.5-plus - ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.5-plus
- ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.5-plus - ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.5-plus
- CLAUDE_CODE_SUBAGENT_MODEL=qwen3.5-plus - CLAUDE_CODE_SUBAGENT_MODEL=qwen3.5-plus
# 保持容器在前台常驻,防止执行完立刻退出崩溃
command: sh -c "tail -f /dev/null" command: >
sh -c '
git config --global credential.helper store &&
echo "http://oauth2:$${AI_GITLAB_TOKEN}@gitlab.test.glsx.com.cn" > ~/.git-credentials &&
tail -f /dev/null
'
restart: unless-stopped restart: unless-stopped
volumes:
npm-cache:
claude-cache:
volta-cache:
import request from "./request";
import RequestMethods from "./request.methods";
// 获取营销活动列表数据
export function getMarketingActivityList(data) {
data.method = `dj.api.marketing.activity.page`;
return request(data, RequestMethods.POST);
}
// 获取营销活动详情(基础信息)
export function getMarketingActivityDetail(data) {
data.method = `dj.api.marketing.activity.detail`;
return request(data, RequestMethods.POST);
}
// 获取营销活动详情(适用门店)
export function getMarketingActivityStores(data) {
data.method = `dj.api.marketing.activity.stores`;
return request(data, RequestMethods.POST);
}
// 获取营销活动详情(适用车系)
export function getMarketingActivityCarSeries(data) {
data.method = `dj.api.marketing.activity.carSeries`;
return request(data, RequestMethods.POST);
}
// 获取营销活动详情(商品/套餐)
export function getMarketingActivityProducts(data) {
data.method = `dj.api.marketing.activity.products`;
return request(data, RequestMethods.POST);
}
// 获取营销活动详情(操作日志)
export function getMarketingActivityLogs(data) {
data.method = `dj.api.marketing.activity.logs`;
return request(data, RequestMethods.POST);
}
// 创建营销活动
export function addMarketingActivity(data) {
data.method = `dj.api.marketing.activity.create`;
return request(data, RequestMethods.POST);
}
// 编辑营销活动
export function editMarketingActivity(data) {
data.method = `dj.api.marketing.activity.update`;
return request(data, RequestMethods.POST);
}
// 获取活动标签列表数据
export function getActivityTagList(data) {
data.method = `dj.api.marketing.tag.list`;
return request(data, RequestMethods.POST);
}
// 新增活动标签数据
export function addActivityTag(data) {
data.method = `dj.api.marketing.tag.create`;
return request(data, RequestMethods.POST);
}
// 重命名活动标签
export function updateActivityTag(data) {
data.method = "dj.api.marketing.tag.rename";
return request(data, RequestMethods.POST);
}
// 删除活动标签数据
export function deleteActivityTag(data) {
data.method = `dj.api.marketing.tag.delete`;
return request(data, RequestMethods.POST);
}
// 根据门店列表获取车系数据
export function getCarDataByMerchant(data) {
data.method = `dj.api.smartcarlife.common.merchant.carseries.list`;
return request(data, RequestMethods.POST);
}
// 根据门店列表获取套餐数据
export function getPackageListByMerchant(data) {
data.method = `dj.api.marketing.package.page`;
return request(data, RequestMethods.POST);
}
// 根据套餐获取套餐内子商品数据
export function getGoodsDataByPackage(data) {
data.method = `dj.api.marketing.package.items`;
return request(data, RequestMethods.POST);
}
// 根据门店列表获取商品数据
export function getGoodsListByMerchant(data) {
data.method = `dj.api.marketing.goods.page`;
return request(data, RequestMethods.POST);
}
// 根据商品/套餐查询适用门店数据
export function getMerchantByGoodsOrPackage(data) {
data.method = `dj.api.marketing.goods.stores`;
return request(data, RequestMethods.POST);
}
// 删除营销活动
export function deleteMarketingActivity(data) {
data.method = `dj.api.marketing.activity.delete`;
return request(data, RequestMethods.POST);
}
// 暂停营销活动
export function pauseMarketingActivity(data) {
data.method = `dj.api.marketing.activity.pause`;
return request(data, RequestMethods.POST);
}
// 恢复营销活动
export function resumeMarketingActivity(data) {
data.method = `dj.api.marketing.activity.resume`;
return request(data, RequestMethods.POST);
}
// 延期营销活动
export function extendMarketingActivity(data) {
data.method = `dj.api.marketing.activity.extend`;
return request(data, RequestMethods.POST);
}
// 下线营销活动
export function offlineMarketingActivity(data) {
data.method = `dj.api.marketing.activity.cease`;
return request(data, RequestMethods.POST);
}
...@@ -100,4 +100,22 @@ export function findMerchantStaffList(data) { ...@@ -100,4 +100,22 @@ export function findMerchantStaffList(data) {
export function linkMerchant(data) { export function linkMerchant(data) {
data.method = `dj.staff.api.recruitment.demand.link.merchant`; data.method = `dj.staff.api.recruitment.demand.link.merchant`;
return request(data); return request(data);
}
// 试岗计划审批(通过/驳回)
export function trialOnboardingApproval(data) {
data.method = `dj.staff.api.recruitment.trial.onboarding.approval`;
return request(data);
}
// 试岗门店列表
export function getTrialOnboardingStoreList(data) {
data.method = `dj.staff.api.recruitment.demand.store.list`;
return request(data);
}
// 招聘需求业务场景列表
export function getRecruitmentDemandSubSceneList(data) {
data.method = `dj.staff.api.recruitment.demand.sub.scene.list`;
return request(data);
} }
\ No newline at end of file \ No newline at end of file
...@@ -21,7 +21,9 @@ function request( ...@@ -21,7 +21,9 @@ function request(
) { ) {
// 兼容线上dj和scrm appkey和secret不一样的情况 // 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = ""; let apiName = "";
if (params.method.includes("dj.api.smartcarlife")) { if (params.method.includes("dj.api.smartcarlife.sop.strategy")) {
apiName = "strategy";
} else if (params.method.includes("dj.api.smartcarlife")) {
apiName = "dj"; apiName = "dj";
} else if (params.method.includes("dj.api.script")) { } else if (params.method.includes("dj.api.script")) {
apiName = "script"; apiName = "script";
...@@ -45,6 +47,8 @@ function request( ...@@ -45,6 +47,8 @@ function request(
} else if (params.method.includes("merchants.api.open.createMerchantWithPermissions")) { } else if (params.method.includes("merchants.api.open.createMerchantWithPermissions")) {
/** 开放平台创建商户 — 与同网关 oaapproval 一致,使用 axios_oaapproval / baseURL */ /** 开放平台创建商户 — 与同网关 oaapproval 一致,使用 axios_oaapproval / baseURL */
apiName = "oaapproval"; apiName = "oaapproval";
} else if (params.method.includes("dj.api.marketing")) {
apiName = "strategy";
} else { } else {
// console.log(params.method.split(".api")) // console.log(params.method.split(".api"))
apiName = params.method.split(".api")[0]; apiName = params.method.split(".api")[0];
......
...@@ -1984,7 +1984,7 @@ export const goodsAuditStatusList = [ ...@@ -1984,7 +1984,7 @@ export const goodsAuditStatusList = [
}, },
{ {
confId: "2", confId: "2",
confLabel: "线上运营待审批", confLabel: "运营待审批",
}, },
{ {
confId: "3", confId: "3",
...@@ -2083,6 +2083,16 @@ export const trialStatusOpt = [ ...@@ -2083,6 +2083,16 @@ export const trialStatusOpt = [
confValue: "无试岗", confValue: "无试岗",
}, },
]; ];
export const approvalStatusOpt=[
{
confId: 0,
confValue: "待审批",
},
{
confId: 1,
confValue: "已审批",
},
]
export const connectionFlagOptMap = { export const connectionFlagOptMap = {
true: "#2CCA74", true: "#2CCA74",
false: "#EB4E4E", false: "#EB4E4E",
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
* 时间控件-限制月份 * 时间控件-限制月份
*/ */
export const beforeRangePickerOptions = { export const beforeRangePickerOptions = {
disabledDate(date) { disabledDate(date) {
if (date > new Date()) { if (date > new Date()) {
return true return true;
} }
return false return false;
} },
} };
export const afterRangePickerOptions = { export const afterRangePickerOptions = {
disabledDate(date) { disabledDate(date) {
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1)) const yesterday = new Date(new Date().setDate(new Date().getDate() - 1));
if (date < yesterday) { if (date < yesterday) {
return true return true;
} }
return false return false;
} },
} };
<template> <template>
<el-dialog ref="elDialog" <el-dialog ref="elDialog"
v-bind="$attrs" v-bind="$attrs"
:visible.sync="innerVisible" :custom-class="dialogCustomClass"
:width="computedWidth" :fullscreen="innerFullscreen"
:fullscreen="innerFullscreen" :show-close="false"
:custom-class="dialogCustomClass" :visible.sync="innerVisible"
:show-close="false" :width="computedWidth"
v-on="$listeners" v-on="$listeners"
@open="handleOpen"> @open="handleOpen">
<!-- Title slot wrapper for fullscreen support --> <!-- Title slot wrapper for fullscreen support -->
<template #title> <template #title>
<div class="venus-dialog-header-inner"> <div class="venus-dialog-header-inner">
<slot name="title"> <slot name="title">
<span class="el-dialog__title">{{ $attrs.title }}</span> <span class="el-dialog__title">{{ $attrs.title }}</span>
</slot> </slot>
<div class="venus-dialog-actions"> <div class="venus-dialog-actions">
<!-- Fullscreen toggle button --> <!-- Fullscreen toggle button -->
<button v-if="allowFullscreen" <button v-if="allowFullscreen"
type="button" class="venus-dialog-action-btn"
class="venus-dialog-action-btn" type="button"
@click="toggleFullscreen"> @click="toggleFullscreen">
<i :class="innerFullscreen ? 'el-icon-crop' : 'el-icon-full-screen'"></i> <i :class="innerFullscreen ? 'el-icon-crop' : 'el-icon-full-screen'"></i>
</button> </button>
<!-- Custom Close button --> <!-- Custom Close button -->
<button v-if="showClose" <button v-if="showClose"
type="button" class="venus-dialog-action-btn"
class="venus-dialog-action-btn" type="button"
@click="handleClose"> @click="handleClose">
<i class="el-icon-close"></i> <i class="el-icon-close"></i>
</button> </button>
</div> </div>
</div>
</template>
<!-- Default slot for dialog body -->
<slot></slot>
<!-- Footer slot -->
<template #footer>
<transition name="footer-slide">
<div v-if="showFooter" class="venus-dialog-footer-wrapper">
<slot name="footer">
<div class="venus-dialog-footer">
<VenusButton v-if="showCancel"
size="small"
@click="handleCancel">
{{ cancelText }}
</VenusButton>
<VenusButton size="small"
type="primary"
:loading="confirmLoading"
@click="handleConfirm">
{{ confirmText }}
</VenusButton>
</div> </div>
</template> </slot>
</div>
<!-- Default slot for dialog body --> </transition>
<slot></slot> </template>
</el-dialog>
<!-- Footer slot -->
<template #footer>
<transition name="footer-slide">
<div v-if="showFooter" class="venus-dialog-footer-wrapper">
<slot name="footer">
<div class="venus-dialog-footer">
<VenusButton v-if="showCancel"
size="small"
@click="handleCancel">
{{ cancelText }}
</VenusButton>
<VenusButton size="small"
type="primary"
:loading="confirmLoading"
@click="handleConfirm">
{{ confirmText }}
</VenusButton>
</div>
</slot>
</div>
</transition>
</template>
</el-dialog>
</template> </template>
<script> <script>
......
/**
* @param {Array} arr 原数组
* @param {number} fromIndex 原下标
* @param {number} toIndex 目标下标
* @returns {Array} 新数组,不修改原数组
*/
export function moveItem(arr, fromIndex, toIndex) {
if (fromIndex === toIndex)
return [...arr];
// 先拷贝一份新数组
const newArr = [...arr];
// 取出并删除原位置元素
const item = newArr.splice(fromIndex, 1)[0];
// 插入到目标位置
newArr.splice(toIndex, 0, item);
return newArr;
}
...@@ -10,3 +10,17 @@ export function readFileAsDataURL(file) { ...@@ -10,3 +10,17 @@ export function readFileAsDataURL(file) {
}; };
}); });
} }
const IMAGE_EXTENSIONS = ["jpg", "jpeg", "png", "gif", "webp", "bmp", "svg", "ico"];
/**
* 根据文件后缀判断是否为图片
* @param {string} fileName - 文件名
* @returns {boolean}
*/
export function isImageFile(fileName) {
if (!fileName || typeof fileName !== "string")
return false;
const ext = fileName.split(".").pop()?.toLowerCase();
return IMAGE_EXTENSIONS.includes(ext);
}
...@@ -82,6 +82,7 @@ export const routerName = { ...@@ -82,6 +82,7 @@ export const routerName = {
parentId: "92203", parentId: "92203",
label: "编辑", label: "编辑",
category: "Button", category: "Button",
type: "primary",
handle: "handleEdit", handle: "handleEdit",
}, },
{ {
...@@ -95,32 +96,108 @@ export const routerName = { ...@@ -95,32 +96,108 @@ export const routerName = {
authId: "9220105", authId: "9220105",
parentId: "92203", parentId: "92203",
label: "暂停", label: "暂停",
handle: "handleToggleStatus", category: "Button",
handle: "handlePause",
}, },
{ {
authId: "9220106", authId: "9220106",
parentId: "92203", parentId: "92203",
label: "恢复", label: "恢复",
handle: "handleToggleStatus", category: "Button",
type: "primary",
handle: "handleResume",
}, },
{ {
authId: "9220107", authId: "9220107",
parentId: "92203", parentId: "92203",
label: "延期", label: "延期",
handle: "handleDelay", category: "Button",
handle: "handleOpenDelay",
}, },
{ {
authId: "9220108", authId: "9220108",
parentId: "92203", parentId: "92203",
label: "下线", label: "下线",
category: "Button",
type: "danger",
handle: "handleOffline", handle: "handleOffline",
}, },
{ {
authId: "9220109", authId: "9220109",
parentId: "92203", parentId: "92203",
category: "Button",
type: "primary",
label: "再次创建", label: "再次创建",
handle: "handleRecreate", handle: "handleRecreate",
}, },
], ],
}, },
92210: {
path: "/marketing-push-strategy",
name: "marketingPushStrategy",
meta: {
title: "营销推送策略",
authId: "92210",
parentId: "922",
cache: false,
},
component: _import("marketingManagement/marketingPushStrategy/views/table/index"),
auth: [
{
authId: "9221001",
parentId: "92210",
label: "新增策略",
category: "Button",
type: "primary",
handle: "handleModify",
addRoutePath: [
{
authId: "9221010",
name: "新增策略",
parentId: "92210",
},
],
},
{
authId: "9221002",
parentId: "92210",
label: "执行记录",
handle: "handleRecord",
},
{
authId: "9221003",
parentId: "92210",
label: "修改",
handle: "handleModify",
addRoutePath: [
{
authId: "9221010",
name: "修改策略",
parentId: "92210",
},
],
},
{
authId: "9221004",
parentId: "92210",
label: "删除",
handle: "handleDelete",
},
],
},
9221010: {
path: "/marketing-push-strategy/modify",
name: "marketingPushStrategyModify",
meta: {
title: "新增策略",
authId: "9221010",
parentId: "92210",
cache: false,
sideHidden: true,
activePath: "/marketing-push-strategy/modify",
},
component: _import("marketingManagement/marketingPushStrategy/views/modify/index"),
},
}; };
<!-- 关联门店弹窗 --> <!-- 关联门店弹窗 -->
<template> <template>
<d2-dialog btn-ok-label="确定" <d2-dialog btn-ok-label="确定"
class="relateStore" class="relateStore"
:is-visible.sync="relateStoreVisible" width="70%"
:title="title" :is-visible.sync="relateStoreVisible"
width="70%" :title="title"
@closeDialog="handleRelateStoreClose" @closeDialog="handleRelateStoreClose"
@confirmDialog="handleRelateStoreConfirm"> @confirmDialog="handleRelateStoreConfirm">
<slot /> <slot />
<el-row class="tableCon"> <el-row class="tableCon">
<div class="tableBox left"> <div class="tableBox left">
<el-table ref="seletingTable" <el-table ref="seletingTable"
border class="table"
class="table" height="464px"
:data="selectingData" border
height="464px" :data="selectingData"
@select="handleChange" @select="handleChange"
@select-all="handleAll"> @select-all="handleAll">
<el-table-column align="center" <el-table-column align="center"
type="selection" type="selection"
width="55" /> width="55" />
<el-table-column align="center" <template v-for="(item, index) in tablecolumnList">
label="门店名称" <el-table-column v-if="tableHeadItems.includes(item.label)"
prop="merchantName"> :key="index"
</el-table-column> align="center"
<el-table-column align="center" :label="item.label"
label="门店地址" :prop="item.prop">
prop="merchantAddress"> </el-table-column>
</el-table-column> </template>
<el-table-column align="center" </el-table>
label="门店商户号" <el-pagination layout="total, prev, pager, next"
prop="merchantId"> background
</el-table-column> small
<el-table-column align="center" :current-page.sync="currentPage"
label="服务对接" :page-size="pageSize"
prop="yqMerchantName"> :total="total"
</el-table-column> @current-change="handleCurrentChange" />
<el-table-column align="center" </div>
label="服务对接商户号" <el-table class="tableBox table"
prop="yqMerchantId"> height="464px"
</el-table-column> border
</el-table> :data="selectedData">
<el-pagination background <el-table-column align="center"
:current-page.sync="currentPage" label="门店名称"
layout="total, prev, pager, next" prop="merchantName">
:page-size="pageSize" <template #default="scope">
small <span>{{ scope.row.merchantName }}</span>
:total="total" </template>
@current-change="handleCurrentChange" /> </el-table-column>
</div> <el-table-column align="center"
<el-table border label="门店商户号"
class="tableBox table" prop="merchantId">
:data="selectedData" <template #default="scope">
height="464px"> <span>{{ scope.row.merchantId }}</span>
<el-table-column align="center" </template>
label="门店名称" </el-table-column>
prop="merchantName"> <el-table-column align="center"
<template #default="scope"> label="删除"
<span>{{ scope.row.merchantName }}</span> width="50px">
</template> <template #default="scope">
</el-table-column> <el-button class="el-icon-delete"
<el-table-column align="center" type="text"
label="门店商户号" @click="handleDelete(scope.row)" />
prop="merchantId"> </template>
<template #default="scope"> </el-table-column>
<span>{{ scope.row.merchantId }}</span> </el-table>
</template> </el-row>
</el-table-column> </d2-dialog>
<el-table-column align="center"
label="删除"
width="50px">
<template #default="scope">
<el-button class="el-icon-delete"
type="text"
@click="handleDelete(scope.row)" />
</template>
</el-table-column>
</el-table>
</el-row>
</d2-dialog>
</template> </template>
<script> <script>
...@@ -114,11 +102,42 @@ export default { ...@@ -114,11 +102,42 @@ export default {
default: false, default: false,
}, },
selectedSceneType: { selectedSceneType: {
type: String type: String,
} },
page: {
type: String,
default: "",
},
tableHeadItems: {
type: Array,
default: () => {
return this.tablecolumnList.map(item => item.label);
},
},
}, },
data() { data() {
return { return {
tablecolumnList: [{
label: "门店名称",
prop: "merchantName",
align: "center",
}, {
label: "门店地址",
prop: "merchantAddress",
align: "center",
}, {
label: "门店商户号",
prop: "merchantId",
align: "center",
}, {
label: "服务对接",
prop: "yqMerchantName",
align: "center",
}, {
label: "服务对接商户号",
prop: "yqMerchantId",
align: "center",
}],
selectedData: [], selectedData: [],
selectingData: [], selectingData: [],
// 分页 // 分页
...@@ -147,7 +166,7 @@ export default { ...@@ -147,7 +166,7 @@ export default {
currentPage: this.currentPage, currentPage: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
baseSceneCode: this.selectedBaseSceneCode, baseSceneCode: this.selectedBaseSceneCode,
queryMerchantAddr: true queryMerchantAddr: true,
}).then((res) => { }).then((res) => {
res?.list?.forEach((val) => { res?.list?.forEach((val) => {
// 账户中心门店返回商户号字段是merchantNo // 账户中心门店返回商户号字段是merchantNo
......
<template>
<div class="detail-table">
<!-- 表头 -->
<div class="table-header">
<span class="th th-expand"></span>
<span class="th th-index">排序</span>
<span class="th th-name" style="display: flex;flex-flow: row;align-items: center !important;">
选项卡名称
<el-tooltip content="在展业助手App中对外展示的套餐或商品名称" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-tabDescription">
选项卡描述
<el-tooltip content="在展业助手App中对外展示的套餐或商品描述" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-price">现售价</span>
<span class="th th-min">最低售价</span>
<span class="th th-discount">优惠价(元)</span>
<span class="th th-incentive">销售激励(元)</span>
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-detail">
内容详图
<el-tooltip content="商品或套餐详情展示的内容长图" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
</div>
<!-- 数据行 -->
<div v-for="(item, index) in list"
:key="index"
class="table-item">
<!-- 主行 -->
<div class="table-row"
:class="{ 'is-expanded': expandedRows.includes(index) }">
<span class="td td-expand">
<i v-if="item.productType == 0 && item.packageItems && item.packageItems.length"
class="expand-icon"
:class="[expandedRows.includes(index) ? 'el-icon-arrow-down' : 'el-icon-arrow-right']"
@click="toggleExpand(index)" />
</span>
<span class="td td-index">{{ index + 1 }}</span>
<span class="td td-name">
<span>{{ item.tabName }}</span>
<div class="sub-text">{{ item.packageCode }}</div>
</span>
<span class="td td-tabDescription">{{ item.tabDescription || '-' }}</span>
<span class="td td-price">{{ priceFilter(item.currentPrice) }}</span>
<span class="td td-min">{{ priceFilter(item.minimumPrice) }}</span>
<span class="td td-discount">{{ priceFilter(item.discountPrice) }}</span>
<span class="td td-incentive">{{ priceFilter(item.salesIncentive) }}</span>
<span class="td td-main">{{ item.isMainPush == 1 ? '是' : '否' }}</span>
<span class="td td-img">
<el-image v-if="item.mainImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.mainImageUrl]"
:src="item.mainImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-thumb">
<el-image v-if="item.thumbImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.thumbImageUrl]"
:src="item.thumbImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-detail">
<el-image v-if="item.detailImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.detailImageUrl]"
:src="item.detailImageUrl" />
<span v-else>-</span>
</span>
</div>
<!-- 子商品展开区(仅套餐类型) -->
<div v-if="(item.productType == 0) && (item.packageItems && item.packageItems.length) && expandedRows.includes(index)"
class="sub-table-wrapper">
<div class="sub-table-header">
<span class="sh-col sh-col-name">产品名称</span>
<span class="sh-col sh-col-name">产品别名</span>
<span class="sh-col sh-col-id">产品ID</span>
<span class="sh-col sh-col-price">现售价</span>
<span class="sh-col sh-col-min">最低售价</span>
<span class="sh-col sh-col-discount">优惠价</span>
</div>
<div v-for="(sub, subIdx) in item.packageItems"
:key="subIdx"
class="sub-table-row">
<span class="sc sc-name">{{ sub.goodsName || '-' }}</span>
<span class="sc sc-name">{{ sub.goodsAlias || '-' }}</span>
<span class="sc sc-id">{{ sub.goodsCode || '-' }}</span>
<span class="sc sc-price">{{ priceFilter(sub.currentPrice) }}</span>
<span class="sc sc-min">{{ priceFilter(sub.minimumPrice) }}</span>
<span class="sc sc-discount">{{ priceFilter(sub.discountPrice) }}</span>
</div>
</div>
</div>
<div v-if="!list.length" class="table-empty">
暂无数据
</div>
</div>
</template>
<script>
export default {
name: "MixedDetailTable",
props: {
list: {
type: Array,
default: () => [],
},
},
data() {
return {
expandedRows: [],
};
},
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
return "-";
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
return (data ?? "") === "";
},
toggleExpand(key) {
const idx = this.expandedRows.indexOf(key);
if (idx > -1) {
this.expandedRows.splice(idx, 1);
} else {
this.expandedRows.push(key);
}
},
},
};
</script>
<style lang="scss" scoped>
.detail-table {
border: 1px solid #ebeef5;
font-size: 13px;
max-height: 500px;
overflow: auto;
}
// 表头
.table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-bottom: 1px solid #ebeef5;
min-width: 1340px;
.th {
padding: 10px 8px;
box-sizing: border-box;
color: #909399;
font-weight: 500;
display: flex;
align-items: center;
flex-shrink: 0;
}
}
// 数据行
.table-item {
border-bottom: 1px solid #ebeef5;
}
.table-row {
display: flex;
align-items: center;
min-width: 1340px;
padding: 8px 0;
background-color: #fff;
&:hover {
background-color: #f5f7fa;
}
&.is-expanded {
background-color: #ecf5ff;
}
}
.td {
padding: 0 8px;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
}
// 列宽定义(比 package 多一列 type)
.td-expand,
.th-expand {
width: 36px;
justify-content: center;
}
.td-index,
.th-index {
width: 50px;
justify-content: center;
color: #606266;
}
.td-type,
.th-type {
width: 80px;
justify-content: center;
}
.th-name,
.td-name {
min-width: 180px;
flex: 2;
flex-direction: column;
align-items: flex-start !important;
}
.th-tabDescription,
.td-tabDescription {
min-width: 160px;
flex: 1.5;
}
.th-store,
.td-store {
width: 90px;
justify-content: center;
}
.th-price,
.td-price {
width: 90px;
color: #606266;
}
.th-min,
.td-min {
width: 90px;
color: #606266;
}
.th-discount,
.td-discount {
width: 120px;
}
.th-incentive,
.td-incentive {
width: 120px;
}
.th-main,
.td-main {
width: 80px;
justify-content: center;
}
.th-img,
.td-img {
width: 100px;
justify-content: center;
}
.th-thumb,
.td-thumb {
width: 100px;
justify-content: center;
}
.th-detail,
.td-detail {
width: 100px;
justify-content: center;
}
// 子元素样式
.sub-text {
margin-top: 4px;
font-size: 12px;
color: #c0c4cc;
}
.header-tip {
color: #c0c4cc;
cursor: pointer;
margin-left: 4px;
font-size: 12px;
}
.expand-icon {
cursor: pointer;
color: #909399;
font-size: 12px;
&:hover {
color: #409eff;
}
}
.thumb-img {
width: 60px;
height: 60px;
border-radius: 4px;
}
// 子商品表格
.sub-table-wrapper {
border: 1px solid #ebeef5;
padding: 8px 20px 8px 80px;
background-color: #fafafa;
}
.sub-table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border: 1px solid #e4e7ed;
min-width: 700px;
.sh-col {
padding: 8px 10px;
color: #909399;
font-weight: 500;
font-size: 12px;
flex-shrink: 0;
}
}
.sub-table-row {
display: flex;
align-items: center;
border-bottom: 1px solid #ebeef5;
min-width: 700px;
.sc {
padding: 8px 10px;
font-size: 12px;
flex-shrink: 0;
}
}
.sh-col-name,
.sc-name {
min-width: 160px;
flex: 2;
}
.sh-col-id,
.sc-id {
width: 160px;
text-align: center;
}
.sh-col-price,
.sc-price {
width: 100px;
text-align: center;
}
.sh-col-min,
.sc-min {
width: 100px;
text-align: center;
}
.sh-col-discount,
.sc-discount {
width: 120px;
text-align: center;
}
.table-empty {
text-align: center;
padding: 30px;
color: #c0c4cc;
}
</style>
<template>
<div class="detail-table">
<!-- 表头 -->
<div class="table-header">
<span class="th th-expand"></span>
<span class="th th-index">排序</span>
<span class="th th-name">
选项卡名称
<el-tooltip content="在展业助手App中对外展示的套餐或商品名称" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-tabDescription">
选项卡描述
<el-tooltip content="在展业助手App中对外展示的套餐或商品描述" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-price">现售价</span>
<span class="th th-min">最低售价</span>
<span class="th th-discount">优惠价(元)</span>
<span class="th th-incentive">销售激励(元)</span>
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-detail">
内容详图
<el-tooltip content="商品或套餐详情展示的内容长图" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
</div>
<!-- 数据行 -->
<div v-for="(item, index) in list"
:key="item.id || index"
class="table-item">
<!-- 主行 -->
<div class="table-row"
:class="{ 'is-expanded': expandedRows.includes(item.id || index) }">
<span class="td td-expand">
<i v-if="item.packageItems && item.packageItems.length"
class="expand-icon"
:class="[expandedRows.includes(item.id || index) ? 'el-icon-arrow-down' : 'el-icon-arrow-right']"
@click="toggleExpand(item.id || index)" />
</span>
<span class="td td-index">{{ index + 1 }}</span>
<span class="td td-name">
<span>{{ item.tabName }}</span>
<div class="sub-text">{{ item.packageCode }}</div>
</span>
<span class="td td-tabDescription">{{ item.tabDescription || '-' }}</span>
<span class="td td-price">{{ priceFilter(item.currentPrice) }}</span>
<span class="td td-min">{{ priceFilter(item.minimumPrice) }}</span>
<span class="td td-discount">{{ priceFilter(item.discountPrice) }}</span>
<span class="td td-incentive">{{ priceFilter(item.salesIncentive) }}</span>
<span class="td td-main">{{ item.isMainPush == 1 ? '是' : '否' }}</span>
<span class="td td-img">
<el-image v-if="item.mainImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.mainImageUrl]"
:src="item.mainImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-thumb">
<el-image v-if="item.thumbImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.thumbImageUrl]"
:src="item.thumbImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-detail">
<el-image v-if="item.detailImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.detailImageUrl]"
:src="item.detailImageUrl" />
<span v-else>-</span>
</span>
</div>
<!-- 子商品展开区 -->
<div v-if="(item.packageItems && item.packageItems.length) && expandedRows.includes(item.id || index)"
class="sub-table-wrapper">
<div class="sub-table-header">
<span class="sh-col sh-col-name">产品名称</span>
<span class="sh-col sh-col-name">产品别名</span>
<span class="sh-col sh-col-id">产品ID</span>
<span class="sh-col sh-col-price">现售价</span>
<span class="sh-col sh-col-min">最低售价</span>
<span class="sh-col sh-col-discount">优惠价</span>
</div>
<div v-for="(sub, subIdx) in item.packageItems"
:key="subIdx"
class="sub-table-row">
<span class="sc sc-name">{{ sub.goodsName || '-' }}</span>
<span class="sc sc-name">{{ sub.goodsAlias || '-' }}</span>
<span class="sc sc-id">{{ sub.goodsCode || '-' }}</span>
<span class="sc sc-price">{{ priceFilter(sub.currentPrice) }}</span>
<span class="sc sc-min">{{ priceFilter(sub.minimumPrice) }}</span>
<span class="sc sc-discount">{{ priceFilter(sub.discountPrice) }}</span>
</div>
</div>
</div>
<div v-if="!list.length" class="table-empty">
暂无数据
</div>
</div>
</template>
<script>
export default {
name: "PackageDetailTable",
props: {
list: {
type: Array,
default: () => [],
},
},
data() {
return {
expandedRows: [],
};
},
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
return "-";
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
return (data ?? "") === "";
},
toggleExpand(key) {
const idx = this.expandedRows.indexOf(key);
if (idx > -1) {
this.expandedRows.splice(idx, 1);
} else {
this.expandedRows.push(key);
}
},
},
};
</script>
<style lang="scss" scoped>
.detail-table {
border: 1px solid #ebeef5;
font-size: 13px;
max-height: 500px;
overflow: auto;
}
// 表头
.table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-bottom: 1px solid #ebeef5;
min-width: 1300px;
.th {
padding: 10px 8px;
box-sizing: border-box;
color: #909399;
font-weight: 500;
display: flex;
align-items: center;
flex-shrink: 0;
}
}
// 数据行
.table-item {
border-bottom: 1px solid #ebeef5;
}
.table-row {
display: flex;
align-items: center;
min-width: 1300px;
padding: 8px 0;
background-color: #fff;
&:hover {
background-color: #f5f7fa;
}
&.is-expanded {
background-color: #ecf5ff;
}
}
.td {
padding: 0 8px;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
}
// 列宽定义(和新增页保持一致)
.td-expand,
.th-expand {
width: 36px;
justify-content: center;
flex-shrink: 0;
}
.td-index,
.th-index {
width: 50px;
justify-content: center;
flex-shrink: 0;
color: #606266;
}
.th-name,
.td-name {
min-width: 180px;
flex: 2;
align-items: flex-start;
}
.td-name {
flex-flow: column;
}
.th-tabDescription,
.td-tabDescription {
min-width: 160px;
flex: 1.5;
}
.th-store,
.td-store {
width: 90px;
justify-content: center;
flex-shrink: 0;
}
.th-price,
.td-price {
width: 90px;
flex-shrink: 0;
color: #606266;
}
.th-min,
.td-min {
width: 90px;
flex-shrink: 0;
color: #606266;
}
.th-discount,
.td-discount {
width: 120px;
flex-shrink: 0;
}
.th-incentive,
.td-incentive {
width: 120px;
flex-shrink: 0;
}
.th-main,
.td-main {
width: 80px;
justify-content: center;
flex-shrink: 0;
}
.th-img,
.td-img {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
.th-thumb,
.td-thumb {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
.th-detail,
.td-detail {
width: 100px;
justify-content: center;
flex-shrink: 0;
}
// 子元素样式
.sub-text {
margin-top: 4px;
font-size: 12px;
color: #c0c4cc;
}
.header-tip {
color: #c0c4cc;
cursor: pointer;
margin-left: 4px;
font-size: 12px;
}
.expand-icon {
cursor: pointer;
color: #909399;
font-size: 12px;
transition: transform 0.2s;
&:hover {
color: #409eff;
}
}
.thumb-img {
width: 60px;
height: 60px;
border-radius: 4px;
}
// 子商品表格
.sub-table-wrapper {
border: 1px solid #ebeef5;
padding: 8px 20px 8px 80px;
background-color: #fafafa;
}
.sub-table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border: 1px solid #e4e7ed;
min-width: 700px;
.sh-col {
padding: 8px 10px;
color: #909399;
font-weight: 500;
font-size: 12px;
flex-shrink: 0;
}
}
.sub-table-row {
display: flex;
align-items: center;
border-bottom: 1px solid #ebeef5;
min-width: 700px;
.sc {
padding: 8px 10px;
font-size: 12px;
flex-shrink: 0;
}
}
.sh-col-name,
.sc-name {
min-width: 160px;
flex: 2;
}
.sh-col-id,
.sc-id {
width: 160px;
text-align: center;
}
.sh-col-price,
.sc-price {
width: 100px;
text-align: center;
}
.sh-col-min,
.sc-min {
width: 100px;
text-align: center;
}
.sh-col-discount,
.sc-discount {
width: 120px;
text-align: center;
}
.table-empty {
text-align: center;
padding: 30px;
color: #c0c4cc;
}
</style>
<template>
<div class="detail-table">
<!-- 表头 -->
<div class="table-header">
<span class="th th-index">排序</span>
<span class="th th-name">
选项卡名称
<el-tooltip content="在展业助手App中对外展示的套餐或商品名称" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-tabDescription">
选项卡描述
<el-tooltip content="在展业助手App中对外展示的套餐或商品描述" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-price">现售价</span>
<span class="th th-min">最低售价</span>
<span class="th th-discount">优惠价(元)</span>
<span class="th th-incentive">销售激励(元)</span>
<span class="th th-main">是否主推</span>
<span class="th th-img">
预览主图
<el-tooltip content="页面展示主图,建议尺寸 750×420px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-thumb">
预览小图
<el-tooltip content="列表中展示的缩略图,建议尺寸 200×200px" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
<span class="th th-detail">
内容详图
<el-tooltip content="商品或套餐详情展示的内容长图" placement="top">
<i class="el-icon-question header-tip"></i>
</el-tooltip>
</span>
</div>
<!-- 数据行 -->
<div v-for="(item, index) in list"
:key="item.id || index"
class="table-row">
<span class="td td-index">{{ index + 1 }}</span>
<span class="td td-name">
<span>{{ item.tabName }}</span>
<div class="sub-text">{{ item.goodsCode }}</div>
</span>
<span class="td td-tabDescription">{{ item.tabDescription || '-' }}</span>
<span class="td td-price">{{ priceFilter(item.currentPrice) }}</span>
<span class="td td-min">{{ priceFilter(item.minimumPrice) }}</span>
<span class="td td-discount">{{ priceFilter(item.discountPrice) }}</span>
<span class="td td-incentive">{{ priceFilter(item.salesIncentive) }}</span>
<span class="td td-main">{{ item.isMainPush == 1 ? '是' : '否' }}</span>
<span class="td td-img">
<el-image v-if="item.mainImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.mainImageUrl]"
:src="item.mainImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-thumb">
<el-image v-if="item.thumbImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.thumbImageUrl]"
:src="item.thumbImageUrl" />
<span v-else>-</span>
</span>
<span class="td td-detail">
<el-image v-if="item.detailImageUrl"
class="thumb-img"
fit="cover"
:preview-src-list="[item.detailImageUrl]"
:src="item.detailImageUrl" />
<span v-else>-</span>
</span>
</div>
<div v-if="!list.length" class="table-empty">
暂无数据
</div>
</div>
</template>
<script>
export default {
name: "ProductDetailTable",
props: {
list: {
type: Array,
default: () => [],
},
},
methods: {
priceFilter(num) {
const pow = 10 ** 2;
if (this.filterEmpty(num))
return "-";
return `¥${(Math.round(num * pow) / pow).toFixed(2)}`;
},
filterEmpty(data) {
return (data ?? "") === "";
},
},
};
</script>
<style lang="scss" scoped>
.detail-table {
border: 1px solid #ebeef5;
font-size: 13px;
max-height: 500px;
overflow: auto;
}
// 表头
.table-header {
display: flex;
align-items: center;
background-color: #f5f7fa;
border-bottom: 1px solid #ebeef5;
min-width: 1260px;
.th {
padding: 10px 8px;
box-sizing: border-box;
color: #909399;
font-weight: 500;
display: flex;
align-items: center;
flex-shrink: 0;
}
}
// 数据行
.table-row {
display: flex;
align-items: center;
min-width: 1260px;
padding: 8px 0;
background-color: #fff;
border-bottom: 1px solid #ebeef5;
&:hover {
background-color: #f5f7fa;
}
}
.td {
padding: 0 8px;
display: flex;
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
}
// 列宽定义
.td-index,
.th-index {
width: 50px;
justify-content: center;
color: #606266;
}
.th-name,
.td-name {
min-width: 180px;
flex: 2;
align-items: flex-start;
}
.td-name {
flex-flow: column;
}
.th-tabDescription,
.td-tabDescription {
min-width: 160px;
flex: 1.5;
}
.th-store,
.td-store {
width: 90px;
justify-content: center;
}
.th-price,
.td-price {
width: 90px;
color: #606266;
}
.th-min,
.td-min {
width: 90px;
color: #606266;
}
.th-discount,
.td-discount {
width: 120px;
}
.th-incentive,
.td-incentive {
width: 120px;
}
.th-main,
.td-main {
width: 80px;
justify-content: center;
}
.th-img,
.td-img {
width: 100px;
justify-content: center;
}
.th-thumb,
.td-thumb {
width: 100px;
justify-content: center;
}
.th-detail,
.td-detail {
width: 100px;
justify-content: center;
}
.sub-text {
margin-top: 4px;
font-size: 12px;
color: #c0c4cc;
}
.header-tip {
color: #c0c4cc;
cursor: pointer;
margin-left: 4px;
font-size: 12px;
}
.thumb-img {
width: 60px;
height: 60px;
border-radius: 4px;
}
.table-empty {
text-align: center;
padding: 30px;
color: #c0c4cc;
}
</style>
<!-- 销售门店列表弹窗 --> <!-- 销售门店列表弹窗 -->
<template> <template>
<el-dialog :visible.sync="dialogVisible" title="相关门店列表" width="600px" :close-on-click-modal="false" append-to-body @close="handleClose"> <el-dialog title="相关门店列表"
width="600px"
append-to-body
:close-on-click-modal="false"
:visible.sync="dialogVisible"
@close="handleClose">
<div class="store-list-dialog"> <div class="store-list-dialog">
<el-table :data="storeList" border size="mini" max-height="400"> <el-table max-height="400"
<el-table-column label="门店名称" prop="merchantName" min-width="150" /> size="mini"
<el-table-column label="门店商户号" prop="merchantId" width="120" /> border
<el-table-column label="门店地址" prop="address" min-width="200" show-overflow-tooltip /> :data="storeList">
<el-table-column label="门店名称"
min-width="150"
prop="merchantName" />
<el-table-column label="门店商户号"
prop="merchantId"
width="120" />
<el-table-column label="门店地址"
min-width="200"
prop="merchantAddress"
show-overflow-tooltip />
</el-table> </el-table>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button size="mini" @click="handleClose">关 闭</el-button> <el-button size="mini" @click="handleClose">
关 闭
</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { getMerchantByGoodsOrPackage } from "@/api/marketingActivity";
export default { export default {
name: 'StoreListDialog', name: "StoreListDialog",
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
storeList: { storeRow: {
type: Array type: Object,
} default: () => {},
}, },
merchantList: {
data() { type: Array,
return {} default: () => [],
}, },
},
computed: {
dialogVisible: { data() {
get() { return {
return this.visible storeList: [],
}, };
set(val) { },
this.$emit('update:visible', val)
} computed: {
} dialogVisible: {
}, get() {
return this.visible;
methods: { },
handleClose() { set(val) {
this.dialogVisible = false this.$emit("update:visible", val);
} },
} },
} },
watch: {
visible(val) {
if (val) {
this.getMerchantData();
}
},
},
methods: {
getMerchantData() {
const params = {
goodsCode: this.storeRow.goodsCode,
packageCode: this.storeRow.packageId,
merchantIds: this.merchantList?.map((val) => {
return val.merchantId;
}),
};
getMerchantByGoodsOrPackage(params).then((res) => {
this.storeList = res || [];
});
},
handleClose() {
this.dialogVisible = false;
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.store-list-dialog { .store-list-dialog {
padding: 10px 0; padding: 10px 0;
} }
</style> </style>
<!-- 管理活动标签弹窗 --> <!-- 管理活动标签弹窗 -->
<template> <template>
<el-dialog title="设置活动标签" :visible.sync="dialogVisible" width="500px" append-to-body custom-class="tag-manage-dialog"> <el-dialog custom-class="tag-manage-dialog"
<el-table :data="tagTableData" border size="small"> title="设置活动标签"
width="500px"
append-to-body
:visible.sync="dialogVisible">
<el-table size="small"
style="max-height: 55vh;overflow-y: auto;"
border
:data="tagTableData">
<el-table-column label="标签名称" prop="label"> <el-table-column label="标签名称" prop="label">
<template #default="scope"> <template #default="scope">
<el-input v-if="scope.row.editing" v-model="scope.row.editLabel" size="mini" maxlength="10" @keyup.enter.native="confirmEdit(scope.row)" /> <el-input v-if="scope.row.editing"
<span v-else>{{ scope.row.label }}</span> v-model.trim="scope.row.editLabel"
maxlength="10"
size="mini"
@keyup.enter.native="confirmEdit(scope.row)" />
<span v-else>{{ scope.row.tagName }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="160" align="center"> <el-table-column align="center"
label="操作"
width="160">
<template #default="scope"> <template #default="scope">
<template v-if="scope.row.editing"> <template v-if="scope.row.editing">
<el-button type="text" size="mini" @click="confirmEdit(scope.row)">确认</el-button> <el-button size="mini"
<el-button type="text" size="mini" @click="cancelEdit(scope.row)">取消</el-button> type="text"
@click="confirmEdit(scope.row)">
确认
</el-button>
<el-button size="mini"
type="text"
@click="cancelEdit(scope.row)">
取消
</el-button>
</template> </template>
<template v-else> <template v-else>
<el-button type="text" size="mini" @click="startEdit(scope.row)">重命名</el-button> <el-button size="mini"
<el-button type="text" size="mini" style="color: #f56c6c" @click="handleDeleteTag(scope.row)">删除</el-button> type="text"
@click="startEdit(scope.row)">
重命名
</el-button>
<el-button size="mini"
style="color: #f56c6c"
type="text"
@click="handleDeleteTag(scope.row)">
删除
</el-button>
</template> </template>
</template> </template>
</el-table-column> </el-table-column>
...@@ -24,7 +54,9 @@ ...@@ -24,7 +54,9 @@
<!-- 新增标签按钮 --> <!-- 新增标签按钮 -->
<div v-if="!showAddInput" class="tag-add-btn-wrap"> <div v-if="!showAddInput" class="tag-add-btn-wrap">
<el-button class="add-tag-btn" size="small" @click="showAddInput = true"> <el-button class="add-tag-btn"
size="small"
@click="showAddInput = true">
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
新增标签 新增标签
</el-button> </el-button>
...@@ -32,190 +64,187 @@ ...@@ -32,190 +64,187 @@
<!-- 新增标签输入行 --> <!-- 新增标签输入行 -->
<div v-if="showAddInput" class="tag-add-row"> <div v-if="showAddInput" class="tag-add-row">
<el-input v-model="newTagName" placeholder="请输入标签名称" size="small" maxlength="10" style="width: 200px; margin-right: 8px" @keyup.enter.native="handleAddTag" /> <el-input v-model.trim="newTagName"
<el-button type="primary" size="small" @click="handleAddTag">确认</el-button> maxlength="10"
<el-button size="small" @click="cancelAdd">取消</el-button> placeholder="请输入标签名称"
size="small"
style="width: 200px; margin-right: 8px"
@keyup.enter.native="handleAddTag" />
<el-button size="small"
type="primary"
@click="handleAddTag">
确认
</el-button>
<el-button size="small" @click="cancelAdd">
取消
</el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { addActivityTag, deleteActivityTag, getActivityTagList, updateActivityTag } from "@/api/marketingActivity";
export default { export default {
name: 'TagManageDialog', name: "TagManageDialog",
props: { props: {
visible: { visible: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// 初始标签列表 // 初始标签列表
tagList: { tagList: {
type: Array, type: Array,
default: () => [] default: () => [],
} },
}, },
data() { data() {
return { return {
tagTableData: [], tagTableData: [],
newTagName: '', newTagName: "",
showAddInput: false showAddInput: false,
} };
}, },
computed: { computed: {
dialogVisible: { dialogVisible: {
get() { get() {
return this.visible return this.visible;
}, },
set(val) { set(val) {
this.$emit('update:visible', val) this.$emit("update:visible", val);
} },
} },
}, },
watch: { watch: {
visible(val) { visible(val) {
if (val) { if (val) {
this.initTableData() this.initTableData();
} }
} },
}, tagList(val) {
if (val) {
methods: { this.initTableData();
// 初始化表格数据 }
initTableData() { },
this.showAddInput = false },
this.newTagName = ''
this.tagTableData = this.tagList.map(item => ({ methods: {
...item, // 初始化表格数据
editing: false, initTableData() {
editLabel: '' this.showAddInput = false;
})) this.newTagName = "";
}, this.tagTableData = this.tagList.map(item => ({
...item,
// 开始编辑 editing: false,
startEdit(row) { editLabel: "",
row.editing = true }));
row.editLabel = row.label },
},
// 开始编辑
// 确认编辑 startEdit(row) {
confirmEdit(row) { row.editing = true;
if (!row.editLabel.trim()) { row.editLabel = row.tagName;
this.$message.warning('标签名称不能为空') },
return
} // 确认编辑
// 检查是否重复 confirmEdit(row) {
const isDuplicate = this.tagTableData.some(item => item.label === row.editLabel.trim() && item.value !== row.value) if (!row.editLabel.trim()) {
if (isDuplicate) { this.$message.warning("标签名称不能为空");
this.$message.warning('标签名称已存在') return;
return }
} updateActivityTag({ tagId: row.tagId, tagName: row.editLabel }).then(() => {
row.label = row.editLabel.trim() row.label = row.editLabel.trim();
row.editing = false row.editing = false;
this.$message.success('修改成功') this.$message.success("修改成功");
this.emitChange() this.emitChange();
}, });
},
// 取消编辑
cancelEdit(row) { // 取消编辑
row.editing = false cancelEdit(row) {
row.editLabel = '' row.editing = false;
}, row.editLabel = "";
},
// 删除标签
handleDeleteTag(row) { // 删除标签
this.$confirm(`确定删除标签"${row.label}"吗?`, '提示', { handleDeleteTag(row) {
confirmButtonText: '确定', deleteActivityTag({ tagId: row.tagId }).then((res) => {
cancelButtonText: '取消', this.$message.success("删除成功");
type: 'warning' this.emitChange();
}) });
.then(() => { },
this.tagTableData = this.tagTableData.filter(item => item.value !== row.value)
this.$message.success('删除成功') // 新增标签
this.emitChange() handleAddTag() {
}) if (!this.newTagName.trim()) {
.catch(() => {}) this.$message.warning("请输入标签名称");
}, return;
}
// 新增标签 addActivityTag({ tagName: this.newTagName }).then((res) => {
handleAddTag() { this.newTagName = "";
if (!this.newTagName.trim()) { this.showAddInput = false;
this.$message.warning('请输入标签名称') this.$message.success("添加成功");
return this.emitChange();
} });
// 检查是否重复 },
if (this.tagTableData.some(item => item.label === this.newTagName.trim())) {
this.$message.warning('标签名称已存在') // 取消新增
return cancelAdd() {
} this.newTagName = "";
const newId = String(Date.now()) this.showAddInput = false;
this.tagTableData.push({ },
label: this.newTagName.trim(),
value: newId, // 触发变更事件
editing: false, emitChange() {
editLabel: '' // 获取列表
}) getActivityTagList({}).then((res) => {
this.newTagName = '' this.$emit(
this.showAddInput = false "change",
this.$message.success('添加成功') res || [],
this.emitChange() );
}, });
},
// 取消新增 },
cancelAdd() { };
this.newTagName = ''
this.showAddInput = false
},
// 触发变更事件
emitChange() {
this.$emit(
'change',
this.tagTableData.map(item => ({
label: item.label,
value: item.value
}))
)
}
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.tag-add-btn-wrap { .tag-add-btn-wrap {
padding: 16px 0 0; padding: 16px 0 0;
text-align: left; text-align: left;
} }
.add-tag-btn { .add-tag-btn {
border: 1px dashed #dcdfe6; border: 1px dashed #dcdfe6;
color: #606266; color: #606266;
background: #fff; background: #fff;
&:hover { &:hover {
border-color: #409eff; border-color: #409eff;
color: #409eff; color: #409eff;
} }
} }
.tag-add-row { .tag-add-row {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 16px 0 0; padding: 16px 0 0;
} }
</style> </style>
<style lang="scss"> <style lang="scss">
.tag-manage-dialog { .tag-manage-dialog {
.el-dialog__body { .el-dialog__body {
padding: 20px; padding: 20px;
} }
.el-table .cell { .el-table .cell {
line-height: 24px; line-height: 24px;
padding: 0 10px; padding: 0 10px;
} }
} }
</style> </style>
import request from "@api/request";
import RequestMethods from "@/api/request.methods";
const path = "dj.api.smartcarlife.sop.strategy.";
// 查询策略列表
export function getList(data) {
data.method = `${path}list`;
return request(data);
}
// 查询策略详情
export function getMarketingPushStrategyDetailApi(data) {
data.method = `${path}query`;
return request(data, "post");
}
// 创建策略
export function createStrategy(data) {
data.method = `${path}create`;
return request(data, "post");
}
// 修改策略
export function updateStrategy(data) {
data.method = `${path}update`;
return request(data, "post");
}
// 启停策略
export function statusStrategy(data) {
data.method = `${path}status`;
return request(data, "post");
}
// 删除策略
export function deleteStrategy(data) {
data.method = `${path}delete`;
return request(data, "post");
}
// 策略任务确认(支持批量)
export function confirmStrategy(data) {
data.method = `${path}confirm`;
return request(data, "post");
}
// 查询策略执行记录列表
export function recordsStrategy(data) {
data.method = `${path}records`;
return request(data, "post");
}
// 查询策略执行详情(含快照)
export function recordDetail(data) {
data.method = `${path}record.detail`;
return request(data, "post");
}
// 元数据查询接口
export function getMetaData(data) {
data.method = `${path}meta`;
return request(data, "post");
}
export function getMetaOptionsApi(data = {}) {
data.method = "dj.api.smartcarlife.sop.strategy.meta";
return request(data, RequestMethods.POST);
}
<template>
<div class="actions-item-wrapper">
<div class="title-wrapper">
<div class="title">
{{ title }}
</div>
<el-button class="del-button"
icon="el-icon-delete"
size="small"
type="danger"
plain
@click="handleRemoveActions">
删除动作
</el-button>
</div>
<el-form-item label="动作类型:"
:prop="`${propPrefix}.actionType`"
:rules="[{ required: true, message: '请选择动作类型', trigger: 'change' }]">
<el-select style="width:530px"
:value="item.actionType"
@change="handleActionTypeChange">
<el-option label="向客户群发送消息"
:value="1">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="目标群:"
:prop="`${propPrefix}.targetGroupType`"
:rules="[{ required: true, message: '请选择目标群', trigger: 'change' }]">
<el-radio-group :value="item.targetGroupType">
<el-radio :label="1">
目标客户所在群
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="消息内容:"
style="margin-bottom:0 "
:prop="`${propPrefix}.messageType`"
:rules="[
{ required: true, message: '请选择消息类型', trigger: 'change' },
{ validator: validateMessageType, trigger: 'blur' },
]">
<MessageType :item="item"
:message-variables="options.messageVariables"
@input="handleMessageTypeChange" />
</el-form-item>
</div>
</template>
<script>
import MessageType from "@/views/marketingManagement/marketingPushStrategy/components/messageType";
import { MessageTypeEnum } from "@/views/marketingManagement/marketingPushStrategy/constant";
export default {
name: "",
components: {
MessageType,
},
props: {
propPrefix: {
type: String,
default: "",
},
title: {
type: String,
default: "动作",
},
// options.triggers = [] 动作触发条件
// options.messageVariables = [] 消息变量选项
options: {
type: Object,
default: () => ({}),
},
item: {
type: Object,
required: true,
},
},
data() {
return {
tempSelect: undefined,
tempRadio: 1,
temp: {
messageType: 1,
},
};
},
computed: {
},
mounted() {
},
methods: {
validateMessageType(rule, value, callback) {
if (!String(this.item.messageType)) {
callback(new Error("请选择消息类型"));
}
if (this.item.messageType === MessageTypeEnum.VARIABLE_TEXT) {
if (!this.item.content) {
callback(new Error("请输入消息内容"));
}
}
if (this.item.messageType === MessageTypeEnum.VARIABLE_IMAGE) {
if (!this.item.medias) {
callback(new Error("请上传消息图片"));
}
if (!this.item.medias.length) {
callback(new Error("请上传消息图片"));
}
}
if (this.item.messageType === MessageTypeEnum.VARIABLE_VIDEO) {
if (!this.item.medias) {
callback(new Error("请上传消息视频"));
}
if (!this.item.medias.length) {
callback(new Error("请上传消息视频"));
}
}
if (this.item.messageType === MessageTypeEnum.VARIABLE_WEBPAGE) {
if (!this.item.pageTitle || !this.item.pageDesc || !this.item.bgColor) {
callback(new Error("请编辑网页内容"));
}
if (!this.item.materialJson) {
callback(new Error("网页内容的素材不可为空"));
}
if (!this.item.materialJson.length) {
callback(new Error("网页内容的素材不可为空"));
}
if (!String(this.item.intervalPx)) {
callback(new Error("请编辑网页内容"));
}
}
callback();
},
handleActionTypeChange(e) {
this.$emit("input", { ...this.item, actionType: e });
},
handleMessageTypeChange(e) {
this.$emit("input", e);
},
handleRemoveActions() {
this.$emit("remove");
},
},
};
</script>
<style scoped lang="scss">
.actions-item-wrapper {
border-radius: 8px;
border: 1px solid #e5e5e5;
padding: 16px 16px;
> .title-wrapper {
font-style: Bold;
font-size: 14px;
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
> .title {
line-height: 16px;
}
.del-button {
border-style: dashed;
background: white;
transition: background-color 200ms;
&:hover {
background: #fef0f0;
color: #f56c6c;
}
}
}
}
</style>
<template>
<div class="branch-group-wrapper">
<BranchItem v-for="(branch, index) in list"
:key="branch._key"
:branch="branch"
:options="{
messageVariables,
triggers,
conditionVariables,
}"
:prop-prefix="`${propPrefix}[${index}]`"
:title="`分支${index + 1}`"
@appendAction="handleAppendAction(index)"
@input="handleBranchChange($event, index)"
@removeAction="handleRemoveAction($event, index)"
@removeBranch="handleRemoveBranch(index)"
@update:conditionGroups="handleBranchConditionChange($event, index)" />
<el-button class="append-btn"
block
@click="handleAppendBranch">
<i class="el-icon-plus "></i>
添加分支
</el-button>
</div>
</template>
<script>
import BranchItem from "@/views/marketingManagement/marketingPushStrategy/components/branchItem/index.vue";
import { getDefaultAction, getDefaultBranch } from "@/views/marketingManagement/marketingPushStrategy/constant";
export default {
name: "",
components: {
BranchItem,
},
model: {
prop: "list",
event: "input",
},
props: {
propPrefix: {
type: String,
default: "",
},
list: {
type: Array,
default: () => ([]),
},
messageVariables: {
type: Array,
default: () => ([]),
},
conditionVariables: {
type: Array,
default: () => ([]),
},
triggers: {
type: Array,
default: () => ([]),
},
},
data() {
return {
};
},
computed: {
},
mounted() {
},
methods: {
handleBranchConditionChange({ conditionGroups }, branchIndex) {
const newList = JSON.parse(JSON.stringify(this.list));
newList[branchIndex].conditionGroups = conditionGroups;
this.$emit("input", newList);
},
handleRemoveAction(actionIndex, branchIndex) {
const newList = JSON.parse(JSON.stringify(this.list));
newList[branchIndex].actions.splice(actionIndex, 1);
this.$emit("input", newList);
},
handleAppendBranch() {
const newList = JSON.parse(JSON.stringify(this.list));
console.log(newList.length);
newList.push(getDefaultBranch(newList.length));
this.$emit("input", newList);
},
handleRemoveBranch(branchIndex) {
const newList = JSON.parse(JSON.stringify(this.list));
newList.splice(branchIndex, 1);
this.$emit("input", newList);
},
handleAppendAction(branchIndex) {
const newList = JSON.parse(JSON.stringify(this.list));
newList[branchIndex].actions.push(getDefaultAction());
this.$emit("input", newList);
},
handleBranchChange({ actionIndex, actionItem }, branchIndex) {
const newList = JSON.parse(JSON.stringify(this.list));
newList[branchIndex].actions[actionIndex] = actionItem;
this.$emit("input", newList);
},
},
};
</script>
<style scoped lang="scss">
.branch-group-wrapper {
.branch-item-wrapper {
margin-top: 20px;
&:first-child {
margin-top: 0;
}
}
.append-btn {
width: 100%;
margin-top: 20px;
}
}
</style>
<template>
<div class="branch-item-wrapper">
<div class="title-wrapper">
<span class="title">{{ title }}</span>
<el-button class="del-button"
icon="el-icon-delete"
size="small"
type="danger"
plain
@click="handleRemoveBranch">
删除分支
</el-button>
</div>
<div class="container-wrapper">
<el-form-item label="满足条件时执行:"
label-width="150px"
required
:prop="`${propPrefix}.conditionGroups`"
:rules="[{ required: true, message: '请选择条件组', trigger: 'change', type: 'array', min: 1 }]">
<ConditionPanel :condition-variables-options="options.conditionVariables"
:list="branch.conditionGroups"
@change="handleBranchConditionChange"
@input="handleBranchConditionInput" />
</el-form-item>
<div class="tips">
按顺序执行以下动作
</div>
<div class="actions-list-wrapper">
<Actions v-for="(action, index) in branch.actions"
:key="action._key"
:item="action"
:options="options"
:prop-prefix="`${propPrefix}.actions[${index}]`"
:title="`动作${index + 1}`"
@input="handleActionChange($event, index)"
@remove="handleRemoveActions(index)" />
<div class="actions-list-foot-wrapper">
<el-button @click="handleAppendAction">
添加动作
</el-button>
</div>
</div>
</div>
</div>
</template>
<script>
import Actions from "@/views/marketingManagement/marketingPushStrategy/components/actionsItem/index.vue";
import ConditionPanel from "@/views/marketingManagement/marketingPushStrategy/components/conditionPanel/index.vue";
export default {
name: "",
components: {
Actions,
ConditionPanel,
},
inject: ["elForm"],
props: {
propPrefix: {
type: String,
default: "",
},
title: {
type: String,
default: "条件组",
},
// options.triggers 动作触发条件
// options.messageVariables 消息变量选项
// options.conditionVariables 条件变量选项
options: {
type: Object,
default: () => ({}),
},
branch: {
type: Object,
required: true,
},
},
data() {
return {
conditionList: [],
};
},
computed: {
},
mounted() {
},
methods: {
handleBranchConditionChange() {
this.elForm?.validateField(`${this.propPrefix}.conditionGroups`);
},
handleRemoveBranch() {
this.$emit("removeBranch");
},
handleAppendAction() {
this.$emit("appendAction");
},
handleRemoveActions(actionIndex) {
this.$emit("removeAction", actionIndex);
},
handleActionChange(e, actionIndex) {
this.$emit("input", { actionItem: e, actionIndex });
},
handleBranchConditionInput(e) {
this.$emit("update:conditionGroups", { conditionGroups: e });
},
},
};
</script>
<style scoped lang="scss">
.branch-item-wrapper {
border-radius: 8px;
overflow: hidden;
border: 1px solid #0000001a;
> .title-wrapper {
padding: 10px 16px;
font-style: Bold;
font-size: 14px;
display: flex;
align-items: center;
justify-content: space-between;
background-color: #f5f6fa;
> .title {
line-height: 16px;
}
.del-button {
border-style: dashed;
background: white;
transition: background-color 200ms;
&:hover {
background: #fef0f0;
color: #f56c6c;
}
}
}
> .container-wrapper {
padding: 20px;
> .tips {
font-weight: 700;
font-style: Bold;
font-size: 14px;
color: #333;
line-height: 16px;
}
.actions-list-wrapper {
margin-top: 20px;
.actions-item-wrapper {
margin-top: 20px;
&:first-child {
margin-top: 0;
}
}
}
.actions-list-foot-wrapper {
margin-top: 20px;
}
}
}
</style>
<template>
<div class="condition-container-wrapper">
<el-form-item label-width="0"
:prop="`${propPrefix}.variableCode`"
:rules="[
{ required: true, message: '请选择变量', trigger: 'change' },
]">
<el-select placeholder="请选择变量"
style="width:212px"
:value="item.variableCode"
@change="handleVariableChange">
<el-option v-for="opt in options.conditionVariables"
:key="opt.variableCode"
:label="opt.variableName"
:value="opt.variableCode">
</el-option>
</el-select>
</el-form-item>
<el-form-item label-width="0"
:prop="`${propPrefix}.operator`"
:rules="[
{ required: true, message: '请选择操作符', trigger: 'change' },
]">
<el-select placeholder="请选择操作符"
style="width:160px"
:disabled="!item.variableCode"
:value="item.operator"
@change="handleOperatorChange">
<el-option v-for="opt in getOperatorOptions "
:key="opt.code"
:label="opt.name"
:value="opt.code">
</el-option>
</el-select>
</el-form-item>
<el-form-item label-width="0" :prop="`${propPrefix}.valueSource`">
<el-radio-group style="width:98px"
:value="item.valueSource"
@input="handleValueSource">
<el-radio-button :label="enums.conditionVariableSourceTypeEnum.VARIABLE">
变量
</el-radio-button>
<el-radio-button :label="enums.conditionVariableSourceTypeEnum.VALUE">
值
</el-radio-button>
</el-radio-group>
</el-form-item>
<template v-if="item.valueSource === enums.conditionVariableSourceTypeEnum.VARIABLE">
<el-form-item label-width="0"
:prop="`${propPrefix}.variableRefCode`"
:rules="[
{ required: true, message: '请选择变量', trigger: 'change' },
]">
<el-select placeholder="请选择"
style="width:212px"
:disabled="!item.variableCode"
:value="item.variableRefCode"
@change="handleVariableRefCodeChange">
<el-option v-for="opt in getVariableRefCodeOptions"
:key="opt.variableCode"
:label="opt.variableName"
:value="opt.variableCode">
</el-option>
</el-select>
</el-form-item>
</template>
<template v-if="item.valueSource === enums.conditionVariableSourceTypeEnum.VALUE">
<!-- 默认 -->
<el-form-item v-if="![
enums.conditionVariableTypeEnum.TEXT,
enums.conditionVariableTypeEnum.NUMBER,
enums.conditionVariableTypeEnum.DATE,
enums.conditionVariableTypeEnum.ENUM,
].includes(getCurrentVariable.variableType)"
label-width="0">
<el-input placeholder="请先选择变量"
style="width:212px"
disabled>
</el-input>
</el-form-item>
<!-- 文字类型 -->
<el-form-item v-if="getCurrentVariable.variableType === enums.conditionVariableTypeEnum.TEXT"
label-width="0"
:prop="`${propPrefix}.textValue`"
:rules="[
{ required: true, message: '请输入文字值', trigger: 'change' },
]">
<el-input style="width:212px"
:value="item.textValue"
@input="handleTextInput">
</el-input>
</el-form-item>
<!-- 数字类型 -->
<el-form-item v-if="getCurrentVariable.variableType === enums.conditionVariableTypeEnum.NUMBER"
label-width="0"
:prop="`${propPrefix}.numberValue`"
:rules="[
{ required: true, message: '请输入数值', trigger: 'change' },
]">
<el-input-number placeholder="请输入数值"
style="width:212px;"
:controls="false"
:value="item.numberValue"
@change="handleNumberChange">
</el-input-number>
</el-form-item>
<!-- 日期类型 -->
<el-form-item v-if="getCurrentVariable.variableType === enums.conditionVariableTypeEnum.DATE"
label-width="0"
:prop="`${propPrefix}.dateValue`"
:rules="[
{ required: true, message: '请选择日期', trigger: 'change' },
]">
<el-date-picker placeholder="请选择日期"
style="width:212px"
type="date"
value-format="yyyy-MM-DD"
:value="item.dateValue"
@input="handleDateChange">
</el-date-picker>
</el-form-item>
<!-- 枚举类型 -->
<el-form-item v-if="getCurrentVariable.variableType === enums.conditionVariableTypeEnum.ENUM"
label-width="0"
:prop="`${propPrefix}.enumValue`"
:rules="[
{ required: true, message: '请选择枚举值', trigger: 'change' },
]">
<el-select placeholder="请先选择枚举值"
style="width:212px"
:value="item.enumValue"
@change="handleEnumChange">
<el-option v-for="opt in getVariableEnumOptions"
:key="opt.enumCode"
:label="opt.enumName"
:value="opt.enumCode">
</el-option>
</el-select>
</el-form-item>
</template>
<el-form-item label-width="0">
<el-button class="del-button"
type="text"
@click="handleRemove">
删除
</el-button>
</el-form-item>
</div>
</template>
<script>
import { ConditionVariableSourceTypeEnum, ConditionVariableTypeEnum } from "@/views/marketingManagement/marketingPushStrategy/constant/index.js";
export default {
name: "",
model: {
prop: "item",
event: "input",
},
props: {
propPrefix: {
type: String,
default: "",
},
options: {
type: Object,
default: () => ({
conditionVariables: [],
}),
},
item: {
type: Object,
required: true,
},
},
data() {
return {
enums: {
conditionVariableSourceTypeEnum: ConditionVariableSourceTypeEnum,
conditionVariableTypeEnum: ConditionVariableTypeEnum,
},
};
},
computed: {
getCurrentVariable() {
const variable = this.options.conditionVariables.find(item => item.variableCode === this.item.variableCode);
return variable || {};
},
getOperatorOptions() {
if (!this.item.variableCode) {
return [];
}
return this.getCurrentVariable?.operators || [];
},
getVariableRefCodeOptions() {
if (!this.item.variableCode) {
return [];
}
return this.getCurrentVariable?.sopConditionVariableDTOList || [];
},
getVariableEnumOptions() {
if (!this.item.variableCode) {
return [];
}
return this.getCurrentVariable?.enumValues || [];
},
},
mounted() {
},
methods: {
handleRemove() {
this.$emit("remove");
},
updateItem(key, val) {
this.$emit("input", { ...this.item, [key]: val });
},
handleVariableChange(val) {
// 只要切换一个, 子级全清
// variableType
const variable = this.options.conditionVariables.find(item => item.variableCode === val);
this.$emit("input", {
...this.item,
variableCode: val,
variableType: variable?.variableType,
operator: undefined,
valueSource: 0,
variableRefCode: undefined,
textValue: undefined,
numberValue: undefined,
enumValue: undefined,
dateValue: undefined,
});
},
handleOperatorChange(val) {
this.updateItem("operator", val);
},
handleValueSource(val) {
// 切换, 清子级
// variableType
this.$emit("input", {
...this.item,
valueSource: val,
variableRefCode: undefined,
textValue: undefined,
numberValue: undefined,
enumValue: undefined,
dateValue: undefined,
});
},
handleVariableRefCodeChange(val) {
this.updateItem("variableRefCode", val);
},
handleTextInput(val) {
this.updateItem("textValue", val);
},
handleNumberChange(val) {
this.updateItem("numberValue", val);
},
handleDateChange(val) {
this.updateItem("dateValue", val);
},
handleEnumChange(val) {
this.updateItem("enumValue", val);
},
},
};
</script>
<style scoped lang="scss">
.condition-container-wrapper {
display: flex;
align-items: center;
flex: 1 0 0;
overflow: hidden;
> .el-form-item {
flex-shrink: 0;
flex-basis: 0;
margin-right: 8px;
::v-deep .el-input-number {
.el-input__inner {
text-align: left;
}
}
}
.del-button {
transition: color 200ms;
&:hover {
color: #f56c6c;
}
}
}
</style>
import { nanoid } from "nanoid";
export function getDefaultConditionGroup() {
return {
_key: nanoid(),
conditions: [
getDefaultCondition(),
],
};
}
export function getDefaultCondition() {
return {
_key: nanoid(),
valueSource: 0,
};
}
<template>
<div class="condition-group-wrapper">
<el-form ref="ConditionFormRef"
class="condition-form-wrapper"
size="small"
:hide-required-asterisk="false"
:model="formModel">
<template v-for="(item, index) in list">
<div :key="item._key" class="condition-item">
<el-divider v-if="index !== 0" class="divider-wrapper">
<div class="divider-content">
或
</div>
</el-divider>
<ConditionItem :conditions="list[index].conditions"
:options="options"
:prop-prefix="`list[${index}]`"
:title="`条件组${index + 1}`"
@appendCondition="handleAppendCondition(index)"
@input="handleUpdate(index, $event)"
@removeCondition="handleRemoveCondition($event, index)"
@removeConditionGroup="handleRemoveConditionGroup(index)" />
</div>
</template>
<div class="footer-wrapper">
<el-button class="append-button"
icon="el-icon-plus"
@click="handleAppendConditionGroup">
添加条件组
</el-button>
</div>
</el-form>
</div>
</template>
<script>
import ConditionItem from "@/views/marketingManagement/marketingPushStrategy/components/conditionItem/index.vue";
import { getDefaultCondition, getDefaultConditionGroup } from "./constant";
export default {
name: "",
components: {
ConditionItem,
},
model: {
prop: "list",
event: "input",
},
props: {
list: {
type: Array,
default: () => [getDefaultConditionGroup()],
},
// options.conditionVariables
options: {
type: Object,
default: () => ({}),
},
},
computed: {
formModel() {
return { list: this.list };
},
},
mounted() {
this.$refs.ConditionFormRef?.resetFields();
},
methods: {
handleUpdate(groupIndex, { conditionItem, conditionIndex }) {
const newList = this.list.map(group => ({
...group,
conditions: [...group.conditions],
}));
newList[groupIndex].conditions[conditionIndex] = conditionItem;
this.$emit("input", newList);
},
handleAppendConditionGroup() {
this.$emit("input", [...this.list, getDefaultConditionGroup()]);
},
handleRemoveConditionGroup(groupIndex) {
this.$emit("input", this.list.filter((_, i) => i !== groupIndex));
},
handleAppendCondition(groupIndex) {
const newList = this.list.map(group => ({
...group,
conditions: [...group.conditions],
}));
newList[groupIndex].conditions.push(getDefaultCondition());
this.$emit("input", newList);
},
handleRemoveCondition({ conditionIndex }, groupIndex) {
const newList = this.list.map(group => ({
...group,
conditions: [...group.conditions],
}));
newList[groupIndex].conditions.splice(conditionIndex, 1);
this.$emit("input", newList);
},
},
};
</script>
<style scoped lang="scss">
.condition-group-wrapper {
width: 100%;
overflow: hidden;
}
.condition-form-wrapper {
::v-deep .el-form-item {
margin-bottom: 14px;
&.action-form-item {
margin-bottom: 0;
}
}
.footer-wrapper {
text-align: center;
.append-button {
border-style: dashed;
width: 100%;
line-height: 40px;
padding-top: 0;
padding-bottom: 0;
border-radius: 4px;
margin-top: 20px;
}
}
.condition-item {
margin-top: 12px;
&:first-child {
margin-top: 0;
}
}
.divider-wrapper {
background-color: #e5e5e5;
margin: 26px 0;
::v-deep .el-divider__text {
padding: 0 8px;
}
.divider-content {
border-radius: 20px;
padding: 0px 16px;
font-size: 14px;
line-height: 24px;
background-color: #f5f7fa;
color: #2a58ad;
}
}
}
</style>
<template>
<div class="condition-wrapper">
<div class="title-wrapper">
<span class="title">{{ title }}</span>
<el-button class="del-button"
icon="el-icon-delete"
size="small"
type="danger"
plain
@click="handleRemoveGroup">
删除条件组
</el-button>
</div>
<div class="condition-container-list">
<div v-for="(item, index) in conditions"
:key="item._key"
class="condition-item">
<el-divider v-if="index !== 0" class="divider-wrapper">
<div class="divider-content">
且
</div>
</el-divider>
<div class="condition-row">
<div class="title">
条件{{ index + 1 }}
</div>
<ConditionContainer :item="conditions[index]"
:options="options"
:prop-prefix="`${propPrefix}.conditions[${index}]`"
@input="handleUpdateCondition($event, index)"
@remove="handleRemoveCondition(index)">
</ConditionContainer>
</div>
</div>
</div>
<div class="foot-wrapper">
<el-form-item class="action-form-item" label-width="0">
<el-button class="append-btn"
icon="el-icon-plus"
size="small"
@click="handleAppendCondition">
添加条件
</el-button>
</el-form-item>
</div>
</div>
</template>
<script>
import ConditionContainer from "@/views/marketingManagement/marketingPushStrategy/components/conditionContainer/index.vue";
export default {
name: "ConditionItem",
components: {
ConditionContainer,
},
model: {
prop: "conditions",
event: "input",
},
props: {
options: {
type: Object,
default: () => ({}),
},
propPrefix: {
type: String,
default: "",
},
conditions: {
type: Array,
required: true,
},
title: {
type: String,
default: "条件组",
},
},
methods: {
handleUpdateCondition(conditionItem, index) {
console.log("?");
this.$emit("input", { conditionItem, conditionIndex: index });
},
handleAppendCondition() {
this.$emit("appendCondition");
},
handleRemoveCondition(index) {
this.$emit("removeCondition", { conditionIndex: index });
},
handleRemoveGroup() {
this.$emit("removeConditionGroup");
},
},
};
</script>
<style scoped lang="scss">
.condition-wrapper {
padding: 16px;
border-radius: 4px;
border: 1px solid #e5e5e5;
background: white;
.condition-container-list {
padding-top: 8px;
.condition-item {
width: 100%;
overflow: hidden;
.condition-row {
display: flex;
align-items: center;
width: 100%;
overflow: hidden;
> .title {
font-weight: 400;
font-size: 14px;
margin-right: 8px;
white-space: nowrap;
width: 4em;
margin-bottom: 14px;
}
}
}
}
> .title-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
> .title {
font-style: Bold;
font-size: 14px;
}
.del-button {
border-style: dashed;
background: white;
transition: background-color 200ms;
&:hover {
background: #fef0f0;
color: #f56c6c;
}
}
}
.foot-wrapper {
.append-btn {
border-style: dashed;
border-radius: 4px;
background-color: white;
transition: background-color 200ms;
&:hover {
background-color: #eaeaf7;
}
}
}
.divider-wrapper {
background-color: #e5e5e5;
margin: 10px 0 24px;
::v-deep .el-divider__text {
padding: 0 8px;
}
.divider-content {
border-radius: 20px;
border: 1px solid #e5e5e5;
padding: 0px 8px;
font-size: 14px;
line-height: 24px;
color: #999;
}
}
}
</style>
<template>
<div class="condition-panel-wrapper">
<template v-if="list.length <= 0 ">
<el-button icon="el-icon-plus"
plain
@click="handleShowConditionGroup">
设置条件规则
</el-button>
</template>
<div v-else class="text-panel">
<ConditionTextPanel :condition-list="list" :condition-variables="conditionVariablesOptions" />
<div class="action-wrapper">
<el-button type="text" @click="handleShowConditionGroup">
重新编辑
</el-button>
<el-button class="red-btn"
type="text"
@click="handleClearCondition">
清除
</el-button>
</div>
</div>
<el-drawer custom-class="step2-condition-group-drawer"
size="880px"
title="设置条件规则"
append-to-body
:visible.sync="dialog.step2ConditionGroup.show"
:wrapper-closable="false">
<div class="drawer-content">
<ConditionGroup v-if="dialog.step2ConditionGroup.show"
ref="ConditionGroupRef"
v-model="dialog.step2ConditionGroup.conditionCache"
:options="{ conditionVariables: conditionVariablesOptions }" />
</div>
<div class="footer-wrapper">
<el-button size="small" @click="handleCloseConditionGroup">
取消
</el-button>
<el-button size="small"
type="primary"
@click="handleConfirmConditionGroup">
确认
</el-button>
</div>
</el-drawer>
</div>
</template>
<script>
import { cloneDeep } from "lodash-es";
import { getDefaultConditionGroup } from "@/views/marketingManagement/marketingPushStrategy/components/conditionGroup/constant.js";
import ConditionGroup from "@/views/marketingManagement/marketingPushStrategy/components/conditionGroup/index.vue";
import ConditionTextPanel from "@/views/marketingManagement/marketingPushStrategy/components/conditionTextyPanel/index.vue";
export default {
name: "ConditionPanel",
components: {
ConditionGroup,
ConditionTextPanel,
},
model: {
prop: "list",
event: "input",
},
props: {
conditionVariablesOptions: {
type: Array,
default: () => ([]),
},
list: {
type: Array,
default: () => ([]),
},
},
data() {
return {
dialog: {
step2ConditionGroup: {
show: false,
conditionCache: {},
},
},
};
},
computed: {
},
mounted() {
},
methods: {
handleClearCondition() {
this.$emit("input", []);
this.$emit("change", []);
},
handleShowConditionGroup() {
this.dialog.step2ConditionGroup.show = true;
this.dialog.step2ConditionGroup.conditionCache = cloneDeep(this.list);
if (this.dialog.step2ConditionGroup.conditionCache.length === 0) {
this.dialog.step2ConditionGroup.conditionCache.push(getDefaultConditionGroup());
}
},
handleCloseConditionGroup() {
this.dialog.step2ConditionGroup.show = false;
this.dialog.step2ConditionGroup.conditionCache = [];
},
async handleConfirmConditionGroup() {
const ConditionGroupRef = this.$refs.ConditionGroupRef;
if (!ConditionGroupRef) {
return;
}
const ConditionFormRef = ConditionGroupRef.$refs.ConditionFormRef;
if (!ConditionFormRef) {
return;
}
await ConditionFormRef.validate();
// 校验不通过不会往下执行
const condition = cloneDeep(this.dialog.step2ConditionGroup.conditionCache);
this.$emit("input", condition);
this.$emit("change", condition);
this.handleCloseConditionGroup();
},
},
};
</script>
<style scoped lang="scss">
::v-deep .el-drawer__header {
font-weight: 600;
font-size: 16px;
line-height: 22px;
padding: 20px;
margin-bottom: 0;
border-bottom: 1px solid #e5e5e5;
color: #333;
}
::v-deep .el-drawer__body {
overflow: hidden;
flex-shrink: 0;
flex-basis: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
.drawer-content {
padding: 20px;
width: 100%;
flex: 1 0 0;
overflow-y: auto;
overflow-x: hidden;
position: relative;
box-sizing: border-box;
.condition-group-wrapper {
width: 100%;
overflow: hidden;
}
&::after {
content: "";
display: block;
height: 1px;
}
}
> .footer-wrapper {
width: 100%;
display: flex;
justify-content: flex-end;
padding: 20px;
border-top: 1px solid #e5e5e5;
}
}
.condition-panel-wrapper {
display: inline-block;
max-width: 400px;
overflow-x: auto;
}
.text-panel {
> .action-wrapper {
text-align: right;
.red-btn {
color: #eb4e4e;
transition: color 200ms;
&:hover {
color: #f05a5a;
}
&:active {
color: #c54242;
}
}
}
}
</style>
<template>
<div class="condition-text-panel-wrapper">
<div v-for="(conditionGroup, conditionGroupIndex) in list"
:key="conditionGroup.id || conditionGroup._key"
class="condition-group-text-wrapper">
<div v-for="(condition, conditionIndex) in conditionGroup.conditions"
:key="condition.id || condition._key"
class="condition-item-text-wrapper"
style="margin-left:14px">
<div>
<span>
{{ condition.variableName }}
</span>
<span>
{{ condition.operatorName }}
</span>
<span>
{{ condition.valueLabel }}
</span>
</div>
<div v-if="conditionGroup.conditions.length > 1 && conditionIndex !== conditionGroup.conditions.length - 1"
style="margin-top:4px;margin-bottom:4px;padding-left:8px;color:#999999 ">
且
</div>
</div>
<div v-if="list.length > 1 && conditionGroupIndex !== list.length - 1"
style="margin-left:4px;margin-top:8px;margin-bottom:8px;color:#F59619">
或
</div>
</div>
</div>
</template>
<script>
import { cloneDeep, isArray } from "lodash-es";
import { ConditionVariableSourceTypeEnum, ConditionVariableTypeEnum } from "@/views/marketingManagement/marketingPushStrategy/constant/index.js";
export default {
name: "",
props: {
conditionList: {
type: Array,
default: () => ([]),
},
conditionVariables: {
type: Array,
default: () => ([]),
},
},
data() {
return {
list: [],
};
},
computed: {
},
watch: {
conditionList: {
handler(newVal, oldVal) {
if (!isArray(this.conditionList)) {
return;
}
const list = cloneDeep(this.conditionList);
for (const group of list) {
for (const condition of group.conditions) {
const option = this.conditionVariables.find(item => item.variableCode === condition.variableCode);
console.log("option", option);
const operator = option.operators.find(item => item.code === condition.operator);
if (option) {
condition.variableName = option.variableName;
condition.operatorName = operator.name;
if (condition.valueSource === ConditionVariableSourceTypeEnum.VARIABLE) {
const variableOption = option.sopConditionVariableDTOList.find(item => item.variableCode === condition.variableRefCode);
condition.valueLabel = variableOption?.variableName || "-";
} else {
condition.valueLabel = condition.numberValue ?? (condition.textValue || condition.dateValue || condition.enumValue);
}
}
}
}
this.list = list;
},
immediate: true,
deep: true,
},
},
mounted() {
},
methods: {
},
};
</script>
<style scoped lang="scss">
.red-btn {
color: #eb4e4e;
}
.condition-text-panel-wrapper {
background-color: #f5f7fa;
padding: 16px;
border-radius: 8px;
.condition-group-text-wrapper {
font-size: 12px;
line-height: 14px;
}
}
</style>
<template>
<div class="">
<div>
<el-radio-group :value="item.messageType" @input="handleMessageTypeChange">
<el-radio :label="MessageTypeEnum.VARIABLE_TEXT">
文本
</el-radio>
<el-radio :label="MessageTypeEnum.VARIABLE_IMAGE">
图片
</el-radio>
<el-radio :label="MessageTypeEnum.VARIABLE_VIDEO">
视频
</el-radio>
<el-radio :label="MessageTypeEnum.VARIABLE_WEBPAGE">
网页
</el-radio>
</el-radio-group>
</div>
<div style="margin-top:14px">
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_TEXT" class="type-item">
<VariableTextarea style="width:580px"
:value="item.content"
:variable-list="messageVariables"
@input="handleContentChange" />
</div>
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_IMAGE" class="type-item">
<VenusOssUpload :key="item.messageType"
v-model="fileList"
type="image"
@change="(urls, _currentUrl, _currentName, names, sizes) => handleMediasChange(urls, names, sizes, 1)" />
</div>
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_VIDEO" class="type-item">
<VenusOssUpload :key="item.messageType"
v-model="fileList"
type="video"
:file-size="50"
@change="(urls, _currentUrl, _currentName, names, sizes) => handleMediasChange(urls, names, sizes, 2)" />
</div>
<div v-if="item.messageType === MessageTypeEnum.VARIABLE_WEBPAGE" class="type-item">
<el-button size="mini"
plain
@click="handleShowPageConfig">
编辑
</el-button>
</div>
</div>
<VenusDialog v-model="dialog.page.show"
title="编辑网页内容"
width="1060px"
:close-on-click-modal="false"
@close="handleClosePageConfig"
@confirm="handleConfirmPageConfig">
<PageConfig v-if="dialog.page.show"
ref="PageConfig"
v-model="itemCache" />
</VenusDialog>
</div>
</template>
<script>
import { cloneDeep, last } from "lodash-es";
import VenusDialog from "@/components/venusDialog";
import VenusOssUpload from "@/components/venusOssUpload";
import { MessageTypeEnum } from "@/views/marketingManagement/marketingPushStrategy/constant";
import PageConfig from "../pageConfig/index.vue";
import VariableTextarea from "../variableTextarea";
export default {
name: "",
components: {
VariableTextarea,
VenusOssUpload,
VenusDialog,
PageConfig,
},
model: {
prop: "item",
event: "input",
},
props: {
item: {
type: Object,
required: true,
},
messageVariables: {
type: Array,
default: () => ([]),
},
},
data() {
return {
fileList: [],
itemCache: undefined,
MessageTypeEnum,
dialog: {
page: {
show: false,
},
},
};
},
computed: {
},
watch: {
"item.medias": {
immediate: true,
handler(newVal) {
if (MessageTypeEnum.VARIABLE_IMAGE === this.item.messageType) {
this.fileList = (newVal || []).filter(item => item.mediaType === 1).map(item => item.mediaUrl);
}
if (MessageTypeEnum.VARIABLE_VIDEO === this.item.messageType) {
this.fileList = (newVal || []).filter(item => item.mediaType === 2).map(item => item.mediaUrl);
}
},
},
},
mounted() {
},
methods: {
handleShowPageConfig() {
this.dialog.page.show = true;
this.itemCache = cloneDeep(this.item);
},
handleClosePageConfig() {
this.dialog.page.show = false;
this.itemCache = {};
},
async handleConfirmPageConfig() {
const PageConfigRef = this.$refs.PageConfig;
if (!PageConfigRef) {
return;
}
const pageConfigFormRef = PageConfigRef.$refs.PageConfigFromRef;
if (!pageConfigFormRef) {
return;
}
await pageConfigFormRef.validate();
this.$emit("input", this.itemCache);
await this.$nextTick();
this.handleClosePageConfig();
},
handleMediasChange(urls, names, sizes, mediaType) {
this.$emit("input", { ...this.item, medias: urls.map((item, index) => ({
mediaType,
mediaName: names[index],
mediaUrl: item,
sortNo: index,
})) });
},
handleMessageTypeChange(e) {
this.fileList = [];
this.$emit("input", {
...this.item,
messageType: e,
content: "",
medias: [],
pageTitle: "",
pageDesc: "",
bgColor: "#ffffff",
materialJson: [],
intervalPx: 0,
});
},
handleContentChange(e) {
this.$emit("input", { ...this.item, content: e });
},
handlePageConfigChange(e) {
this.$emit("input", e);
},
},
};
</script>
<style scoped lang="scss">
</style>
const EMPTY_TEXT = "-";
function getValue(value) {
if (value === 0)
return 0;
return value || EMPTY_TEXT;
}
function flattenConditions(conditionGroups) {
if (!Array.isArray(conditionGroups))
return [];
return conditionGroups.reduce((list, group) => {
const conditions = Array.isArray(group.conditions) ? group.conditions : [];
return list.concat(conditions.map(item => item.conditionDesc).filter(Boolean));
}, []);
}
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) {
return [];
}
}
export function getBasicRows(info = {}) {
const basicInfo = info.basicInfo || {};
return [
{ label: "策略名称", value: getValue(basicInfo.strategyName) },
{ label: "适用场景", value: getValue(basicInfo.bizTypeName) },
{ label: "适用门店", value: getValue(basicInfo.storeDescription || basicInfo.storeScopeDesc) },
{ label: "营销阶段", value: getValue(basicInfo.marketingStageName) },
];
}
export function getCustomerRows(info = {}) {
const customerInfo = info.customerInfo || {};
return [
{ label: "所属门店", value: getValue(customerInfo.storeName) },
{ label: "客户名称", value: getValue(customerInfo.customerName) },
{ label: "客户手机号", value: getValue(customerInfo.customerPhone) },
];
}
export function getTriggerRows(info = {}) {
const triggerInfo = info.triggerInfo || {};
const rows = [
{ label: "触发类型", value: getValue(triggerInfo.triggerTypeName) },
{ label: "实际触发时间", value: getValue(triggerInfo.triggerTimeDesc) },
];
const conditionText = flattenConditions(triggerInfo.step2ConditionGroups).join(";");
if (conditionText) {
rows.push({ label: "同时满足以下条件", value: conditionText });
}
rows.push({ label: "动作执行确认", value: getValue(triggerInfo.actionConfirmDesc) });
return rows;
}
export function getBranchBlocks(info = {}) {
const branches = Array.isArray(info.branches) ? info.branches : [];
return branches.map((branch, branchIndex) => {
const conditionText = flattenConditions(branch.conditionGroups).join(";") || "默认分支";
const actions = Array.isArray(branch.actions) ? branch.actions : [];
return {
name: branch.branchName || `分支${branchIndex + 1}`,
conditionText,
actions: actions.map((action, actionIndex) => {
const actionTitle = action.actionTypeName === "发送消息" ? "向客户群发送消息" : getValue(action.actionTypeName);
const rows = [
{ label: "动作", value: getValue(action.actionTypeName) },
{ label: "消息类型", value: getValue(action.messageTypeName) },
{ label: "消息内容", value: getValue(action.content) },
];
if (action.bgColor) {
rows.push({ label: "背景颜色", value: action.bgColor });
}
if (action.intervalPx || action.intervalPx === 0) {
rows.push({ label: "素材间距", value: `${action.intervalPx}px` });
}
return {
name: `动作${actionIndex + 1}`,
title: actionTitle,
rows,
materials: parseMaterials(action.materialJson),
};
}),
};
});
}
<!-- 策略详情弹窗 -->
<template>
<div>
<d2-dialog btn-ok-label="确定"
class="detail"
width="70%"
:is-visible.sync="detailVisible"
:title="title"
@closeDialog="handleDetailClose"
@confirmDialog="handleDetailConfirm">
<div class="strategy-detail-dialog">
<template v-if="hasDetail">
<div class="detail-section">
<div class="detail-section-title">
<span>基础信息</span>
</div>
<div class="detail-section-body">
<p v-for="item in basicRows"
:key="item.label">
<span class="detail-label">{{ item.label }}:</span>{{ item.value }}
</p>
</div>
</div>
<div class="detail-section">
<div class="detail-section-title">
<span>目标客户</span>
</div>
<div class="detail-section-body">
<p v-for="item in customerRows"
:key="item.label">
<span class="detail-label">{{ item.label }}:</span>{{ item.value }}
</p>
</div>
</div>
<div class="detail-section">
<div class="detail-section-title">
<span>触发条件</span>
</div>
<div class="detail-section-body">
<p v-for="item in triggerRows"
:key="item.label">
<span class="detail-label">{{ item.label }}:</span>{{ item.value }}
</p>
</div>
</div>
<div class="detail-section">
<div class="detail-section-title">
<span>执行动作</span>
</div>
<div class="detail-section-body">
<template v-if="branchBlocks.length">
<div v-for="(branch, branchIndex) in branchBlocks"
:key="branch.name"
class="branch-block">
<p>
<span class="detail-label">[分支 {{ branchIndex + 1 }}] 触发条件:</span>{{ branch.conditionText }}
</p>
<div v-for="action in branch.actions"
:key="action.name"
class="action-block">
<p>
<span class="detail-label">{{ action.name }}:</span>{{ action.title }}
</p>
<p v-for="row in action.rows"
:key="row.label">
<span class="detail-label">{{ row.label }}:</span>{{ row.value }}
</p>
<p v-if="action.materials.length">
<span class="detail-label">素材内容:</span>
<span v-for="(material, index) in action.materials"
:key="material.url"
class="material-text">
{{ material.typeName }}:{{ material.url }}<span v-if="index < action.materials.length - 1">;</span>
</span>
</p>
</div>
</div>
</template>
<p v-else>
暂无执行动作
</p>
</div>
</div>
</template>
<el-empty v-else
description="暂无详情数据" />
</div>
</d2-dialog>
</div>
</template>
<script>
import {
getBasicRows,
getBranchBlocks,
getCustomerRows,
getTriggerRows,
} from "./detailFormat";
export default {
name: "DetailDialog",
props: {
title: {
type: String,
default: "查看策略详情",
},
detailVisible: {
type: Boolean,
default: false,
},
detailInfo: {
type: Object,
default: () => ({}),
},
},
data() {
return {
info: {},
};
},
computed: {
hasDetail() {
return Object.keys(this.info).length > 0;
},
basicRows() {
return getBasicRows(this.info);
},
customerRows() {
return getCustomerRows(this.info);
},
triggerRows() {
return getTriggerRows(this.info);
},
branchBlocks() {
return getBranchBlocks(this.info);
},
},
watch: {
detailInfo: {
immediate: true,
deep: true,
handler() {
this.initInfo();
},
},
},
methods: {
initInfo() {
const snapshotInfo = this.detailInfo && this.detailInfo.snapshotInfo;
if (!snapshotInfo) {
this.info = {};
return;
}
this.info = JSON.parse(snapshotInfo);
console.log(this.info, "info---");
},
handleDetailConfirm() {
this.$emit("handleDetailConfirm");
},
handleDetailClose() {
this.$emit("handleDetailClose");
},
},
};
</script>
<style lang="scss">
.strategy-detail-dialog {
max-height: 620px;
overflow-y: auto;
padding-right: 6px;
color: #303133;
font-size: 13px;
.detail-section {
margin-bottom: 18px;
&:last-child {
margin-bottom: 0;
}
}
.detail-section-title {
display: flex;
align-items: center;
margin-bottom: 12px;
font-weight: 700;
color: #303133;
span {
padding-right: 12px;
background: #fff;
white-space: nowrap;
}
&::after {
content: "";
flex: 1;
height: 1px;
background: #ebeef5;
}
}
.detail-section-body {
padding: 14px 16px;
border-radius: 4px;
background: #f5f7fa;
line-height: 24px;
p {
margin: 0 0 6px;
word-break: break-all;
&:last-child {
margin-bottom: 0;
}
}
}
.detail-label {
font-weight: 700;
color: #303133;
}
.branch-block {
margin-top: 18px;
&:first-child {
margin-top: 0;
}
}
.action-block {
margin-top: 8px;
}
.material-text {
display: inline;
}
}
</style>
<!-- 关联门店弹窗 -->
<template>
<div>
<d2-dialog btn-ok-label="确定"
class="record"
width="70%"
:is-visible.sync="recordVisible"
:title="title"
@closeDialog="handleRecordClose"
@confirmDialog="handleRecordConfirm">
<d2-table ref="recordTable"
:before-search-fn="beforeSearchFn"
:get-list-api="getListApi"
:search-form="searchFormSearch"
:table-params="tableParams">
<el-button slot="auth-button"
slot-scope="scope"
type="text"
@click="handleDetail(scope.scope)">
查看策略详情
</el-button>
</d2-table>
</d2-dialog>
<RecordDetailDialog v-if="dialog.detailVisible"
:detail-info="dialog.detailInfo"
:detail-visible="dialog.detailVisible"
@handleDetailClose="handleDetailClose"
@handleDetailConfirm="handleDetailClose">
</RecordDetailDialog>
</div>
</template>
<script>
import { Util } from "@/common/util";
import { recordsStrategy } from "@/views/marketingManagement/marketingPushStrategy/api/index";
import recordDetailDialog from "@/views/marketingManagement/marketingPushStrategy/components/recordDetailDialog/index";
export default {
name: "RecordDialog",
components: {
RecordDetailDialog: recordDetailDialog,
},
props: {
title: {
type: String,
default: "查看执行记录",
},
recordVisible: {
type: Boolean,
default: false,
},
strategyId: {
type: String,
default: "",
},
},
data() {
return {
searchFormSearch: {},
getListApi: recordsStrategy,
tableParams: {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list",
tableOption: true,
tableColumns: [{
label: "执行时间",
prop: "executeTime",
formatter: (cellValue) => {
return Util.dateFormate(cellValue.executeTime, "YYYY-MM-DD HH:mm:ss");
},
}, {
label: "执行结果",
prop: "executeResult",
formatter: (cellValue) => {
const obj = {
1: "成功",
2: "失败",
};
return obj[cellValue.executeResult];
},
}, {
label: "描述",
prop: "errorMessage",
}],
},
dialog: {
detailVisible: false,
detailInfo: {},
},
};
},
mounted() {},
methods: {
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch.strategyId = this.strategyId;
this.searchFormSearch.pageNo = this.$refs.recordTable.page.currentPage || 1;
resolve();
});
},
handleDetailClose() {
this.dialog.detailVisible = !this.dialog.detailVisible;
},
handleDetail(row) {
console.log(row, "row---");
this.handleDetailClose();
this.dialog.detailInfo = row;
},
handleRecordConfirm() {
this.$emit("handleRecordConfirm");
},
handleRecordClose() {
this.$emit("handleRecordClose");
},
},
};
</script>
<style lang="scss">
</style>
<template>
<RelateStoreDialog v-if="relateStoreVisible"
ref="formRelateStore"
page="marketingPushStrategy"
title="选择门店"
:relate-store-visible="relateStoreVisible"
:store-api="getMerchantList"
:store-search-form="storeSearchForm"
:store-selected="storeSelected"
:table-head-items="tableHeadItems"
@handleRelateStoreClose="handleRelateStoreClose"
@handleRelateStoreConfirm="handleRelateStoreConfirm">
<template #default>
<el-row>
<el-form ref="relate"
:inline="true"
:model="storeSearchForm">
<el-form-item label="门店名称:">
<el-input v-model.trim="storeSearchForm.merchantName"
placeholder="门店名称"
clearable
@keydown.native="handleStoreInput" />
</el-form-item>
<el-form-item label="门店商户号:">
<el-input v-model.trim="storeSearchForm.merchantId"
placeholder="门店商户号"
clearable
@keydown.native="handleStoreInput" />
</el-form-item>
<el-button type="primary" @click="handleSearchStore">
搜索
</el-button>
</el-form>
</el-row>
</template>
</RelateStoreDialog>
</template>
<script>
import { getMerchantList } from "@/api/merchant";
import relateStoreDialog from "@/views/goods/grounding/components/relateStoreDialog.vue";
export default {
components: {
RelateStoreDialog: relateStoreDialog,
},
props: {
relateStoreVisible: {
type: Boolean,
default: false,
},
storeSelected: {
type: Array,
default: () => [],
},
},
data() {
return {
getMerchantList,
storeSearchForm: {
merchantName: "",
merchantId: "",
yqMerchantName: "",
yqMerchantId: "",
},
tableHeadItems: ["门店名称", "门店地址", "门店商户号"],
};
},
mounted() { },
methods: {
handleStoreInput(e) {
e.keyCode === 13 && this.handleSearchStore();
},
// 门店搜索
handleSearchStore() {
this.$refs.formRelateStore.handleCurrentChange(1);
},
handleRelateStoreConfirm(selectedData) {
if (!selectedData.length) {
this.$message({
message: "请选择门店",
type: "warning",
showClose: true,
});
return true;
}
// this.formData.merchantGoodsRefList = selectedData;
// // 清空产品信息
// this.clearUpgradeGoods();
// this.relateStoreVisible = false;
this.$emit("handleRelateStoreConfirm", selectedData);
},
handleRelateStoreClose() {
this.$emit("handleRelateStoreClose");
},
},
};
</script>
<style scoped>
</style>
<template>
<div class="variable-textarea-wrapper">
<el-input ref="textareaRef"
placeholder="请输入消息内容"
resize="none"
rows="8"
type="textarea"
:value="value"
@input="handleInput">
</el-input>
<div class="foot-wrapper">
<el-dropdown placement="bottom-start"
style="width:100%"
trigger="click"
@command="handleCommand">
<div class="dropdown-wrapper">
<i class="el-icon-plus "></i>
<span class="el-dropdown-link" style="margin-left:8px">
插入变量
</span>
</div>
<el-dropdown-menu slot="dropdown"
class="marketing-dropdown-menu"
style="max-height: 400px; overflow: auto;">
<el-dropdown-item v-for="variable in variableList"
:key="variable.code"
:command="variable.name">
{{ variable.name }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</template>
<script>
export default {
name: "VariableTextarea",
props: {
value: {
type: String,
required: true,
},
variableList: {
type: Array,
default: () => ([]),
},
},
data() {
return {
autosize: {
minRows: 6,
maxRows: 60,
},
};
},
computed: {
},
mounted() {
},
methods: {
handleInput(e) {
this.$emit("input", e);
},
handleCommand(command) {
const textarea = this.$refs.textareaRef.$el.querySelector("textarea");
const text = this.value || "";
const insertion = `{{${command}}}`;
if (textarea) {
// 在光标位置插入
const start = textarea.selectionStart;
const end = textarea.selectionEnd;
const newValue = text.substring(0, start) + insertion + text.substring(end);
this.$emit("input", newValue);
this.$nextTick(() => {
const newPos = start + insertion.length;
textarea.setSelectionRange(newPos, newPos);
textarea.focus();
});
} else {
this.$emit("input", text + insertion);
}
},
},
};
</script>
<style scoped lang="scss">
.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;
}
.foot-wrapper {
background-color: #f5f6fa;
border-top: 1px solid #e5e5e5;
.dropdown-wrapper {
width: 100%;
color: #2a58ad;
cursor: pointer;
display: flex;
align-items: center;
padding: 8px 16px;
}
}
}
</style>
import { nanoid } from "nanoid";
export const actionConfirmOptions = [
{ value: 0, label: "自动执行" },
{ value: 1, label: "需驻店人员确认" },
];
export const MessageTypeEnum = {
VARIABLE_TEXT: 1,
VARIABLE_IMAGE: 2,
VARIABLE_VIDEO: 3,
VARIABLE_WEBPAGE: 4,
};
// 条件的 变量 是 变量 还是值
export const ConditionVariableSourceTypeEnum = {
VARIABLE: 0,
VALUE: 1,
};
export const ConditionVariableTypeEnum = {
TEXT: 1,
NUMBER: 2,
DATE: 3,
ENUM: 4,
};
export const intervalPxOptions = [
{ value: 0, label: "无间隔" },
{ value: 4, label: "4px" },
{ value: 8, label: "8px" },
{ value: 16, label: "16px" },
];
// index: branch 的index
export function getDefaultBranch() {
return {
_key: nanoid(),
conditionGroups: [],
actions: [
getDefaultAction(),
],
};
}
export function getDefaultAction() {
return {
_key: nanoid(),
actionType: undefined,
targetGroupType: 1,
messageType: MessageTypeEnum.VARIABLE_TEXT,
content: "",
medias: [],
pageTitle: undefined,
pageDesc: undefined,
bgColor: undefined,
materialJson: [],
intervalPx: undefined,
};
}
export const bizTypeOpt = [
{ confId: 1, confLabel: "轻改" },
];
export const storeTypeOpt = [
{ confId: 1, confLabel: "指定门店" },
{ confId: 0, confLabel: "不限门店" },
];
export const relativeDateTypeOpt = [
{ code: 0, name: "提前" },
{ code: 1, name: "当天" },
{ code: 2, name: "推后" },
];
// 生成小时选项 00-23
export const hourOptions = Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0"));
// 生成分钟选项 00-59
export const minuteOptions = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!