|
|
|
@ -16,10 +16,13 @@ |
|
|
|
}" |
|
|
|
:key="index" |
|
|
|
@click="changeRole(item.id, index)" |
|
|
|
class="tab-item" |
|
|
|
class="tab-item relative" |
|
|
|
v-for="(item, index) in data.roles" |
|
|
|
> |
|
|
|
<view class="tab-children u-skeleton-fillet u-font-14">{{ item.name }}</view> |
|
|
|
<view class="tab-children relative u-skeleton-fillet u-font-14"> |
|
|
|
{{ item.name }} |
|
|
|
</view> |
|
|
|
<view class="remind-box absolute bg-red-500 text-white text-xs" v-if="item.remindNum">{{ item.remindNum > 99 ? '99+' : item.remindNum }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</scroll-view> |
|
|
|
@ -32,6 +35,7 @@ |
|
|
|
<script setup> |
|
|
|
import { reactive, computed, watchEffect, onMounted, nextTick } from 'vue'; |
|
|
|
import { useStore } from 'vuex'; |
|
|
|
import useGetTasks from '@/hooks/project/useGetTasks'; |
|
|
|
|
|
|
|
const data = reactive({ |
|
|
|
tabIndex: 0, // 当前访问的 index 默认为0 |
|
|
|
@ -40,14 +44,32 @@ const data = reactive({ |
|
|
|
loading: false, // 是否显示骨架屏组件 |
|
|
|
roles: [{ id: 1, name: '项目经理', mine: 0, pm: 1, sequence: 1 }, { id: 2, name: '运维', mine: 0, pm: 0, sequence: 2 }], |
|
|
|
roleLeft: 0, |
|
|
|
clickNum: 0, |
|
|
|
firstClickTime: 0, |
|
|
|
secClickTime: 0 |
|
|
|
}); |
|
|
|
|
|
|
|
const store = useStore(); |
|
|
|
const getTasksHook = useGetTasks(); |
|
|
|
const visibleRoles = computed(() => store.state.role.visibleRoles); |
|
|
|
const roleId = computed(() => store.state.role.roleId); |
|
|
|
const tasks = computed(() => store.state.task.tasks); |
|
|
|
const remindData = computed(() => store.state.socket.remindData); // 小红点 |
|
|
|
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // 前需要定位到的任务id |
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
|
if (remindData.value && visibleRoles.value) { |
|
|
|
visibleRoles.value.forEach(role => { |
|
|
|
role.remindNum = 0; |
|
|
|
remindData.value.forEach(remind => { |
|
|
|
const remind_data = JSON.parse(remind.data); |
|
|
|
if (remind_data.data.roleId === role.id) { |
|
|
|
role.remindNum++; |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
if (visibleRoles.value && visibleRoles.value.length) { |
|
|
|
data.roles = visibleRoles.value; |
|
|
|
data.loading = false; |
|
|
|
@ -112,12 +134,6 @@ function setCurrentRole(index) { |
|
|
|
// 清除插件script |
|
|
|
function clearPluginScript() { |
|
|
|
try { |
|
|
|
// const query = uni.createSelectorQuery().select(`script[data-type=plugin]`).fields({ |
|
|
|
// id: true, |
|
|
|
// dataset: true, |
|
|
|
// context: true |
|
|
|
// }); |
|
|
|
|
|
|
|
const scripts = document.querySelectorAll('script[data-type=plugin]'); |
|
|
|
for (let i = 0; i < scripts.length; i++) { |
|
|
|
document.body.removeChild(scripts[i]); |
|
|
|
@ -132,14 +148,70 @@ function clearPluginScript() { |
|
|
|
// 时间基准点不用管 project监听了roleId 里处理了 |
|
|
|
function changeRole(id, index) { |
|
|
|
try { |
|
|
|
// 清除多余的script |
|
|
|
clearPluginScript(); |
|
|
|
nextTick(() => { |
|
|
|
store.commit('role/setRoleId', id); |
|
|
|
store.commit('role/setRoleIndex', index); |
|
|
|
// 改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 |
|
|
|
setCurrentRole(index); |
|
|
|
}); |
|
|
|
data.clickNum = data.clickNum === 0 ? 1 : data.clickNum + 1; |
|
|
|
|
|
|
|
if (data.clickNum === 1) { |
|
|
|
data.firstClickTime = new Date().getTime(); |
|
|
|
|
|
|
|
// 清除多余的script |
|
|
|
clearPluginScript(); |
|
|
|
nextTick(() => { |
|
|
|
store.commit('role/setRoleId', id); |
|
|
|
store.commit('role/setRoleIndex', index); |
|
|
|
// 改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 |
|
|
|
setCurrentRole(index); |
|
|
|
}); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
data.clickNum = data.firstClickTime = data.secClickTime = 0; |
|
|
|
}, 500) |
|
|
|
} else if (data.clickNum === 2) { |
|
|
|
data.secClickTime = new Date().getTime(); |
|
|
|
|
|
|
|
if (data.secClickTime - data.firstClickTime < 500) { |
|
|
|
let arr = []; |
|
|
|
remindData.value.forEach(item => { |
|
|
|
const remind_data = JSON.parse(item.data); |
|
|
|
if (remind_data.data.taskType === 1) { |
|
|
|
arr.push(item); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
if (arr.length > 0) { |
|
|
|
let nextLocationTaskId = ''; |
|
|
|
|
|
|
|
for (let i = 0; i < arr.length; i++) { |
|
|
|
const first_option = JSON.parse(arr[0].data); |
|
|
|
const curr_option = JSON.parse(arr[i].data); |
|
|
|
|
|
|
|
if (!currLocationTaskId.value) { |
|
|
|
nextLocationTaskId = first_option.data.taskId; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (curr_option.data.taskId === currLocationTaskId.value) { |
|
|
|
if (i === arr.length - 1) { |
|
|
|
nextLocationTaskId = first_option.data.taskId; |
|
|
|
} else { |
|
|
|
const next_option = JSON.parse(arr[i+1].data); |
|
|
|
nextLocationTaskId = next_option.data.taskId; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
store.commit('socket/setCurrLocationTaskId', nextLocationTaskId); |
|
|
|
store.commit('task/clearTasks'); // 清空定期任务 |
|
|
|
store.commit('task/clearRealTasks'); // 清空真实任务数据 |
|
|
|
store.commit('task/setUpNextPage', 1); |
|
|
|
store.commit('task/setDownNextPage', 1); |
|
|
|
// store.commit('task/setTimeLineType', timeLineType.value === 1 ? 2 : 1); |
|
|
|
let params = { pageNum: 1, taskId: nextLocationTaskId }; |
|
|
|
getTasksHook.getTasks(params); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data.clickNum = data.firstClickTime = data.secClickTime = 0; |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('role.vue changeRole error: ', error); |
|
|
|
} |
|
|
|
@ -216,6 +288,19 @@ function changeRole(id, index) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.remind-box { |
|
|
|
top: 0; |
|
|
|
right: -5px; |
|
|
|
padding: 0 3px; |
|
|
|
min-width: 16px; |
|
|
|
height: 16px; |
|
|
|
text-align: center; |
|
|
|
line-height: 16px; |
|
|
|
border-radius: 8px; |
|
|
|
font-weight: 100; |
|
|
|
transform: scale(0.8); |
|
|
|
} |
|
|
|
|
|
|
|
// // 删除 底部滚动条 |
|
|
|
/* #ifndef APP-NVUE */ |
|
|
|
::-webkit-scrollbar, |
|
|
|
|