Browse Source

feat: lwbs跳转

test2
xuesinan 4 years ago
parent
commit
78e31c59be
  1. 3
      CHANGELOG.md
  2. 3
      components/Plugin/Plugin.vue
  3. 4
      components/Projects/ProjectItem.vue
  4. 1
      components/Roles/Roles.vue
  5. 14
      components/TimeLine/TimeLine.vue
  6. 2
      components/TimeLine/component/TimeBox.vue
  7. 36
      hooks/project/useGetTasks.js
  8. 5
      hooks/project/useInit.js
  9. 78
      pages/project/project.vue
  10. 23
      plugins/p-task-to-detail/p-task-to-detail.vue
  11. 38
      store/task/mutations.js
  12. 3
      store/task/state.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-03-17)
# 1.0.0 (2022-03-21)
### 🌟 新功能
范围|描述|commitId
@ -10,6 +10,7 @@
- | 插件的填写与提交,修改与删除 | [d461252](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/d461252)
- | 插件调用 | [9146b40](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9146b40)
- | 插件面板分开显示 | [fb5e86b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/fb5e86b)
- | 插件详情页 | [0e96e53](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/0e96e53)
- | 插件渲染 | [e15123a](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e15123a)
- | 插件api | [08bdf74](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/08bdf74)
- | 查找任务时,返回交付物和财务条插件初始数据 | [29d7173](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/29d7173)

3
components/Plugin/Plugin.vue

@ -29,6 +29,9 @@
<p-account-management v-else-if="pluginId === '19'" class="p-2" />
<p-domain-source-manage v-else-if="pluginId === '20'" class="p-2" />
<p-project-version-management v-else-if="pluginId === '21'" class="p-2" />
<!-- 任务名和跳转详情页箭头 -->
<p-task-to-detail :task="task" v-else-if="pluginId === '24'" class="p-2"></p-task-to-detail>
<Render
v-else

4
components/Projects/ProjectItem.vue

