|
|
@@ -1,5 +1,20 @@
|
|
|
<template>
|
|
|
<view class="page-team-system" :style="{ '--font-scale': fontScale }">
|
|
|
+ <!-- 团队切换器(T31 多团队管理) -->
|
|
|
+ <view class="team-switcher-wrap" v-if="teamList.length > 0">
|
|
|
+ <scroll-view class="team-switcher" scroll-x="true" :show-scrollbar="false">
|
|
|
+ <view
|
|
|
+ class="team-tab"
|
|
|
+ v-for="team in teamList"
|
|
|
+ :key="team.id"
|
|
|
+ :class="{ 'team-tab-active': currentSystemId === team.id }"
|
|
|
+ @click="switchTeam(team.id)"
|
|
|
+ >
|
|
|
+ <text class="team-tab-text">{{ team.name || '未命名团队' }}</text>
|
|
|
+ </view>
|
|
|
+ </scroll-view>
|
|
|
+ </view>
|
|
|
+
|
|
|
<!-- 头部:体系信息 -->
|
|
|
<view class="system-header" v-if="systemInfo">
|
|
|
<view class="system-info">
|
|
|
@@ -134,13 +149,15 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getVendorSystemInfo, getVendorHierarchyInfo, getVendorTeamMembers, getVendorTeamCustomers } from '@/utils/api.js'
|
|
|
+import { getVendorSystemInfo, getVendorHierarchyInfo, getVendorTeamMembers, getVendorTeamCustomers, getVendorTeamList } from '@/utils/api.js'
|
|
|
import fontScaleMixin from '@/mixins/font-scale.js'
|
|
|
|
|
|
export default {
|
|
|
mixins: [fontScaleMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
+ teamList: [], // 我的团队列表(切换器数据源,T31)
|
|
|
+ currentSystemId: null, // 当前选中的团队
|
|
|
systemInfo: null,
|
|
|
hierarchyInfo: null,
|
|
|
teamStats: {
|
|
|
@@ -171,13 +188,48 @@ export default {
|
|
|
methods: {
|
|
|
async loadData() {
|
|
|
try {
|
|
|
- // 并发获取所有数据
|
|
|
+ // 1. 拉取我的团队列表,解析当前选中团队
|
|
|
+ var teams = []
|
|
|
+ try {
|
|
|
+ const teamsRes = await getVendorTeamList()
|
|
|
+ teams = teamsRes.data || []
|
|
|
+ } catch (e) {
|
|
|
+ teams = []
|
|
|
+ }
|
|
|
+ this.teamList = teams
|
|
|
+
|
|
|
+ // 保持当前选中;失效(被移除/首次进入)则回退第一个团队
|
|
|
+ var stillValid = false
|
|
|
+ for (var i = 0; i < teams.length; i++) {
|
|
|
+ if (teams[i].id === this.currentSystemId) {
|
|
|
+ stillValid = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.currentSystemId || !stillValid) {
|
|
|
+ this.currentSystemId = teams.length > 0 ? teams[0].id : null
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!this.currentSystemId) {
|
|
|
+ // 无任何团队:清空数据
|
|
|
+ this.systemInfo = null
|
|
|
+ this.hierarchyInfo = null
|
|
|
+ this.teamMembers = []
|
|
|
+ this.teamCustomers = []
|
|
|
+ this.updateStats()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 并发加载当前团队数据(竞态防护:切换后旧响应不覆盖新团队)
|
|
|
+ var seq = (this._teamLoadSeq || 0) + 1
|
|
|
+ this._teamLoadSeq = seq
|
|
|
const [systemRes, hierarchyRes, membersRes, customersRes] = await Promise.all([
|
|
|
this.fetchSystemInfo(),
|
|
|
this.fetchHierarchyInfo(),
|
|
|
this.fetchTeamMembers(),
|
|
|
this.fetchTeamCustomers()
|
|
|
])
|
|
|
+ if (seq !== this._teamLoadSeq) return
|
|
|
|
|
|
if (systemRes) {
|
|
|
this.systemInfo = systemRes
|
|
|
@@ -199,10 +251,52 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 切换团队:联动刷新成员/客户/统计(T31)
|
|
|
+ switchTeam(systemId) {
|
|
|
+ if (!systemId || systemId === this.currentSystemId) return
|
|
|
+ this.currentSystemId = systemId
|
|
|
+ this.systemInfo = null
|
|
|
+ this.hierarchyInfo = null
|
|
|
+ this.teamMembers = []
|
|
|
+ this.teamCustomers = []
|
|
|
+ this.loadTeamData()
|
|
|
+ },
|
|
|
+
|
|
|
+ // 按当前选中团队加载各数据源
|
|
|
+ async loadTeamData() {
|
|
|
+ // 竞态防护:仅应用最新一次切换的响应,避免快速切换时旧数据覆盖新团队
|
|
|
+ var seq = (this._teamLoadSeq || 0) + 1
|
|
|
+ this._teamLoadSeq = seq
|
|
|
+ try {
|
|
|
+ const [systemRes, hierarchyRes, membersRes, customersRes] = await Promise.all([
|
|
|
+ this.fetchSystemInfo(),
|
|
|
+ this.fetchHierarchyInfo(),
|
|
|
+ this.fetchTeamMembers(),
|
|
|
+ this.fetchTeamCustomers()
|
|
|
+ ])
|
|
|
+ if (seq !== this._teamLoadSeq) return
|
|
|
+ if (systemRes) {
|
|
|
+ this.systemInfo = systemRes
|
|
|
+ }
|
|
|
+ if (hierarchyRes) {
|
|
|
+ this.hierarchyInfo = hierarchyRes
|
|
|
+ }
|
|
|
+ if (membersRes) {
|
|
|
+ this.teamMembers = membersRes
|
|
|
+ }
|
|
|
+ if (customersRes) {
|
|
|
+ this.teamCustomers = customersRes
|
|
|
+ }
|
|
|
+ this.updateStats()
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载团队数据失败:', error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 获取体系信息
|
|
|
async fetchSystemInfo() {
|
|
|
try {
|
|
|
- const res = await getVendorSystemInfo()
|
|
|
+ const res = await getVendorSystemInfo(this.currentSystemId)
|
|
|
return res.data || null
|
|
|
} catch (e) {
|
|
|
return null
|
|
|
@@ -212,7 +306,7 @@ export default {
|
|
|
// 获取层级关系
|
|
|
async fetchHierarchyInfo() {
|
|
|
try {
|
|
|
- const res = await getVendorHierarchyInfo()
|
|
|
+ const res = await getVendorHierarchyInfo(this.currentSystemId)
|
|
|
return res.data || null
|
|
|
} catch (e) {
|
|
|
return null
|
|
|
@@ -222,7 +316,7 @@ export default {
|
|
|
// 获取团队成员
|
|
|
async fetchTeamMembers() {
|
|
|
try {
|
|
|
- const res = await getVendorTeamMembers(this.systemInfo && this.systemInfo.id)
|
|
|
+ const res = await getVendorTeamMembers(this.currentSystemId)
|
|
|
return res.data || []
|
|
|
} catch (e) {
|
|
|
return []
|
|
|
@@ -233,7 +327,7 @@ export default {
|
|
|
async fetchTeamCustomers() {
|
|
|
try {
|
|
|
const res = await getVendorTeamCustomers({
|
|
|
- systemId: this.systemInfo && this.systemInfo.id,
|
|
|
+ systemId: this.currentSystemId,
|
|
|
parentId: null,
|
|
|
page: 1,
|
|
|
size: 50
|
|
|
@@ -257,10 +351,14 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 跳转客户列表
|
|
|
+ // 跳转客户列表(携带当前团队)
|
|
|
goToCustomers() {
|
|
|
+ var url = '/pages/vendor/team-customers/team-customers'
|
|
|
+ if (this.currentSystemId) {
|
|
|
+ url = url + '?systemId=' + this.currentSystemId
|
|
|
+ }
|
|
|
uni.navigateTo({
|
|
|
- url: '/pages/vendor/team-customers/team-customers'
|
|
|
+ url: url
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
@@ -285,6 +383,47 @@ export default {
|
|
|
box-shadow: 0 2rpx 12rpx rgba(249,115,22,0.08);
|
|
|
}
|
|
|
|
|
|
+/* 团队切换器(T31 多团队管理) */
|
|
|
+.team-switcher-wrap {
|
|
|
+ background-color: $app-surface;
|
|
|
+ padding: 20rpx 0;
|
|
|
+ margin-bottom: 24rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.team-switcher {
|
|
|
+ width: 100%;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+.team-tab {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 12rpx 28rpx;
|
|
|
+ margin-left: $uni-space-lg;
|
|
|
+ border-radius: 999rpx;
|
|
|
+ background-color: $uni-primary-pale;
|
|
|
+ flex-shrink: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.team-tab:last-child {
|
|
|
+ margin-right: $uni-space-lg;
|
|
|
+}
|
|
|
+
|
|
|
+.team-tab-active {
|
|
|
+ background-color: $brand-primary;
|
|
|
+}
|
|
|
+
|
|
|
+.team-tab-text {
|
|
|
+ font-size: calc(26rpx * var(--font-scale, 1));
|
|
|
+ color: $facade-text-body;
|
|
|
+ white-space: nowrap;
|
|
|
+}
|
|
|
+
|
|
|
+.team-tab-active .team-tab-text {
|
|
|
+ color: $app-surface;
|
|
|
+ font-weight: bold;
|
|
|
+}
|
|
|
+
|
|
|
.system-info {
|
|
|
display: flex;
|
|
|
align-items: center;
|