内容看板页按钮实现私有和公有转化

This commit is contained in:
WindowBird 2025-11-12 16:39:40 +08:00
parent 44539cf7ac
commit a74badc79a
2 changed files with 41 additions and 10 deletions

View File

@ -11,7 +11,11 @@
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
// 构建查询参数字符串
const params = [`joinUserId=${joinUserId}`];
let params=[]
if (joinUserId) {
params = [`joinUserId=${joinUserId}`];
}
if (keys && Array.isArray(keys)) {
keys.forEach((key) => {
params.push(`keys=${encodeURIComponent(key)}`);

View File

@ -5,7 +5,16 @@
<view class="loading-text">加载中...</view>
</view>
<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
@ -150,12 +159,17 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ref, onMounted, watch, computed } from 'vue';
import { getTaskStatusType, getTaskStatusStyle, getStatusText } from '@/utils/taskConfig.js';
import { getDashboardBrief, getTaskList } from '@/api';
import { useUserStore } from '@/store/user';
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([
@ -321,15 +335,16 @@ const loadDashboardData = async () => {
'customerMonthFollowCount'
];
// store ID使
const userStore = useUserStore();
// userInfo ID使
const joinUserId = userStore.userInfo?.user?.userId || userStore.userInfo?.userId || '23';
const res = await getDashboardBrief({
joinUserId,
const params = {
keys
});
};
if (filterSelf.value) {
const joinUserId = userStore.userInfo?.user?.userId;
params.joinUserId = joinUserId;
}
const res = await getDashboardBrief(params);
console.log('看板数据加载成功:', res);
mapApiDataToComponent(res);
@ -352,6 +367,10 @@ onMounted(() => {
loadDashboardData();
});
watch(filterSelf, () => {
loadDashboardData();
});
//
const goToTaskList = (label) => {
//
@ -502,6 +521,14 @@ const getTagCustomStyle = (status) => {
padding: 10px 30rpx;
}
.private-filter {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 12px;
justify-content: center;
}
//
.task-card-base {
background: #fff;