Commit 3cb4d42d by 张立顺

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

…stem into SAAS+V5.8.2_zls
2 parents a6765c90 3c246a4c
Showing 34 changed files with 473 additions and 217 deletions
##
### 仅给自动化流程时使用
请根据 git diff 为此处改动编写单元测试代码。
## 要求:
1. 严格遵循 /.ai/rules/JEST_TESTING.md 和 /.ai/rules/TESTING_GUIDE.md 中的规范
2. 使用 Jest 测试框架,遵循 AAA 模式(Arrange-Act-Assert)
3. 测试文件命名:*.spec.js,存放在与被测文件同级目录
## Mock 规范(必须遵守):
- 在测试文件顶部按顺序执行:定义 mock 函数 → jest.mock() → require() 导入被测试模块
- 每次测试前使用 jest.clearAllMocks() 重置 mock
- 组件测试在 afterEach 中调用 wrapper.destroy()
## 输出格式:
1. 📂 测试文件路径:[完整路径]
2. 📝 测试代码:[完整的测试代码,可直接运行]
......@@ -17,7 +17,6 @@ npx playwright test tests/e2e/xxx.spec.js
# 核心规范(必须严格遵守)
## 1. 测试分类与文件存放规范
请根据我的要求,将测试严格分类,并【在回复中明确指出该测试文件应该存放的路径】:
* 【单元测试 (Unit Test)】
- 命名格式:`*.spec.js`
......@@ -31,14 +30,37 @@ npx playwright test tests/e2e/xxx.spec.js
* 【E2E 测试 (End-to-End Test)】
- 命名格式:`*.e2e.js`
- 存放位置:必须独立于 src,统一存放在项目根目录的 【`/e2e`】 文件夹下。
- 存放位置:必须独立于 src,统一存放在项目根目录的【`/e2e`】文件夹下。
- 测试原则:站在真实用户视角测试完整业务流,不涉及任何 Vue 内部实现细节。
## 2. Vue 2 测试代码编写守则
## 2. 测试编写原则
**重要:如果单元测试暴露出来业务代码的问题,不要修改业务代码,只修复测试代码。**
业务代码的逻辑应该由业务需求驱动,而不是为了通过测试而修改。
## 3. Vue 2 测试代码编写守则
* 【内存泄露防护】:在单测和集成测试的 `afterEach` 钩子中,必须调用 `wrapper.destroy()` 销毁实例。
* 【异步处理】:遇到事件触发、数据改变后影响 DOM 的情况,必须使用 `await localVue.nextTick()` 或 `await wrapper.vm.$nextTick()`。
* 【Vuex 注入】:如果组件依赖 Vuex,必须使用 `createLocalVue()` 并注入对应的局部 store module,禁止直接污染全局 store。
* 【测试用例结构】:遵循 AAA 模式(Arrange 准备数据, Act 执行操作, Assert 断言结果)。描述性文字(`describe`, `it`)要清晰表达业务意图。
* 【测试用例结构】:遵循 AAA 模式(Arrange 准备数据,Act 执行操作,Assert 断言结果)。描述性文字(`describe`, `it`)要清晰表达业务意图。
## 4. E2E 测试编写指南
### 测试场景设计
- 从真实用户视角出发,测试完整业务流程
- 覆盖主要功能路径和常见边缘情况
- 验证页面导航、数据展示、表单交互等
### 最佳实践
- 使用 `test.beforeEach` 进行登录等前置操作
- 使用 `page.waitForLoadState('networkidle')` 等待异步请求完成
- 使用有意义的测试用例名称,描述业务意图
- 截图和录屏仅在失败时保存(已在配置中设置)
### 文件命名
- 格式:`*.e2e.js`
- 示例:`e2e/taskCenter.e2e.js`
---
......@@ -47,13 +69,60 @@ npx playwright test tests/e2e/xxx.spec.js
1. 💡 这是一个 [单元测试 / 集成测试 / E2E 测试]。
2. 📂 推荐的文件存放路径是:`[具体路径/文件名]`
3. 📝 测试代码:[具体的测试代码]
### E2E 测试 (End-to-End Tests)
存放位置:放在项目根目录的 e2e/ 文件夹下。
原因:Vue 2 官方早期推荐的 vue-cli 工具链(如 Cypress 或 Nightwatch 插件)默认也会在根目录生成 tests/e2e。由于 E2E 模拟的是真实用户在浏览器里点来点去,它会经历“登录 -> 个人中心 -> 购物车 -> 结账”一整套完整业务,无法归属于任何一个单一的 feature 目录,所以必须独立出来。
## 已修改的配置文件
- `jest.config.js` - 添加了 transformIgnorePatterns
- `package.json` - 修复了 test:unit 脚本,添加了 test:unit:legacy
- `playwright.config.js` - 新增 E2E 测试配置
---
## 5. E2E 登录态处理(重要)
### 问题背景
本项目(D2Admin + Vuex)的登录态判断依赖 **Vuex 内存状态**(`store.state.d2admin.user.info`),
而非仅 Cookie/Token。路由守卫逻辑:
```
store.state.d2admin.user.info 存在 → 放行
store.state.d2admin.user.info 为空 → 跳转 /login
```
Playwright 的 `storageState` 只能持久化 **Cookie + localStorage**,无法保存 Vuex 内存,
因此每个新 browser context 都会丢失登录态,无法通过 `storageState` 跨 context 保持登录。
### 解决方案:共享 context
**不动业务代码**,在 `beforeAll` 中创建 context 并登录一次,同一个 describe 内的
所有 test 复用同一个 `sharedPage`,Vuex 内存态自然保持。
```js
let sharedPage;
test.beforeAll(async ({ browser }) => {
const context = await browser.newContext();
sharedPage = await context.newPage();
await sharedPage.goto("/#/login");
await sharedPage.getByPlaceholder("账户").fill("xxx");
await sharedPage.getByPlaceholder("密码").fill("xxx");
await sharedPage.getByRole("button", { name: "登录" }).click();
await sharedPage.waitForURL(/#\/index/);
});
test("用例1", async () => {
await sharedPage.goto("/#/target-page"); // 复用已登录的 page
});
test.afterAll(async () => {
await sharedPage.context().close();
});
```
### 注意事项
1. **不使用 Playwright 默认的 `page` fixture**,改用闭包变量 `sharedPage`
2. **每个 test 开头做 `goto`** 导航到目标页面,用 URL 导航来隔离 test 间状态
3. **afterAll 关闭 context**,避免资源泄漏
4. URL 提取为常量(如 `BASE_URL`),方便切换测试环境
# CodeGraph data files
# These are local to each machine and should not be committed
# Database
*.db-wal
*.db-shm
# Cache
cache/
# Logs
*.log
# Hook markers
.dirty
This file is too large to display.
......@@ -7,3 +7,7 @@ indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{yml,yaml}]
indent_style = space
indent_size = 2
......@@ -28,9 +28,15 @@ yarn-error.log*
*.sw*
# AI Local
.cursor/
.claude/settings.local.json
.roo/
.copilot/
.windsurf/
/.codegraph/
# test
/playwright/
## 变更内容
-
## 测试情况
-
## 风险评估
-
## Checklist
- [ ] 已自测
- [ ] 已更新文档
- [ ] 已通知相关人员
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
# 基础工具
RUN apt-get update && apt-get install -y \
curl \
git \
nano \
ca-certificates \
bash \
unzip \
jq \
&& rm -rf /var/lib/apt/lists/*
# Volta
ENV VOLTA_HOME=/root/.volta
ENV PATH=$VOLTA_HOME/bin:$PATH
RUN curl https://get.volta.sh | bash
# 安装 Node14
RUN volta install node@14
# 默认 Node22
RUN volta install node@22
# Claude Code
RUN npm install -g @anthropic-ai/claude-code
# 触发一次 claude 命令让它生成初始的 ~/.claude.json(如果它还没生成的话)
# 并使用 jq 安全地注入 hasCompletedOnboarding 字段,不破坏原有内容
RUN mkdir -p /root && \
touch /root/.claude.json && \
(echo '{}' > /root/.claude.json) && \
jq '. + {"hasCompletedOnboarding": true}' /root/.claude.json > /root/.claude.json.tmp && \
mv /root/.claude.json.tmp /root/.claude.json
WORKDIR /workspace
CMD ["/bin/bash"]
services:
ai-worker:
build:
context: .
dockerfile: ../build/Dockerfile.unit.test
container_name: ai-worker
working_dir: /workspace
volumes:
- ./workspace:/workspace
environment:
- ANTHROPIC_AUTH_TOKEN
- ANTHROPIC_BASE_URL=https://dashscope.aliyuncs.com/apps/anthropic
- ANTHROPIC_MODEL=qwen3.5-plus
- ANTHROPIC_SMALL_FAST_MODEL=qwen3.5-flash
- ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.5-flash
- ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.5-plus
- ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.5-plus
- CLAUDE_CODE_SUBAGENT_MODEL=qwen3.5-plus
# 保持容器在前台常驻,防止执行完立刻退出崩溃
command: sh -c "tail -f /dev/null"
restart: unless-stopped
......@@ -12,7 +12,6 @@ export default antfu({
"dist",
// unplugin-auto-import 生成的类型文件,每次提交都改变,所以加入这里吧,与 .gitignore 配合使用
"auto-import.d.ts",
"e2e/",
"build/",
"node_modules/",
// # node 覆盖率文件
......
This diff could not be displayed because it is too large.
......@@ -68,7 +68,7 @@
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.17.12",
"@babel/plugin-proposal-optional-chaining": "7.13.12",
"@kazupon/vue-i18n-loader": "^0.4.1",
"@playwright/test": "^1.60.0",
"@playwright/test": "^1.39.0",
"@sentry/webpack-plugin": "^1.18.9",
"@vue/babel-helper-vue-jsx-merge-props": "^1.4.0",
"@vue/cli-plugin-babel": "~5.0.8",
......@@ -85,6 +85,7 @@
"jest-serializer-vue": "^3.1.0",
"jest-transform-stub": "^2.0.0",
"md5": "^2.3.0",
"playwright": "^1.39.0",
"postcss-preset-env": "^7.7.2",
"postcss-px-to-viewport": "^1.1.1",
"sass": "~1.62.0",
......
......@@ -11,11 +11,18 @@
*/
import { defineConfig, devices } from "@playwright/test";
import dayjs from "dayjs";
// 生成时间戳,用于报告和结果目录
const timestamp = dayjs().format("YYYY-MM-DD HH");
export default defineConfig({
// 测试文件位置
testDir: "./e2e",
// 测试文件匹配模式
testMatch: "**/*.e2e.js",
// 超时时间
timeout: 30 * 1000,
......@@ -28,21 +35,28 @@ export default defineConfig({
retries: 1,
// 并行执行配置
workers: 4,
workers: 1,
// 是否失败即停止
failOnFlakyTests: false,
// 报告配置
// 产出到 playwright/report/index.YYYY-MM-DD hh-mm.html
reporter: [
["list"],
["html", { outputFolder: "playwright-report", open: "never" }],
[
"html",
{
outputFolder: `playwright/report/${timestamp}`,
open: "never",
},
],
],
// 共享配置
use: {
// 基础 URL
baseURL: process.env.BASE_URL || "http://localhost:8080",
// 基础 URL - 使用当前 IP 访问
baseURL: process.env.BASE_URL || "http://192.168.1.146:8080/dj-carlife-web/",
// 截图配置
screenshot: "only-on-failure",
......@@ -58,6 +72,10 @@ export default defineConfig({
navigationTimeout: 30000,
},
// 测试结果目录(截图、视频、trace)
// 产出到 playwright/result/YYYY-MM-DD hh-mm/
outputDir: `playwright/result/${timestamp}`,
// 浏览器配置
projects: [
{
......@@ -67,40 +85,19 @@ export default defineConfig({
viewport: { width: 1920, height: 1080 },
},
},
{
name: "firefox",
use: {
...devices["Desktop Firefox"],
viewport: { width: 1920, height: 1080 },
},
},
{
name: "webkit",
use: {
...devices["Desktop Safari"],
viewport: { width: 1920, height: 1080 },
},
},
// 移动端测试
{
name: "Mobile Chrome",
use: {
...devices["Pixel 5"],
},
},
{
name: "Mobile Safari",
use: {
...devices["iPhone 12"],
},
},
],
// Web 服务器配置 (可选,用于自动启动开发服务器)
// webServer: {
// command: "npm run dev",
// port: 8080,
// timeout: 120 * 1000,
// reuseExistingServer: true,
// },
// Web 服务器配置 (用于自动启动开发服务器)
// 如果在远程机器运行,请设置 SKIP_WEBSERVER=true 并手动启动服务
webServer: process.env.SKIP_WEBSERVER
? undefined
: {
command: "npm run serve",
timeout: 120 * 1000,
reuseExistingServer: true,
// 等待 URL,确保服务器准备好
url: process.env.BASE_URL
? process.env.BASE_URL.replace(/\/$/, "") + "/#/"
: "http://192.168.1.146:8080/dj-carlife-web/#/",
},
});
......@@ -141,7 +141,7 @@
<el-tag v-if="hasValue(sub, scope.row)" :type="getSchemaTagOptions(sub, scope.row).type">
{{ getSchemaTagOptions(sub, scope.row).label }}
</el-tag>
<span v-else>-</span>
<span v-else>-</span>
</div>
</template>
<template v-else-if="sub.formatter">
......@@ -254,7 +254,9 @@
<el-tag v-if="hasValue(item, scope.row)" :type="getSchemaTagOptions(item, scope.row).type">
{{ getSchemaTagOptions(item, scope.row).label }}
</el-tag>
<span v-else>-</span>
<span v-else>-</span>
</div>
</template>
<template v-else-if="item.formatter">
......
<template>
<div class="dashboard-card rank-card">
<div class="card-header">
<span class="card-title">线上运营分布</span>
</div>
<div class="rank-list">
<!-- 表头 -->
<div class="rank-header">
<span class="rank-header-col" style="flex: 1;">排名</span>
<span class="rank-header-col" style="flex: 1;">姓名</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">策略总数</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">占比</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">门店总数</span>
<span class="rank-header-col" style="flex: 1; text-align: center;">占比</span>
</div>
<!-- 列表内容 -->
<block v-if="rankData.length > 0">
<div v-for="(item, index) in rankData"
:key="index"
class="rank-item">
<!-- 排名 Icon 处理 -->
<div class="rank-index"
:class="`rank-${index + 1}`">
<img v-if="index < 3"
:src="require(`@/assets/strategy/icon-strategy-rank0${index + 1}.png`)"
style="width: 24px; height: 24px;" />
<span v-else
style="width: 20px; height: 20px; border-radius: 50%; opacity: 1; background: #2a58ad1a; display: inline-block; text-align: center; line-height: 20px;">
{{ index + 1 }}
</span>
</div>
<div class="rank-name" :title="item.staffName">
{{ item.staffName }}
</div>
<div class="rank-col">
{{ item.strategyCount }}
</div>
<div class="rank-col">
{{ item.strategyCountPercent }}%
</div>
<div class="rank-col">
{{ item.storeCount }}
</div>
<div class="rank-col">
{{ item.storeCountPercent }}%
</div>
</div>
</block>
<block v-else>
<!-- 空数据占位,实际显示在 .dashboard-card 层级 -->
</block>
<div class="dashboard-card rank-card">
<div class="card-header">
<span class="card-title">线上运营分布</span>
</div>
<div class="rank-list">
<!-- 表头 -->
<div class="rank-header">
<div v-for="col in rankColumns"
:key="col.key"
:class="col.className">
{{ col.label }}
</div>
<div v-if="rankData.length === 0" class="empty-box">
<img alt="暂无数据" :src="noDataImg">
<div class="empty-text">
暂无数据
</div>
</div>
<!-- 列表内容 -->
<template v-if="rankData.length > 0">
<div v-for="(item, index) in rankData"
:key="index"
class="rank-item">
<!-- 排名 Icon 处理 -->
<div class="rank-index"
:class="`rank-${index + 1}`">
<img v-if="index < 3"
style="width: 24px; height: 24px;"
:src="require(`@/assets/strategy/icon-strategy-rank0${index + 1}.png`)" />
<span v-else
style="width: 20px; height: 20px; border-radius: 50%; opacity: 1; background: #2a58ad1a; display: inline-block; text-align: center; line-height: 20px;">
{{ index + 1 }}
</span>
</div>
<div class="rank-name" :title="item.staffName">
{{ item.staffName || '-' }}
</div>
<div class="rank-col">
{{ item.strategyCount }}
</div>
<div class="rank-col">
{{ item.strategyCountPercent }}%
</div>
<div class="rank-col">
{{ item.storeCount }}
</div>
<div class="rank-col">
{{ item.storeCountPercent }}%
</div>
</div>
<div class="bottom-cover"></div>
</template>
</div>
<div v-if="rankData.length === 0" class="empty-box">
<img alt="暂无数据" :src="noDataImg">
<div class="empty-text">
暂无数据
</div>
</div>
<div class="bottom-cover"></div>
</div>
</template>
<script>
import noDataImg from "@/assets/strategy/emepty-strategy.png";
const RANK_COLUMNS = [
{ key: "rank", label: "排名", className: "rank-index" },
{ key: "name", label: "姓名", className: "rank-name" },
{ key: "strategyCount", label: "策略总数", className: "rank-col" },
{ key: "strategyPercent", label: "占比", className: "rank-col" },
{ key: "storeCount", label: "门店总数", className: "rank-col" },
{ key: "storePercent", label: "占比", className: "rank-col" },
];
export default {
name: "OnlineOperatorRanking",
props: {
......@@ -75,6 +80,7 @@ export default {
data() {
return {
noDataImg,
rankColumns: RANK_COLUMNS,
};
},
};
......@@ -123,13 +129,19 @@ $bg-white: #fff;
font-size: 13px;
overflow: scroll;
max-height: 260px;
.rank-index,
.rank-name,
.rank-col {
flex: 1;
}
.rank-col {
text-align: center;
}
.rank-header {
display: flex;
color: #909399;
.rank-header-col {
display: inline-block;
}
}
.rank-item {
......@@ -141,12 +153,7 @@ $bg-white: #fff;
border-bottom: none;
}
.rank-index {
flex: 1;
}
.rank-name {
flex: 1;
color: #303133;
overflow: hidden;
white-space: nowrap;
......@@ -154,8 +161,6 @@ $bg-white: #fff;
}
.rank-col {
flex: 1;
text-align: center;
color: #606266;
}
}
......
......@@ -3,6 +3,7 @@
<!-- 1. 顶部导航栏 -->
<div class="top-header-wrapper">
<HeaderCustom v-model="currentTab"
:show-bottom-border="false"
:tabs="tabs">
</HeaderCustom>
<!-- 日期选择器 -->
......@@ -13,6 +14,7 @@
@date-range-change="handleDateRangeChange"
@time-range-change="handleTimeRangeChange" />
</div>
<div class="border-bottom-line"></div>
<div class="content-area">
<!-- 2. KPI 核心指标 -->
<div class="top-content">
......@@ -428,6 +430,10 @@ export default {
this.fetchStrategyOnlineDist();
// 重置运营人员筛选
this.strategyTypeOperatorFilter = null;
// 切换业务类型后,更新效果分析表格传参并重新请求
this.$nextTick(() => {
this.refreshEffectTable();
});
}
},
// 监听策略类型分布运营人员筛选变化,防抖请求数据
......@@ -503,8 +509,11 @@ export default {
};
}
},
handleTabChange(tab) {
this.currentTab = tab;
/**
* 刷新效果分析表格(beforeSearchFn 会同步 businessType 等参数,再调用 wrapStrategyEffectList)
*/
refreshEffectTable() {
this.$refs.table && this.$refs.table.refreshTable();
},
/**
* 搜索前处理
......@@ -565,14 +574,7 @@ export default {
value: item.value !== undefined ? item.value : item.label,
};
this.$nextTick(() => {
this.searchFormSearch = deepClone({
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
warningType: this.currentWatchType.value || null,
periodType: this.timeRangeType.value,
});
this.$refs.table && this.$refs.table.refreshTable();
this.refreshEffectTable();
});
},
/**
......@@ -672,7 +674,7 @@ export default {
this.fetchStrategyTypeDist();
this.fetchStrategyOnlineDist();
// 刷新表格数据
this.$refs.table && this.$refs.table.refreshTable();
this.refreshEffectTable();
},
/**
* 处理时间范围类型变化
......@@ -713,7 +715,6 @@ export default {
uuid: this.strategyTypeOperatorFilter,
};
const res = await getStrategyTypeDist(params);
console.log("getStrategyTypeDist", res);
this.strategyTypeData = res || [];
} catch (error) {
console.error("获取策略类型分布失败:", error);
......@@ -806,6 +807,11 @@ $bg-white: #fff;
background-color: #fff;
}
.border-bottom-line {
margin-top: -1px;
border-bottom: 1px solid #e5e5e5;
}
.content-area {
min-height: 0;
width: 100%;
......
<template>
<div class="top-header">
<!-- Tabs -->
<div ref="tabsNav" class="tabs-nav">
<div ref="tabsNav"
class="tabs-nav"
:class="{ 'tabs-nav--no-border': !showBottomBorder }">
<div v-for="(tab, index) in tabs"
:key="getTabKey(tab, index)"
:ref="`tabItem${index}`"
......@@ -220,6 +222,11 @@ export default {
type: Boolean,
default: false,
},
// 是否显示 tabs 区域下边框,默认显示
showBottomBorder: {
type: Boolean,
default: true,
},
},
data() {
return {
......@@ -428,6 +435,10 @@ $text-orange: #ff7d00;
font-size: 16px;
}
}
&--no-border {
border-bottom: none;
}
}
.active-line {
......
<template>
<el-dropdown :disabled="disabled"
placement="bottom-start"
<el-dropdown placement="bottom-start"
trigger="click"
:disabled="disabled"
@command="handleSelect">
<div class="icon-text-btn"
:class="{ 'has-selected': value && value.label && value.label !== defaultText, 'is-disabled': disabled }">
......
......@@ -399,6 +399,7 @@ export default {
// getMonitorList(cleanParams).then((res) => {
getWarningSummaryList(cleanParams).then((res) => {
if (res) {
console.log("getWarningSummaryList", res);
// 为每个数组元素添加 checked 字段,默认为 false
this.cardList = Array.isArray(res)
? res.map(item => ({ ...item, checked: false }))
......
......@@ -193,12 +193,13 @@
<div v-loading="staffRightLoading"
class="staff-overview-item right">
<div class="content">
<OverViewList :business-type="paramsInfo.bizs"
<OverViewList v-if="paramsInfo.bizs != 3"
:business-type="paramsInfo.bizs"
:is-harmony="isHarmony"
:is-staff="true"
:view-data="viewData">
</OverViewList>
<div v-show="!isHarmony" class="empty-box">
<div v-show="!isHarmony || paramsInfo.bizs == 3" class="empty-box">
<img alt="暂无数据" src="@/assets/strategy/emepty-strategy.png">
<div class="empty-text">
暂无数据
......@@ -507,12 +508,12 @@ export default {
warningInfoList.forEach((e, index) => {
if ((index + 1) % 2 == 0) {
rightWarningInfoList.push({
type: e.warningText.startsWith("兜底预警") ? 1 : 2,
type: e.warningType,
text: `${e.warningTypeName}: ${e.warningText}`,
});
} else {
leftWarningInfoList.push({
type: e.warningText.startsWith("兜底预警") ? 1 : 2,
type: e.warningType,
text: `${e.warningTypeName}: ${e.warningText}`,
});
}
......
......@@ -7,9 +7,12 @@
<div class="text text-hide">
{{ STRATEGYTYPEOPTIONS[item.strategyType] }}
</div>
<div class="strategy-item-status" :style="{ color: formatStatusStyle(item.pushFlag).color, background: formatStatusStyle(item.pushFlag).bg }">
{{ formatPushFlag(item.pushFlag) }}
</div>
<template v-if="item.strategyType != 7">
<div class="strategy-item-status" :style="{ color: formatStatusStyle(item.pushFlag).color, background: formatStatusStyle(item.pushFlag).bg }">
{{ formatPushFlag(item.pushFlag) }}
</div>
</template>
</div>
<div class="strategy-item-created">
{{ item.createdDateText }}<span>{{ item.createdBy }}</span>
......@@ -33,7 +36,7 @@
<template v-else>
<div v-html="item[i.key]"></div>
</template>
<div v-html="item[i.key]"></div>
</div>
</template>
<span :class="[i.format ? 'one-line-ellipsis' : 'two-line-ellipsis']"
......@@ -56,7 +59,8 @@
</template>
<div class="btn-list flex">
<!-- 状态=未下发 -->
<template v-if="item.pushFlag == 0 || item.pushFlag == 2 || item.pushFlag == 3">
<!-- 留言没有删除 -->
<template v-if="(item.pushFlag == 0 || item.pushFlag == 2 || item.pushFlag == 3) && item.strategyType != 7">
<el-button class="btn-default _btn"
:size="size"
@click="deleteStrategy(item)">
......
......@@ -2,7 +2,7 @@
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2026-04-01 09:57:49
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2026-06-10 10:14:26
* @LastEditTime: 2026-06-11 16:15:15
* @FilePath: \dj-car-life-system\src\views\earlyWarningManager\strategyCentre\storeSignboard\components\StrategyList\contant.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -93,6 +93,7 @@ const STRATEGY_9 = [
// STAFF_FORMAT("问题人员"),
{
label: "问题人员",
tooltip: true,
format: (val) => {
let { staffList } = val;
return staffList.filter(item => item.userPosition != 8 && item.userPosition != 9).map(item => item.userName).join("/") || "-";
......
......@@ -149,13 +149,14 @@
<div class="summary-overview-item right">
<div v-loading="summaryRightLoading"
class="content">
<OverViewList has-e-hi
<OverViewList v-if="paramsInfo.bizs != 3"
has-e-hi
:business-type="paramsInfo.bizs"
:is-harmony="isHarmony"
:is-oem-data-source="activeDataSource === 2"
:view-data="viewData">
</OverViewList>
<div v-show="!isHarmony" class="empty-box">
<div v-show="!isHarmony || paramsInfo.bizs == 3" class="empty-box">
<img alt="暂无数据" src="@/assets/strategy/emepty-strategy.png">
<div class="empty-text">
暂无数据
......@@ -370,6 +371,7 @@ export default {
} else {
this.getStrategyMerchantAnalysisStoreDetailSummary();
this.getStrategyMerchantAnalysisGoodsSummaryWithWarn();
this.getStrategyMerchantListWarningInfo();
}
},
async getStrategyBusinessAnalysisStoreSpecialBrand() {
......
......@@ -124,6 +124,37 @@ describe('taskCenter 集成测试', () => {
// 验证 optionList 使用的是 overdueFlagOptions
expect(overdueItem.optionList).toBe(overdueFlagOptions);
});
it('表格列应该包含任务分类列', async () => {
const mockCategories = [
{ bizType: 'type1', categoryName: '分类 1' },
{ bizType: 'type2', categoryName: '分类 2' },
];
mockGetTaskCenterBizCategoryListApi.mockResolvedValue(mockCategories);
const columns = await getTableColumns();
const bizTypeCol = columns.find((col) => col.prop === 'bizTypeName');
expect(bizTypeCol).toBeDefined();
expect(bizTypeCol.label).toBe('任务分类');
expect(bizTypeCol.prop).toBe('bizTypeName');
});
it('表格搜索表单的任务分类选项应该来自 API', async () => {
const mockCategories = [
{ bizType: 'type1', categoryName: '分类 1' },
{ bizType: 'type2', categoryName: '分类 2' },
];
mockGetTaskCenterBizCategoryListApi.mockResolvedValue(mockCategories);
const schema = await getTableFormSchema();
const bizTypeItem = schema.find((item) => item.name === 'condition.bizTypes');
expect(bizTypeItem).toBeDefined();
expect(bizTypeItem.optionList).toEqual(mockCategories);
expect(bizTypeItem.optionId).toBe('bizType');
expect(bizTypeItem.optionLabel).toBe('categoryName');
});
});
describe('数据结构完整性测试', () => {
......@@ -141,7 +172,7 @@ describe('taskCenter 集成测试', () => {
const tableFields = tableColumns.map((col) => col.prop);
// 共同的字段应该都存在
const commonFields = ['taskNo', 'createdBy', 'createdDate', 'dueTime', 'completeTime'];
const commonFields = ['taskNo', 'createdBy', 'createdDate', 'dueTime', 'completeTime', 'bizTypeName'];
commonFields.forEach((field) => {
expect(detailFields).toContain(field);
expect(tableFields).toContain(field);
......
......@@ -7,7 +7,7 @@ export async function getTaskCenterTaskDescriptionSchema() {
label: "任务描述",
col: 24,
labelWidth: "120px",
// slot : 整体的插槽名,优先级高于 name
// slot : 整体的插槽名,优先级高于name
// itemStyle: 每一项的样式
// tooltipProps: el-tooltip 的传参
render: (h, { data, schemaItem, schema }) => {
......@@ -67,7 +67,7 @@ export async function getTaskCenterTaskDescriptionSchema() {
col: 24,
labelWidth: "120px",
render: (h, { data }) => {
const names = data.assignees.map(item => item.assigneeName).join(",") || "-";
const names = (data.assignees || []).map(item => item.assigneeName).join(",") || "-";
return h("span", {
style: {
whiteSpace: "normal",
......
import { getTaskCenterTaskDescriptionSchema } from './detail.data.js';
import { getTaskCenterTaskDescriptionSchema } from "./detail.data.js";
// Mock h 函数(Vue 的渲染函数)
const createMockH = () => {
function createMockH() {
return jest.fn((tag, data, children) => ({ tag, data, children }));
};
}
describe('detail.data.js 测试', () => {
describe('getTaskCenterTaskDescriptionSchema', () => {
it('应该返回一个数组', async () => {
describe("detail.data.js 测试", () => {
describe("getTaskCenterTaskDescriptionSchema", () => {
it("应该返回一个数组", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
expect(Array.isArray(schema)).toBe(true);
});
it('应该包含基本的 schema 项', async () => {
it("应该包含基本的 schema 项", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const names = schema.map((item) => item.name).filter(Boolean);
expect(names).toContain('description');
expect(names).toContain('bizTypeName');
expect(names).toContain('status');
expect(names).toContain('priority');
expect(names).toContain('assignees');
expect(names).toContain('taskNo');
expect(names).toContain('createdBy');
expect(names).toContain('createdDate');
expect(names).toContain('dueTime');
expect(names).toContain('completeTime');
const names = schema.map(item => item.name).filter(Boolean);
expect(names).toContain("description");
expect(names).toContain("bizTypeName");
expect(names).toContain("status");
expect(names).toContain("priority");
expect(names).toContain("assignees");
expect(names).toContain("taskNo");
expect(names).toContain("createdBy");
expect(names).toContain("createdDate");
expect(names).toContain("dueTime");
expect(names).toContain("completeTime");
});
it('每个 schema 项应该包含 name 和 label 属性', async () => {
it("每个 schema 项应该包含 name 和 label 属性", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const itemsWithName = schema.filter((item) => item.name);
const itemsWithName = schema.filter(item => item.name);
itemsWithName.forEach((item) => {
expect(item).toHaveProperty('name');
expect(item).toHaveProperty('label');
expect(item).toHaveProperty("name");
expect(item).toHaveProperty("label");
});
});
it('description 字段应该有正确的配置', async () => {
it("description 字段应该有正确的配置", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const descriptionItem = schema.find((item) => item.name === 'description');
const descriptionItem = schema.find(item => item.name === "description");
expect(descriptionItem).toEqual({
name: 'description',
label: '任务描述',
name: "description",
label: "任务描述",
col: 24,
labelWidth: '120px',
labelWidth: "120px",
tooltip: true,
parentProps: {
style: {
display: 'inline-block',
height: '32px',
width: 'auto',
maxWidth: '100%',
verticalAlign: 'top',
display: "inline-block",
height: "32px",
width: "auto",
maxWidth: "100%",
verticalAlign: "top",
},
},
render: expect.any(Function),
......@@ -62,29 +62,29 @@ describe('detail.data.js 测试', () => {
});
});
it('status 字段应该有 render 函数', async () => {
it("status 字段应该有 render 函数", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const statusItem = schema.find((item) => item.name === 'status');
const statusItem = schema.find(item => item.name === "status");
expect(statusItem.render).toBeInstanceOf(Function);
});
it('priority 字段应该有 render 函数', async () => {
it("priority 字段应该有 render 函数", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const priorityItem = schema.find((item) => item.name === 'priority');
const priorityItem = schema.find(item => item.name === "priority");
expect(priorityItem.render).toBeInstanceOf(Function);
});
it('assignees 字段的 render 函数应该正确处理执行人列表', async () => {
it("assignees 字段的 render 函数应该正确处理执行人列表", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const assigneesItem = schema.find((item) => item.name === 'assignees');
const assigneesItem = schema.find(item => item.name === "assignees");
const h = createMockH();
const data = {
assignees: [
{ assigneeName: '张三' },
{ assigneeName: '李四' },
{ assigneeName: "张三" },
{ assigneeName: "李四" },
],
};
......@@ -94,9 +94,9 @@ describe('detail.data.js 测试', () => {
expect(h).toHaveBeenCalled();
});
it('assignees 字段的 render 函数应该处理空列表', async () => {
it("assignees 字段的 render 函数应该处理空列表", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const assigneesItem = schema.find((item) => item.name === 'assignees');
const assigneesItem = schema.find(item => item.name === "assignees");
const h = createMockH();
const data = { assignees: [] };
......@@ -106,29 +106,41 @@ describe('detail.data.js 测试', () => {
expect(h).toHaveBeenCalled();
});
it('description 的 isHide 函数应该在 formModel.description 为空时返回 true', async () => {
it("assignees 字段的 render 函数应该处理 undefined 情况", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const descriptionItem = schema.find((item) => item.name === 'description');
const assigneesItem = schema.find(item => item.name === "assignees");
const h = createMockH();
const data = { };
const result = assigneesItem.render(h, { data });
expect(h).toHaveBeenCalledWith("span", {}, "-");
});
it("description 的 isHide 函数应该在 formModel.description 为空时返回 true", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const descriptionItem = schema.find(item => item.name === "description");
const result = descriptionItem.isHide({ formModel: {} });
expect(result).toBe(true);
});
it('description 的 isHide 函数应该在 formModel.description 有值时返回 false', async () => {
it("description 的 isHide 函数应该在 formModel.description 有值时返回 false", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const descriptionItem = schema.find((item) => item.name === 'description');
const descriptionItem = schema.find(item => item.name === "description");
const result = descriptionItem.isHide({
formModel: { description: '测试描述' },
formModel: { description: "测试描述" },
});
expect(result).toBe(false);
});
it('应该包含两个 divider 项', async () => {
it("应该包含两个 divider 项", async () => {
const schema = await getTaskCenterTaskDescriptionSchema();
const dividers = schema.filter((item) => item.divider === true);
const dividers = schema.filter(item => item.divider === true);
expect(dividers).toHaveLength(2);
});
......
......@@ -15,6 +15,17 @@ jest.mock("@/views/residentManage/taskCenter/api/index.js", () => ({
getTaskCenterBizCategoryListApi: mockGetTaskCenterBizCategoryListApi,
}));
// Mock lodash-es 的 keyBy
jest.mock("lodash-es", () => ({
keyBy: jest.fn((arr, key) => {
const result = {};
arr.forEach(item => {
result[item[key]] = item;
});
return result;
}),
}));
// 在 mock 之后才导入被测试模块
const { getTableFormSchema, getTableColumns } = require("./table.data.js");
......@@ -268,6 +279,18 @@ describe("table.data.js 测试", () => {
expect(dueTimeCol.valueClass).toBeInstanceOf(Function);
});
it("应该包含任务分类列", async () => {
const columns = await getTableColumns();
const bizTypeCol = columns.find(col => col.prop === "bizTypeName");
expect(bizTypeCol).toEqual({
label: "任务分类",
prop: "bizTypeName",
width: "180px",
align: "left",
});
});
it("应该包含 10 个列", async () => {
const columns = await getTableColumns();
expect(columns).toHaveLength(10);
......
......@@ -161,7 +161,7 @@
</template>
</el-input>
</el-form-item>
<span class="range-sep">&lt;</span>
<span class="range-sep">&lt;=</span>
<span class="range-mid">选中的指标值</span>
<span class="range-sep">&lt;</span>
<el-form-item class="condition-row__item condition-row__item--range-end"
......@@ -800,9 +800,7 @@ export default {
const isLastCondition = condIndex === conditions.length - 1;
const condLogic = this.getConditionNextLogic(cond) || fallbackLogic;
const metricId = cond.metricId != null && cond.metricId !== ""
? Number(cond.metricId)
: null;
const metricId = this.getMetricId(group, cond);
const rule = {
sortNo: rules.length + 1,
......
......@@ -321,7 +321,7 @@ export default {
async getMerchantList() {
this.merchantSearchLoading = true;
try {
const data = await listShop4sByRef({});
const data = await listShop4sByRef({ queryAbsoluteEnable: 1 });
this.setMerchantOptions(Array.isArray(data) ? data : []);
} finally {
this.merchantSearchLoading = false;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!