Browse Source

fix: 调试定期任务bug;不能合并使用

pull/1/head
wally 4 years ago
parent
commit
d64131272c
  1. 1
      CHANGELOG.md
  2. 2
      package.json
  3. 7
      src/components/TimeLine/TimeLine.vue
  4. 44
      src/mixins/timeline.js
  5. 97
      src/pages/project/project.vue
  6. 2
      src/store/task/mutations.js
  7. 23
      src/utils/task.js

1
CHANGELOG.md

@ -136,6 +136,7 @@
- | 时间轴无任务时时间刻度加载修改 | 4921672 - | 时间轴无任务时时间刻度加载修改 | 4921672
- | 时间轴滚动位置修改 | 551da63 - | 时间轴滚动位置修改 | 551da63
- | 时间轴骨架屏修改 | ca78d02 - | 时间轴骨架屏修改 | ca78d02
- | 滚动id函数优化 | b351b67
- | 监听时间基本点 | 033fca0 - | 监听时间基本点 | 033fca0
- | 角色显示状态修改 | 7d3b906 - | 角色显示状态修改 | 7d3b906
- | 角色栏修改 | 19228d6 - | 角色栏修改 | 19228d6

2
package.json

@ -82,7 +82,7 @@
"postcss": "^7.0.36", "postcss": "^7.0.36",
"postcss-comment": "^2.0.0", "postcss-comment": "^2.0.0",
"prettier": "^2.2.1", "prettier": "^2.2.1",
"puppeteer": "^10.2.0", "puppeteer": "^3.0.1",
"right-pad": "^1.0.1", "right-pad": "^1.0.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"vue-cli-plugin-commitlint": "~1.0.12", "vue-cli-plugin-commitlint": "~1.0.12",

7
src/components/TimeLine/TimeLine.vue

