Browse Source

Merge remote-tracking branch 'origin/lucky' into song

pull/45/head
song 4 years ago
parent
commit
037adb2575
  1. 10
      CHANGELOG.md
  2. 4
      src/apis/plugin.js
  3. 4
      src/components/Plugin/Plugin.vue
  4. 11
      src/components/Roles/Roles.vue
  5. 145
      src/components/TimeLine/TimeLine.vue
  6. 10
      src/components/TimeLine/component/TimeBox.vue
  7. 28
      src/components/TimeLine/component/TimeStatus.vue
  8. 44
      src/mixins/timeline.js
  9. 160
      src/pages/project/project.vue
  10. 50
      src/plugins/p-subproject/p-subproject.vue
  11. 32
      src/plugins/p-subtasks/p-subtasks.vue
  12. 3
      src/plugins/p-wbs-import/p-wbs-import.vue
  13. 11
      src/store/task/actions.js
  14. 158
      src/store/task/mutations.js
  15. 2
      src/store/task/state.js
  16. 12
      src/utils/time.js

10
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-08-19)
# 0.1.0 (2021-08-18)
### 🌟 新功能
范围|描述|commitId
@ -82,6 +82,7 @@
### 🐛 Bug 修复
范围|描述|commitId
--|--|--
- | 1.时间轴数据渲染 2.时间基准线 | [d643af2](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/d643af2)
ID1000343 | 解决向下预加载查询参数时间没+1颗粒度;以及滚动加载颗粒度写死的问题 | [940603a](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/940603a), closes [#ID1000343](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/issues/ID1000343)
plugin | 插件解析机制完善 | [0f5a27d](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/0f5a27d)
project title | 项目标题修改; 切换角色移除script | [5c20017](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/5c20017)
@ -94,12 +95,14 @@
- | 下拉加载定期任务传参,时间格式化修改 | [0b95a0e](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/0b95a0e)
- | 任务开始时间延迟插件 | [992a313](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/992a313)
- | 修改main | [749ae9a](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/749ae9a)
- | 修改定期任务状态0和4时不加载圆圈 | [30e352f](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/30e352f)
- | 修改小红点传参 | [87b20fd](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/87b20fd)
- | 修改报错 | [531c14d](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/531c14d)
- | 修改接口路径 | [df6acf2](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/df6acf2)
- | 修改角色栏组件 | [a54c601](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/a54c601)
- | 切换到默认项目角色没有激活状态的bug | [438d448](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/438d448)
- | 切换日历时查询小红点 | [7091789](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/7091789)
- | 初始展示角色修改 | [2ac4053](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/2ac4053)
- | 定期任务key值修改 | [c6688db](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c6688db)
- | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/aa4981c)
- | 定期任务插件 | [92b3254](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/92b3254)
@ -118,11 +121,13 @@
- | 时间轴上下滚动数据加载bug修改 | [e82ede4](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/e82ede4)
- | 时间轴插件 | [225d3cc](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/225d3cc)
- | 时间轴无任务时时间刻度加载修改 | [4921672](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/4921672)
- | 时间轴滚动位置修改 | [551da63](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/551da63)
- | 时间轴骨架屏修改 | [ca78d02](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/ca78d02)
- | 监听时间基本点 | [033fca0](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/033fca0)
- | 角色显示状态修改 | [7d3b906](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/7d3b906)
- | 角色栏修改 | [19228d6](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/19228d6)
- | 解决时间轴报错 | [da1eece](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/da1eece)
- | 设置时间轴自动滚动到当前位置 | [a3474f8](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/a3474f8)
- | 跳转详情页返回路径修改 | [c5e17c0](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c5e17c0)
- | 骨架屏替换 | [e9fdd71](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/e9fdd71)
@ -163,6 +168,8 @@
### 🚀 性能优化
范围|描述|commitId
--|--|--
- | 1.时间轴筛选相同的时间替换数据 2.整理代码 | [e082ccb](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/e082ccb)
- | 修改代码格式 | [14123d7](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/14123d7)
- | 修改定期任务骨架屏高度 | [909a734](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/909a734)
- | 插件查询及展示 | [4dba770](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/4dba770)
- | 整理代码 | [7a55315](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/7a55315)
@ -197,4 +204,3 @@
- | style:index | [978f272](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/978f272)
- | !2 基础模板v1.1.0 | [f5e61dd](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/f5e61dd)
- | init | [c0f1deb](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c0f1deb)

