Browse Source

feat: 修改时间轴滚动

develop
song 4 years ago
parent
commit
537df8ca69
  1. 1
      CHANGELOG.md
  2. 4
      src/components/Evaluated/EvaluatedNLCP.vue
  3. 6
      src/components/Roles/Roles.vue
  4. 37
      src/components/TimeLine/TimeLine.vue
  5. 191
      src/components/TimeLine/component/TimeBox.vue
  6. 138
      src/components/TimeLine/component/TimeBoxIn.vue
  7. 136
      src/components/TimeLine/component/TimeBoxOut.vue
  8. 1
      src/pagesProject/project/project.vue

1
CHANGELOG.md

@ -194,6 +194,7 @@
- | 暂时移除了jest浏览器配置 | [5088d01](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/5088d01)
- | 添加测试,测试utils/time.js的computeDurationText | [e758010](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/e758010)
- | 禁用任务开始操作 | [b5425db](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/b5425db)
- | 解决error | [c5bd659](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c5bd659)
### 🔨 代码重构

4
src/components/Evaluated/EvaluatedNLCP.vue

@ -50,7 +50,9 @@ export default {
query
.selectAll('.charts-box')
.boundingClientRect(data => {
this.cWidth = data[0].width;
if (data && data.length) {
this.cWidth = data[0].width;
}
})
.exec();

6
src/components/Roles/Roles.vue

@ -114,7 +114,7 @@ export default {
methods: {
...mapActions('task', ['handleRegularTask']),
...mapMutations('role', ['setRoleId']),
...mapMutations('task', ['setPermanents', 'clearEndFlag']),
...mapMutations('task', ['setPermanents', 'clearEndFlag', 'setScrollToTaskId', 'setShowScrollTo']),
back() {
uni.navigateBack();
@ -174,6 +174,10 @@ export default {
// index
this.setCurrentRole(index);
});
// id
this.setScrollToTaskId('');
this.setShowScrollTo(false);
} catch (error) {
console.error('role.vue changeRole error: ', error);
}

37
src/components/TimeLine/TimeLine.vue

@ -15,7 +15,12 @@
>
<!-- 时间轴 -->
<!-- <u-divider bg-color="#f3f4f6" class="pt-5" fontSize="14px" v-if="topEnd">已到顶部</u-divider> -->
<TimeBox />
<view class="column">
<view :key="task.id" v-for="(task, taskIndex) in tasks" :id="`a${task.id}`">
<TimeBoxIn :task="task" :taskIndex="taskIndex" v-if="task.array && task.array.length" />
<TimeBoxOut :task="task" :taskIndex="taskIndex" v-else />
</view>
</view>
<!-- <u-divider bg-color="#f3f4f6" class="pb-5" fontSize="14px" v-if="bottomEnd">我也是有底线的</u-divider> -->
</scroll-view>
</template>
@ -24,11 +29,12 @@
// import Barrier from './component/Barrier.vue';
import { mapState, mapMutations, mapGetters } from 'vuex';
import { setPlaceholderTasks } from '@/utils/task';
import TimeBox from './component/TimeBox.vue';
import TimeBoxIn from './component/TimeBoxIn.vue';
import TimeBoxOut from './component/TimeBoxOut.vue';
export default {
name: 'TimeLine',
components: { TimeBox },
components: { TimeBoxIn, TimeBoxOut },
data() {
return { top: 0 };
@ -45,7 +51,6 @@ export default {
//
scroll(e) {
console.log('e: ', e);
this.top = e.detail.scrollTop;
this.setShrink(this.top > this.scrollTop);
this.setScrollTop(this.top);
@ -141,20 +146,6 @@ export default {
this.$t.storage.setStorageSync('taskId', ''); //
} else {
let item = null;
// for (let i = 0; i < this.tasks.length; i++) {
// const task = this.tasks[i];
// if (task && task.length) {
// index = i;
// item = task.find(item => item.detailId);
// if (item !== -1) {
// break;
// }
// }
// }
// const item = this.tasks.find(task => task.detailId);
// if (item) {
// this.setScrollToTaskId(`a${item.id}`);
// } else {
// taskId
// 线id 线
for (let i = 0; i < this.tasks.length; i++) {
@ -166,13 +157,15 @@ export default {
}
}
}
console.log('跳转: ', `a${item.id}`);
item && this.setScrollToTaskId(`a${item.id}`); // task id
// const task = this.tasks.find(item => this.$moment(+item.planStart).isSame(this.timeNode, this.timeGranularity));
// task && this.setScrollToTaskId(`a${task.id}`); // task id
// }
}
},
},
};
</script>
<style scoped lang="scss">
.column {
padding: 24px 14px;
}
</style>

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

@ -1,191 +0,0 @@
<template>
<view class="column">
<!-- v-if="tasks && tasks.length" -->
<view>
<view :key="task.id" v-for="(task, taskIndex) in tasks" :id="`a${task.id}`">
<view v-if="scrollToTaskId === `a${task.id}`">AAA</view>
<!-- 内层 -->
<view v-if="task.array && task.array.length">
<view class="flex">
<TimeStatus :task="task.array[0]" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view v-if="task.array[0].process !== 4">{{ $moment(+task.array[0].planStart).format(startTimeFormat) }}</view>
<view v-else>{{ $moment(+task.array[0].planStart).format('D日') }}</view>
</view>
</view>
<view v-for="(item, itemIndex) in task.array" :key="item.id">
<view class="border-l-2 border-gray-300 plugin">
<view class="h-3" v-if="item.process === 4"></view>
<view class="ml-3 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(item.panel) }"
class="h-16"
margin="0"
v-if="showSkeleton"
>
<view slot="body">
<view>
<skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
</view>
</view>
</u-card>
<u-card
@click="onClickTask(item.planStart - 0, item.id)"
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(item.panel) }"
class="h-16"
margin="0"
v-if="task.array && task.array.length && item.process !== 4 && !showSkeleton"
>
<view slot="body">
<!-- 脑力测评 -->
<view class="p-0 u-col-between">
<NotEvaluated :task="item" v-if="item.data.mentalTest.finishStatus === 0" />
<view v-else>
<EvaluatedNLCP :task="item" :taskIndex="taskIndex" :itemIndex="itemIndex" v-if="item.data.type === 0" />
<EvaluatedXLJH :task="item" :taskIndex="taskIndex" :itemIndex="itemIndex" v-if="item.data.type === 1" />
</view>
</view>
</view>
</u-card>
</view>
</view>
</view>
</view>
<!-- 外层 -->
<view v-else>
<view class="flex">
<TimeStatus :task="task" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view v-if="task.process2 !== 4">{{ $moment(+task.planStart).format(startTimeFormat) }}</view>
<view v-else>{{ $moment(+task.planStart).format('D日') }}</view>
</view>
</view>
<view class="border-l-2 border-gray-300 plugin">
<view class="h-3" v-if="task.process === 4"></view>
<view class="ml-3 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(task.panel) }"
class="h-16"
margin="0"
v-if="showSkeleton"
>
<view slot="body">
<view>
<skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
</view>
</view>
</u-card>
<u-card
@click="onClickTask(task.planStart - 0, task.id)"
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(task.panel) }"
class="h-16"
margin="0"
v-if="tasks && tasks.length && task.process !== 4 && !showSkeleton"
>
<view slot="body">
<view class="p-0 u-col-between">
<NotEvaluated :task="task" v-if="task.data.mentalTest.finishStatus === 0" />
<view v-else>
<EvaluatedNLCP :task="task" v-if="task.data.type === 0" />
<EvaluatedXLJH :task="task" v-if="task.data.type === 1" />
</view>
</view>
</view>
</u-card>
</view>
</view>
</view>
</view>
</view>
<!-- 局部弹框操作栏 -->
<Tips />
</view>
</template>
<script>
import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
import Skeleton from '@/components/Skeleton/Skeleton';
import TimeStatus from './TimeStatus.vue';
// import TaskTools from './TaskTools.vue';
import EvaluatedNLCP from 'components/Evaluated/EvaluatedNLCP';
import EvaluatedXLJH from 'components/Evaluated/EvaluatedXLJH';
export default {
name: 'TimeBox',
components: { TimeStatus, Skeleton, EvaluatedNLCP, EvaluatedXLJH },
data() {
return {
currentComponent: '',
styleType: 0,
};
},
computed: {
...mapState('role', ['roleId']),
...mapState('task', ['timeUnit', 'tasks', 'taskLoading', 'showSkeleton', 'isEvaluated', 'scrollToTaskId']),
...mapGetters('task', ['startTimeFormat']),
},
methods: {
...mapActions('task', ['getGlobal']),
...mapMutations('task', ['setTipsContent', 'setTipsContent']),
//
setHeight(panel) {
if (panel && panel.height) {
return panel.height + 'px';
} else {
return 'auto';
}
},
/**
* 点击了定期任务的面板 更新可变的日常任务
* @param {number} planStart 任务计划开始时间
* @param {string} taskId 任务id
*/
onClickTask(planStart, taskId) {
const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit };
this.getGlobal(param);
this.$t.storage.setStorageSync('taskId', taskId);
this.$t.storage.setStorageSync('roleId', this.roleId);
},
},
};
</script>
<style scoped lang="scss">
.task-box {
border-radius: 24rpx;
}
.column {
padding: 24px 14px;
}
.task-column {
height: 33px;
}
.plugin {
margin-top: 8px;
margin-bottom: 8px;
margin-left: 15px;
}
::v-deep .ml-2 {
margin-left: 16px;
}
::v-deep .ml-3 {
margin-left: 20px;
}
</style>

