Commit 9d9c1b7b by chenwq

feat(teamWork): 优化统计卡片展示并抽取常量配置

新建统一的统计卡片配置文件,抽取硬编码的卡片配置到常量中
重构StaticInfo组件,优化布局与文本溢出处理
团队列表页动态根据标签页展示统计卡片,专项督办页仅展示两类卡片
更新标签页名称与上报类型逻辑,调整静态资源URL前缀
1 parent 0bc87d50
<template> <template>
<div class="static-info"> <div class="static-info">
<div class="static-item" v-for="(item, index) in list" :key="index" :style="{ flex: `${item.width || 1} 0 0`, background: item.background }"> <div class="static-item" v-for="(item, index) in list" :key="index" :style="{ background: item.background }">
<div class="label">{{item.label}}</div> <div class="label">{{item.label}}</div>
<div class="value">{{data[item.key] || '-'}}</div> <div class="value">{{data[item.key] || '-'}}</div>
</div> </div>
...@@ -27,17 +27,22 @@ export default { ...@@ -27,17 +27,22 @@ export default {
.static-info { .static-info {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 3px; justify-content: space-between;
gap: 8px; /* 增加一点间距 */
padding: 8px 12px 12px; padding: 8px 12px 12px;
.static-item { .static-item {
box-sizing: border-box; box-sizing: border-box;
padding: 12px; padding: 12px;
flex: 1; flex: 1; /* 无论几个,都是平分剩余空间 */
border-radius: 8px; border-radius: 8px;
font-size: 14px; font-size: 13px; /* 字体稍微调小一点,防挤压 */
color: #ffffff; color: #ffffff;
min-width: 0; /* 防止内容过长撑破 flex 布局 */
.label { .label {
margin-bottom: 4px; margin-bottom: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.value { .value {
font-size: 20px; font-size: 20px;
......
// 统一定义顶部的统计卡片配置项
export const STATIC_CARD_MAP = {
completed: {
label: '已完成人数',
key: 'completedCount',
background: 'linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)'
},
partial: {
label: '部分完成人数',
key: 'partialCount',
background: 'linear-gradient(90deg, #7552FF 0%, #977DFF 100%)'
},
unfinished: {
label: '未完成人数',
key: 'unfinishedCount',
background: 'linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)'
}
}
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
</van-tabs> </van-tabs>
</div> </div>
<div class="date"> <div class="date">
<date-search :tabSelected="tabIndex" :showDateTypeFilter="tabIndex === 3" :isSticky="isSticky" @search="search"></date-search> <date-search :tabSelected="tabIndex" :showDateTypeFilter="tabIndex == 3" :isSticky="isSticky" @search="search"></date-search>
</div> </div>
</div> </div>
<div class="data-container"> <div class="data-container">
<static-info :list="staticList" :data="staticData" /> <static-info :list="computedStaticList" :data="staticData" />
<van-sticky @change="isSticky = $event" :offset-top="90"> <van-sticky @change="isSticky = $event" :offset-top="90">
...@@ -61,8 +61,9 @@ import dayjs from 'dayjs' ...@@ -61,8 +61,9 @@ import dayjs from 'dayjs'
import dateSearch from '@/components/dateSearch/dateSearch.vue' import dateSearch from '@/components/dateSearch/dateSearch.vue'
import SearchBar from '@/components/searchBar/index.vue' import SearchBar from '@/components/searchBar/index.vue'
import StaticInfo from '@/components/staticInfo/index.vue' import StaticInfo from '@/components/staticInfo/index.vue'
import { STATIC_CARD_MAP } from './constantData.js'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/supervise-wecom/' const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
export default { export default {
name: 'TeamList', name: 'TeamList',
...@@ -76,30 +77,19 @@ export default { ...@@ -76,30 +77,19 @@ export default {
IMG_URL, IMG_URL,
isSticky: false, isSticky: false,
userInfo: {}, userInfo: {},
staticList: [{
label: '驻店人员',
width: '104px',
key: 'staffCount',
background: 'linear-gradient(90deg, #42CCCF 0%, #36D9A5 100%)'
}, {
label: '门店数量',
width: '96px',
key: 'shopCount',
background: 'linear-gradient(90deg, #5E69FF 0%, #4079FF 100%)'
}, {
label: '总产值',
key: 'totalValue',
background: 'linear-gradient(90deg, #3D76FC 0%, #4DA6FF 100%)'
}],
staticData: {}, staticData: {},
tabList: [{ tabList: [{
text: '每日任务' text: '今日动态',
reportType: 1
}, { }, {
text: '本周任务' text: '本周概览',
reportType: 2
}, { }, {
text: '月度任务' text: '月度总览',
reportType: 3
}, { }, {
text: '专项任务' text: '专项督办',
reportType: 4
}], }],
tabIndex: 0, tabIndex: 0,
statusMap: { statusMap: {
...@@ -126,10 +116,17 @@ export default { ...@@ -126,10 +116,17 @@ export default {
searchKeyword: '' searchKeyword: ''
} }
}, },
computed: {
computedStaticList() {
const { completed, partial, unfinished } = STATIC_CARD_MAP
// 专项督办(tabIndex === 3)仅展示已完成和未完成
return this.tabIndex == 3 ? [completed, unfinished] : [completed, partial, unfinished]
}
},
mounted() { mounted() {
this.userInfo = (this.$util && this.$util.getUserInfo()) || { name: '' } this.userInfo = (this.$util && this.$util.getUserInfo()) || { name: '' }
// this.getStaticData() // this.getStaticData()
this.onRefresh() // this.onRefresh()
}, },
methods: { methods: {
formatThousands(v) { formatThousands(v) {
...@@ -146,9 +143,9 @@ export default { ...@@ -146,9 +143,9 @@ export default {
// api.getMissionData({}).then(res => { // api.getMissionData({}).then(res => {
// let { code, data, message } = res // let { code, data, message } = res
// if (code === 0) { // if (code === 0) {
// data.staffCount = (data.staffCount ?? '') === '' ? '-' : this.formatThousands(data.staffCount) // data.completedCount = data.completedCount ?? '-'
// data.shopCount = (data.shopCount ?? '') === '' ? '-' : this.formatThousands(data.shopCount) // data.partialCount = data.partialCount ?? '-'
// data.totalValue = (data.totalValue ?? '') === '' ? '-' : this.formatThousands(data.totalValue) // data.unfinishedCount = data.unfinishedCount ?? '-'
// this.staticData = data // this.staticData = data
// } else { // } else {
// this.$toast && this.$toast(message) // this.$toast && this.$toast(message)
...@@ -161,7 +158,7 @@ export default { ...@@ -161,7 +158,7 @@ export default {
this.$track.setTrackData(0, eventCode[index], {}, '') this.$track.setTrackData(0, eventCode[index], {}, '')
} }
this.tabIndex = index this.tabIndex = index
this.onRefresh() // this.onRefresh()
}, },
// jump(target) { // jump(target) {
// const pageUrl = { // const pageUrl = {
...@@ -215,13 +212,13 @@ export default { ...@@ -215,13 +212,13 @@ export default {
this.getList() this.getList()
}, },
getList() { getList() {
const taskList = [1, 2, 3, 4] const taskList = [[0, 3, 5], [1], [2], [4]]
if (this.$toast && this.$toast.loading) { if (this.$toast && this.$toast.loading) {
this.$toast.loading({ duration: 0, forbidClick: true, message: '加载中...' }) this.$toast.loading({ duration: 0, forbidClick: true, message: '加载中...' })
} }
const params = { let params = {
reportType: taskList[this.tabIndex], reportType: this.tabList[this.tabIndex].reportType,
startDate: this.startStr, startDate: this.startStr,
endDate: this.endStr, endDate: this.endStr,
// pageNum: this.pageNum, // pageNum: this.pageNum,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!