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 范围|描述|commitId
@ -10,6 +10,7 @@
- | 插件的填写与提交,修改与删除 | [d461252](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/d461252) - | 插件的填写与提交,修改与删除 | [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) - | 插件调用 | [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) - | 插件面板分开显示 | [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) - | 插件渲染 | [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) - | 插件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) - | 查找任务时,返回交付物和财务条插件初始数据 | [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-account-management v-else-if="pluginId === '19'" class="p-2" />
<p-domain-source-manage v-else-if="pluginId === '20'" 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-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 <Render
v-else v-else

4
components/Projects/ProjectItem.vue

@ -135,8 +135,8 @@ function openProject(project) {
store.commit('task/setUpNextPage', 1); store.commit('task/setUpNextPage', 1);
store.commit('task/setDownNextPage', 1); store.commit('task/setDownNextPage', 1);
store.commit('task/setTimeLineType', 1); store.commit('task/setTimeLineType', 1);
const { name, id, url } = project; const { name, id, url, businessCode } = project;
uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${id}&pname=${name}&url=${encodeURIComponent(url)}` }); 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 getTasksHook = useGetTasks();
const visibleRoles = computed(() => store.state.role.visibleRoles); const visibleRoles = computed(() => store.state.role.visibleRoles);
const roleId = computed(() => store.state.role.roleId); const roleId = computed(() => store.state.role.roleId);
// const tasks = computed(() => store.state.task.tasks);
const allTasks = computed(() => store.state.task.allTasks); // const allTasks = computed(() => store.state.task.allTasks); //
const remindData = computed(() => store.state.socket.remindData); // const remindData = computed(() => store.state.socket.remindData); //
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // id 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) store.commit('task/updateTasks', props.tasks)
console.warn('滚动到顶部: '); 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 }; let params = { pageNum: upNextPage.value, queryType: 0 };
getTasksHook.dataRender(params); getTasksHook.dataRender(params);
} }
@ -79,13 +72,6 @@ async function handleScrollBottom() {
store.commit('task/updateTasks', props.tasks); store.commit('task/updateTasks', props.tasks);
console.warn('滚动到底部: '); 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 }; let params = { pageNum: downNextPage.value, queryType: 1 };
getTasksHook.dataRender(params); 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 param = { projectId: projectId.value, roleId: roleId.value, timeNode: planStart, timeUnit: timeUnit.value };
const index = visibleRoles.value.findIndex(role => role.id === roleId.value); const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.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.commit('task/setPermanents', permanents);
store.dispatch('task/getGlobal', param); store.dispatch('task/getGlobal', param);
uni.$storage.setStorageSync('taskId', taskId); 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 currRoleShowTasks = computed(() => store.state.task.currRoleShowTasks); // 当前角色的展示任务数据
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId);
const businessCode = computed(() => store.state.task.businessCode);
// 初始化 定期任务 // 初始化 定期任务
async function initPlanTasks() { async function initPlanTasks() {
// if (timeLineType.value === 1) setNextPlaceholderTasks({}); // if (timeLineType.value === 1) setNextPlaceholderTasks({});
@ -49,7 +51,8 @@ export default function useGetTasks() {
queryType: query.queryType === 0 ? 0 : 1, queryType: query.queryType === 0 ? 0 : 1,
pageNum: query.pageNum || 1, pageNum: query.pageNum || 1,
pageSize: query.pageSize || uni.$taskConfig.pageCount, 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(); uni.$ui.showLoading();
store.commit('task/setShowSkeleton', false); 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); const params = generateGetTaskParam(query);
console.log('查询定期任务api', params); console.log('查询定期任务api', params);
uni.$catchReq.getTaskByNum(params, (err, data) => { uni.$catchReq.getTaskByNum(params, (err, data) => {
@ -75,25 +85,22 @@ export default function useGetTasks() {
console.error('err: ', err); console.error('err: ', err);
} else { } else {
store.commit('task/setShowScrollTo', true); store.commit('task/setShowScrollTo', true);
params.queryType === 0 ? store.commit('task/setUpRealTasks', data.list) : store.commit('task/setDownRealTasks', data.list); 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); 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]; const arr = [...allTasks.value];
arr[index].realTasks = [...realTasks.value]; arr[index].realTasks = [...realTasks.value];
arr[index].upNextPage = params.queryType === 0 ? data.nextPage : 1; arr[index].upNextPage = params.queryType === 0 ? data.nextPage : 1;
arr[index].downNextPage = params.queryType === 1 ? data.nextPage : 1; arr[index].downNextPage = params.queryType === 1 ? data.nextPage : 1;
store.commit('task/setAllTasks', arr); store.commit('task/setAllTasks', arr);
console.log('设置当前真实任务', arr[index].realTasks);
store.commit('task/setCurrRoleRealTasks', 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 (businessCode.value === 'ZERO' && data.list.length < params.pageSize) {
// if (!currRoleShowTasks.value || !currRoleShowTasks.value.length && timeLineType.value === 1) { params.queryType === 0 ? store.commit('task/setUpNextPage', 0) : store.commit('task/setDownNextPage', 0); // 下一页
// setNextPlaceholderTasks(params); } else if (businessCode.value !== 'ZERO') {
// } params.queryType === 0 ? store.commit('task/setUpNextPage', arr[index].upNextPage) : store.commit('task/setDownNextPage', arr[index].downNextPage); // 下一页
}
// 数据处理 // 数据处理
dataRender(params); dataRender(params);
@ -108,8 +115,7 @@ export default function useGetTasks() {
// 刻度模式数据处理 // 刻度模式数据处理
async function renderScaleTask(query) { async function renderScaleTask(query) {
const params = generateGetTaskParam(query); const params = generateGetTaskParam(query);
console.log('当前角色id', roleId.value); console.log('当前角色id和真实任务', roleId.value, currRoleRealTasks.value);
console.log('当前角色的真实任务', currRoleRealTasks.value);
let centerData = await showTaskTime(params, currRoleShowTasks.value, currRoleRealTasks.value) || []; let centerData = await showTaskTime(params, currRoleShowTasks.value, currRoleRealTasks.value) || [];
console.log('需要显示的真实任务', centerData); console.log('需要显示的真实任务', centerData);
await handleTasksData(params, centerData, currRoleRealTasks.value); await handleTasksData(params, centerData, currRoleRealTasks.value);
@ -312,9 +318,11 @@ export default function useGetTasks() {
// 添加到allTasks里 // 添加到allTasks里
const index = visibleRoles.value.findIndex(role => role.id === roleId.value); const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.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/setAllTasks', arr);
store.commit('task/setCurrRoleShowTasks', arr[index].task); // 设置当前角色的展示任务数据
}); });
return { return {

5
hooks/project/useInit.js

@ -85,9 +85,12 @@ export default function useInit() {
uni.$ui.showToast('缺少项目信息参数'); // 没有项目id参数 uni.$ui.showToast('缺少项目信息参数'); // 没有项目id参数
} else { } else {
if (options.p !== uni.$storage.getStorageSync('projectId')) { 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', ''); uni.$storage.setStorageSync('roleId', '');
store.commit('task/setAllTasks', []); store.commit('task/setAllTasks', []);
store.commit('task/setBusinessCode', options.businessCode || '');
store.commit('task/setTaskId', options.taskId || '');
} }
// 根据项目id获取项目信息 // 根据项目id获取项目信息
const params = { projectId: options.p, num: 0 }; 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 timeLineType = computed(() => store.state.task.timeLineType); //
const remindData = computed(() => store.state.socket.remindData); // const remindData = computed(() => store.state.socket.remindData); //
const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // id const currLocationTaskId = computed(() => store.state.socket.currLocationTaskId); // id
const taskId = computed(() => store.state.task.taskId); // id
onMounted(() => { onMounted(() => {
const system = uni.getSystemInfoSync(); const system = uni.getSystemInfoSync();
@ -99,17 +100,6 @@ watch(roleId, () => {
) return; ) return;
store.commit('task/setTimeNode', Date.now()); 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 => { watch(timeNode, newValue => {
if (newValue && roleId.value) { if (newValue && roleId.value) {
clearTasksData(); 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(); // getGlobalData(); //
getPermanent(); // getPermanent(); //
@ -142,26 +154,28 @@ watch(timeNode, newValue => {
* 重新根据时间和角色查询普通日常任务 * 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变 * 永久日常任务不发生改变
*/ */
watch(newProjectInfo, newValue => { // watch(newProjectInfo, newValue => {
if (newValue && newValue.value.projectId && newValue.value.url) { // if (newValue && newValue.value.projectId && newValue.value.url) {
uni.$u.route('/', { // uni.$u.route('/', {
u: userId.value, // u: userId.value,
p: newValue.value.projectId, // p: newValue.value.projectId,
url: newValue.value.url, // url: newValue.value.url,
}); // });
clearTasksData(); // clearTasksData();
store.commit('role/setRoleId', ''); // store.commit('role/setRoleId', '');
const options = uni.$route.query; // const options = uni.$route.query;
initHook.init(options); // initHook.init(options);
} // }
}); // });
watch(globals, () => { watch(globals, () => {
// allTasks // allTasks
const index = visibleRoles.value.findIndex(role => role.id === roleId.value); const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.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); store.commit('task/setAllTasks', arr);
}); });
@ -210,19 +224,7 @@ function clearTasksData() {
// tabsswiper // tabsswiper
function tabsChange(e) { function tabsChange(e) {
const { id } = visibleRoles.value[e.detail.current]; console.log('切换角色', e);
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', '');
} }
// //

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) { setUpRealTasks(state, data) {
state.realTasks = [...data, ...state.realTasks]; 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) { setDownRealTasks(state, data) {
state.realTasks = [...state.realTasks, ...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) { setCurrRoleShowTasks(state, data) {
state.currRoleShowTasks = 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: [], // 当前角色真实任务 currRoleRealTasks: [], // 当前角色真实任务
currRoleShowTasks: [], // 当前角色展示任务 currRoleShowTasks: [], // 当前角色展示任务
businessCode: '' ,// 当前打开的项目的所属服务
taskId: '', // 任务id
}; };
export default state; export default state;

Loading…
Cancel
Save