138
src/components/TimeLine/component/TimeBoxIn.vue

@ -0,0 +1,138 @@
<template>
<!-- 内层 -->
<!-- v-if="task.array && task.array.length" -->
<view>
<view class="flex">
<TimeStatus :task="task.array[0]" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view v-if="task.array[0].process !== 4">{{ $moment(+task.array[0].planStart).format('YYYY年MM月DD日') }}</view>
<view v-else>{{ $moment(+task.array[0].planStart).format('YYYY年MM月DD日') }}</view>
</view>
</view>
<view v-for="(item, itemIndex) in task.array" :key="item.id">
<view class="border-l-2 border-gray-300 plugin">
<view class="h-3" v-if="item.process === 4"></view>
<view class="ml-3 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(item.panel) }"
class="h-16"
margin="0"
v-if="showSkeleton"
>
<view slot="body">
<view>
<skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
</view>
</view>
</u-card>
<u-card
@click="onClickTask(item.planStart - 0, item.id)"
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(item.panel) }"
class="h-16"
margin="0"
v-if="task.array && task.array.length && item.process !== 4 && !showSkeleton"
>
<view slot="body">
<view class="p-0 u-col-between">
<NotEvaluated :task="item" v-if="item.data.mentalTest.finishStatus === 0" />
<view v-else>
<EvaluatedNLCP :task="item" :taskIndex="taskIndex" :itemIndex="itemIndex" v-if="item.data.type === 0" />
<EvaluatedXLJH :task="item" :taskIndex="taskIndex" :itemIndex="itemIndex" v-if="item.data.type === 1" />
</view>
</view>
</view>
</u-card>
</view>
</view>
</view>
<!-- 局部弹框操作栏 -->
<Tips />
</view>
</template>
<script>
import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
import Skeleton from '@/components/Skeleton/Skeleton';
import TimeStatus from './TimeStatus.vue';
import EvaluatedNLCP from 'components/Evaluated/EvaluatedNLCP';
import EvaluatedXLJH from 'components/Evaluated/EvaluatedXLJH';
export default {
name: 'TimeBox',
components: { TimeStatus, Skeleton, EvaluatedNLCP, EvaluatedXLJH },
props: {
task: {
type: Object,
default: null,
},
taskIndex: {
type: Number,
default: 0,
},
},
data() {
return {};
},
computed: {
...mapState('role', ['roleId']),
...mapState('task', ['timeUnit', 'showSkeleton']),
...mapGetters('task', ['startTimeFormat']),
},
methods: {
...mapActions('task', ['getGlobal']),
...mapMutations('task', ['setTipsContent']),
//
setHeight(panel) {
if (panel && panel.height) {
return panel.height + 'px';
} else {
return 'auto';
}
},
/**
* 点击了定期任务的面板 更新可变的日常任务
* @param {number} planStart 任务计划开始时间
* @param {string} taskId 任务id
*/
onClickTask(planStart, taskId) {
const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit };
this.getGlobal(param);
this.$t.storage.setStorageSync('taskId', taskId);
this.$t.storage.setStorageSync('roleId', this.roleId);
},
},
};
</script>
<style scoped lang="scss">
.task-box {
border-radius: 24rpx;
}
.task-column {
height: 33px;
}
.plugin {
margin-top: 8px;
margin-bottom: 8px;
margin-left: 15px;
}
::v-deep .ml-2 {
margin-left: 16px;
}
::v-deep .ml-3 {
margin-left: 20px;
}
</style>

