Commit 9d9c1b7b by chenwq

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

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