@ -135,8 +135,8 @@ function openProject(project) {
store.commit('task/setUpNextPage', 1);
store.commit('task/setDownNextPage', 1);
store.commit('task/setTimeLineType', 1);
const { name, id, url } = project;
uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}` });
const { name, id, url, businessCode } = project;
uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}&businessCode=${businessCode}` });
}
/**

1
components/Roles/Roles.vue

@ -58,7 +58,6 @@ 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 allTasks = computed(() => store.state.task.allTasks); //
const remindData = computed(() => store.state.socket.remindData); //
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // id

14
components/TimeLine/TimeLine.vue

@ -61,13 +61,6 @@ async function handleScrollTop() {
store.commit('task/updateTasks', props.tasks)
console.warn('滚动到顶部: ');
// if (timeLineType.value === 1) {
// const startTime = props.tasks[0].planStart - 0;
// store.commit('task/setCurrUpTimeNode', startTime);
// const addTasks = uni.$task.setPlaceholderTasks(startTime, true, timeGranularity.value);
// store.commit('task/setUpTasks', addTasks);
// }
let params = { pageNum: upNextPage.value, queryType: 0 };
getTasksHook.dataRender(params);
}
@ -79,13 +72,6 @@ async function handleScrollBottom() {
store.commit('task/updateTasks', props.tasks);
console.warn('滚动到底部: ');
// if (timeLineType.value === 1) {
// const startTime = dayjs(+props.tasks[props.tasks.length - 1].planStart).add(1, timeGranularity.value).valueOf();
// store.commit('task/setCurrDownTimeNode', startTime);
// const addTasks = uni.$task.setPlaceholderTasks(startTime, false, timeGranularity.value);
// store.commit('task/setDownTasks', addTasks);
// }
let params = { pageNum: downNextPage.value, queryType: 1 };
getTasksHook.dataRender(params);
}

2
components/TimeLine/component/TimeBox.vue

@ -108,7 +108,7 @@ function onClickTask(planStart, taskId) {
const param = { projectId: projectId.value, roleId: roleId.value, timeNode: planStart, timeUnit: timeUnit.value };
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
const permanents = arr[index].global || [];
const permanents = arr.length && index > -1 ? arr[index].global : [];
store.commit('task/setPermanents', permanents);
store.dispatch('task/getGlobal', param);
uni.$storage.setStorageSync('taskId', taskId);

36
hooks/project/useGetTasks.js

@ -28,6 +28,8 @@ export default function useGetTasks() {
const currRoleShowTasks = computed(() => store.state.task.currRoleShowTasks); // 当前角色的展示任务数据
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId);
const businessCode = computed(() => store.state.task.businessCode);
// 初始化 定期任务
async function initPlanTasks() {
// if (timeLineType.value === 1) setNextPlaceholderTasks({});
@ -49,7 +51,8 @@ export default function useGetTasks() {
queryType: query.queryType === 0 ? 0 : 1,
pageNum: query.pageNum || 1,
pageSize: query.pageSize || uni.$taskConfig.pageCount,
taskId: query.taskId || currLocationTaskId.value
taskId: query.taskId || currLocationTaskId.value,
businessCode: query.businessCode || businessCode.value
};
}
@ -66,6 +69,13 @@ export default function useGetTasks() {
uni.$ui.showLoading();
store.commit('task/setShowSkeleton', false);
if (businessCode.value === 'ZERO' && currRoleRealTasks.value.length > 0) {
let needTask = query.queryType === 0 ? currRoleRealTasks.value[0] : currRoleRealTasks.value[currRoleRealTasks.value.length - 1];
query.taskId = needTask.id;
query.timeNode = needTask.planStart;
query.businessCode = needTask.businessCode;
}
const params = generateGetTaskParam(query);
console.log('查询定期任务api', params);
uni.$catchReq.getTaskByNum(params, (err, data) => {
@ -75,25 +85,22 @@ export default function useGetTasks() {
console.error('err: ', err);
} else {
store.commit('task/setShowScrollTo', true);
params.queryType === 0 ? store.commit('task/setUpRealTasks', data.list) : store.commit('task/setDownRealTasks', data.list);
console.log('查询到的真实任务', data.list);
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
console.log('api当前角色id', roleId.value, index);
console.log('api当前角色id', roleId.value, index, data.list);
const arr = [...allTasks.value];
arr[index].realTasks = [...realTasks.value];
arr[index].upNextPage = params.queryType === 0 ? data.nextPage : 1;
arr[index].downNextPage = params.queryType === 1 ? data.nextPage : 1;
store.commit('task/setAllTasks', arr);
console.log('设置当前真实任务', arr[index].realTasks);
store.commit('task/setCurrRoleRealTasks', arr[index].realTasks); // 设置当前角色的真实任务数据
params.queryType === 0 ? store.commit('task/setUpNextPage', arr[index].upNextPage) : store.commit('task/setDownNextPage', arr[index].downNextPage); // 下一页
// 如果第一次渲染但没有空数据则加载空数据
// if (!currRoleShowTasks.value || !currRoleShowTasks.value.length && timeLineType.value === 1) {
// setNextPlaceholderTasks(params);
// }
if (businessCode.value === 'ZERO' && data.list.length < params.pageSize) {
params.queryType === 0 ? store.commit('task/setUpNextPage', 0) : store.commit('task/setDownNextPage', 0); // 下一页
} else if (businessCode.value !== 'ZERO') {
params.queryType === 0 ? store.commit('task/setUpNextPage', arr[index].upNextPage) : store.commit('task/setDownNextPage', arr[index].downNextPage); // 下一页
}
// 数据处理
dataRender(params);
@ -108,8 +115,7 @@ export default function useGetTasks() {
// 刻度模式数据处理
async function renderScaleTask(query) {
const params = generateGetTaskParam(query);
console.log('当前角色id', roleId.value);
console.log('当前角色的真实任务', currRoleRealTasks.value);
console.log('当前角色id和真实任务', roleId.value, currRoleRealTasks.value);
let centerData = await showTaskTime(params, currRoleShowTasks.value, currRoleRealTasks.value) || [];
console.log('需要显示的真实任务', centerData);
await handleTasksData(params, centerData, currRoleRealTasks.value);
@ -312,9 +318,11 @@ export default function useGetTasks() {
// 添加到allTasks里
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
arr[index].task = [...tasks.value];
if (arr.length && index > -1) {
arr[index].task = [...tasks.value];
store.commit('task/setCurrRoleShowTasks', arr[index].task); // 设置当前角色的展示任务数据
}
store.commit('task/setAllTasks', arr);
store.commit('task/setCurrRoleShowTasks', arr[index].task); // 设置当前角色的展示任务数据
});
return {

5
hooks/project/useInit.js

@ -85,9 +85,12 @@ export default function useInit() {
uni.$ui.showToast('缺少项目信息参数'); // 没有项目id参数
} else {
if (options.p !== uni.$storage.getStorageSync('projectId')) {
store.commit('role/setRoleId', '');
store.commit('project/setProject', options);
store.commit('role/setRoleId', options.roleId || '');
uni.$storage.setStorageSync('roleId', '');
store.commit('task/setAllTasks', []);
store.commit('task/setBusinessCode', options.businessCode || '');
store.commit('task/setTaskId', options.taskId || '');
}
// 根据项目id获取项目信息
const params = { projectId: options.p, num: 0 };

78
pages/project/project.vue

@ -61,6 +61,7 @@ const height = ref(null); // 页面高度
const timeLineType = computed(() => store.state.task.timeLineType); //
const remindData = computed(() => store.state.socket.remindData); //
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // id
const taskId = computed(() => store.state.task.taskId); // id
onMounted(() => {
const system = uni.getSystemInfoSync();
@ -99,17 +100,6 @@ watch(roleId, () => {
) return;
store.commit('task/setTimeNode', Date.now());
let currRoleRealTasks = [];
let currRoleShowTasks = [];
if (allTasks.value.length) {
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
currRoleRealTasks = allTasks.value[index].realTasks || [];
currRoleShowTasks = allTasks.value[index].task || [];
}
store.commit('socket/setCurrLocationTaskId', '');
store.commit('task/setCurrRoleRealTasks', currRoleRealTasks); //
store.commit('task/setCurrRoleShowTasks', currRoleShowTasks); //
}
});
@ -121,6 +111,28 @@ watch(roleId, () => {
watch(timeNode, newValue => {
if (newValue && roleId.value) {
clearTasksData();
let currRoleRealTasks = [];
let currRoleShowTasks = [];
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
let upNextPage = 1;
let downNextPage = 1;
if (arr.length && index > -1) {
currRoleRealTasks = arr[index].realTasks || [];
currRoleShowTasks = arr[index].task || [];
upNextPage = arr[index].upNextPage || 1;
downNextPage = arr[index].downNextPage || 1;
}
store.commit('task/updateTasks', currRoleShowTasks); // store
store.commit('task/updateRealTasks', currRoleRealTasks); // store
store.commit('task/setCurrRoleRealTasks', currRoleRealTasks); //
store.commit('task/setCurrRoleShowTasks', currRoleShowTasks); //
store.commit('task/setUpNextPage', upNextPage); //
store.commit('task/setDownNextPage', downNextPage); //
store.commit('socket/setCurrLocationTaskId', taskId.value || '');
//
getGlobalData(); //
getPermanent(); //
@ -142,26 +154,28 @@ watch(timeNode, newValue => {
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
watch(newProjectInfo, newValue => {
if (newValue && newValue.value.projectId && newValue.value.url) {
uni.$u.route('/', {
u: userId.value,
p: newValue.value.projectId,
url: newValue.value.url,
});
clearTasksData();
store.commit('role/setRoleId', '');
const options = uni.$route.query;
// watch(newProjectInfo, newValue => {
// if (newValue && newValue.value.projectId && newValue.value.url) {
// uni.$u.route('/', {
// u: userId.value,
// p: newValue.value.projectId,
// url: newValue.value.url,
// });
// clearTasksData();
// store.commit('role/setRoleId', '');
// const options = uni.$route.query;
initHook.init(options);
}
});
// initHook.init(options);
// }
// });
watch(globals, () => {
// allTasks
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
arr[index].global = [...globals.value];
if (arr.length && index > -1) {
arr[index].global = [...globals.value];
}
store.commit('task/setAllTasks', arr);
});
@ -210,19 +224,7 @@ function clearTasksData() {
// tabsswiper
function tabsChange(e) {
const { id } = visibleRoles.value[e.detail.current];
store.commit('role/setRoleIndex', e.detail.current);
store.commit('role/setRoleId', id);
const index = visibleRoles.value.findIndex(role => role.id === id);
const arr = [...allTasks.value];
store.commit('task/updateTasks', arr[index].task || []); // store
store.commit('task/updateRealTasks', arr[index].realTasks || []); // store
store.commit('task/setCurrRoleRealTasks', arr[index].realTasks || []); //
store.commit('task/setCurrRoleShowTasks', arr[index].task || []); //
store.commit('task/setUpNextPage', arr[index].upNextPage || 1); //
store.commit('task/setDownNextPage', arr[index].downNextPage || 1); //
store.commit('socket/setCurrLocationTaskId', '');
console.log('切换角色', e);
}
//

23
plugins/p-task-to-detail/p-task-to-detail.vue

@ -0,0 +1,23 @@
<template>
<!-- 任务名 跳转详情页 -->
<view class="u-font-14 flex justify-between item-center">
{{ task.name }}
<u-icon name="arrow-right" class="ml-3" @click="toDetail(task)"></u-icon>
</view>
</template>
<script setup>
import { useStore } from 'vuex';
const store = useStore();
defineProps({ task: { type: Object, default: () => {} } });
function toDetail(task) {
const { id, projectId, executorRoleId, businessUrl, businessCode } = task;
uni.navigateTo({ url: `/pages/project/project?p=${projectId}&url=${encodeURIComponent(businessUrl)}&businessCode=${businessCode}&taskId=${id}&roleId=${executorRoleId}` });
}
</script>
<style>
</style>

38
store/task/mutations.js

@ -15,6 +15,16 @@ const mutations = {
*/
setUpRealTasks(state, data) {
state.realTasks = [...data, ...state.realTasks];
let arr = [];
state.realTasks.forEach(item => {
const index = arr.findIndex(v => v.id === item.id);
if (index === -1) {
arr.push(item);
}
})
state.realTasks = [...arr];
},
/**
@ -24,6 +34,16 @@ const mutations = {
*/
setDownRealTasks(state, data) {
state.realTasks = [...state.realTasks, ...data];
let arr = [];
state.realTasks.forEach(item => {
const index = arr.findIndex(v => v.id === item.id);
if (index === -1) {
arr.push(item);
}
})
state.realTasks = [...arr];
},
/**
@ -371,6 +391,24 @@ const mutations = {
setCurrRoleShowTasks(state, data) {
state.currRoleShowTasks = data || [];
},
/**
* 当前打开的项目的所属服务
* @param {Object} state
* @param {Object} data
*/
setBusinessCode(state, data) {
state.businessCode = data;
},
/**
* 是否冒泡
* @param {Object} state
* @param {Object} data
*/
setTaskId(state, data) {
state.taskId = data;
}
};

3
store/task/state.js

@ -35,6 +35,9 @@ const state = {
currRoleRealTasks: [], // 当前角色真实任务
currRoleShowTasks: [], // 当前角色展示任务
businessCode: '' ,// 当前打开的项目的所属服务
taskId: '', // 任务id
};
export default state;

Loading…
Cancel
Save