Browse Source

fix: 时间轴无任务时时间刻度加载修改

pull/1/head
song 4 years ago
parent
commit
4921672176
  1. 1
      CHANGELOG.md
  2. 7
      src/components/Roles/Roles.vue
  3. 19
      src/components/TimeLine/TimeLine.vue
  4. 1
      src/components/TimeLine/component/TimeStatus.vue
  5. 1
      src/components/Upload/Upload.vue
  6. 13
      src/pages/project/project.vue
  7. 71
      src/store/task/mutations.js
  8. 36
      src/store/task/state.js

1
CHANGELOG.md

@ -101,6 +101,7 @@
- | 手动展开日常任务 | [0a4a622](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/0a4a622)
- | 提示信息显示bug及日常任务收缩问题 | [f2f06c5](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/f2f06c5)
- | 插件bug解决 | [41257eb](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/41257eb)
- | 收到消息修改任务状态 | [c378063](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/c378063)
- | 日常任务html数据查验 | [880ce5c](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/880ce5c)
- | 日常任务插件遍历时的key值修改 | [cd26285](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/cd26285)
- | 日常任务插件面板高度修改 | [249f9e4](https://dd.tall.wiki/gitea/ccsens_fe/TALL-MUI-3/commits/249f9e4)

7
src/components/Roles/Roles.vue

@ -58,7 +58,7 @@ export default {
methods: {
...mapActions('task', ['handleRegularTask']),
...mapMutations('role', ['setRoleId']),
...mapMutations('task', ['setTasks', 'setPermanents', 'setDailyTasks', 'clearEndFlag']),
...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag']),
//
setCurrentRole(index) {
@ -91,14 +91,13 @@ export default {
this.setRoleId(id);
//index
this.setCurrentRole(index);
//
this.setTasks();
//
this.setPermanents([]);
this.setDailyTasks([]);
//
//
//
// this.clearEndFlag();
this.clearEndFlag();
});
} catch (error) {
console.error('role.vue changeRole error: ', error);

19
src/components/TimeLine/TimeLine.vue

@ -54,13 +54,11 @@ export default {
//
async handleScrollTop() {
if (!this.tasks || !this.tasks.length) return;
const startTime = this.tasks[0].planStart - 0;
if ((this.tasks[0].plugins && this.tasks[0].plugins.length === 0) || this.topEnd) {
//
console.warn(
'滚动到顶部没有数据时: ',
this.$moment(+this.$t.time.add(startTime, -1, 'day').valueOf()).format('YYYY-MM-DD HH:mm:ss'),
);
console.warn('滚动到顶部没有数据时: ');
const addTasks = [
{
panel: {},
@ -82,7 +80,7 @@ export default {
},
];
this.setUpTasks([...addTasks.concat(this.tasks)]);
this.setUpTasks(addTasks);
} else {
//
console.warn('滚动到顶部有数据时: ');
@ -97,17 +95,12 @@ export default {
//
async handleScrollBottom() {
if (!this.tasks || !this.tasks.length) return;
const { tasks, timeGranularity } = this;
console.log('timeGranularity: ', timeGranularity);
const startTime = tasks[tasks.length - 1].planStart - 0;
console.log('startTime: ', startTime);
if ((tasks[0].plugins && tasks[0].plugins.length === 0) || this.bottomEnd) {
//
console.warn(
'滚动到底部没有数据时: ',
this.$moment(+startTime).format('YYYY-MM-DD HH:mm:ss'),
this.$moment(+this.$t.time.add(startTime, 1, timeGranularity).valueOf()).format('YYYY-MM-DD HH:mm:ss'),
);
console.warn('滚动到底部没有数据时: ');
const addTasks = [
{
panel: {},
@ -128,7 +121,7 @@ export default {
planStart: this.$t.time.add(startTime, 3, timeGranularity).valueOf(),
},
];
this.setDownTasks([...tasks.concat(addTasks)]);
this.setDownTasks(addTasks);
} else {
// =+
const timeNode = this.$t.time.add(startTime, 1, timeGranularity).valueOf();

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

@ -189,7 +189,6 @@ export default {
} else {
time = null;
}
console.log('time', time); // DEBUG:
this.$nextTick(() => {
if (!time) return;
this.timer = setTimeout(() => {

1
src/components/Upload/Upload.vue

@ -14,7 +14,6 @@ export default {
async handleUpload() {
try {
const data = await this.$u.api.import();
console.log('data: ', data);
// WBS
//
this.$emit('success');

13
src/pages/project/project.vue

@ -68,6 +68,10 @@ export default {
this.height = window.screen.height + 'px';
},
onUnload() {
this.clearEndFlag();
},
methods: {
...mapActions('user', ['getToken']),
...mapActions('project', ['getProjectById']),
@ -76,7 +80,7 @@ export default {
...mapMutations('user', ['setToken']),
...mapMutations('project', ['setProject', 'setProjectName']),
...mapMutations('role', ['setInvisibleRoles', 'setVisibleRoles', 'setRoleId']),
...mapMutations('task', ['setUpTasks', 'setDownTasks', 'setDailyTasks', 'setTimeNode']),
...mapMutations('task', ['setUpTasks', 'setDownTasks', 'setDailyTasks', 'setTimeNode', 'clearEndFlag']),
/**
* 初始化
@ -117,14 +121,12 @@ export default {
// ||
async getInitTasks() {
console.log('获取初始定期任务: ');
//
await this.getTasks({ queryType: 0 });
await this.getTasks({ queryType: 1 });
//
if (this.tasks && this.tasks.length && this.tasks.plugins && this.tasks.plugins.length) {
console.log('预加载: ');
this.$nextTick(() => {
const { tasks, timeGranularity } = this;
this.getTasks({ timeNode: +tasks[0].planStart, queryType: 0, queryNum: 6 });
@ -132,6 +134,11 @@ export default {
const nextQueryTime = +this.$t.time.add(+tasks[tasks.length - 1].planStart, 1, timeGranularity);
this.getTasks({ timeNode: nextQueryTime, queryType: 1, queryNum: 6 });
});
} else {
//
this.setUpTasks();
//
this.setDownTasks();
}
},

71
src/store/task/mutations.js

@ -71,30 +71,35 @@ const mutations = {
setUpTasks(state, data) {
if (!data || !data.length) {
state.topEnd = true;
const time = +state.tasks[0].planStart - 0;
let sTime = '';
if (!state.tasks || !state.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +state.tasks[0].planStart - 0;
}
const initData = [
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, -3, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, -3, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, -2, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, -2, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, -1, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, -1, 'day').valueOf(),
},
];
state.tasks = [...initData.concat(state.tasks)];
} else {
if (!state.tasks[0].name) {
if (!state.tasks && !state.tasks.length) {
state.tasks = [...data];
} else {
state.tasks = [...data.concat(state.tasks)];
@ -110,30 +115,35 @@ const mutations = {
setDownTasks(state, data) {
if (!data || !data.length) {
state.bottomEnd = true;
const time = +state.tasks[state.tasks.length - 1].planStart - 0;
let sTime = '';
if (!state.tasks || !state.tasks.length) {
sTime = +new Date().getTime();
} else {
sTime = +state.tasks[state.tasks.length - 1].planStart - 0;
}
const initData = [
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, 1, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, 1, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, 2, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, 2, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, 3, 'day').valueOf(),
planStart: uni.$t.time.add(sTime, 3, 'day').valueOf(),
},
];
state.tasks = [...state.tasks.concat(initData)];
} else {
if (!state.tasks[0] || !state.tasks[0].name) {
if (!state.tasks && !state.tasks.length) {
state.tasks = [...data];
} else {
state.tasks = [...state.tasks.concat(data)];
@ -141,36 +151,6 @@ const mutations = {
}
},
/**
* 清空定期任务数据
* @param {Object} state
* @param {Array} data 服务端返回的模板数组
*/
setTasks(state) {
const time = +new Date().getTime();
const initData = [
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, -1, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: time,
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(time, 1, 'day').valueOf(),
},
];
state.tasks = initData;
},
/**
* 设置日常任务数据
* @param {Object} state
@ -189,11 +169,12 @@ const mutations = {
state.permanents = tasks || [];
},
// 清空标志位 如切换角色等使用
// clearEndFlag(state) {
// state.topEnd = false;
// state.bottomEnd = false;
// },
// 清空标志位 任务 如切换角色等使用
clearEndFlag(state) {
state.tasks = [];
state.topEnd = false;
state.bottomEnd = false;
},
/**
* 收到消息设置任务状态

36
src/store/task/state.js

@ -24,24 +24,24 @@ const state = {
dailyTasks: [], // 日常任务
// 定期任务
tasks: [
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(+new Date().getTime(), -1, 'day').valueOf(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: new Date().getTime(),
},
{
panel: {},
plugins: [],
process: 4,
planStart: uni.$t.time.add(+new Date().getTime(), 1, 'day').valueOf(),
},
// {
// panel: {},
// plugins: [],
// process: 4,
// planStart: uni.$t.time.add(+new Date().getTime(), -1, 'day').valueOf(),
// },
// {
// panel: {},
// plugins: [],
// process: 4,
// planStart: new Date().getTime(),
// },
// {
// panel: {},
// plugins: [],
// process: 4,
// planStart: uni.$t.time.add(+new Date().getTime(), 1, 'day').valueOf(),
// },
],
};

Loading…
Cancel
Save