4
src/apis/plugin.js

@ -5,6 +5,10 @@ const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
// 获取插件信息
vm.$u.api.getOtherPlugin = param => vm.$u.post(`${url}/pluginshop/plugin/query`, param);
// 查询子任务
vm.$u.api.findSonTask = param => vm.$u.post(`${uni.$t.domain}/task/findSonTask`, param);
// 查询子项目
vm.$u.api.findSonProject = param => vm.$u.post(`${uni.$t.domain}/project/findSonProject`, param);
};
export default { install };

4
src/components/Plugin/Plugin.vue

@ -27,8 +27,8 @@
<p-task-duration-delay :task="task" v-if="pluginId === '3'" />
<p-task-start-time-delay :task="task" v-if="pluginId === '4'" />
<!-- <p-deliverable :task="task" v-if="pluginId === '5'" /> -->
<!-- <p-subtasks :task="task" v-if="pluginId === '6'" /> -->
<!-- <p-subproject :task="task" v-if="pluginId === '7'" /> -->
<p-subtasks :task="task" v-if="pluginId === '6'" />
<p-subproject :task="task" v-if="pluginId === '7'" />
<!-- <p-task-countdown :task="task" v-if="pluginId === '8'" /> -->
<p-manage-project :task="task" v-if="pluginId === '9'" />
<p-manage-role :task="task" v-if="pluginId === '10'" />

11
src/components/Roles/Roles.vue

