Commit c2159531 by chenwq

feat(teamWork): 新增督导报表详情页面及工作台跳转逻辑

- 新增移动端路由配置,添加teamWork/reportDetail页面路由
- 新增getTaskDetailById接口,用于获取督导任务详情数据
- 重构团队工作台tab配置体系,改用tabKey替代数字下标作为配置标识,提升代码扩展性
- 新增报表详情页组件,支持日报、月报两种类型的详情展示,包含加载状态、数据渲染、页面返回功能
- 优化列表项点击跳转逻辑,通过sessionStorage传递页面参数,实现从列表页跳转到对应详情页
- 修复部分代码细节:将dateSearch组件的临时变量声明从let改为const,修正类型判断的`==`为`===`提升类型安全性
1 parent b6716e91
import api from './request' import api from './request'
export default { export default {
// 获取招聘管理列表数据
// getRecruitList(data) {
// return post('dj.api.staff.h5.recruitment.demand.technicalSupervisor.page', data, 'djStaffUrl')
// }
// 获取督导团队概况数据
// getSupervisorStaticData(data) {
// return api.post('dj.api.supervisor.mini.get.teamOverview', data, 'supervisorUrl')
// },
// 获取数据看板和任务列表数据 // 获取数据看板和任务列表数据
getMissionData(data) { getMissionData(data) {
return api.post('dj.api.supervisor.mini.get.workbenchReport', data, 'supervisorUrl') return api.post('dj.api.supervisor.mini.get.workbenchReport', data, 'supervisorUrl')
},
// 工作台-根据ID查询督导任务详情
getTaskDetailById(data) {
return api.post('dj.api.supervisor.mini.workbench.getTaskDetailById', data, 'supervisorUrl')
} }
} }
...@@ -126,7 +126,7 @@ export default { ...@@ -126,7 +126,7 @@ export default {
watch: { watch: {
tabSelected(n) { tabSelected(n) {
if (n !== undefined && n !== null && n !== '') { if (n !== undefined && n !== null && n !== '') {
let timeTypeEnum = this.timeTypeEnum const timeTypeEnum = this.timeTypeEnum
if ([1, 2].includes(n)) { if ([1, 2].includes(n)) {
this.dateCurrent = n this.dateCurrent = n
this.timeType = timeTypeEnum[n] this.timeType = timeTypeEnum[n]
...@@ -180,7 +180,7 @@ export default { ...@@ -180,7 +180,7 @@ export default {
}, },
selectDate(index) { selectDate(index) {
if (this.setTrackData && this.$track) { if (this.setTrackData && this.$track) {
let events = ['supervisor_dayTime_tab', 'supervisor_weekTime_tab', 'supervisor_monthTime_tab'] const events = ['supervisor_dayTime_tab', 'supervisor_weekTime_tab', 'supervisor_monthTime_tab']
this.$track.setTrackData(0, events[index], {}, '') this.$track.setTrackData(0, events[index], {}, '')
} }
this.dateCurrent = index this.dateCurrent = index
...@@ -190,7 +190,7 @@ export default { ...@@ -190,7 +190,7 @@ export default {
this.initDate(this.timeType) this.initDate(this.timeType)
}, },
getParams() { getParams() {
let { dateCurrent, date, currentWeek } = this const { dateCurrent, date, currentWeek } = this
const obj = {} const obj = {}
switch (dateCurrent) { switch (dateCurrent) {
case 0: case 0:
...@@ -249,7 +249,7 @@ export default { ...@@ -249,7 +249,7 @@ export default {
const end = this._normalizeDateStr(this.initEndDate) const end = this._normalizeDateStr(this.initEndDate)
if (dim === 1 && !this.weekColumns.length) return if (dim === 1 && !this.weekColumns.length) return
let nextData = { dateCurrent: dim, timeType: this.timeTypeEnum[dim] || 'date' } const nextData = { dateCurrent: dim, timeType: this.timeTypeEnum[dim] || 'date' }
if (dim === 0) { if (dim === 0) {
const base = start || end const base = start || end
const d = base ? dayjs(base) : dayjs() const d = base ? dayjs(base) : dayjs()
...@@ -313,7 +313,7 @@ export default { ...@@ -313,7 +313,7 @@ export default {
}, },
handleConfirm() { handleConfirm() {
const { timeType, selectedDate, currentWeek } = this const { timeType, selectedDate, currentWeek } = this
let rightCurrent = false, leftCurrent = false let rightCurrent = false; let leftCurrent = false
if (timeType === 'date') { if (timeType === 'date') {
const sel = dayjs(selectedDate).startOf('day') const sel = dayjs(selectedDate).startOf('day')
rightCurrent = sel.isSame(dayjs().startOf('day'), 'day') rightCurrent = sel.isSame(dayjs().startOf('day'), 'day')
......
...@@ -7,6 +7,13 @@ export const mobilePages = { ...@@ -7,6 +7,13 @@ export const mobilePages = {
title: '团队工作台', title: '团队工作台',
showTabBar: true showTabBar: true
} }
},
{
name: 'teamWork/reportDetail',
path: '/teamWork/reportDetail',
meta: {
title: '督导日报'
}
} }
], ],
performance: [ performance: [
......
...@@ -19,10 +19,10 @@ export const STATIC_CARD_MAP = { ...@@ -19,10 +19,10 @@ export const STATIC_CARD_MAP = {
// 顶部 Tab 切换配置 // 顶部 Tab 切换配置
export const TAB_LIST = [ export const TAB_LIST = [
{ text: '今日动态', reportType: 1 }, { text: '今日动态', reportType: 1, tabKey: 'dailyReport' },
{ text: '本周概览', reportType: 2 }, { text: '本周概览', reportType: 2, tabKey: 'weeklyReport' },
{ text: '月度总览', reportType: 3 }, { text: '月度总览', reportType: 3, tabKey: 'monthReport' },
{ text: '专项督办', reportType: 4 } { text: '专项督办', reportType: 4, tabKey: 'specialTask' }
] ]
// 完成状态映射 (用于卡片右上角状态徽标) // 完成状态映射 (用于卡片右上角状态徽标)
...@@ -54,22 +54,21 @@ export const STATUS_MAP = { ...@@ -54,22 +54,21 @@ export const STATUS_MAP = {
// 统一定义不同 Tab 下的列表字段配置 // 统一定义不同 Tab 下的列表字段配置
export const GRID_CONFIG_MAP = { export const GRID_CONFIG_MAP = {
0: [ dailyReport: [
// 今日动态 // 今日动态
{ label: '战败复盘', key: 'defeatReviewRate', type: 'rate', unit: '%' }, { label: '战败复盘', key: 'defeatReviewRate', type: 'rate', unit: '%' },
{ label: '线上带教', key: 'onlineTeachingCount', type: 'number' }, { label: '线上带教', key: 'onlineTeachingCount', type: 'number' },
{ label: '线上带教', key: 'onlineTeachingCount', type: 'number' },
{ label: '线下带教', key: 'offlineTeachingCount', type: 'number' }, { label: '线下带教', key: 'offlineTeachingCount', type: 'number' },
{ label: '日报', key: 'dailyReportStatus', type: 'dailyStatus' } { label: '日报', key: 'dailyReportStatus', type: 'dailyStatus' }
], ],
1: [ weeklyReport: [
// 本周概览 // 本周概览
{ label: '日报提交', key: 'dailyReportProgress', type: 'progress' }, { label: '日报提交', key: 'dailyReportProgress', type: 'progress' },
{ label: '复盘任务', key: 'reviewTaskProgress', type: 'progress' }, { label: '复盘任务', key: 'reviewTaskProgress', type: 'progress' },
{ label: '带教任务', key: 'teachingTaskProgress', type: 'progress' }, { label: '带教任务', key: 'teachingTaskProgress', type: 'progress' },
{ label: '录音提报', key: 'excellentCaseProgress', type: 'progress' } { label: '录音提报', key: 'excellentCaseProgress', type: 'progress' }
], ],
2: [ monthReport: [
// 月度总览 // 月度总览
{ label: '日报提交', key: 'dailyReportProgress', type: 'progress' }, { label: '日报提交', key: 'dailyReportProgress', type: 'progress' },
{ label: '复盘任务', key: 'reviewTaskProgress', type: 'progress' }, { label: '复盘任务', key: 'reviewTaskProgress', type: 'progress' },
...@@ -81,9 +80,25 @@ export const GRID_CONFIG_MAP = { ...@@ -81,9 +80,25 @@ export const GRID_CONFIG_MAP = {
// 统一定义点击跳转与箭头展示的策略映射 // 统一定义点击跳转与箭头展示的策略映射
export const JUMP_STRATEGY_MAP = { export const JUMP_STRATEGY_MAP = {
0: { key: 'dailyReportDetailEnabled', msg: '跳转今日动态日报详情' }, dailyReport: { key: 'dailyReportDetailEnabled', msg: '跳转今日动态日报详情', path: '/teamWork/reportDetail', title: '督导日报', detailType: 'dailyReport', taskIdKey: 'dailyReportTaskId' },
2: { key: 'monthReportDetailEnabled', msg: '跳转月度总览月报详情' }, monthReport: { key: 'monthReportDetailEnabled', msg: '跳转月度总览月报详情', path: '/teamWork/reportDetail', title: '督导月报', detailType: 'monthReport', taskIdKey: 'monthReportTaskId' },
3: { key: null, msg: '跳转专项督办详情' } // null 表示无条件允许跳转 specialTask: { key: null, msg: '跳转专项督办详情' } // null 表示无条件允许跳转
}
// 统一定义详情页的展示配置
export const DETAIL_CONFIG_MAP = {
dailyReport: [
{ label: '当日状态', key: 'dailyReportStatus', type: 'dailyStatus' },
{ label: '选择门店', key: 'taskMerchantList', type: 'tags', tagKey: 'merchantName' },
{ label: '今日工作事项', key: 'taskContext', type: 'text' },
{ label: '明日工作事项', key: 'nextWorkItems', type: 'text' },
{ label: '需协作事项', key: 'needAssistItems', type: 'text' }
],
monthReport: [
{ label: '辖区门店情况总结', key: 'taskContext', type: 'text' },
{ label: '带教进展/结果', key: 'teachingProgress', type: 'text' },
{ label: '下月计划', key: 'nextMonthPlan', type: 'text' }
]
} }
export default { export default {
...@@ -94,5 +109,6 @@ export default { ...@@ -94,5 +109,6 @@ export default {
MONTH_STATUS_MAP, MONTH_STATUS_MAP,
STATUS_MAP, STATUS_MAP,
GRID_CONFIG_MAP, GRID_CONFIG_MAP,
JUMP_STRATEGY_MAP JUMP_STRATEGY_MAP,
DETAIL_CONFIG_MAP
} }
<template>
<div class="report-detail-page">
<van-nav-bar
:title="title"
left-arrow
@click-left="onClickLeft"
fixed
placeholder
class="navigation-header"
/>
<div class="detail-container">
<div class="detail-section" v-for="(sec, index) in config" :key="index">
<!-- 状态类型,左右布局 -->
<template v-if="sec.type === 'dailyStatus' || sec.type === 'monthStatus'">
<div class="status-row">
<span class="label">{{ sec.label }}</span>
<span class="value" :style="getStatusStyle(sec, itemData[sec.key])">
{{ getStatusText(sec, itemData[sec.key]) }}
</span>
</div>
</template>
<!-- 标签类型 (如选择门店) -->
<template v-else-if="sec.type === 'tags'">
<div class="label">{{ sec.label }}</div>
<div class="tags-container">
<template v-if="getTags(itemData[sec.key], sec.tagKey).length > 0">
<span class="tag" v-for="(tag, tIndex) in getTags(itemData[sec.key], sec.tagKey)" :key="tIndex">{{ tag }}</span>
</template>
<span v-else class="empty-text">暂无</span>
</div>
</template>
<!-- 默认长文本类型 -->
<template v-else>
<div class="label">{{ sec.label }}</div>
<div class="text-content">
{{ itemData[sec.key] || '暂无' }}
</div>
</template>
</div>
</div>
</div>
</template>
<script>
import api from '@/api/teamWork'
import constantData from './constantData.js'
export default {
name: 'ReportDetail',
data() {
return {
title: '详情',
itemData: {},
config: [],
taskIdKey: ''
}
},
created() {
const detailType = this.$route.query.detailType || 'dailyReport'
const strategy = constantData.JUMP_STRATEGY_MAP[detailType] || {}
this.title = strategy.title || '详情'
this.taskIdKey = strategy.taskIdKey
try {
const storedItem = sessionStorage.getItem('reportDetailItem')
if (storedItem) {
this.itemData = JSON.parse(storedItem)
}
} catch (e) {
console.error('Failed to parse item data', e)
}
this.config = constantData.DETAIL_CONFIG_MAP[detailType] || []
this.getDetail()
},
methods: {
getDetail() {
const taskId = this.itemData[this.taskIdKey] || this.$route.query[this.taskIdKey]
if (!taskId) return
if (this.$toast && this.$toast.loading) {
this.$toast.loading({ duration: 0, forbidClick: true, message: '加载中...' })
}
api.getTaskDetailById({ id: taskId }).then(res => {
if (this.$toast && this.$toast.clear) {
this.$toast.clear()
}
// 合并接口返回的数据和列表带过来的数据,以接口返回为准
this.itemData = { ...this.itemData, ...res }
}).catch(() => {
if (this.$toast && this.$toast.clear) {
this.$toast.clear()
}
})
},
onClickLeft() {
this.$router.go(-1)
},
getStatusText(sec, val) {
if (val == null) return '-'
const map = constantData[`${sec.type === 'dailyStatus' ? 'DAILY_STATUS_MAP' : 'MONTH_STATUS_MAP'}`]
return map?.[val]?.text ?? val
},
getStatusStyle(sec, val) {
if (val == null) return { color: '#000000E5' }
const map = constantData[`${sec.type === 'dailyStatus' ? 'DAILY_STATUS_MAP' : 'MONTH_STATUS_MAP'}`]
if (map && map[val]) {
return {
color: map[val].color || '#000000E5',
fontSize: map[val].fontSize || '14px'
}
}
return { color: '#000000E5' }
},
getTags(val, tagKey) {
if (!val) return []
if (Array.isArray(val)) {
// 如果指定了 tagKey,并且数组项是对象,则提取对应的属性
if (tagKey && val.length > 0 && typeof val[0] === 'object') {
return val.map(item => item[tagKey]).filter(Boolean)
}
return val
}
if (typeof val === 'string') return val.split(',').filter(Boolean)
return []
}
}
}
</script>
<style lang="scss" scoped>
.report-detail-page {
background: #f2f3f7;
min-height: 100vh;
box-sizing: border-box;
padding-bottom: env(safe-area-inset-bottom);
.navigation-header {
:deep(.van-nav-bar__title) {
font-size: var(--fontSize34, 17px);
color: #222222;
font-weight: 600;
}
:deep(.van-icon) {
color: #222222;
}
}
.detail-container {
padding: 12px;
.detail-section {
background: #ffffff;
border-radius: 8px;
padding: 16px;
margin-bottom: 12px;
.status-row {
display: flex;
align-items: center;
justify-content: space-between;
.label {
font-size: 14px;
color: #000000E5;
font-weight: 400;
margin-bottom: 0;
}
.value {
font-weight: 500;
}
}
.label {
font-size: 14px;
color: #000000E5;
font-weight: 500;
margin-bottom: 12px;
}
.tags-container {
display: flex;
flex-wrap: wrap;
gap: 8px;
.tag {
background: #F2F3F7;
border-radius: 4px;
padding: 6px 8px;
font-size: 12px;
color: #000000E5;
word-break: break-all;
}
.empty-text {
font-size: 14px;
color: #00000066;
}
}
.text-content {
font-size: 14px;
color: #00000066;
line-height: 22px;
/* 要求:关注数字/字母的折行展示,不需要省略号 */
word-break: break-all;
word-wrap: break-word;
white-space: pre-wrap;
}
}
}
}
</style>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<van-list v-if="list.length" v-model="loading" :finished="finished" finished-text="到底了~" @load="onLoadMore"> <van-list v-if="list.length" v-model="loading" :finished="finished" finished-text="到底了~" @load="onLoadMore">
<div class="list" v-if="list.length > 0"> <div class="list" v-if="list.length > 0">
<div class="item content" v-for="(item, index) in list" :key="index" @click="jump(item)"> <div class="item content" v-for="(item, index) in list" :key="index" @click="jump(item)">
<!-- 专项督办 (tabIndex == 3) --> <!-- 专项督办 (tabIndex === 3) -->
<div v-if="tabIndex == 3" class="special-item"> <div v-if="tabIndex == 3" class="special-item">
<div class="name text-hide">{{ item.supervisorName }}</div> <div class="name text-hide">{{ item.supervisorName }}</div>
<div class="right-info"> <div class="right-info">
...@@ -134,9 +134,13 @@ export default { ...@@ -134,9 +134,13 @@ export default {
// this.onRefresh() // this.onRefresh()
}, },
methods: { methods: {
// 获取当前 Tab 的 key
getCurrentTabKey() {
return this.tabList[this.tabIndex]?.tabKey || 'dailyReport'
},
// 动态获取不同 Tab 下的列表字段配置 // 动态获取不同 Tab 下的列表字段配置
getGridConfig() { getGridConfig() {
return constantData.GRID_CONFIG_MAP[this.tabIndex] || [] return constantData.GRID_CONFIG_MAP[this.getCurrentTabKey()] || []
}, },
// 月度总览字段较多,采用 5 列布局,其他为 4 列 // 月度总览字段较多,采用 5 列布局,其他为 4 列
getGridCols() { getGridCols() {
...@@ -188,18 +192,32 @@ export default { ...@@ -188,18 +192,32 @@ export default {
}, },
// 判断是否显示箭头 // 判断是否显示箭头
canShowArrow(item) { canShowArrow(item) {
const strategy = constantData.JUMP_STRATEGY_MAP[this.tabIndex] const strategy = constantData.JUMP_STRATEGY_MAP[this.getCurrentTabKey()]
// 只有配置了依赖字段,且该字段值为 true 时才显示箭头(tabIndex为3无依赖字段,不显示) // 只有配置了依赖字段,且该字段值为 true 时才显示箭头(专项督办无依赖字段,不显示)
return strategy?.key ? item[strategy.key] === true : false return strategy?.key ? item[strategy.key] === true : false
}, },
// 处理列表点击跳转 // 处理列表点击跳转
jump(item) { jump(item) {
const { key, msg } = constantData.JUMP_STRATEGY_MAP[this.tabIndex] || {} const strategy = constantData.JUMP_STRATEGY_MAP[this.getCurrentTabKey()] || {}
const { key, msg, path, detailType, taskIdKey } = strategy
// 未配置策略、或依赖的权限字段为 false 时,直接拦截跳转 // 未配置策略、或依赖的权限字段为 false 时,直接拦截跳转
if (!msg || (key && !item[key])) return if (!msg || (key && !item[key])) return
console.log(msg) // 后续可替换为 this.$router.push(path) if (path) {
// 使用 sessionStorage 传递当前项数据和 tabIndex
sessionStorage.setItem('reportDetailItem', JSON.stringify(item))
const query = { detailType }
if (taskIdKey && item[taskIdKey]) {
query[taskIdKey] = item[taskIdKey]
}
this.$router.push({
path,
query
})
}
}, },
formatThousands(v) { formatThousands(v) {
const s = String(v) const s = String(v)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!