@ -22,13 +22,12 @@
<script> <script>
// import Barrier from './component/Barrier.vue'; // import Barrier from './component/Barrier.vue';
import { mapState, mapMutations, mapGetters } from 'vuex'; import { mapState, mapMutations, mapGetters } from 'vuex';
import { setPlaceholderTasks } from '@/utils/task';
import TimeBox from './component/TimeBox.vue'; import TimeBox from './component/TimeBox.vue';
import mixin from '@/mixins/timeline';
export default { export default {
name: 'TimeLine', name: 'TimeLine',
components: { TimeBox }, components: { TimeBox },
mixins: [mixin],
data() { data() {
return { top: 0 }; return { top: 0 };
@ -57,7 +56,7 @@ export default {
if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) { if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) {
// //
console.warn('滚动到顶部没有数据时: '); console.warn('滚动到顶部没有数据时: ');
const addTasks = this.setTime(startTime, true); const addTasks = setPlaceholderTasks(startTime, true, this.timeGranularity);
this.setUpTasks(addTasks); this.setUpTasks(addTasks);
} else { } else {
// //
@ -79,7 +78,7 @@ export default {
if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) { if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) {
// //
console.warn('滚动到底部没有数据时: '); console.warn('滚动到底部没有数据时: ');
const addTasks = this.setTime(startTime, false); const addTasks = setPlaceholderTasks(startTime, false, this.timeGranularity);
this.setDownTasks(addTasks); this.setDownTasks(addTasks);
} else { } else {
// =+ // =+

44
src/mixins/timeline.js

@ -1,44 +0,0 @@
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;

97
src/pages/project/project.vue

@ -3,7 +3,7 @@
<!-- 标题栏 --> <!-- 标题栏 -->
<Title /> <Title />
<view class="container flex flex-col flex-1 overflow-hidden bg-gray-100 mx-auto"> <view class="container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100">
<!-- 角色栏 --> <!-- 角色栏 -->
<Roles /> <Roles />
@ -18,10 +18,9 @@
<script> <script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'; import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
import mixin from '@/mixins/timeline'; import { setPlaceholderTasks } from '@/utils/task';
export default { export default {
mixins: [mixin],
data() { data() {
return { height: '', show: false }; return { height: '', show: false };
}, },
@ -48,8 +47,8 @@ export default {
timeNode(val) { timeNode(val) {
if (val && this.roleId) { if (val && this.roleId) {
this.clearTasksData(); this.clearTasksData();
// this.getGlobalData(); //
this.initTasks(); this.initPlanTasks(); //
} }
}, },
@ -75,9 +74,8 @@ export default {
}, },
onUnload() { onUnload() {
this.clearEndFlag(); this.clearTasksData();
this.clearTasks(); this.setRoleId('');
this.setRoleId();
}, },
methods: { methods: {
@ -169,29 +167,13 @@ export default {
}, },
// //
async initTasks() { async initPlanTasks() {
this.getGlobalData(); //
this.setPrevTasks(); // this.setPrevTasks(); //
// storage this.setNextTasks(); //
// taskIdid this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); //
//
const storageTaskId = this.$t.storage.getStorageSync('taskId');
this.$nextTick(() => {
if (!storageTaskId) {
this.$refs.timeLine.setScrollPosition();
}
});
//
this.setNextTasks();
await this.getInitTasks(); await this.getInitTasks();
// id this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); //
// storage
this.$nextTick(() => {
if (storageTaskId) {
this.$refs.timeLine.setScrollPosition();
}
});
}, },
// || // ||
@ -218,10 +200,10 @@ export default {
} }
} }
// //
this.getTasks({ queryType: 0 }); this.getTasks({ queryType: 0 }); //
// id // id
this.getTasks({ queryType: 1 }, fn); this.getTasks({ queryType: 1 }, fn); //
}, },
// //
@ -246,9 +228,8 @@ export default {
* @param {string} query.queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含 * @param {string} query.queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含
*/ */
getTasks(query, fn) { getTasks(query, fn) {
const that = this; this.setShowSkeleton(true);
that.setShowSkeleton(true); const { roleId, timeNode, timeUnit, projectId } = this;
const { roleId, timeNode, timeUnit, projectId } = that;
const params = { const params = {
roleId, roleId,
timeNode: query.timeNode || timeNode, timeNode: query.timeNode || timeNode,
@ -258,27 +239,22 @@ export default {
projectId, projectId,
}; };
that.$t.$q.getRegularTask(params, function (err, data) { this.$t.$q.getRegularTask(params, (err, data) => {
console.log('data: ', data); this.setShowSkeleton(false);
console.log('that.show: ', that.show); if (err) {
if (!that.show) { // TODO:
if (err) { console.error('err: ', err);
that.setShowSkeleton(false); } else {
console.error('err: ', err); // 0 -> 1 ->
//
//
if (data && data.length) {
this.replacePrevData(data, params.queryType);
} else { } else {
that.show = true; params.queryType === 0 ? this.setPrevTasks() : this.setNextTasks();
that.setShowSkeleton(false); }
// 0 -> 1 -> if (this.tasks.length && fn) {
if (data && data.length) { fn(this);
that.replacePrevData(data, params.queryType);
that.show = false;
} else {
params.queryType === 0 ? that.setPrevTasks() : that.setNextTasks();
that.show = false;
}
if (that.tasks.length && fn) {
fn(that);
}
} }
} }
}); });
@ -294,14 +270,15 @@ export default {
// //
setPrevTasks() { setPrevTasks() {
this.setTopEnd(true); this.setTopEnd(true);
let sTime = ''; let startTime = '';
if (!this.tasks || !this.tasks.length) { const { tasks } = this;
sTime = +new Date().getTime(); if (!tasks || !tasks.length) {
startTime = Date.now(); //
} else { } else {
sTime = +this.tasks[0].planStart - 0; startTime = tasks[0].planStart - 0; //
} }
const initData = this.setTime(sTime, true); const placeholderTasks = setPlaceholderTasks(startTime, true, this.timeGranularity);
this.setUpTasks(initData); this.setUpTasks(placeholderTasks);
}, },
// //
@ -313,7 +290,7 @@ export default {
} else { } else {
sTime = +this.tasks[this.tasks.length - 1].planStart - 0; sTime = +this.tasks[this.tasks.length - 1].planStart - 0;
} }
const initData = this.setTime(sTime, false); const initData = setPlaceholderTasks(sTime, false, this.timeGranularity);
this.setDownTasks(initData); this.setDownTasks(initData);
}, },

2
src/store/task/mutations.js

@ -79,7 +79,7 @@ const mutations = {
*/ */
setUpTasks(state, data) { setUpTasks(state, data) {
if (!state.tasks.length) { if (!state.tasks.length) {
state.tasks = [...data]; state.tasks = [...data]; // 原来没有数据
} else { } else {
state.tasks = [...data.concat(state.tasks)]; state.tasks = [...data.concat(state.tasks)];
} }

23
src/utils/task.js

@ -0,0 +1,23 @@
/**
* 设置时间轴空数据
* @param {number} startTime
* @param {boolean} isUp true 向上加载,false 向下加载
* @param {string} timeGranularity 颗粒度
*/
export const setPlaceholderTasks = (startTime, isUp, timeGranularity) => {
let result = [];
for (let i = 0; i < 10; i++) {
const delta = isUp ? `-${i + 1}` - 0 : i + 1;
let item = {
id: uni.$u.guid(20, false, 10),
panel: {},
plugins: [],
process: 4,
planStart: uni.$moment(startTime).add(delta, timeGranularity).valueOf(),
};
// console.log('isup: ', isUp, 'result:', new Date(item.planStart).toLocaleDateString());
isUp ? result.unshift(item) : result.push(item);
}
return result;
};
Loading…
Cancel
Save