136
src/components/TimeLine/component/TimeBoxOut.vue

@ -0,0 +1,136 @@
<template>
<!-- 外层 -->
<view>
<view class="flex">
<TimeStatus :task="task" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view v-if="task.process2 !== 4">{{ $moment(+task.planStart).format('YYYY年MM月DD日') }}</view>
<view v-else>{{ $moment(+task.planStart).format('YYYY年MM月DD日') }}</view>
</view>
</view>
<view class="border-l-2 border-gray-300 plugin">
<view class="h-3" v-if="task.process === 4"></view>
<view class="ml-3 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(task.panel) }"
class="h-16"
margin="0"
v-if="showSkeleton"
>
<view slot="body">
<view>
<skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
</view>
</view>
</u-card>
<u-card
@click="onClickTask(task.planStart - 0, task.id)"
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(task.panel) }"
class="h-16"
margin="0"
v-if="tasks && tasks.length && task.process !== 4 && !showSkeleton"
>
<view slot="body">
<view class="p-0 u-col-between">
<NotEvaluated :task="task" v-if="task.data.mentalTest.finishStatus === 0" />
<view v-else>
<EvaluatedNLCP :task="task" v-if="task.data.type === 0" />
<EvaluatedXLJH :task="task" v-if="task.data.type === 1" />
</view>
</view>
</view>
</u-card>
</view>
</view>
<!-- 局部弹框操作栏 -->
<Tips />
</view>
</template>
<script>
import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
import Skeleton from '@/components/Skeleton/Skeleton';
import TimeStatus from './TimeStatus.vue';
import EvaluatedNLCP from 'components/Evaluated/EvaluatedNLCP';
import EvaluatedXLJH from 'components/Evaluated/EvaluatedXLJH';
export default {
name: 'TimeBox',
components: { TimeStatus, Skeleton, EvaluatedNLCP, EvaluatedXLJH },
props: {
task: {
type: Object,
default: null,
},
taskIndex: {
type: Number,
default: 0,
},
},
data() {
return {};
},
computed: {
...mapState('role', ['roleId']),
...mapState('task', ['timeUnit', 'showSkeleton', 'tasks']),
...mapGetters('task', ['startTimeFormat']),
},
methods: {
...mapActions('task', ['getGlobal']),
...mapMutations('task', ['setTipsContent']),
//
setHeight(panel) {
if (panel && panel.height) {
return panel.height + 'px';
} else {
return 'auto';
}
},
/**
* 点击了定期任务的面板 更新可变的日常任务
* @param {number} planStart 任务计划开始时间
* @param {string} taskId 任务id
*/
onClickTask(planStart, taskId) {
const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit };
this.getGlobal(param);
this.$t.storage.setStorageSync('taskId', taskId);
this.$t.storage.setStorageSync('roleId', this.roleId);
},
},
};
</script>
<style scoped lang="scss">
.task-box {
border-radius: 24rpx;
}
.task-column {
height: 33px;
}
.plugin {
margin-top: 8px;
margin-bottom: 8px;
margin-left: 15px;
}
::v-deep .ml-2 {
margin-left: 16px;
}
::v-deep .ml-3 {
margin-left: 20px;
}
</style>

1
src/pagesProject/project/project.vue

@ -155,7 +155,6 @@ export default {
async initPlanTasks() {
this.setPrevPlaceholderTasks(); //
this.setNextPlaceholderTasks(); //
// // this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); //
await this.getInitTasks(); //
//
let timer = null;

Loading…
Cancel
Save