Commit 8f985ee4 by wangzhihui

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

…e-system into SAAS+V5.8.3_wzh
2 parents 51d6bfc5 15e2b919
Showing 123 changed files with 3993 additions and 493 deletions
...@@ -126,3 +126,91 @@ test.afterAll(async () => { ...@@ -126,3 +126,91 @@ test.afterAll(async () => {
2. **每个 test 开头做 `goto`** 导航到目标页面,用 URL 导航来隔离 test 间状态 2. **每个 test 开头做 `goto`** 导航到目标页面,用 URL 导航来隔离 test 间状态
3. **afterAll 关闭 context**,避免资源泄漏 3. **afterAll 关闭 context**,避免资源泄漏
4. URL 提取为常量(如 `BASE_URL`),方便切换测试环境 4. URL 提取为常量(如 `BASE_URL`),方便切换测试环境
---
## 6. 旧后台项目 E2E 稳定性经验
适用于本项目这类 `Vue2 + Element UI + D2Admin` 的后台页面。
### 页面就绪判断
不要只等待路由切换完成,也不要只依赖固定 `waitForTimeout`。
推荐组合:
1. 等关键接口返回
2. 等页面核心容器可见
3. 等表单控件或表格真实渲染完成
例如新增/编辑页如果依赖元数据接口,必须先等真实接口返回,再继续执行后续步骤。
### 选择器策略
#### 1. 表格操作列
Element UI 表格和 D2Admin 表格可能存在 fixed 列副本、隐藏节点、slot 包装节点。
因此:
- 不要默认认为 `getByRole()` 一定稳定
- 优先在“当前行的操作列作用域”内定位
- 优先点击真实可见的 `button`
- 如果组件渲染结构复杂,可在受控范围内做 DOM fallback
#### 2. 弹窗套弹窗
不要只靠“包含某段文本”来区分外层弹窗和内层弹窗。
推荐组合:
1. 先记录当前可见弹窗数量
2. 点击后等待可见弹窗数量增加
3. 用二级弹窗专属根节点或专属内容区定位
如果详情弹窗有独立根 class,应优先以该 class 作为锚点。
#### 3. 文本定位
在旧项目里,按钮和表格操作列经常是复杂 slot 渲染,文本选择器通常比过度依赖语义角色更稳定。
但前提是:
- 文案必须以真实页面为准
- 不要只照测试用例文档写死文案
- 文案更新后要同步维护测试
### 断言策略
- 优先断言稳定的内容区、根容器、业务字段
- 少依赖容易变化的局部 DOM 结构
- 如果标题节点不稳定,可以断言整个弹窗包含标题文本和专属内容区同时存在
### 调试顺序
推荐顺序:
1. 先定向跑失败用例
2. 再看失败截图和 trace
3. 根据真实 DOM 和真实文案修正选择器
4. 最后全量回归
不要在定位未收敛时反复全量跑整个文件。
### 真实环境约束
- E2E 默认优先走真实接口和真实链路
- 如果页面依赖真实环境数据,测试里要显式写明依赖项
- 对固定数据依赖要用常量集中管理,方便替换和排查
例如:
```js
const RECORD_DETAIL_STRATEGY_NAME = "测试发送策略";
```
### 实操原则
- 先保证流程稳定,再考虑写法优雅
- 先最小改动,再逐步增强健壮性
- 每次修复后先做定向验证,再做整文件回归
...@@ -40,3 +40,4 @@ yarn-error.log* ...@@ -40,3 +40,4 @@ yarn-error.log*
# test # test
/playwright/ /playwright/
/testCase/
{
"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:
...@@ -164,4 +164,37 @@ export default antfu({ ...@@ -164,4 +164,37 @@ export default antfu({
*/ */
html: true, html: true,
}, },
}, {
files: ["**/*.spec.js", "**/*.integration.spec.js"],
languageOptions: {
globals: {
jest: "readonly",
describe: "readonly",
it: "readonly",
test: "readonly",
expect: "readonly",
beforeEach: "readonly",
afterEach: "readonly",
beforeAll: "readonly",
afterAll: "readonly",
require: "readonly",
module: "readonly",
process: "readonly",
window: "readonly",
document: "readonly",
navigator: "readonly",
location: "readonly",
URL: "readonly",
Blob: "readonly",
File: "readonly",
FormData: "readonly",
MessageEvent: "readonly",
localStorage: "readonly",
sessionStorage: "readonly",
setTimeout: "readonly",
clearTimeout: "readonly",
setInterval: "readonly",
clearInterval: "readonly",
},
},
}); });
...@@ -15,6 +15,7 @@ module.exports = { ...@@ -15,6 +15,7 @@ module.exports = {
], ],
moduleNameMapper: { moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1", "^@/(.*)$": "<rootDir>/src/$1",
"^@api/(.*)$": "<rootDir>/src/api/$1",
"\\.css$": "jest-transform-stub", "\\.css$": "jest-transform-stub",
"^@/plugin/d2admin/(.*)$": "<rootDir>/jest.mocks/d2admin.js", "^@/plugin/d2admin/(.*)$": "<rootDir>/jest.mocks/d2admin.js",
"^@/assets/svg-icons/index.js$": "<rootDir>/jest.mocks/svg-icons-index.js", "^@/assets/svg-icons/index.js$": "<rootDir>/jest.mocks/svg-icons-index.js",
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
"private": true, "private": true,
"scripts": { "scripts": {
"备注": "去掉nomock配置命令", "备注": "去掉nomock配置命令",
"serve": "vue-cli-service serve", "serve": "set NODE_OPTIONS=--max-old-space-size=4096&& vue-cli-service serve",
"start": "set NODE_OPTIONS=--openssl-legacy-provider && npm run serve", "start": "npm run serve",
"dev": "set NODE_OPTIONS=--openssl-legacy-provider && npm run serve", "dev": "npm run serve",
"build": "vue-cli-service build --no-module", "build": "vue-cli-service build --no-module",
"build:nomock": "vue-cli-service build --mode nomock", "build:nomock": "vue-cli-service build --mode nomock",
"lint": "vue-cli-service lint --fix", "lint": "vue-cli-service lint --fix",
......
import request from "./request";
import RequestMethods from "./request.methods";
/** 查询客户画像 */
export function queryCustomerPortrait(data = {}) {
data.method = "dj.api.customer.profile";
data.id = data.id ?? data.customerId;
return request(data, RequestMethods.POST);
}
/** 查询客户群关联 */
export function queryCustomerGroups(data = {}) {
data.method = "dj.api.customer.groupAssoc";
data.id = data.id ?? data.customerId;
return request(data, RequestMethods.POST);
}
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);
}
...@@ -112,9 +112,33 @@ export function onlinePaymentDetailPage(data) { ...@@ -112,9 +112,33 @@ export function onlinePaymentDetailPage(data) {
} }
/** /**
* 分页查询银盛线上对账单汇总-分账记录
*/
export function onlineDivisionMonthTotalPage(data) {
data.method = "dj.api.smartcarlife.onlineStatementAccount.divisionMonthTotalPage";
return request(data, "post");
}
/**
* 分页查询银盛线上对账单汇总-收款记录 * 分页查询银盛线上对账单汇总-收款记录
*/ */
export function onlinePaymentMonthTotalPage(data) { export function onlinePaymentMonthTotalPage(data) {
data.method = "dj.api.smartcarlife.onlineStatementAccount.paymentMonthTotalPage"; data.method = "dj.api.smartcarlife.onlineStatementAccount.paymentMonthTotalPage";
return request(data, "post"); return request(data, "post");
} }
/**
* 查询银盛线上对账单收款统计信息
*/
export function paymentCountTotal(data) {
data.method = "dj.api.smartcarlife.onlineStatementAccount.paymentCountTotal";
return request(data, "post");
}
/**
* 查询银盛线上对账单分账统计记录
*/
export function divisionCountTotal(data) {
data.method = "dj.api.smartcarlife.onlineStatementAccount.divisionCountTotal";
return request(data, "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];
......
import request from "./request";
import RequestMethods from "./request.methods";
const METHOD_PREFIX = "dj.api.strategy.tag.";
/** 查询标签类别树 */
export function queryTagCategoryTree(data = {}) {
data.method = `${METHOD_PREFIX}category.tree`;
return request(data, RequestMethods.POST);
}
/** 查询可新增子级的分类列表 */
export function queryTagCategoryLeafList(data = {}) {
data.method = `${METHOD_PREFIX}category.leaf.list`;
return request(data, RequestMethods.POST);
}
/** 创建标签类别 */
export function createTagCategory(data = {}) {
data.method = `${METHOD_PREFIX}category.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签类别 */
export function updateTagCategory(data = {}) {
data.method = `${METHOD_PREFIX}category.update`;
return request(data, RequestMethods.POST);
}
/** 分页查询标签维度列表 */
export function queryTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.query`;
return request(data, RequestMethods.POST);
}
/** 获取新增维度时可选的分类列表 */
export function queryTagDimensionCategoryOptions(data = {}) {
data.method = `${METHOD_PREFIX}dimension.category.options`;
return request(data, RequestMethods.POST);
}
/**
* 查询标签维度详情
* @param {Object} data categoryId — 参数名沿用后端,实际传维度 ID
*/
export function queryTagDimensionDetail(data = {}) {
data.method = `${METHOD_PREFIX}dimension.detail`;
return request(data, RequestMethods.POST);
}
/** 创建标签维度 */
export function createTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签维度 */
export function updateTagDimension(data = {}) {
data.method = `${METHOD_PREFIX}dimension.update`;
return request(data, RequestMethods.POST);
}
/** 分页查询枚举值列表 */
export function pageTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.page`;
return request(data, RequestMethods.POST);
}
/** 创建标签枚举值 */
export function createTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.create`;
return request(data, RequestMethods.POST);
}
/** 编辑标签枚举值 */
export function updateTagEnum(data = {}) {
data.method = `${METHOD_PREFIX}enum.update`;
return request(data, RequestMethods.POST);
}
...@@ -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>
...@@ -145,6 +145,9 @@ export default { ...@@ -145,6 +145,9 @@ export default {
computedHeight() { computedHeight() {
return this.formatSize(this.height); return this.formatSize(this.height);
}, },
computedTop() {
return this.formatSize(this.$attrs.top);
},
innerVisible: { innerVisible: {
get() { get() {
return this.visible; return this.visible;
...@@ -258,11 +261,14 @@ export default { ...@@ -258,11 +261,14 @@ export default {
// Calculate vertical center // Calculate vertical center
const screenHeight = document.body.clientHeight; const screenHeight = document.body.clientHeight;
// Calculate top offset for centering
// el-dialog default has margin-top: 15vh, we need to override it to center vertically
const topOffset = Math.max(0, (screenHeight - dragDomHeight) / 2);
dragDom.style.marginTop = "0"; dragDom.style.marginTop = "0";
dragDom.style.top = `${topOffset}px`; if (this.computedTop) {
dragDom.style.top = this.computedTop;
} else {
// el-dialog default has margin-top: 15vh, we need to override it to center vertically
const topOffset = Math.max(0, (screenHeight - dragDomHeight) / 2);
dragDom.style.top = `${topOffset}px`;
}
} }
}); });
}, },
......
/**
* @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);
}
const _import = require("@/libs/util.import." + process.env.NODE_ENV) const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = { export const routerName = {
902: { 902: {
path: "/flowManage", path: "/flowManage",
name: "flowManage", name: "flowManage",
meta: { meta: {
title: "流量管理", title: "流量管理",
authId: "902", authId: "902",
parentId: "1", parentId: "1",
cache: false cache: false,
} },
}, },
90201: { 90201: {
path: "/customerList", path: "/customerList",
name: "customerList", name: "customerList",
meta: { meta: {
title: "客户列表", title: "客户列表",
authId: "90201", authId: "90201",
parentId: "902", parentId: "902",
cache: false cache: false,
}, },
auth: [ auth: [
{ {
authId: "9020101", authId: "9020101",
parentId: "90201", parentId: "90201",
label: "导出", label: "导出",
category: "Button", category: "Button",
type: "primary", type: "primary",
handle: "handleExport" handle: "handleExport",
} },
], {
component: _import("customer/customerList") authId: "9020102",
}, parentId: "90201",
90202: { label: "客户画像",
path: "/recordList", handle: "handleViewPortrait",
name: "recordList", addRoutePath: [
meta: { {
title: "预录信息", authId: "90205",
authId: "90202", name: "客户画像",
parentId: "902", parentId: "90201",
cache: false },
}, ],
auth: [ },
{ {
authId: "9020201", authId: "9020103",
parentId: "90202", parentId: "90201",
label: "预录客户", label: "群关联",
icon: "plus", handle: "handleViewGroups",
category: "Button", addRoutePath: [
type: "primary", {
handle: "handleAdd", authId: "90206",
addRoutePath: [ name: "群关联",
{ parentId: "90201",
authId: "901", },
name: "预录客户", ],
parentId: "90202" },
} {
] authId: "9020104",
}, parentId: "90201",
{ label: "订单信息",
authId: "9020202", handle: "handleViewOrders",
parentId: "90202", // addRoutePath: [
label: "一键导入", // {
category: "Button", // authId: "90401",
type: "primary", // name: "订单列表",
handle: "handleImport" // parentId: "904",
}, // },
{ // ],
authId: "9020203", },
parentId: "90202", ],
label: "编辑", component: _import("customer/customerList"),
handle: "handleEdit", },
addRoutePath: [ 90202: {
{ path: "/recordList",
authId: "901", name: "recordList",
name: "预录客户", meta: {
parentId: "90202" title: "预录信息",
} authId: "90202",
] parentId: "902",
} cache: false,
], },
component: _import("customer/recordList") auth: [
}, {
authId: "9020201",
90203: { parentId: "90202",
path: "/invitation", label: "预录客户",
name: "invitation", icon: "plus",
meta: { category: "Button",
title: "邀约管理", type: "primary",
authId: "90203", handle: "handleAdd",
parentId: "902", addRoutePath: [
cache: false {
}, authId: "901",
auth: [ name: "预录客户",
{ parentId: "90202",
authId: "9020301", },
parentId: "90203", ],
label: "再次电联", },
handle: "handleMoreCall" {
// ruleObj: { authId: "9020202",
// attr: 'status', parentId: "90202",
// rule: { label: "一键导入",
// 0: '上架', category: "Button",
// 1: '下架' type: "primary",
// } handle: "handleImport",
// } },
}, {
{ authId: "9020203",
authId: "9020302", parentId: "90202",
parentId: "90203", label: "编辑",
label: "取消预约", handle: "handleEdit",
handle: "handleCancel" addRoutePath: [
}, {
{ authId: "901",
authId: "9020303", name: "预录客户",
parentId: "90203", parentId: "90202",
label: "更新备注", },
handle: "handleUpdateRemark" ],
}, },
{ ],
authId: "9020304", component: _import("customer/recordList"),
parentId: "90203", },
label: "修改时间",
handle: "handleChangeTime" 90203: {
}, path: "/invitation",
{ name: "invitation",
authId: "9020305", meta: {
parentId: "90203", title: "邀约管理",
label: "电联一下", authId: "90203",
handle: "handleCall" parentId: "902",
}, cache: false,
{ },
authId: "9020306", auth: [
parentId: "90203", {
label: "预约时间", authId: "9020301",
handle: "handleAppoint" parentId: "90203",
}, label: "再次电联",
{ handle: "handleMoreCall",
authId: "9020307", // ruleObj: {
parentId: "90203", // attr: 'status',
label: "更新备注", // rule: {
handle: "handleUpdateRemark" // 0: '上架',
} // 1: '下架'
], // }
component: _import("customer/invitation") // }
}, },
901: { {
path: "/editCustomer", authId: "9020302",
name: "editCustomer", parentId: "90203",
meta: { label: "取消预约",
title: "预录客户", handle: "handleCancel",
authId: "901", },
parentId: "90202", {
cache: false, authId: "9020303",
sideHidden: false, parentId: "90203",
activePath: "/recordList" label: "更新备注",
}, handle: "handleUpdateRemark",
component: _import("customer/editCustomer") },
} {
} authId: "9020304",
parentId: "90203",
// { routerName } label: "修改时间",
handle: "handleChangeTime",
},
{
authId: "9020305",
parentId: "90203",
label: "电联一下",
handle: "handleCall",
},
{
authId: "9020306",
parentId: "90203",
label: "预约时间",
handle: "handleAppoint",
},
{
authId: "9020307",
parentId: "90203",
label: "更新备注",
handle: "handleUpdateRemark",
},
],
component: _import("customer/invitation"),
},
90205: {
path: "/customerPortrait",
name: "customerPortrait",
meta: {
title: "客户画像",
authId: "90205",
parentId: "90201",
cache: false,
sideHidden: true,
activePath: "/customerList",
},
component: _import("customer/portrait/index"),
},
90206: {
path: "/customerGroupRel",
name: "customerGroupRel",
meta: {
title: "群关联",
authId: "90206",
parentId: "90201",
cache: false,
sideHidden: true,
activePath: "/customerList",
},
component: _import("customer/groupRel/index"),
},
901: {
path: "/editCustomer",
name: "editCustomer",
meta: {
title: "预录客户",
authId: "901",
parentId: "90202",
cache: false,
sideHidden: false,
activePath: "/recordList",
},
component: _import("customer/editCustomer"),
},
};
// { routerName }
...@@ -854,7 +854,7 @@ export const routerName = { ...@@ -854,7 +854,7 @@ export const routerName = {
path: "/ysprepaymentManage", path: "/ysprepaymentManage",
name: "ysprepaymentManage", name: "ysprepaymentManage",
meta: { meta: {
title: "银盛线上对账单", title: "银盛线上对账单(广联)",
authId: "90517", authId: "90517",
parentId: "905", parentId: "905",
cache: false, cache: false,
......
const _import = require("@/libs/util.import." + process.env.NODE_ENV) const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = { export const routerName = {
922: { 922: {
path: "/marketingManagement", path: "/marketingManagement",
...@@ -8,7 +8,7 @@ export const routerName = { ...@@ -8,7 +8,7 @@ export const routerName = {
authId: "922", authId: "922",
parentId: "1", parentId: "1",
cache: false, cache: false,
} },
}, },
92201: { 92201: {
path: "/marketingActivity", path: "/marketingActivity",
...@@ -29,12 +29,12 @@ export const routerName = { ...@@ -29,12 +29,12 @@ export const routerName = {
type: "primary", type: "primary",
handle: "handleAdd", handle: "handleAdd",
addRoutePath: [ addRoutePath: [
{ {
authId: "92202", authId: "92202",
name: "新增活动", name: "新增活动",
parentId: "92201" parentId: "92201",
} },
] ],
}, },
{ {
authId: "9220102", authId: "9220102",
...@@ -42,14 +42,14 @@ export const routerName = { ...@@ -42,14 +42,14 @@ export const routerName = {
label: "查看详情", label: "查看详情",
handle: "handleDetail", handle: "handleDetail",
addRoutePath: [ addRoutePath: [
{ {
authId: "92203", authId: "92203",
name: "订单详情", name: "订单详情",
parentId: "92201" parentId: "92201",
} },
] ],
}, },
] ],
}, },
92202: { 92202: {
path: "/addMarketingActivity", path: "/addMarketingActivity",
...@@ -62,7 +62,7 @@ export const routerName = { ...@@ -62,7 +62,7 @@ export const routerName = {
sideHidden: true, sideHidden: true,
activePath: "/marketingActivity", activePath: "/marketingActivity",
}, },
component: _import("marketingManagement/marketingActivity/addMarketingActivity") component: _import("marketingManagement/marketingActivity/addMarketingActivity"),
}, },
92203: { 92203: {
path: "/viewMarketingActivity", path: "/viewMarketingActivity",
...@@ -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",
},
component: _import("marketingManagement/marketingPushStrategy/views/modify/index"),
},
};
const _import = require("@/libs/util.import." + process.env.NODE_ENV);
export const routerName = {
923: {
path: "/tagManagement",
name: "tagManagementGroup",
meta: {
title: "标签管理",
authId: "923",
parentId: "1",
cache: false,
},
},
92301: {
path: "/tagManagementList",
name: "tagManagement",
meta: {
title: "标签管理",
authId: "92301",
parentId: "923",
cache: false,
},
addRoutePath: [
{
authId: "92302",
name: "维护枚举值",
parentId: "92301",
},
],
auth: [
{
authId: "9230101",
parentId: "92301",
label: "新增子分类",
category: "Button",
type: "primary",
handle: "handleAddCategory",
},
{
authId: "9230102",
parentId: "92301",
label: "新增标签维度",
category: "Button",
type: "primary",
handle: "handleAddDimension",
},
{
authId: "9230103",
parentId: "92301",
label: "编辑",
handle: "handleEditCategory",
},
{
authId: "9230104",
parentId: "92301",
label: "新增枚举",
handle: "handleAddEnum",
},
{
authId: "9230105",
parentId: "92301",
label: "编辑",
handle: "handleEditDimension",
},
{
authId: "9230106",
parentId: "92301",
label: "编辑枚举",
handle: "handleEditEnum",
},
{
authId: "9230108",
parentId: "92301",
label: "维护枚举值",
handle: "handleMaintainEnum",
addRoutePath: [
{
authId: "92302",
name: "维护枚举值",
parentId: "92301",
},
],
},
],
component: _import("tagCustomerManagement/tagManagement/index"),
},
92302: {
path: "/tagEnumMaintain",
name: "tagEnumMaintain",
meta: {
title: "维护枚举值",
authId: "92302",
parentId: "92301",
cache: false,
sideHidden: true,
activePath: "/tagManagementList",
},
auth: [
{
authId: "9230104",
parentId: "92302",
label: "新增枚举值",
category: "Button",
type: "primary",
handle: "handleAddEnum",
},
{
authId: "9230106",
parentId: "92302",
label: "编辑枚举",
handle: "handleEditEnum",
},
],
component: _import("tagCustomerManagement/tagManagement/enumMaintain/index"),
},
};
<template>
<section class="detail-card">
<h3 class="detail-card__title">
基础信息
</h3>
<el-row :gutter="16">
<el-col
v-for="item in fieldList"
:key="item.prop"
class="detail-row"
:span="item.span || 8"
>
<span class="detail-label">{{ item.label }}:</span>
<span class="detail-value">{{ displayInfo[item.prop] || "-" }}</span>
</el-col>
</el-row>
</section>
</template>
<script>
import { CUSTOMER_STATUS_LIST, mapBasicInfoFromRow } from "../utils/customerSnapshot";
export default {
name: "CustomerBasicInfoCard",
props: {
customerRow: {
type: Object,
default: () => ({}),
},
basicInfo: {
type: Object,
default: () => ({}),
},
statusList: {
type: Array,
default: () => CUSTOMER_STATUS_LIST,
},
},
computed: {
displayInfo() {
const fromRow = mapBasicInfoFromRow(this.customerRow, this.statusList);
if (this.basicInfo && Object.keys(this.basicInfo).length) {
return {
...fromRow,
...this.basicInfo,
// 客户分类、客户状态仅来自列表行数据,详情接口不返回
customerCategory: fromRow.customerCategory,
customerStatus: fromRow.customerStatus,
};
}
return fromRow;
},
fieldList() {
return [
{ label: "客户姓名", prop: "customerName" },
{ label: "手机号", prop: "mobile" },
{ label: "客户分类", prop: "customerCategory" },
{ label: "品牌车型", prop: "carModel" },
{ label: "客户状态", prop: "customerStatus" },
{ label: "服务时间", prop: "serviceTime" },
{ label: "备注", prop: "remark", span: 24 },
{ label: "流量来源", prop: "trafficSource" },
{ label: "推荐人", prop: "referrer" },
{ label: "园区店", prop: "parkStore" },
{ label: "转化专员", prop: "conversionStaff" },
{ label: "群关联信息", prop: "groupRelInfo" },
{ label: "创建方式", prop: "createMethod" },
{ label: "创建时间", prop: "createTime" },
{ label: "交车时间", prop: "deliveryTime" },
];
},
},
};
</script>
<style lang="scss" scoped>
.detail-card {
background: #fff;
border-radius: 4px;
padding: 16px 20px 8px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.detail-row {
margin-bottom: 14px;
font-size: 14px;
line-height: 22px;
}
.detail-label {
color: #606266;
}
.detail-value {
color: #303133;
word-break: break-all;
}
</style>
<template>
<d2-container v-loading="pageLoading" class="customer-group-rel-page">
<div class="page-content">
<CustomerBasicInfoCard :basic-info="groupData.basicInfo"
:customer-row="customerRow" />
<section class="detail-card">
<h3 class="detail-card__title">
群关联
</h3>
<div v-for="item in groupFieldList"
:key="item.prop"
class="field-row">
<span class="field-label">{{ item.label }}:</span>
<span class="field-value">{{ displayGroupInfo[item.prop] || "-" }}</span>
</div>
</section>
<div class="footer-actions">
<el-button size="medium"
type="primary"
@click="handleBack">
返回
</el-button>
</div>
</div>
</d2-container>
</template>
<script>
import { queryCustomerGroups } from "@api/customerDetail";
import CustomerBasicInfoCard from "../components/CustomerBasicInfoCard.vue";
import { loadCustomerSnapshot, mapGroupAssocResponse, resolveCustomerRowFromRoute } from "../utils/customerSnapshot";
export default {
name: "CustomerGroupRel",
components: { CustomerBasicInfoCard },
data() {
return {
pageLoading: false,
customerId: "",
customerRow: {},
groupData: {
basicInfo: {},
groupRelStatus: "",
groupName: "",
groupMemberCustomer: "",
},
};
},
computed: {
groupFieldList() {
return [
{ label: "群关联状态", prop: "groupRelStatus" },
{ label: "群名称", prop: "groupName" },
{ label: "群成员-客户", prop: "groupMemberCustomer" },
];
},
displayGroupInfo() {
return {
groupRelStatus: this.groupData.groupRelStatus || "未关联",
groupName: this.groupData.groupName || "",
groupMemberCustomer: this.groupData.groupMemberCustomer || "",
};
},
},
created() {
this.customerId = this.$route.query.customerId;
if (!this.customerId) {
this.$message.warning("缺少客户参数");
this.$router.back();
return;
}
this.customerRow = resolveCustomerRowFromRoute(
this.$route,
loadCustomerSnapshot(),
);
this.loadGroupInfo();
},
methods: {
async loadGroupInfo() {
this.pageLoading = true;
try {
const res = await queryCustomerGroups({
id: this.customerId,
});
this.applyGroupData(mapGroupAssocResponse(res || {}, this.customerRow));
} catch (err) {
this.$message.error(err.message || "加载群关联失败");
this.applyGroupData(mapGroupAssocResponse({}, this.customerRow));
} finally {
this.pageLoading = false;
}
},
applyGroupData(res) {
this.groupData = {
basicInfo: res.basicInfo || {},
groupRelStatus: res.groupRelStatus || "未关联",
groupName: res.groupName || "",
groupMemberCustomer: res.groupMemberCustomer || "",
};
},
handleBack() {
this.$router.push({ name: "customerList" });
},
},
};
</script>
<style lang="scss" scoped>
.customer-group-rel-page {
::v-deep .d2-container-full__body {
padding: 0 !important;
background: #f0f2f5;
}
.page-content {
width: 100%;
box-sizing: border-box;
padding: 12px 20px 32px;
}
.detail-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 16px 20px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.field-row {
display: flex;
align-items: flex-start;
margin-bottom: 14px;
font-size: 14px;
line-height: 22px;
&:last-child {
margin-bottom: 0;
}
}
.field-label {
flex-shrink: 0;
min-width: 110px;
color: #606266;
}
.field-value {
flex: 1;
color: #303133;
word-break: break-all;
}
.footer-actions {
margin-top: 8px;
padding: 16px 0 8px;
text-align: center;
}
}
</style>
...@@ -14,34 +14,36 @@ ...@@ -14,34 +14,36 @@
</div> </div>
<p class="date-y-line" /> <p class="date-y-line" />
</template> </template>
<el-button icon="el-icon-d-arrow-left" <el-button class="arrow-left-icon"
icon="el-icon-d-arrow-left"
type="text" type="text"
class="arrow-left-icon"
:disabled="currentWeek === 1" :disabled="currentWeek === 1"
@click="handleWeek(false)" /> @click="handleWeek(false)" />
<template> <template>
<div class="date-picker"> <div class="date-picker">
<div class="wrapper" <div v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)"
v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)" :key="index"
:key="index"> class="wrapper">
<span> <span>
<p v-for="(info, infoIndex) in appointData[index].infoList" <p v-for="(info, infoIndex) in appointData[index].infoList"
:key="infoIndex"> :key="infoIndex">
<el-popover placement="bottom-start" <el-popover open-delay="600"
placement="bottom-start"
title="" title=""
width="200"
open-delay="600"
trigger="hover" trigger="hover"
width="200"
:disabled="info.status === 0"> :disabled="info.status === 0">
<div> <div>
<p>1、客户姓名,时间,项目</p> <p>1、客户姓名,时间,项目</p>
<p>2、客户姓名,时间,项目</p> <p>2、客户姓名,时间,项目</p>
<p>余位数:8</p> <p>余位数:8</p>
</div> </div>
<el-button :class="{'col-width': true, 'hour-template': true, 'status-full': info.status === 2, 'status-remain': info.status === 1 }" <el-button slot="reference"
slot="reference" class="col-width hour-template"
:class="{ 'status-full': info.status === 2, 'status-remain': info.status === 1 }"
@click="handleAppoint(item, infoIndex)"> @click="handleAppoint(item, infoIndex)">
{{ appointStatusList[info.status] }}</el-button> {{ appointStatusList[info.status] }}
</el-button>
</el-popover> </el-popover>
</p> </p>
</span> </span>
...@@ -49,13 +51,14 @@ ...@@ -49,13 +51,14 @@
</div> </div>
<p class="date-x-line" /> <p class="date-x-line" />
<div class="date-picker"> <div class="date-picker">
<div class="wrapper" <div v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)"
v-for="(item, index) in dateList.slice(currentWeek * 7 - 7, currentWeek * 7)" :key="index"
:key="index"> class="wrapper">
<el-button type="text" <el-button class="date-btn col-width"
:class="{'date-btn': true, 'col-width': true, 'active': item.active}" type="text"
:class="{ active: item.active }"
@click="handleSelectDate(index)"> @click="handleSelectDate(index)">
<p>{{ item.date.split('/')[1] + '.' + item.date.split('/')[2] }}</p> <p>{{ `${item.date.split('/')[1]}.${item.date.split('/')[2]}` }}</p>
<p>{{ weekList[item.week] }}</p> <p>{{ weekList[item.week] }}</p>
</el-button> </el-button>
</div> </div>
...@@ -70,59 +73,60 @@ ...@@ -70,59 +73,60 @@
</template> </template>
<script> <script>
import { appointDays } from '@/common/format' import { appointDays } from "@/common/format";
export default {
name: 'TimeDate',
data() {
return {
// 7天为一个周期,预约时间为35天,一共5个周期,当前周期
currentWeek: 1,
// 日期
dateIndex: 0,
weekList: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
dateList: new Array(appointDays).fill(null).map((item, index) => {
var date = new Date(new Date().setDate(new Date().getDate() + index))
return {
date: date.toLocaleDateString(),
week: date.getDay(),
active: !index
}
}),
// 时间
appointStatusList: ['空', '余', '满']
}
},
props: { export default {
appointData: { name: "TimeDate",
type: Array,
default: () => []
},
hoursList: {
type: Array,
default: () => []
}
},
mounted() { }, props: {
appointData: {
type: Array,
default: () => [],
},
hoursList: {
type: Array,
default: () => [],
},
},
data() {
return {
// 7天为一个周期,预约时间为35天,一共5个周期,当前周期
currentWeek: 1,
// 日期
dateIndex: 0,
weekList: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
dateList: new Array(appointDays).fill(null).map((item, index) => {
let date = new Date(new Date().setDate(new Date().getDate() + index));
return {
date: date.toLocaleDateString(),
week: date.getDay(),
active: !index,
};
}),
// 时间
appointStatusList: ["空", "余", "满"],
};
},
methods: { mounted() { },
// 日期选择
handleSelectDate(currentIndex) {
// this.dateList[this.dateIndex].active = false
// this.dateIndex = currentIndex
// this.dateList[currentIndex].active = true
},
handleAppoint(date, hourIndex) {
// this.$emit('handleAppoint', { date: date.date, hour: this.hoursList[hourIndex].hour })
},
handleWeek(isAdd) {
isAdd ? this.currentWeek++ : this.currentWeek--
}
}
}
methods: {
// 日期选择
handleSelectDate(currentIndex) {
// this.dateList[this.dateIndex].active = false
// this.dateIndex = currentIndex
// this.dateList[currentIndex].active = true
},
handleAppoint(date, hourIndex) {
// this.$emit('handleAppoint', { date: date.date, hour: this.hoursList[hourIndex].hour })
},
handleWeek(isAdd) {
isAdd ? this.currentWeek++ : this.currentWeek--;
},
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./css/timeDateStyle.scss"; @import "./css/timeDateStyle.scss";
</style> </style>
<template>
<d2-container v-loading="pageLoading" class="customer-portrait-page">
<div class="page-content">
<CustomerBasicInfoCard :basic-info="portraitData.basicInfo"
:customer-row="customerRow" />
<section class="detail-card">
<h3 class="detail-card__title">
消费力标签({{ consumptionScore }}分)
</h3>
<template v-if="consumptionDimensions.length">
<div v-for="(dimension, index) in consumptionDimensions"
:key="`consumption-${index}`"
class="field-row">
<span class="field-label">{{ dimension.dimensionName }}:</span>
<div class="tag-list">
<template v-if="dimension.tags.length">
<el-tag v-for="(tag, tagIndex) in dimension.tags"
:key="`consumption-tag-${index}-${tagIndex}`"
class="tag-item"
size="small">
{{ tag }}
</el-tag>
</template>
<span v-else class="empty-text">-</span>
</div>
</div>
</template>
<div v-else class="field-row">
<span class="empty-text">-</span>
</div>
</section>
<section class="detail-card">
<h3 class="detail-card__title">
产品标签({{ productScore }}分)
</h3>
<template v-if="productDimensions.length">
<div v-for="(dimension, index) in productDimensions"
:key="`product-${index}`"
class="field-row">
<span class="field-label">{{ dimension.dimensionName }}:</span>
<div class="tag-list">
<template v-if="dimension.tags.length">
<el-tag v-for="(tag, tagIndex) in dimension.tags"
:key="`product-tag-${index}-${tagIndex}`"
class="tag-item"
size="small">
{{ tag }}
</el-tag>
</template>
<span v-else class="empty-text">-</span>
</div>
</div>
</template>
<div v-else class="field-row">
<span class="empty-text">-</span>
</div>
</section>
<section class="detail-card">
<h3 class="detail-card__title">
行为标签({{ behaviorScore }}分)
</h3>
<el-table class="behavior-table"
size="small"
border
:data="behaviorTagList">
<el-table-column align="center"
label="序号"
type="index"
width="60" />
<el-table-column align="center"
label="标签维度"
min-width="200"
prop="dimensionName" />
<el-table-column align="center"
label="枚举值"
min-width="120">
<template #default="scope">
<el-tag v-if="scope.row.enumName"
class="tag-item"
size="small">
{{ scope.row.enumName }}
</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="left"
label="依据"
min-width="320"
prop="basis">
<template #default="scope">
<span class="basis-text">{{ scope.row.basis || "-" }}</span>
</template>
</el-table-column>
</el-table>
</section>
<div class="footer-actions">
<el-button size="medium"
type="primary"
@click="handleBack">
返回
</el-button>
</div>
</div>
</d2-container>
</template>
<script>
import { queryCustomerPortrait } from "@api/customerDetail";
import CustomerBasicInfoCard from "../components/CustomerBasicInfoCard.vue";
import {
loadCustomerSnapshot,
mapProfileResponse,
resolveCustomerRowFromRoute,
} from "../utils/customerSnapshot";
export default {
name: "CustomerPortrait",
components: { CustomerBasicInfoCard },
data() {
return {
pageLoading: false,
customerId: "",
customerRow: {},
portraitData: {
basicInfo: {},
consumptionScore: 0,
consumptionDimensions: [],
productScore: 0,
productDimensions: [],
behaviorScore: 0,
behaviorTagList: [],
},
};
},
computed: {
consumptionScore() {
return this.portraitData.consumptionScore || 0;
},
productScore() {
return this.portraitData.productScore || 0;
},
behaviorScore() {
return this.portraitData.behaviorScore || 0;
},
consumptionDimensions() {
return this.portraitData.consumptionDimensions || [];
},
productDimensions() {
return this.portraitData.productDimensions || [];
},
behaviorTagList() {
return this.portraitData.behaviorTagList || [];
},
},
created() {
this.customerId = this.$route.query.customerId;
if (!this.customerId) {
this.$message.warning("缺少客户参数");
this.$router.back();
return;
}
this.customerRow = resolveCustomerRowFromRoute(
this.$route,
loadCustomerSnapshot(),
);
this.loadPortrait();
},
methods: {
async loadPortrait() {
this.pageLoading = true;
try {
const res = await queryCustomerPortrait({
id: this.customerId,
});
this.applyPortraitData(
mapProfileResponse(res || {}, this.customerRow),
);
} catch (err) {
this.$message.error(err.message || "加载客户画像失败");
this.applyPortraitData(
mapProfileResponse({}, this.customerRow),
);
} finally {
this.pageLoading = false;
}
},
applyPortraitData(res) {
this.portraitData = {
basicInfo: res.basicInfo || {},
consumptionScore: res.consumptionScore || 0,
consumptionDimensions: res.consumptionDimensions || [],
productScore: res.productScore || 0,
productDimensions: res.productDimensions || [],
behaviorScore: res.behaviorScore || 0,
behaviorTagList: res.behaviorTagList || [],
};
},
handleBack() {
this.$router.push({ name: "customerList" });
},
},
};
</script>
<style lang="scss" scoped>
.customer-portrait-page {
::v-deep .d2-container-full__body {
padding: 0 !important;
background: #f0f2f5;
}
.page-content {
width: 100%;
box-sizing: border-box;
padding: 12px 20px 32px;
}
.detail-card {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 16px 20px;
margin-bottom: 12px;
&__title {
margin: 0 0 16px;
padding-left: 10px;
border-left: 3px solid #409eff;
font-size: 14px;
font-weight: 600;
color: #303133;
line-height: 20px;
}
}
.field-row {
display: flex;
align-items: flex-start;
margin-bottom: 12px;
font-size: 14px;
line-height: 22px;
&:last-child {
margin-bottom: 0;
}
}
.field-label {
flex-shrink: 0;
min-width: 90px;
color: #606266;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
flex: 1;
}
.tag-item {
background: #ecf5ff;
border-color: #d9ecff;
color: #409eff;
&--plain {
background: #f4f4f5;
border-color: #e9e9eb;
color: #909399;
}
}
.empty-text {
color: #909399;
}
.behavior-table {
width: 100%;
}
.basis-text {
display: inline-block;
word-break: break-all;
white-space: pre-wrap;
line-height: 20px;
color: #606266;
}
.footer-actions {
margin-top: 8px;
padding: 16px 0 8px;
text-align: center;
}
}
</style>
const SNAPSHOT_KEY = "customerDetailSnapshot";
export const CUSTOMER_STATUS_LIST = [
{ confId: 1, confLabel: "待跟进" },
{ confId: 2, confLabel: "已升级" },
{ confId: 3, confLabel: "战败" },
{ confId: 4, confLabel: "已退款" },
];
export function saveCustomerSnapshot(row) {
if (!row) {
return;
}
try {
sessionStorage.setItem(SNAPSHOT_KEY, JSON.stringify(row));
} catch (err) {
// ignore quota errors
}
}
export function loadCustomerSnapshot() {
try {
const raw = sessionStorage.getItem(SNAPSHOT_KEY);
return raw ? JSON.parse(raw) : {};
} catch (err) {
return {};
}
}
/** 合并列表行快照与路由参数,客户分类仅来自列表数据 */
export function resolveCustomerRowFromRoute(route = {}, snapshotRow = {}) {
const row = { ...snapshotRow };
if (route.query && route.query.customerClass) {
row.customerClass = route.query.customerClass;
}
if (route.query && route.query.customerStatus !== undefined && route.query.customerStatus !== "") {
row.customerStatus = route.query.customerStatus;
}
return row;
}
function formatDateValue(value) {
if (!value) {
return "";
}
return new Date(value).toLocaleDateString();
}
export function formatCarModel(row = {}) {
const carModel = (row.carModel || "").trim();
if (carModel) {
return carModel;
}
const parts = [row.carBrand, row.carSeriesName, row.carTypeName]
.map(item => (item || "").trim())
.filter(Boolean);
return parts.length ? parts.join("-") : "";
}
export function formatCarModelForList(row = {}) {
const value = formatCarModel(row);
return value || "";
}
export function formatListPhone(row = {}) {
return row.customerPhone || row.mobile || row.phone || row.phoneNumber || "";
}
export function formatCustomerClass(row = {}) {
const customerClass = row.customerClass || row.customerCategory;
if (!customerClass) {
return "";
}
const normalized = String(customerClass).trim().toUpperCase();
if (normalized === "A" || normalized === "A类") {
return "A类";
}
if (normalized === "B" || normalized === "B类") {
return "B类";
}
if (normalized === "C" || normalized === "C类") {
return "C类";
}
return String(customerClass);
}
export function formatGroupStatus(row = {}) {
if (row.groupStatus === true || row.groupStatus === "已关联") {
return "已关联";
}
return "未关联";
}
export function formatDeliveryTime(row = {}) {
const time = row.deliveryDate;
return formatDateValue(time);
}
export function formatRecorder(row = {}) {
return row.userName || row.advanceUserName || row.createdBy || "";
}
export function formatReferrer(row = {}) {
return row.referrerName
|| row.employeeName
|| (row.order && row.order.employeeName)
|| "";
}
export function formatCustomerStatus(row = {}, statusList = CUSTOMER_STATUS_LIST) {
const customerStatus = row.customerStatus;
if (customerStatus == null || customerStatus === "") {
return "-";
}
const matched = statusList.find(item => Number(item.confId) === Number(customerStatus));
return matched ? matched.confLabel : "-";
}
export function formatServiceTime(row = {}) {
const time = row.order && row.order.installUpgradeTime;
if (!time) {
return "-";
}
return new Date(time).toLocaleDateString();
}
export function formatRemark(row = {}) {
if (!row.order) {
return "无";
}
if (row.order.upgradeFlag === "N") {
return row.order.customer
? (row.order.customer.refusalReason || "无")
: "无";
}
return row.order.remark || "无";
}
export function formatSource(row = {}) {
const source = row.order ? row.order.source : row.source;
if (source === 3) {
return "现场升级";
}
if (source === 5) {
return "核销抵扣";
}
return "系统录入";
}
export function formatCreateTime(row = {}) {
if (!row.createdDate) {
return "";
}
return formatDateValue(row.createdDate);
}
export function mapBasicInfoFromRow(row = {}, statusList = CUSTOMER_STATUS_LIST) {
const deliveryTime = formatDeliveryTime(row);
const referrer = formatReferrer(row);
const recorder = formatRecorder(row);
return {
customerName: row.customerName || "-",
mobile: formatListPhone(row) || "-",
customerCategory: formatCustomerClass(row) || "-",
carModel: formatCarModel(row) || "-",
customerStatus: formatCustomerStatus(row, statusList),
serviceTime: formatServiceTime(row),
remark: formatRemark(row),
trafficSource: row.merchantName || "-",
referrer: referrer || "-",
parkStore: row.yqMerchantName || "-",
conversionStaff: (row.order && row.order.sellerName) || "-",
groupRelInfo: formatGroupStatus(row),
createMethod: formatSource(row),
createTime: formatCreateTime(row) || "-",
deliveryTime: deliveryTime || "-",
recorder: recorder || "-",
};
}
function buildProfileCarModel(res = {}) {
const carModel = (res.carModel || "").trim();
if (carModel) {
return carModel;
}
const parts = [res.carBrand, res.carSeriesName]
.map(item => (item || "").trim())
.filter(Boolean);
return parts.length ? parts.join("-") : "";
}
export function mapProfileResponse(res = {}, snapshotRow = {}) {
const snapshotBasic = mapBasicInfoFromRow(snapshotRow);
const deliveryTime = res.deliveryDate
? formatDateValue(res.deliveryDate)
: snapshotBasic.deliveryTime;
const basicInfo = {
...snapshotBasic,
customerName: res.customerName || snapshotBasic.customerName,
mobile: res.customerPhone || snapshotBasic.mobile,
carModel: buildProfileCarModel(res) || snapshotBasic.carModel,
trafficSource: res.merchantName || snapshotBasic.trafficSource,
deliveryTime: deliveryTime || "-",
// 客户分类、客户状态仅来自列表接口,详情接口不返回
customerCategory: snapshotBasic.customerCategory,
customerStatus: snapshotBasic.customerStatus,
};
const consumptionTag = res.consumptionTag || {};
const productTag = res.productTag || {};
const behaviorTag = res.behaviorTag || {};
const consumptionDimensions = (consumptionTag.dimensions || []).map(dimension => ({
dimensionName: dimension.dimensionName || "-",
tags: (dimension.enumValues || []).map(item => item.enumName).filter(Boolean),
}));
const productDimensions = [];
const dealTags = (productTag.dealEnumValues || [])
.map(item => item.enumName)
.filter(Boolean);
if (dealTags.length) {
productDimensions.push({ dimensionName: "已成交品类", tags: dealTags });
}
const noDealTags = (productTag.noDealEnumValues || [])
.map(item => item.enumName)
.filter(Boolean);
if (noDealTags.length) {
productDimensions.push({ dimensionName: "未成交品类", tags: noDealTags });
}
const behaviorTagList = [];
(behaviorTag.dimensions || []).forEach((dimension) => {
(dimension.enumValues || []).forEach((enumValue) => {
behaviorTagList.push({
dimensionName: dimension.dimensionName || "-",
enumName: enumValue.enumName || "",
basis: enumValue.scoreBasis || "",
});
});
});
return {
basicInfo,
consumptionScore: consumptionTag.totalScore || 0,
consumptionDimensions,
productScore: productTag.totalScore || 0,
productDimensions,
behaviorScore: behaviorTag.totalScore || 0,
behaviorTagList,
};
}
export function mapGroupAssocResponse(res = {}, snapshotRow = {}) {
const snapshotBasic = mapBasicInfoFromRow(snapshotRow);
const groupRelStatus = res.groupStatus || "未关联";
const basicInfo = {
...snapshotBasic,
customerName: res.customerName || snapshotBasic.customerName,
mobile: res.customerPhone || snapshotBasic.mobile,
// 客户分类、客户状态仅来自列表接口,详情接口不返回
customerCategory: snapshotBasic.customerCategory,
customerStatus: snapshotBasic.customerStatus,
// 接口返回后同步基础信息中的群关联状态
groupRelInfo: groupRelStatus,
};
return {
basicInfo,
groupRelStatus,
groupName: res.qwGroupName || "",
groupMemberCustomer: res.wxName || "",
};
}
...@@ -101,6 +101,16 @@ import multipleMixin from "./multipleMixin"; ...@@ -101,6 +101,16 @@ import multipleMixin from "./multipleMixin";
export default { export default {
name: "MultipleRecording", name: "MultipleRecording",
mixins: [multipleMixin], mixins: [multipleMixin],
props: {
/**
* biz: 业务类型
* 1.延保 2.轻改 3.权益 4.二手车
*/
biz: {
type: Number,
default: 1,
},
},
data() { data() {
return { return {
dialogConfig: { dialogConfig: {
...@@ -183,6 +193,14 @@ export default { ...@@ -183,6 +193,14 @@ export default {
mounted() { mounted() {
}, },
methods: { methods: {
beforeSearchFn() {
// 1.延保 2.轻改 3.权益 4.二手车 延保和权益都传1
return new Promise((resolve) => {
this.searchFormSearch = this.getParams();
this.searchFormSearch.businessType = this.biz == 3 ? 1 : this.biz;
resolve();
});
},
getParams() { getParams() {
let params = this.deepClone(this.searchForm); let params = this.deepClone(this.searchForm);
if (params.receptionDate) { if (params.receptionDate) {
......
...@@ -149,6 +149,7 @@ ...@@ -149,6 +149,7 @@
@dialogClose="staffTag1Visible = false"> @dialogClose="staffTag1Visible = false">
</MultipleStaff> </MultipleStaff>
<MultipleRecording ref="recordingTagRef" <MultipleRecording ref="recordingTagRef"
:biz="biz"
:choose-data="formData.recordingList" :choose-data="formData.recordingList"
:visible="recordingTagVisible" :visible="recordingTagVisible"
@choose="formatMultipleList($event, 'recordingList')" @choose="formatMultipleList($event, 'recordingList')"
......
...@@ -230,7 +230,7 @@ export default { ...@@ -230,7 +230,7 @@ export default {
formatter: row => formatThousand(row.dayEndBalance), formatter: row => formatThousand(row.dayEndBalance),
}, },
{ {
label: "待补录订单", label: "待补录未分账订单",
prop: "waitInputMoney", prop: "waitInputMoney",
minWidth: "90px", minWidth: "90px",
formatter: row => formatThousand(row.waitInputMoney), formatter: row => formatThousand(row.waitInputMoney),
...@@ -391,11 +391,11 @@ export default { ...@@ -391,11 +391,11 @@ export default {
}); });
}, },
handleOnlineDetail(row) { handleOnlineDetail(row) {
const { merchantId, merchantName, yqMerchantId, yqMerchantName } = row; const { yqMerchantId, yqMerchantName } = row;
const { startTradeTime: startTime, endTradeTime: endTime } = this.getParams(); const { startTradeTime: startTime, endTradeTime: endTime } = this.getParams();
this.$router.push({ this.$router.push({
name: "ysprepaymentDetail", name: "ysprepaymentDetail",
params: { merchantId, merchantName, yqMerchantId, yqMerchantName, startTime, endTime }, params: { yqMerchantId, yqMerchantName, startTime, endTime },
}); });
}, },
handleExport() { handleExport() {
......
const mockDivisionCountTotal = jest.fn();
const mockPaymentCountTotal = jest.fn();
jest.mock("@api/prepaymentManage", () => ({
divisionCountTotal: mockDivisionCountTotal,
onlineDivisionDetailPage: jest.fn(),
onlineDivisionMonthTotalPage: jest.fn(),
onlinePaymentDetailPage: jest.fn(),
onlinePaymentMonthTotalPage: jest.fn(),
paymentCountTotal: mockPaymentCountTotal,
}), { virtual: true });
jest.mock("@/mixins/reportTrackPageMixin", () => ({}));
const { shallowMount } = require("@vue/test-utils");
const OnlineDetail = require("./onlineDetail.vue").default;
const { ONLINE_DETAIL_TAB } = require("./onlineDetail.constant");
describe("onlineDetail summary", () => {
let wrapper;
const mountComponent = () => {
wrapper = shallowMount(OnlineDetail, {
mocks: {
$route: {
params: {
yqMerchantId: "merchant-1",
},
},
$router: {
push: jest.fn(),
},
$store: {
state: {
d2admin: {
user: {
dowloadList: [],
},
},
},
dispatch: jest.fn(),
},
},
stubs: [
"d2-container",
"el-tabs",
"el-tab-pane",
"d2-table-header",
"d2-table",
"el-button",
],
});
};
beforeEach(() => {
jest.clearAllMocks();
mockDivisionCountTotal.mockResolvedValue({
lightChangeAmount: 1000,
equityAmount: 2000,
extendedWarrantyAmount: 3000,
});
mockPaymentCountTotal.mockResolvedValue({});
mountComponent();
});
afterEach(() => {
wrapper && wrapper.destroy();
});
it("loads summary data before table search", async () => {
wrapper.setData({
activeName: ONLINE_DETAIL_TAB.SUMMARY_ALLOCATION,
});
await wrapper.vm.beforeSearchFn();
expect(mockPaymentCountTotal).toHaveBeenCalledWith({
yqMerchantId: "merchant-1",
});
expect(wrapper.vm.summaries).toEqual({});
});
it("returns summary row synchronously from cached summary data", () => {
wrapper.setData({
activeName: ONLINE_DETAIL_TAB.SUMMARY_ALLOCATION,
summaries: {
lightChangeAmount: 1000,
equityAmount: 2000,
extendedWarrantyAmount: 3000,
},
});
const result = wrapper.vm.getSummaries({
columns: [
{ property: "ownSerialNum" },
{ property: "lightChangeAmount" },
{ property: "equityAmount" },
{ property: "extendedWarrantyAmount" },
],
});
expect(Array.isArray(result)).toBe(true);
expect(result).toEqual(["合计", "1,000.00", "2,000.00", "3,000.00"]);
});
});
...@@ -18,11 +18,13 @@ ...@@ -18,11 +18,13 @@
</div> </div>
</d2-table-header> </d2-table-header>
<d2-table ref="usedCarFundWarningManageTable" <d2-table :key="tableKey"
:key="tableKey" ref="usedCarFundWarningManageTable"
show-summary
:before-search-fn="beforeSearchFn" :before-search-fn="beforeSearchFn"
:get-list-api="getListApi" :get-list-api="getListApi"
:search-form="searchFormSearch" :search-form="searchFormSearch"
:summary-method="getSummaries"
:table-params="tableParams"> :table-params="tableParams">
</d2-table> </d2-table>
</div> </div>
...@@ -35,17 +37,26 @@ ...@@ -35,17 +37,26 @@
</template> </template>
<script> <script>
import { onlineDivisionDetailPage, onlinePaymentDetailPage, onlinePaymentMonthTotalPage } from "@api/prepaymentManage"; import { divisionCountTotal, onlineDivisionDetailPage, onlineDivisionMonthTotalPage, onlinePaymentDetailPage, onlinePaymentMonthTotalPage, paymentCountTotal } from "@api/prepaymentManage";
import { mapActions, mapState } from "vuex"; import { mapActions, mapState } from "vuex";
import { formatThousand } from "@/common/format";
import reportTrackPageMixin from "@/mixins/reportTrackPageMixin"; import reportTrackPageMixin from "@/mixins/reportTrackPageMixin";
import { ONLINE_DETAIL_TAB, ONLINE_DETAIL_TABLE_COLUMNS } from "./onlineDetail.constant"; import { ONLINE_DETAIL_TAB, ONLINE_DETAIL_TABLE_COLUMNS } from "./onlineDetail.constant";
const ONLINE_DETAIL_API_MAP = { const ONLINE_DETAIL_API_MAP = {
[ONLINE_DETAIL_TAB.SUMMARY_COLLECTION]: onlinePaymentMonthTotalPage, [ONLINE_DETAIL_TAB.SUMMARY_COLLECTION]: onlinePaymentMonthTotalPage,
[ONLINE_DETAIL_TAB.DETAIL_COLLECTION]: onlinePaymentDetailPage, [ONLINE_DETAIL_TAB.DETAIL_COLLECTION]: onlinePaymentDetailPage,
[ONLINE_DETAIL_TAB.SUMMARY_ALLOCATION]: onlineDivisionMonthTotalPage,
[ONLINE_DETAIL_TAB.DETAIL_ALLOCATION]: onlineDivisionDetailPage, [ONLINE_DETAIL_TAB.DETAIL_ALLOCATION]: onlineDivisionDetailPage,
}; };
const TOTAL_API_MAP = {
[ONLINE_DETAIL_TAB.SUMMARY_COLLECTION]: paymentCountTotal,
[ONLINE_DETAIL_TAB.DETAIL_COLLECTION]: paymentCountTotal,
[ONLINE_DETAIL_TAB.SUMMARY_ALLOCATION]: divisionCountTotal,
[ONLINE_DETAIL_TAB.DETAIL_ALLOCATION]: divisionCountTotal,
};
export default { export default {
name: "UsedCarPaymentManage", name: "UsedCarPaymentManage",
components: { components: {
...@@ -65,6 +76,10 @@ export default { ...@@ -65,6 +76,10 @@ export default {
name: ONLINE_DETAIL_TAB.DETAIL_COLLECTION, name: ONLINE_DETAIL_TAB.DETAIL_COLLECTION,
}, },
{ {
label: "汇总-分账",
name: ONLINE_DETAIL_TAB.SUMMARY_ALLOCATION,
},
{
label: "明细-分账", label: "明细-分账",
name: ONLINE_DETAIL_TAB.DETAIL_ALLOCATION, name: ONLINE_DETAIL_TAB.DETAIL_ALLOCATION,
}, },
...@@ -77,9 +92,10 @@ export default { ...@@ -77,9 +92,10 @@ export default {
btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000), btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
listName: "list", listName: "list",
tableOption: false, tableOption: false,
tableColumns: ONLINE_DETAIL_TABLE_COLUMNS[ONLINE_DETAIL_TAB.SUMMARY_COLLECTION], tableColumns: ONLINE_DETAIL_TABLE_COLUMNS[ONLINE_DETAIL_TAB.SUMMARY_COLLECTION].tableColumns,
}, },
detailInfo: {}, detailInfo: {},
summaries: {},
}; };
}, },
computed: { computed: {
...@@ -87,11 +103,10 @@ export default { ...@@ -87,11 +103,10 @@ export default {
dowloadList: state => state.d2admin.user.dowloadList, dowloadList: state => state.d2admin.user.dowloadList,
}), }),
routerInfo() { routerInfo() {
console.log(this.$route.params);
return this.$route.params; return this.$route.params;
}, },
}, },
mounted() { created() {
this.searchFormSearch = { this.searchFormSearch = {
...this.routerInfo, ...this.routerInfo,
}; };
...@@ -103,11 +118,8 @@ export default { ...@@ -103,11 +118,8 @@ export default {
close: "d2admin/page/close", close: "d2admin/page/close",
}), }),
...mapActions("d2admin/user", ["actionSetDownloadList"]), ...mapActions("d2admin/user", ["actionSetDownloadList"]),
beforeSearchFn() { async beforeSearchFn() {
return new Promise((resolve) => { await this.getSummaryData();
// this.searchFormSearch = this.getParams()
resolve();
});
}, },
goBack() { goBack() {
this.$router.push({ this.$router.push({
...@@ -118,10 +130,11 @@ export default { ...@@ -118,10 +130,11 @@ export default {
return this.searchFormSearch; return this.searchFormSearch;
}, },
handleClick() { handleClick() {
this.summaries = {};
this.getListApi = ONLINE_DETAIL_API_MAP[this.activeName]; this.getListApi = ONLINE_DETAIL_API_MAP[this.activeName];
this.tableParams = { this.tableParams = {
...this.tableParams, ...this.tableParams,
tableColumns: ONLINE_DETAIL_TABLE_COLUMNS[this.activeName], tableColumns: ONLINE_DETAIL_TABLE_COLUMNS[this.activeName].tableColumns,
}; };
this.tableKey = this.activeName; this.tableKey = this.activeName;
}, },
...@@ -147,6 +160,31 @@ export default { ...@@ -147,6 +160,31 @@ export default {
]; ];
this.actionSetDownloadList({ list, type: "dowloadList" }); this.actionSetDownloadList({ list, type: "dowloadList" });
}, },
async getSummaryData() {
const res = await TOTAL_API_MAP[this.activeName]({ ...this.getParams() });
this.summaries = res || {};
},
getSummaries(param) {
const { columns } = param;
const { summaries } = this;
const sums = [];
const keyList = ONLINE_DETAIL_TABLE_COLUMNS[this.activeName].tableSummary;
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = "合计";
return;
}
const key = column.property;
if (keyList.includes(key)) {
const value = summaries[key];
sums[index]
= value != null || value != undefined ? formatThousand(value) : 0;
} else {
sums[index] = "";
}
});
return sums;
},
}, },
}; };
</script> </script>
......
<!-- 关联门店弹窗 --> <!-- 关联门店弹窗 -->
<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 ["门店名称", "门店地址", "门店商户号", "服务对接", "服务对接商户号"];
},
},
}, },
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.upgradeProductId || '-' }}</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 {
word-break: break-all;
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.upgradeProductId || '-' }}</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 {
word-break: break-all;
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 {
word-break: break-all;
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,
activityId: this.storeRow?.activityId,
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>
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);
}
const mockRequest = jest.fn();
const mockRequestMethods = { POST: "POST", GET: "GET" };
jest.mock("@/api/request", () => mockRequest);
jest.mock("@/api/request.methods", () => mockRequestMethods);
const {
getList,
getMarketingPushStrategyDetailApi,
createStrategy,
updateStrategy,
statusStrategy,
deleteStrategy,
confirmStrategy,
recordsStrategy,
recordDetail,
getMetaData,
getMetaOptionsApi,
} = require("./index.js");
describe("marketingPushStrategy api/index.js", () => {
beforeEach(() => {
jest.clearAllMocks();
});
it("getList 应追加 list 方法名并走默认请求方式", async () => {
const params = { pageNo: 1 };
mockRequest.mockResolvedValue({ list: [] });
await getList(params);
expect(mockRequest).toHaveBeenCalledWith({
pageNo: 1,
method: "dj.api.smartcarlife.sop.strategy.list",
});
});
it("详情与创建更新相关接口应使用 post", async () => {
mockRequest.mockResolvedValue({});
await getMarketingPushStrategyDetailApi({ strategyId: 1 });
await createStrategy({ strategyName: "A" });
await updateStrategy({ strategyId: 1 });
await statusStrategy({ strategyId: 1, status: 1 });
await deleteStrategy({ strategyId: 1 });
await confirmStrategy({ strategyIds: [1] });
await recordsStrategy({ strategyId: 1 });
await recordDetail({ recordId: 1 });
await getMetaData({});
expect(mockRequest.mock.calls).toEqual([
[{ strategyId: 1, method: "dj.api.smartcarlife.sop.strategy.query" }, "post"],
[{ strategyName: "A", method: "dj.api.smartcarlife.sop.strategy.create" }, "post"],
[{ strategyId: 1, method: "dj.api.smartcarlife.sop.strategy.update" }, "post"],
[{ strategyId: 1, status: 1, method: "dj.api.smartcarlife.sop.strategy.status" }, "post"],
[{ strategyId: 1, method: "dj.api.smartcarlife.sop.strategy.delete" }, "post"],
[{ strategyIds: [1], method: "dj.api.smartcarlife.sop.strategy.confirm" }, "post"],
[{ strategyId: 1, method: "dj.api.smartcarlife.sop.strategy.records" }, "post"],
[{ recordId: 1, method: "dj.api.smartcarlife.sop.strategy.record.detail" }, "post"],
[{ method: "dj.api.smartcarlife.sop.strategy.meta" }, "post"],
]);
});
it("getMetaOptionsApi 应默认空对象并使用 RequestMethods.POST", async () => {
mockRequest.mockResolvedValue({});
await getMetaOptionsApi();
await getMetaOptionsApi({ bizType: 1 });
expect(mockRequest.mock.calls).toEqual([
[
{ method: "dj.api.smartcarlife.sop.strategy.meta" },
mockRequestMethods.POST,
],
[
{ bizType: 1, method: "dj.api.smartcarlife.sop.strategy.meta" },
mockRequestMethods.POST,
],
]);
});
});
import { createLocalVue, shallowMount } from "@vue/test-utils";
jest.mock("@/views/marketingManagement/marketingPushStrategy/components/messageType", () => ({
name: "MessageType",
render(h) {
return h("div");
},
}));
const { MessageTypeEnum } = require("../../constant/index.js");
const ActionsItem = require("./index.vue").default;
describe("marketingPushStrategy components/actionsItem", () => {
const localVue = createLocalVue();
let wrapper;
function createWrapper(item = {}) {
wrapper = shallowMount(ActionsItem, {
localVue,
propsData: {
propPrefix: "branches[0].actions[0]",
options: {
messageVariables: [],
},
item: {
actionType: 1,
targetGroupType: 1,
messageType: MessageTypeEnum.VARIABLE_TEXT,
content: "",
medias: [],
pageTitle: "",
pageDesc: "",
bgColor: "",
materialJson: [],
intervalPx: undefined,
...item,
},
},
stubs: {
"el-button": true,
"el-form-item": true,
"el-select": true,
"el-option": true,
"el-radio-group": true,
"el-radio": true,
},
});
return wrapper;
}
function getErrorMessages(callback) {
return callback.mock.calls
.map(call => call[0])
.filter(arg => arg instanceof Error)
.map(error => error.message);
}
afterEach(() => {
if (wrapper) {
wrapper.destroy();
}
jest.clearAllMocks();
});
it("文本消息缺少内容时应报错", () => {
createWrapper({ messageType: MessageTypeEnum.VARIABLE_TEXT, content: "" });
const callback = jest.fn();
wrapper.vm.validateMessageType({}, undefined, callback);
expect(getErrorMessages(callback)).toContain("请输入消息内容");
});
it("图片消息缺少素材时应报错", () => {
createWrapper({ messageType: MessageTypeEnum.VARIABLE_IMAGE, medias: [] });
const callback = jest.fn();
wrapper.vm.validateMessageType({}, undefined, callback);
expect(getErrorMessages(callback)).toContain("请上传消息图片");
});
it("网页消息配置不完整时应报错", () => {
createWrapper({
messageType: MessageTypeEnum.VARIABLE_WEBPAGE,
pageTitle: "",
pageDesc: "",
bgColor: "",
materialJson: [],
intervalPx: undefined,
});
const callback = jest.fn();
wrapper.vm.validateMessageType({}, undefined, callback);
expect(getErrorMessages(callback)).toEqual(expect.arrayContaining([
"请编辑网页内容",
"网页内容的素材不可为空",
]));
});
it("合法配置应最终回调通过", () => {
createWrapper({
messageType: MessageTypeEnum.VARIABLE_VIDEO,
medias: [{ mediaUrl: "https://video.test/1.mp4" }],
});
const callback = jest.fn();
wrapper.vm.validateMessageType({}, undefined, callback);
expect(callback).toHaveBeenLastCalledWith();
});
it("应透传动作类型、消息类型和删除事件", () => {
createWrapper();
wrapper.vm.handleActionTypeChange(2);
wrapper.vm.handleMessageTypeChange({ messageType: 3 });
wrapper.vm.handleRemoveActions();
expect(wrapper.emitted("input")[0]).toEqual([
expect.objectContaining({ actionType: 2 }),
]);
expect(wrapper.emitted("input")[1]).toEqual([{ messageType: 3 }]);
expect(wrapper.emitted("remove")).toHaveLength(1);
});
});
<template>
<div class="actions-item-wrapper">
<div class="title-wrapper">
<div class="title">
{{ title }}
</div>
<el-button v-show="showDelActionBtn"
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 placeholder="请选择动作类型"
style="width:530px"
:value="item.actionType"
@change="handleActionTypeChange">
<el-option label="向客户群发送消息"
:value="1">
</el-option>
</el-select>
</el-form-item>
<el-form-item v-if="item.actionType === 1"
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 v-if="item.actionType === 1"
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: {
showDelActionBtn: {
type: Boolean,
default: true,
},
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: 32px;
}
.del-button {
border-style: dashed;
background: white;
transition: background-color 200ms;
&:hover {
background: #fef0f0;
color: #f56c6c;
}
}
}
}
</style>
import { createLocalVue, shallowMount } from "@vue/test-utils";
const mockGetDefaultAction = jest.fn();
const mockGetDefaultBranch = jest.fn();
jest.mock("@/views/marketingManagement/marketingPushStrategy/components/branchItem/index.vue", () => ({
name: "BranchItem",
render(h) {
return h("div");
},
}));
jest.mock("@/views/marketingManagement/marketingPushStrategy/constant", () => ({
getDefaultAction: mockGetDefaultAction,
getDefaultBranch: mockGetDefaultBranch,
}));
const BranchGroup = require("./index.vue").default;
describe("marketingPushStrategy components/branchGroup", () => {
const localVue = createLocalVue();
let wrapper;
let consoleLogSpy;
function createWrapper(propsData = {}) {
wrapper = shallowMount(BranchGroup, {
localVue,
propsData: {
list: [
{
_key: "branch-1",
conditionGroups: [],
actions: [{ _key: "action-1", content: "A" }],
},
],
...propsData,
},
stubs: {
"el-button": true,
},
});
return wrapper;
}
afterEach(() => {
if (wrapper) {
wrapper.destroy();
}
if (consoleLogSpy) {
consoleLogSpy.mockRestore();
}
jest.clearAllMocks();
});
beforeEach(() => {
consoleLogSpy = jest.spyOn(console, "log").mockImplementation(() => {});
});
it("handleBranchConditionChange 应更新指定分支条件", () => {
createWrapper();
wrapper.vm.handleBranchConditionChange({ conditionGroups: [{ id: 1 }] }, 0);
expect(wrapper.emitted("input")[0][0][0].conditionGroups).toEqual([{ id: 1 }]);
});
it("handleRemoveAction 应删除指定动作", () => {
createWrapper({
list: [
{
_key: "branch-1",
conditionGroups: [],
actions: [{ _key: "a1" }, { _key: "a2" }],
},
],
});
wrapper.vm.handleRemoveAction(0, 0);
expect(wrapper.emitted("input")[0][0][0].actions).toEqual([{ _key: "a2" }]);
});
it("handleAppendBranch 应追加默认分支", () => {
mockGetDefaultBranch.mockReturnValue({ _key: "branch-2", actions: [], conditionGroups: [] });
createWrapper();
wrapper.vm.handleAppendBranch();
expect(mockGetDefaultBranch).toHaveBeenCalledWith(1);
expect(wrapper.emitted("input")[0][0]).toHaveLength(2);
});
it("handleRemoveBranch 应删除指定分支", () => {
createWrapper({
list: [
{ _key: "branch-1", actions: [], conditionGroups: [] },
{ _key: "branch-2", actions: [], conditionGroups: [] },
],
});
wrapper.vm.handleRemoveBranch(0);
expect(wrapper.emitted("input")[0][0]).toEqual([
{ _key: "branch-2", actions: [], conditionGroups: [] },
]);
});
it("handleAppendAction 应追加默认动作", () => {
mockGetDefaultAction.mockReturnValue({ _key: "action-2" });
createWrapper();
wrapper.vm.handleAppendAction(0);
expect(mockGetDefaultAction).toHaveBeenCalled();
expect(wrapper.emitted("input")[0][0][0].actions).toEqual([
{ _key: "action-1", content: "A" },
{ _key: "action-2" },
]);
});
it("handleBranchChange 应替换指定动作", () => {
createWrapper();
wrapper.vm.handleBranchChange({
actionIndex: 0,
actionItem: { _key: "action-1", content: "B" },
}, 0);
expect(wrapper.emitted("input")[0][0][0].actions).toEqual([
{ _key: "action-1", content: "B" },
]);
});
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!