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
- | 时间轴滚动位置修改 | 551da63
- | 时间轴骨架屏修改 | ca78d02
- | 滚动id函数优化 | b351b67
- | 监听时间基本点 | 033fca0
- | 角色显示状态修改 | 7d3b906
- | 角色栏修改 | 19228d6

2
package.json

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

7
src/components/TimeLine/TimeLine.vue

@ -22,13 +22,12 @@
<script>
// import Barrier from './component/Barrier.vue';
import { mapState, mapMutations, mapGetters } from 'vuex';
import { setPlaceholderTasks } from '@/utils/task';
import TimeBox from './component/TimeBox.vue';
import mixin from '@/mixins/timeline';
export default {
name: 'TimeLine',
components: { TimeBox },
mixins: [mixin],
data() {
return { top: 0 };
@ -57,7 +56,7 @@ export default {
if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) {
//
console.warn('滚动到顶部没有数据时: ');
const addTasks = this.setTime(startTime, true);
const addTasks = setPlaceholderTasks(startTime, true, this.timeGranularity);
this.setUpTasks(addTasks);
} else {
//
@ -79,7 +78,7 @@ export default {
if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) {
//
console.warn('滚动到底部没有数据时: ');
const addTasks = this.setTime(startTime, false);
const addTasks = setPlaceholderTasks(startTime, false, this.timeGranularity);
this.setDownTasks(addTasks);
} 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 />
<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 />
@ -18,10 +18,9 @@
<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
import mixin from '@/mixins/timeline';
import { setPlaceholderTasks } from '@/utils/task';
export default {
mixins: [mixin],
data() {
return { height: '', show: false };
},
@ -48,8 +47,8 @@ export default {
timeNode(val) {
if (val && this.roleId) {
this.clearTasksData();
//
this.initTasks();
this.getGlobalData(); //
this.initPlanTasks(); //
}
},
@ -75,9 +74,8 @@ export default {
},
onUnload() {
this.clearEndFlag();
this.clearTasks();
this.setRoleId();
this.clearTasksData();
this.setRoleId('');
},
methods: {
@ -169,29 +167,13 @@ export default {
},
//
async initTasks() {
this.getGlobalData(); //
async initPlanTasks() {
this.setPrevTasks(); //
// storage
// taskIdid
//
const storageTaskId = this.$t.storage.getStorageSync('taskId');
this.$nextTick(() => {
if (!storageTaskId) {
this.$refs.timeLine.setScrollPosition();
}
});
//
this.setNextTasks();
this.setNextTasks(); //
this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); //
await this.getInitTasks();
// id
// storage
this.$nextTick(() => {
if (storageTaskId) {
this.$refs.timeLine.setScrollPosition();
}
});
this.$nextTick(() => this.$refs.timeLine.setScrollPosition()); //
},
// ||
@ -218,10 +200,10 @@ export default {
}
}
//
this.getTasks({ queryType: 0 });
this.getTasks({ queryType: 0 }); //
// id
this.getTasks({ queryType: 1 }, fn);
this.getTasks({ queryType: 1 }, fn); //
},
//
@ -246,9 +228,8 @@ export default {
* @param {string} query.queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含
*/
getTasks(query, fn) {
const that = this;
that.setShowSkeleton(true);
const { roleId, timeNode, timeUnit, projectId } = that;
this.setShowSkeleton(true);
const { roleId, timeNode, timeUnit, projectId } = this;
const params = {
roleId,
timeNode: query.timeNode || timeNode,
@ -258,27 +239,22 @@ export default {
projectId,
};
that.$t.$q.getRegularTask(params, function (err, data) {
console.log('data: ', data);
console.log('that.show: ', that.show);
if (!that.show) {
if (err) {
that.setShowSkeleton(false);
console.error('err: ', err);
this.$t.$q.getRegularTask(params, (err, data) => {
this.setShowSkeleton(false);
if (err) {
// TODO:
console.error('err: ', err);
} else {
// 0 -> 1 ->
//
//
if (data && data.length) {
this.replacePrevData(data, params.queryType);
} else {
that.show = true;
that.setShowSkeleton(false);
// 0 -> 1 ->
if (data && data.length) {
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);
}
params.queryType === 0 ? this.setPrevTasks() : this.setNextTasks();
}
if (this.tasks.length && fn) {
fn(this);
}
}
});
@ -294,14 +270,15 @@ export default {
//
setPrevTasks() {
this.setTopEnd(true);
let sTime = '';
if (!this.tasks || !this.tasks.length) {
sTime = +new Date().getTime();
let startTime = '';
const { tasks } = this;
if (!tasks || !tasks.length) {
startTime = Date.now(); //
} else {
sTime = +this.tasks[0].planStart - 0;
startTime = tasks[0].planStart - 0; //
}
const initData = this.setTime(sTime, true);
this.setUpTasks(initData);
const placeholderTasks = setPlaceholderTasks(startTime, true, this.timeGranularity);
this.setUpTasks(placeholderTasks);
},
//
@ -313,7 +290,7 @@ export default {
} else {
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);
},

2
src/store/task/mutations.js

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