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) - | 手动展开日常任务 | [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及日常任务收缩问题 | [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) - | 插件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) - | 日常任务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) - | 日常任务插件遍历时的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) - | 日常任务插件面板高度修改 | [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: { methods: {
...mapActions('task', ['handleRegularTask']), ...mapActions('task', ['handleRegularTask']),
...mapMutations('role', ['setRoleId']), ...mapMutations('role', ['setRoleId']),
...mapMutations('task', ['setTasks', 'setPermanents', 'setDailyTasks', 'clearEndFlag']), ...mapMutations('task', ['setPermanents', 'setDailyTasks', 'clearEndFlag']),
// //
setCurrentRole(index) { setCurrentRole(index) {
@ -91,14 +91,13 @@ export default {
this.setRoleId(id); this.setRoleId(id);
//index //index
this.setCurrentRole(index); this.setCurrentRole(index);
//
this.setTasks();
// //
this.setPermanents([]); this.setPermanents([]);
this.setDailyTasks([]); this.setDailyTasks([]);
//
// //
// //
// this.clearEndFlag(); this.clearEndFlag();
}); });
} catch (error) { } catch (error) {
console.error('role.vue changeRole error: ', error); console.error('role.vue changeRole error: ', error);

19
src/components/TimeLine/TimeLine.vue

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

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

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

1
src/components/Upload/Upload.vue

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

13
src/pages/project/project.vue

@ -68,6 +68,10 @@ export default {
this.height = window.screen.height + 'px'; this.height = window.screen.height + 'px';
}, },
onUnload() {
this.clearEndFlag();
},
methods: { methods: {
...mapActions('user', ['getToken']), ...mapActions('user', ['getToken']),
...mapActions('project', ['getProjectById']), ...mapActions('project', ['getProjectById']),
@ -76,7 +80,7 @@ export default {
...mapMutations('user', ['setToken']), ...mapMutations('user', ['setToken']),
...mapMutations('project', ['setProject', 'setProjectName']), ...mapMutations('project', ['setProject', 'setProjectName']),
...mapMutations('role', ['setInvisibleRoles', 'setVisibleRoles', 'setRoleId']), ...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() { async getInitTasks() {
console.log('获取初始定期任务: ');
// //
await this.getTasks({ queryType: 0 }); await this.getTasks({ queryType: 0 });
await this.getTasks({ queryType: 1 }); await this.getTasks({ queryType: 1 });
// //
if (this.tasks && this.tasks.length && this.tasks.plugins && this.tasks.plugins.length) { if (this.tasks && this.tasks.length && this.tasks.plugins && this.tasks.plugins.length) {
console.log('预加载: ');
this.$nextTick(() => { this.$nextTick(() => {
const { tasks, timeGranularity } = this; const { tasks, timeGranularity } = this;
this.getTasks({ timeNode: +tasks[0].planStart, queryType: 0, queryNum: 6 }); 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); const nextQueryTime = +this.$t.time.add(+tasks[tasks.length - 1].planStart, 1, timeGranularity);
this.getTasks({ timeNode: nextQueryTime, queryType: 1, queryNum: 6 }); 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) { setUpTasks(state, data) {
if (!data || !data.length) { if (!data || !data.length) {
state.topEnd = true; 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 = [ const initData = [
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, process: 4,
planStart: uni.$t.time.add(time, -3, 'day').valueOf(), planStart: uni.$t.time.add(sTime, -3, 'day').valueOf(),
}, },
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, process: 4,
planStart: uni.$t.time.add(time, -2, 'day').valueOf(), planStart: uni.$t.time.add(sTime, -2, 'day').valueOf(),
}, },
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, 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)]; state.tasks = [...initData.concat(state.tasks)];
} else { } else {
if (!state.tasks[0].name) { if (!state.tasks && !state.tasks.length) {
state.tasks = [...data]; state.tasks = [...data];
} else { } else {
state.tasks = [...data.concat(state.tasks)]; state.tasks = [...data.concat(state.tasks)];
@ -110,30 +115,35 @@ const mutations = {
setDownTasks(state, data) { setDownTasks(state, data) {
if (!data || !data.length) { if (!data || !data.length) {
state.bottomEnd = true; 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 = [ const initData = [
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, process: 4,
planStart: uni.$t.time.add(time, 1, 'day').valueOf(), planStart: uni.$t.time.add(sTime, 1, 'day').valueOf(),
}, },
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, process: 4,
planStart: uni.$t.time.add(time, 2, 'day').valueOf(), planStart: uni.$t.time.add(sTime, 2, 'day').valueOf(),
}, },
{ {
panel: {}, panel: {},
plugins: [], plugins: [],
process: 4, 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)]; state.tasks = [...state.tasks.concat(initData)];
} else { } else {
if (!state.tasks[0] || !state.tasks[0].name) { if (!state.tasks && !state.tasks.length) {
state.tasks = [...data]; state.tasks = [...data];
} else { } else {
state.tasks = [...state.tasks.concat(data)]; 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 * @param {Object} state
@ -189,11 +169,12 @@ const mutations = {
state.permanents = tasks || []; state.permanents = tasks || [];
}, },
// 清空标志位 如切换角色等使用 // 清空标志位 任务 如切换角色等使用
// clearEndFlag(state) { clearEndFlag(state) {
// state.topEnd = false; state.tasks = [];
// state.bottomEnd = false; state.topEnd = false;
// }, state.bottomEnd = false;
},
/** /**
* 收到消息设置任务状态 * 收到消息设置任务状态

36
src/store/task/state.js

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

Loading…
Cancel
Save