@ -58,10 +58,11 @@ export default {
methods: {
...mapActions('task', ['handleRegularTask', 'getPermanent']),
...mapMutations('role', ['setRoleId']),
...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag', 'setTimeNode']),
...mapMutations('task', ['setPermanents', 'clearEndFlag']),
//
setCurrentRole(index) {
console.log('index: ', index);
const data = document.getElementsByClassName('tab-children');
// tabList
data.forEach(item => {
@ -85,20 +86,12 @@ export default {
// projectroleId
changeRole(id, index) {
try {
console.log('切换角色');
// script
this.clearPluginScript();
this.$nextTick(() => {
this.setRoleId(id);
//index
this.setCurrentRole(index);
//
this.setPermanents([]);
this.setDailyTasks([]);
//
//
//
this.clearEndFlag();
});
} catch (error) {
console.error('role.vue changeRole error: ', error);

145
src/components/TimeLine/TimeLine.vue

@ -4,9 +4,9 @@
<scroll-view
:lower-threshold="300"
:scrollTop="top"
:scrollY="true"
scroll-y="true"
:upper-threshold="300"
:scroll-into-view="viewId"
@scroll="scroll"
@scrolltolower="handleScrollBottom"
@scrolltoupper="handleScrollTop"
@ -23,10 +23,12 @@
// import Barrier from './component/Barrier.vue';
import { mapState, mapMutations, mapGetters } from 'vuex';
import TimeBox from './component/TimeBox.vue';
import mixin from '@/mixins/timeline';
export default {
name: 'TimeLine',
components: { TimeBox },
mixins: [mixin],
data() {
return { top: 0 };
@ -34,16 +36,12 @@ export default {
computed: {
...mapState('role', ['visibleRoles']),
...mapState('task', ['scrollTop', 'showTips', 'tasks', 'topEnd', 'bottomEnd', 'showSkeleton', 'randomId']),
...mapState('task', ['scrollTop', 'showTips', 'tasks', 'topEnd', 'bottomEnd', 'showSkeleton', 'timeNode', 'viewId']),
...mapGetters('task', ['timeGranularity']),
},
mounted() {
this.setDatumPoint();
},
methods: {
...mapMutations('task', ['setScrollTop', 'setShrink', 'setUpTasks', 'setDownTasks']),
...mapMutations('task', ['setScrollTop', 'setShrink', 'setUpTasks', 'setDownTasks', 'setViewId']),
//
scroll(e) {
@ -58,52 +56,8 @@ export default {
const startTime = this.tasks[0].planStart - 0;
if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) {
//
// console.warn(': ');
const addTasks = [
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -6, 'day').valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -5, 'day').valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -4, 'day').valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -3, 'day').valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -2, 'day').valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, -1, 'day').valueOf(),
},
];
console.warn('滚动到顶部没有数据时: ');
const addTasks = this.setTime(startTime, true);
this.setUpTasks(addTasks);
} else {
//
@ -124,54 +78,12 @@ export default {
const startTime = tasks[tasks.length - 1].planStart - 0;
if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) {
//
// console.warn(': ');
const addTasks = [
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 1, timeGranularity).valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 2, timeGranularity).valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 3, timeGranularity).valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 4, timeGranularity).valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 5, timeGranularity).valueOf(),
},
{
id: this.randomId,
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, 6, timeGranularity).valueOf(),
},
];
console.warn('滚动到底部没有数据时: ');
const addTasks = this.setTime(startTime, false);
this.setDownTasks(addTasks);
} else {
// =+
console.warn('滚动到底部有数据时: ');
const timeNode = this.$t.time.add(startTime, 1, timeGranularity).valueOf();
const downQuery = {
timeNode,
@ -182,25 +94,24 @@ export default {
}
},
//
setDatumPoint() {
const { tasks } = this;
if (tasks && tasks.length) {
let tasksHeight = 0;
const scrollHeight = document.getElementById('scroll').clientHeight;
let width = document.documentElement.clientWidth;
for (let i = 0; i < 3; i++) {
if (tasks[i].panel && tasks[i].panel.height) {
// + 42
tasksHeight += +tasks[i].panel.height + 42;
} else {
// rem + 42
// u-card h-16 = 4rem
// += 1rem + 42 = width / 20 + 42
tasksHeight += (width / 20) * 4 + 42;
}
//
setScrollPosition() {
const { tasks, timeNode } = this;
for (let i = 0; i < tasks.length; i++) {
const item = tasks[i];
const show = this.$t.time.isSame(+item.planStart, +timeNode, this.timeGranularity);
// storagetimeNode,storetimeNode
const taskId = this.$t.storage.getStorageSync('taskId');
// storage
if (taskId) {
this.setViewId(`a${taskId}`);
this.$t.storage.setStorageSync('taskId', '');
return;
}
if (show) {
this.setViewId(`a${item.id}`);
return;
}
this.top = tasksHeight - scrollHeight / 2;
}
},
},

10
src/components/TimeLine/component/TimeBox.vue

@ -2,12 +2,13 @@
<view class="column">
<!-- v-if="tasks && tasks.length" -->
<view>
<view :key="task.id" v-for="task in tasks">
<view :key="task.id" v-for="task in tasks" class="ssssss" :id="`a${task.id}`">
<view class="flex">
<TimeStatus :task="task" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view v-if="task.process !== 4">{{ $moment(+task.planStart).format(startTimeFormat) }}</view>
<view v-else>{{ $moment(+task.planStart).format('D日') }}</view>
<!-- 任务功能菜单 -->
<TaskTools v-if="task.process !== 4" />
</view>
@ -37,7 +38,7 @@
class="h-16"
margin="0"
v-if="tasks && tasks.length && task.process !== 4 && !showSkeleton"
@click="onClickTask(+task.planStart)"
@click="onClickTask(+task.planStart, task.id)"
>
<!-- 任务面板插件 -->
<view slot="body">
@ -104,11 +105,12 @@ export default {
/**
* 点击了定期任务的面板 更新可变的日常任务
* @param {number} planStart 任务计划开始时间
* @param {string} taskId 任务id
*/
onClickTask(planStart) {
onClickTask(planStart, taskId) {
const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit };
this.getGlobal(param);
this.$t.storage.setStorageSync('timeNode', planStart);
this.$t.storage.setStorageSync('taskId', taskId);
this.$t.storage.setStorageSync('roleId', this.roleId);
},

28
src/components/TimeLine/component/TimeStatus.vue

@ -5,13 +5,25 @@
:style="{ color: orderStyle.color }"
@tap="changeStatus($event, task.process)"
>
<!-- 1进行中 2暂停中 3已完成 -->
<u-circle-progress
:percent="+orderStyle.persent"
:active-color="orderStyle.color"
bg-color="rgba(255,255,255,0)"
border-width="4"
:width="task.process !== 4 ? 66 : 50"
v-if="task.process === 1 || task.process === 2 || task.process === 3"
>
<view class="u-progress-content">
<view class="u-progress-dot"></view>
<view class="u-progress-info">
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="15px"></u-icon>
<template v-else>{{ computeDurationText() }}</template>
</view>
</view>
</u-circle-progress>
<!-- 0未开始 4添加任务 -->
<view class="progress-box flex justify-center items-center rounded-full" v-else :class="task.process === 4 ? 'progress-box-4' : ''">
<view class="u-progress-content">
<view class="u-progress-dot"></view>
<view class="u-progress-info">
@ -22,7 +34,7 @@
<template v-else>{{ computeDurationText() }}</template>
</view>
</view>
</u-circle-progress>
</view>
</view>
</view>
</template>
@ -106,7 +118,6 @@ export default {
* @param {object} event
*/
changeStatus(event, process) {
console.log('event, process: ', event, process);
if (process === 4) {
this.addTask();
return;
@ -184,4 +195,17 @@ export default {
height: 33px;
width: 33px;
}
.progress-box {
background: rgba(255, 255, 255, 0);
width: 33px;
height: 33px;
border: 2px solid #9ca3af;
}
.progress-box-4 {
width: 25px;
height: 25px;
border: 2px solid #60a5fa;
}
</style>

44
src/mixins/timeline.js

@ -0,0 +1,44 @@
import { mapGetters } from 'vuex';
const mixin = {
computed: mapGetters('task', ['timeGranularity']),
methods: {
/**
* 设置时间轴空数据
* @param {*} startTime
* @param {*} show true 向上加载,false 向下加载
*/
setTime(startTime, show) {
let { timeGranularity } = this;
let arr = [];
let str = {};
if (show) {
for (let i = 10; i > 0; i--) {
str = {
id: this.$u.guid(20, false, 10),
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, `-${i}` - 0, timeGranularity).valueOf(),
};
arr.push(str);
}
} else {
for (let i = 0; i < 10; i++) {
str = {
id: this.$u.guid(20, false, 10),
panel: {},
plugins: [],
process: 4,
planStart: this.$t.time.add(startTime, i + 1, timeGranularity).valueOf(),
};
arr.push(str);
}
}
return arr;
},
},
};
export default mixin;

160
src/pages/project/project.vue

@ -18,8 +18,10 @@
<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
import mixin from '@/mixins/timeline';
export default {
mixins: [mixin],
data() {
return { height: '' };
},
@ -41,12 +43,10 @@ export default {
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
timeNode(val) {
console.log('val: ', val);
async timeNode(val) {
if (val && this.roleId) {
//
this.getGlobalData();
this.getInitTasks();
await this.initTasks();
}
},
@ -58,13 +58,7 @@ export default {
*/
roleId(val) {
if (val) {
// storagetimeNode,storetimeNode
this.setTimeNode(
+this.$t.storage.getStorageSync('timeNode') !== 0 ? +this.$t.storage.getStorageSync('timeNode') !== 0 : Date.now(),
);
// storage
this.$t.storage.setStorageSync('timeNode', '');
console.log('当角色发生变化时: ', this.timeNode);
this.setTimeNode(Date.now());
//
this.getPermanent(val);
}
@ -77,6 +71,7 @@ export default {
onUnload() {
this.clearEndFlag();
this.clearTasks();
},
methods: {
@ -87,7 +82,18 @@ export default {
...mapMutations('user', ['setToken']),
...mapMutations('project', ['setProject', 'setProjectName']),
...mapMutations('role', ['setInvisibleRoles', 'setVisibleRoles', 'setRoleId']),
...mapMutations('task', ['setUpTasks', 'setDownTasks', 'setDailyTasks', 'setTimeNode', 'clearEndFlag', 'setShowSkeleton']),
...mapMutations('task', [
'setPermanents',
'setUpTasks',
'setDownTasks',
'setDailyTasks',
'setTimeNode',
'clearTasks',
'clearEndFlag',
'setShowSkeleton',
'setTopEnd',
'setBottomEnd',
]),
/**
* 初始化
@ -113,11 +119,6 @@ export default {
// id
this.$t.ui.showToast('缺少项目信息参数');
} else {
// storagetimeNode,storetimeNode
this.setTimeNode(this.$t.storage.getStorageSync('timeNode') - 0);
// storage
this.$t.storage.setStorageSync('timeNode', '');
console.log('timeNode: ', this.$t.storage.getStorageSync('timeNode'), this.timeNode);
// id
await this.getProjectById({ projectId: options.p });
// id
@ -129,6 +130,38 @@ export default {
}
},
//
async initTasks() {
//
this.setPermanents([]);
this.setDailyTasks([]);
//
this.clearTasks();
//
//
this.clearEndFlag();
//
this.getGlobalData();
//
this.setPrevTasks();
// storage
const storageTaskId = this.$t.storage.getStorageSync('taskId');
this.$nextTick(() => {
if (!storageTaskId) {
this.$refs.child.setScrollPosition();
}
});
//
this.setNextTasks();
await this.getInitTasks();
// storage
this.$nextTick(() => {
if (storageTaskId) {
this.$refs.child.setScrollPosition();
}
});
},
// ||
async getInitTasks() {
//
@ -136,26 +169,27 @@ export default {
await this.getTasks({ queryType: 1 });
//
if (this.tasks && this.tasks.length && this.tasks[0].detailId) {
this.$nextTick(() => {
const detailId = this.tasks.findIndex(task => task.detailId);
if (detailId !== -1) {
this.$nextTick(async () => {
const { tasks, timeGranularity } = this;
this.getTasks({ timeNode: +tasks[0].planStart, queryType: 0, queryNum: 6 }); //
await this.getTasks({ timeNode: +tasks[0].planStart, queryType: 0, queryNum: 6 }); //
//
const nextQueryTime = +this.$t.time.add(+tasks[tasks.length - 1].planStart, 1, timeGranularity);
this.getTasks({ timeNode: nextQueryTime, queryType: 1, queryNum: 6 }); //
await this.getTasks({ timeNode: nextQueryTime, queryType: 1, queryNum: 6 }); //
});
} else {
//
//
this.setUpTasks();
this.setPrevTasks();
//
this.setDownTasks();
this.setNextTasks();
}
},
//
setInitialRoleId(visibleList) {
const index = visibleList.findIndex(item => item.mine === '1');
const index = visibleList.findIndex(item => +item.mine === 1);
const currentRole = index > 0 ? visibleList[index] : visibleList[0];
const storageRoleId = this.$t.storage.getStorageSync('roleId');
const currentRoleId = storageRoleId ? storageRoleId : currentRole ? currentRole.id : '';
@ -184,9 +218,14 @@ export default {
queryNum: query.queryNum || 3,
queryType: query.queryType,
};
console.log('params: ', params);
await this.getRegulars(params);
const res = await this.getRegulars(params);
this.setShowSkeleton(false);
// 0 -> 1 ->
if (res && res.length) {
this.replacePrevData(res, params.queryType);
} else {
params.queryType === 0 ? this.setPrevTasks() : this.setNextTasks();
}
} catch (error) {
this.setShowSkeleton(false);
console.error('error: ', error);
@ -199,6 +238,75 @@ export default {
const param = { roleId, timeNode, timeUnit };
this.getGlobal(param);
},
//
setPrevTasks() {
this.setTopEnd(true);
let sTime = '';
if (!this.tasks || !this.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +this.tasks[0].planStart - 0;
}
const initData = this.setTime(sTime, true);
this.setUpTasks(initData);
},
//
setNextTasks() {
this.setBottomEnd(true);
let sTime = '';
if (!this.tasks || !this.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +this.tasks[this.tasks.length - 1].planStart - 0;
}
const initData = this.setTime(sTime, false);
this.setDownTasks(initData);
},
//
replacePrevData(data, type) {
let newTasks = [...this.tasks];
for (let i = 0; i < newTasks.length; i++) {
const task = newTasks[i];
let arr = [];
for (let j = 0; j < data.length; j++) {
const item = data[j];
//
if (+newTasks[0].planStart > +data[0].planStart) {
this.setPrevTasks();
newTasks = [...this.tasks];
i--;
break;
} else if (+data[data.length - 1].planStart > +newTasks[newTasks.length - 1].planStart) {
this.setNextTasks();
newTasks = [...this.tasks];
i--;
break;
} else {
//
const taskItem = this.$t.time.isSame(+task.planStart, +item.planStart, this.timeGranularity);
if (taskItem) {
arr.push(item);
if (task.detailId) {
newTasks.splice(i, 0, item);
} else {
if (arr.length === 1) {
newTasks.splice(i, 1, item);
}
if (arr.length > 1) {
newTasks.splice(i, 0, item);
}
}
i++;
}
}
}
}
this.clearTasks();
type === 0 ? this.setUpTasks(newTasks) : this.setDownTasks(newTasks);
},
},
};
</script>

50
src/plugins/p-subproject/p-subproject.vue

@ -1,18 +1,58 @@
<template>
<!-- 子项目插件 -->
<view>子项目插件显示子项目</view>
<view>
<view v-for="item in sonProject" :key="item.detailId">
<span class="text-xs text-blue-500" @click="openProject(item)">{{ item.name }}</span>
</view>
</view>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'p-subproject',
props: { item: { type: Object, default: null } },
props: {
task: {
type: Object,
default: () => {},
},
},
data() {
return {};
return { sonProject: [] };
},
computed: {},
methods: {},
computed: mapGetters('project', ['projectId']),
mounted() {
this.getSonProject();
},
methods: {
async getSonProject() {
try {
const data = await this.$u.api.findSonProject({ projectId: this.task.detailId });
this.sonProject = data;
} catch (error) {
console.error('p-subproject.vue getSonProject error: ', error);
}
},
/**
* 打开项目
* @param {object} project 所点击的项目的信息
*/
openProject(project) {
const { name, id, url } = project;
url && (uni.$t.domain = url);
this.$u.route('pages/project/project', {
u: this.userId,
p: id,
pname: name,
url: encodeURIComponent(url),
});
},
},
watch: {},
};
</script>

32
src/plugins/p-subtasks/p-subtasks.vue

@ -1,18 +1,38 @@
<template>
<view>子任务插件显示子任务</view>
<view>
<view v-for="item in sonTask" :key="item.detailId">
<span class="text-xs text-gray-500">{{ item.name }}</span>
</view>
</view>
</template>
<script>
export default {
name: 'p-subtasks',
props: { item: { type: Object, default: null } },
props: {
task: {
type: Object,
default: () => {},
},
},
data() {
return {};
return { sonTask: [] };
},
created() {
this.getSonTask();
},
computed: {},
methods: {},
watch: {},
methods: {
async getSonTask() {
try {
const data = await this.$u.api.findSonTask({ detailId: this.task.detailId });
this.sonTask = data;
} catch (error) {
console.error('p-subtasks.vue getSonTask error: ', error);
}
},
},
};
</script>

3
src/plugins/p-wbs-import/p-wbs-import.vue

@ -54,8 +54,7 @@ export default {
// TODO:
async handleUpdate() {
try {
const data = await this.$u.api.import({ projectId: this.projectId });
console.log('data: ', data);
await this.$u.api.import({ projectId: this.projectId });
// WBS
//
this.onUploadSuccess();

11
src/store/task/actions.js

@ -33,16 +33,9 @@ const actions = {
* @param {number} param.queryType 必填 0 -> 向上 1 -> 向下
*/
// eslint-disable-next-line
async getRegulars({ commit, state }, param) {
async getRegulars({ commit }, param) {
try {
// 向上查 且 上边没数据了 不查
// if (param.queryType === 0) return;
// 向下查 且 下边美术家了 不查
// if (param.queryType === 1) return;
const data = await uni.$u.api.getRegularTask(param);
// 0 -> 向上 1 -> 向下
// data 有无的判断在mutations里
param.queryType === 0 ? commit('setUpTasks', data) : commit('setDownTasks', data);
return await uni.$u.api.getRegularTask(param);
} catch (error) {
throw error || '获取定期任务失败';
}

158
src/store/task/mutations.js

@ -8,6 +8,15 @@ const mutations = {
state.scrollTop = num;
},
/**
* 记录时间轴向上滚动的距离
* @param { object } state
* @param { string } data
*/
setViewId(state, data) {
state.viewId = data;
},
/**
* 设置日常任务当前是否应该处于收缩状态
* @param { object } state
@ -52,7 +61,6 @@ const mutations = {
*/
setTimeNode(state, data) {
state.timeNode = data;
console.log('state.timeNode : ', state.timeNode);
},
/**
@ -70,65 +78,10 @@ const mutations = {
* @param {Array} data 服务端返回的模板数组
*/
setUpTasks(state, data) {
if (!data || !data.length) {
state.topEnd = true;
let sTime = '';
if (!state.tasks || !state.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +state.tasks[0].planStart - 0;
}
const initData = [
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -6, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -5, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -4, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -3, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -2, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, -1, 'day').valueOf(),
},
];
state.tasks = [...initData.concat(state.tasks)];
if (!state.tasks.length) {
state.tasks = [...data];
} else {
if (!state.tasks && !state.tasks.length) {
state.tasks = [...data];
} else {
state.tasks = [...data.concat(state.tasks)];
}
state.tasks = [...data.concat(state.tasks)];
}
},
@ -138,65 +91,10 @@ const mutations = {
* @param {Array} data 服务端返回的模板数组
*/
setDownTasks(state, data) {
if (!data || !data.length) {
state.bottomEnd = true;
let sTime = '';
if (!state.tasks || !state.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +state.tasks[state.tasks.length - 1].planStart - 0;
}
const initData = [
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 1, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 2, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 3, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 4, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 5, 'day').valueOf(),
},
{
id: state.randomId,
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(sTime, 6, 'day').valueOf(),
},
];
state.tasks = [...state.tasks.concat(initData)];
if (!state.tasks && !state.tasks.length) {
state.tasks = [...data];
} else {
if (!state.tasks && !state.tasks.length) {
state.tasks = [...data];
} else {
state.tasks = [...state.tasks.concat(data)];
}
state.tasks = [...state.tasks.concat(data)];
}
},
@ -218,13 +116,35 @@ const mutations = {
state.permanents = tasks || [];
},
// 清空标志位 任务 如切换角色等使用
/**
* 设置时间轴是否继续向上查任务
* @param {Object} state
* @param {Boolean} show
*/
setTopEnd(state, show) {
state.topEnd = show;
},
/**
* 设置时间轴是否继续向下查任务
* @param {Object} state
* @param {Boolean} show
*/
setBottomEnd(state, show) {
state.bottomEnd = show;
},
// 清空标志位 如切换角色等使用
clearEndFlag(state) {
state.tasks = [];
state.topEnd = false;
state.bottomEnd = false;
},
// 清空定期任务
clearTasks(state) {
state.tasks = [];
},
/**
* 收到消息设置任务状态
* @param {Object} state

2
src/store/task/state.js

@ -1,5 +1,6 @@
const state = {
scrollTop: 0,
viewId: '', // 时间轴自动滚动的位置
isShrink: false, // true: 收起, false:展开
tip: {
taskId: '', // 当前正在修改状态的任务的id
@ -18,7 +19,6 @@ const state = {
// 定期任务
tasks: [],
showSkeleton: false, // 定期任务骨架屏
randomId: Math.floor(Math.random() * 100000000000000000000), // 随机id
};
export default state;

12
src/utils/time.js

@ -100,6 +100,17 @@ const validateTimeIsToday = time => {
return timeDate.getFullYear() === date.getFullYear() && timeDate.getMonth() === date.getMonth() && timeDate.getDate() === date.getDate();
};
/**
* 检测两个日期是否相同
* @param {number | date} time
* @param {number | date} value
* @param {string} cycle 传入 day 将会比较 day month和 year
*/
const isSame = (time, value, cycle) => {
const str = dayjs(time).isSame(value, cycle);
return str;
};
/**
* 格式化开始时间
* @param {Number} timestamp 时间戳
@ -344,6 +355,7 @@ export default {
convertTime,
secondToMinute,
setTimestampToStr,
isSame,
formatBeginTime,
formatDuration,
formatDurationToObject,

Loading…
Cancel
Save