内容看板页按钮实现私有和公有转化
This commit is contained in:
parent
44539cf7ac
commit
a74badc79a
|
|
@ -11,7 +11,11 @@
|
||||||
*/
|
*/
|
||||||
export const getDashboardBrief = ({ joinUserId, keys }) => {
|
export const getDashboardBrief = ({ joinUserId, keys }) => {
|
||||||
// 构建查询参数字符串
|
// 构建查询参数字符串
|
||||||
const params = [`joinUserId=${joinUserId}`];
|
let params=[]
|
||||||
|
if (joinUserId) {
|
||||||
|
params = [`joinUserId=${joinUserId}`];
|
||||||
|
}
|
||||||
|
|
||||||
if (keys && Array.isArray(keys)) {
|
if (keys && Array.isArray(keys)) {
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
params.push(`keys=${encodeURIComponent(key)}`);
|
params.push(`keys=${encodeURIComponent(key)}`);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,16 @@
|
||||||
<view class="loading-text">加载中...</view>
|
<view class="loading-text">加载中...</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="dashboard-content" v-else>
|
<view class="dashboard-content" v-else>
|
||||||
|
<view
|
||||||
|
v-if="showPrivateSwitch"
|
||||||
|
class="private-filter"
|
||||||
|
>
|
||||||
|
<view>私有</view>
|
||||||
|
<uv-switch v-model="filterSelf"></uv-switch>
|
||||||
|
</view>
|
||||||
<!-- 任务概览 -->
|
<!-- 任务概览 -->
|
||||||
<view class="task-overview">
|
<view class="task-overview">
|
||||||
<view
|
<view
|
||||||
|
|
@ -150,12 +159,17 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, watch, computed } from 'vue';
|
||||||
import { getTaskStatusType, getTaskStatusStyle, getStatusText } from '@/utils/taskConfig.js';
|
import { getTaskStatusType, getTaskStatusStyle, getStatusText } from '@/utils/taskConfig.js';
|
||||||
import { getDashboardBrief, getTaskList } from '@/api';
|
import { getDashboardBrief, getTaskList } from '@/api';
|
||||||
import { useUserStore } from '@/store/user';
|
import { useUserStore } from '@/store/user';
|
||||||
import {truncateText} from "@/utils/textSolve/truncateText";
|
import {truncateText} from "@/utils/textSolve/truncateText";
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const filterSelf = ref(false);
|
||||||
|
const showPrivateSwitch = computed(() =>
|
||||||
|
userStore.getUserInfo?.roles?.some(r => ['admin', 'sys_admin'].includes(r))
|
||||||
|
);
|
||||||
|
|
||||||
// 任务统计
|
// 任务统计
|
||||||
const taskStats = ref([
|
const taskStats = ref([
|
||||||
|
|
@ -321,15 +335,16 @@ const loadDashboardData = async () => {
|
||||||
'customerMonthFollowCount'
|
'customerMonthFollowCount'
|
||||||
];
|
];
|
||||||
|
|
||||||
// 从 store 获取用户ID,如果没有则使用默认值
|
const params = {
|
||||||
const userStore = useUserStore();
|
|
||||||
// 尝试从 userInfo 中获取用户ID,如果没有则使用默认值
|
|
||||||
const joinUserId = userStore.userInfo?.user?.userId || userStore.userInfo?.userId || '23';
|
|
||||||
|
|
||||||
const res = await getDashboardBrief({
|
|
||||||
joinUserId,
|
|
||||||
keys
|
keys
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (filterSelf.value) {
|
||||||
|
const joinUserId = userStore.userInfo?.user?.userId;
|
||||||
|
params.joinUserId = joinUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await getDashboardBrief(params);
|
||||||
|
|
||||||
console.log('看板数据加载成功:', res);
|
console.log('看板数据加载成功:', res);
|
||||||
mapApiDataToComponent(res);
|
mapApiDataToComponent(res);
|
||||||
|
|
@ -352,6 +367,10 @@ onMounted(() => {
|
||||||
loadDashboardData();
|
loadDashboardData();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(filterSelf, () => {
|
||||||
|
loadDashboardData();
|
||||||
|
});
|
||||||
|
|
||||||
// 跳转到任务列表页
|
// 跳转到任务列表页
|
||||||
const goToTaskList = (label) => {
|
const goToTaskList = (label) => {
|
||||||
// 将中文标签映射为状态参数
|
// 将中文标签映射为状态参数
|
||||||
|
|
@ -502,6 +521,14 @@ const getTagCustomStyle = (status) => {
|
||||||
padding: 10px 30rpx;
|
padding: 10px 30rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.private-filter {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
// 统一卡片基础样式
|
// 统一卡片基础样式
|
||||||
.task-card-base {
|
.task-card-base {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user