Browse Source

fix: 定期任务接口

develop
lucky 4 years ago
parent
commit
aa4981ca12
  1. 1
      CHANGELOG.md
  2. 2
      src/components/Globals/Globals.vue
  3. 9
      src/components/Roles/Roles.vue
  4. 69
      src/components/Roles/component/RoleList.vue
  5. 22
      src/components/TimeLine/TimeLine.vue
  6. 40
      src/components/TimeLine/component/TimeBox.vue
  7. 34
      src/pages/project/project.vue
  8. 2
      src/store/home/actions.js
  9. 10
      src/store/home/getters.js
  10. 9
      src/store/home/mutations.js
  11. 13
      src/store/user/getters.js

1
CHANGELOG.md

@ -67,6 +67,7 @@
### 🚀 性能优化 ### 🚀 性能优化
范围|描述|commitId 范围|描述|commitId
--|--|-- --|--|--
- | 测试接口 | [215e074](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215e074)
- | 角色栏文字颜色修改 | [215c6b3](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215c6b3) - | 角色栏文字颜色修改 | [215c6b3](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215c6b3)
- | 解决警告 | [c932b09](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c932b09) - | 解决警告 | [c932b09](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c932b09)
- | 组件文件夹新建 | [22bfe7b](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/22bfe7b) - | 组件文件夹新建 | [22bfe7b](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/22bfe7b)

2
src/components/Globals/Globals.vue

@ -39,7 +39,7 @@ export default {
}, },
mounted() { mounted() {
setTimeout(() => (this.loading = false), 5000); setTimeout(() => (this.loading = false), 2000);
}, },
computed: mapState('home', ['isShrink']), computed: mapState('home', ['isShrink']),
methods: { methods: {

9
src/components/Roles/Roles.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="wrap bg-white px-2"> <view class="wrap bg-white px-2">
<role-list /> <role-list @getTasks="getTasks" />
</view> </view>
</template> </template>
@ -13,7 +13,12 @@ export default {
data() { data() {
return {}; return {};
}, },
methods: {}, methods: {
getTasks(query) {
console.log('query: ', query);
this.$emit('getTasks', query);
},
},
}; };
</script> </script>

69
src/components/Roles/component/RoleList.vue

@ -39,32 +39,11 @@ export default {
pm: 0, pm: 0,
sequence: 2, sequence: 2,
}, },
{
id: 3,
name: '导师一',
mine: 1,
pm: 0,
sequence: 3,
},
{
id: 4,
name: '导师二',
mine: 1,
pm: 0,
sequence: 4,
},
{
id: 5,
name: '导师三',
mine: 1,
pm: 0,
sequence: 5,
},
], ],
}; };
}, },
computed: { ...mapState('home', ['visibleRoles', 'roleId']) }, computed: { ...mapState('home', ['visibleRoles', 'roleId', 'tasks']) },
watch: { watch: {
visibleRoles(val) { visibleRoles(val) {
@ -104,44 +83,44 @@ export default {
this.scrollLeft = left - screenWidth / 2; this.scrollLeft = left - screenWidth / 2;
}, },
changeIndex(id, index) { async changeIndex(id, index) {
this.setRoleId(id); this.setRoleId(id);
//index //index
this.setCurrentRole(index); this.setCurrentRole(index);
// //
this.getTasks(); await this.$emit('getTasks', { queryType: 0 });
}, await this.$emit('getTasks', { queryType: 1 });
console.log('this.tasks && this.tasks.length: ', this.tasks && this.tasks.length);
/** if (this.tasks && this.tasks.length) {
* 根据时间基准点和角色查找定期任务 debugger;
* @param {string} roleId 角色id //
* @param {string} timeNode 时间基准点 默认当前 const upQuery = {
* @param {string} timeUnit 时间颗粒度 默认天 timeNode: +this.tasks[0].planStart,
*/ queryType: 0,
async getTasks() { queryNum: 6,
try { };
const { roleId, timeNode, timeUnit } = this; console.log('upQuery: ', upQuery);
const params = { await this.$emit('getTasks', upQuery);
roleId, const downQuery = {
timeNode, timeNode: +this.tasks[this.tasks.length - 1].planStart,
timeUnit, queryType: 0,
queryNum: 6,
}; };
await this.handleRegularTask(params); console.log('downQuery: ', downQuery);
} catch (error) { await this.$emit('getTasks', downQuery);
console.log('error: ', error);
} }
}, },
// //
setColor(mine, id) { setColor(mine, id) {
const { roleId } = this; const { roleId } = this;
if (mine === 1 && roleId === id) { if (mine === '1' && roleId === id) {
return 'default-tab-choice'; return 'default-tab-choice';
} }
if (mine === 1 && roleId !== id) { if (mine === '1' && roleId !== id) {
return 'default-tab-item'; return 'default-tab-item';
} }
if (mine === 0 && roleId === id) { if (mine === '0' && roleId === id) {
return 'tab-choice'; return 'tab-choice';
} }
}, },

22
src/components/TimeLine/TimeLine.vue

@ -36,19 +36,6 @@ export default {
computed: mapState('home', ['scrollTop', 'showTips', 'visibleRoles', 'tasks']), computed: mapState('home', ['scrollTop', 'showTips', 'visibleRoles', 'tasks']),
mounted() {
//
// let tasksHeight = 0;
// const scrollHeight = document.getElementById('scroll').clientHeight;
// if (this.visibleRoles && this.visibleRoles.length) {
// for (let i = 0; i < 3; i++) {
// tasksHeight += this.visibleRoles[i].panel.height - 0 + 42;
// }
// this.top = tasksHeight - scrollHeight / 2;
// }
// console.log('this.top: ', this.top);
},
methods: { methods: {
...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId']), ...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId']),
@ -62,13 +49,13 @@ export default {
// //
handleScrollTop() { handleScrollTop() {
console.log('滚动到顶部'); console.log('滚动到顶部');
this.$emit('getTasks', 0); this.$emit('getTasks', { queryType: 0 });
}, },
// //
handleScrollBottom() { handleScrollBottom() {
console.log('滚动到底部'); console.log('滚动到底部');
this.$emit('getTasks', 0); this.$emit('getTasks', { queryType: 1 });
}, },
// //
@ -78,7 +65,10 @@ export default {
let tasksHeight = 0; let tasksHeight = 0;
const scrollHeight = document.getElementById('scroll').clientHeight; const scrollHeight = document.getElementById('scroll').clientHeight;
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
tasksHeight += +tasks[i].panel.height + 42; // TODO:
// if (tasks[i].panel && tasks[i].panel.height) {
// tasksHeight += +tasks[i].panel.height + 42;
// }
} }
this.top = tasksHeight - scrollHeight / 2; this.top = tasksHeight - scrollHeight / 2;
} }

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

@ -2,9 +2,10 @@
<view class="px-3 pb-10"> <view class="px-3 pb-10">
<view :key="index" v-for="(item, index) in tasks"> <view :key="index" v-for="(item, index) in tasks">
<view class="flex items-center"> <view class="flex items-center">
<TimeStatus :content="JSON.stringify(item.state)" :status="item.state" /> <TimeStatus :content="JSON.stringify(item.process)" :status="item.process" />
<view class="flex justify-between flex-1 ml-2"> <view class="flex justify-between flex-1 ml-2">
<view>任务时间栏</view> <view>{{ $u.timeFormat(+item.planStart, 'mm-dd hh:MM') }}</view>
<!-- {{ $u.timeFormat(+item.planDuration, false) }} -->
<view> <view>
<view class="flex justify-between" style="min-width: 180rpx"> <view class="flex justify-between" style="min-width: 180rpx">
<u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon> <u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon>
@ -16,22 +17,11 @@
</view> </view>
<view class="border-l-2 border-gray-300 ml-3.5 my-2"> <view class="border-l-2 border-gray-300 ml-3.5 my-2">
<view class="ml-4 overflow-hidden shadow-lg task-box"> <view class="ml-4 overflow-hidden shadow-lg task-box">
<u-card <u-card :show-foot="false" :show-head="false" :style="{ height: setHeight(item.panel) }" class="h-16" margin="0">
:show-foot="false" <!-- 任务面板插件 -->
:show-head="false"
:style="{ height: item.panel.height + 'px' }"
class="h-16"
margin="0"
v-if="item.panel.height"
>
<view slot="body"> <view slot="body">
<view :key="pluginIndex" class="p-0 u-col-between u-skeleton" v-for="(plugin, pluginIndex) in item.plugins"> <view :key="pluginIndex" class="p-0 u-col-between u-skeleton" v-for="(plugin, pluginIndex) in item.plugins">
<view :key="p.pluginId" v-for="p in plugin"> <view :key="p.pluginId" v-for="p in plugin">
<!-- <component
:is="$t.plugin.defaults.find(item => item.id === p.pluginId).component"
:item="item"
v-if="$t.plugin.defaults.find(item => item.id === p.pluginId)"
></component>-->
<p-task-title :item="item" v-if="p.pluginId === 1" /> <p-task-title :item="item" v-if="p.pluginId === 1" />
<p-task-description :item="item" v-if="p.pluginId === 2" /> <p-task-description :item="item" v-if="p.pluginId === 2" />
<p-task-duration-delay :item="item" v-if="p.pluginId === 3" /> <p-task-duration-delay :item="item" v-if="p.pluginId === 3" />
@ -41,13 +31,6 @@
<p-subproject :item="item" v-if="p.pluginId === 7" /> <p-subproject :item="item" v-if="p.pluginId === 7" />
<p-task-countdown :item="item" v-if="p.pluginId === 8" /> <p-task-countdown :item="item" v-if="p.pluginId === 8" />
</view> </view>
<!-- <view :key="p.pluginId" v-for="p in plugin">
<text v-if="p.pluginId === 4">这是个基准线</text>
<component :is="currentComponent"></component>
<task-title v-if="p.pluginId === 1" />
<task-description v-if="p.pluginId === 2" />
<task-duration-delay v-if="p.pluginId === 3" />
</view>-->
</view> </view>
</view> </view>
</u-card> </u-card>
@ -73,7 +56,18 @@ export default {
created() {}, created() {},
methods: { ...mapMutations('home', ['setTipsContent', 'setTipsContent']) }, methods: {
...mapMutations('home', ['setTipsContent', 'setTipsContent']),
//
setHeight(panel) {
if (panel && panel.height) {
return panel.height + 'px';
} else {
return 'auto';
}
},
},
}; };
</script> </script>

34
src/pages/project/project.vue

@ -2,7 +2,7 @@
<view :style="{ height: height }" class="flex flex-col overflow-hidden"> <view :style="{ height: height }" class="flex flex-col overflow-hidden">
<Title /> <Title />
<view class="container flex flex-col flex-1 overflow-hidden bg-gray-100"> <view class="container flex flex-col flex-1 overflow-hidden bg-gray-100">
<Roles /> <Roles @getTasks="getTasks" />
<Globals :plugins="plugins" /> <Globals :plugins="plugins" />
<TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="child" /> <TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="child" />
</view> </view>
@ -18,7 +18,7 @@ export default {
computed: { computed: {
...mapState('user', ['user', 'token']), ...mapState('user', ['user', 'token']),
...mapState('home', ['visibleRoles', 'roleId', 'timeNode', 'timeUnit']), ...mapState('home', ['visibleRoles', 'roleId', 'timeNode', 'timeUnit', 'tasks']),
}, },
async onLoad(options) { async onLoad(options) {
@ -29,18 +29,26 @@ export default {
await this.getUserId(options.u); await this.getUserId(options.u);
} }
const params = { projectId: options.p }; const params = { projectId: options.p };
this.setProjectName(options.pname);
// id // id
await this.getProjectById(params); await this.getProjectById(params);
// id // id
await this.getRoles(params); await this.getRoles(params);
this.setInitialRoleId(this.visibleRoles); this.setInitialRoleId(this.visibleRoles);
// //
await this.getTasks(0); await this.getTasks({ queryType: 0 });
await this.getTasks(1); await this.getTasks({ queryType: 1 });
// //
await this.getPermanent(); await this.getPermanent();
// //
await this.getGlobal(); await this.getGlobal();
//
if (this.tasks && this.tasks.length) {
console.log('this.tasks[0].planStart: ', this.tasks[0].planStart);
await this.getTasks({ timeNode: +this.tasks[0].planStart, queryType: 0, queryNum: 6 });
console.log('this.tasks[this.tasks.length - 1].planStart: ', this.tasks[this.tasks.length - 1].planStart);
await this.getTasks({ timeNode: +this.tasks[this.tasks.length - 1].planStart, queryType: 1, queryNum: 6 });
}
}, },
mounted() { mounted() {
@ -56,6 +64,7 @@ export default {
'setUpTasks', 'setUpTasks',
'setDownTasks', 'setDownTasks',
'setDailyTasks', 'setDailyTasks',
'setProjectName',
]), ]),
...mapActions('user', ['getUserId']), ...mapActions('user', ['getUserId']),
...mapActions('home', ['getProjectById', 'getRoles', 'handleRegularTask']), ...mapActions('home', ['getProjectById', 'getRoles', 'handleRegularTask']),
@ -81,18 +90,17 @@ export default {
* @param {string} queryNum 查找颗粒度数量 默认3个 * @param {string} queryNum 查找颗粒度数量 默认3个
* @param {string} queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含 * @param {string} queryType 0向上查找 1向下查找(默认) 下查包含自己上查不包含
*/ */
async getTasks(queryType) { async getTasks(query) {
try { try {
const { roleId, timeNode, timeUnit } = this; const { roleId, timeNode, timeUnit } = this;
const params = { const params = { roleId };
roleId, params.timeNode = query.timeNode || timeNode;
timeNode, params.timeUnit = query.timeUnit || timeUnit;
timeUnit, params.queryNum = query.queryNum || 3;
queryNum: 3, params.queryType = query.queryType;
queryType, console.log('params: ', params);
};
const res = await this.handleRegularTask(params); const res = await this.handleRegularTask(params);
queryType === 0 ? this.setUpTasks(res) : this.setDownTasks(res); query.queryType === 0 ? this.setUpTasks(res) : this.setDownTasks(res);
this.$refs.child.setDatumPoint(); this.$refs.child.setDatumPoint();
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);

2
src/store/home/actions.js

@ -36,9 +36,9 @@ const actions = {
* @param {string} timeNode 时间基准点 默认当前 * @param {string} timeNode 时间基准点 默认当前
* @param {string} timeUnit 时间颗粒度 默认天 * @param {string} timeUnit 时间颗粒度 默认天
*/ */
// eslint-disable-next-line
async handleRegularTask({ commit }, param) { async handleRegularTask({ commit }, param) {
try { try {
console.log('commit: ', commit);
return await uni.$u.api.getRegularTask(param); return await uni.$u.api.getRegularTask(param);
} catch (error) { } catch (error) {
throw error || '获取定期任务失败'; throw error || '获取定期任务失败';

10
src/store/home/getters.js

@ -1,3 +1,11 @@
const getters = {}; const getters = {
/**
* 当前项目的id
* @param {object} project
*/
projectId({ project }) {
return project.id;
},
};
export default getters; export default getters;

9
src/store/home/mutations.js

@ -62,6 +62,15 @@ const mutations = {
state.project = { ...data }; state.project = { ...data };
}, },
/**
* 设置当前项目名称
* @param { object } state
* @param { string } data
*/
setProjectName(state, data) {
state.project.name = data;
},
/** /**
* 设置不展示的角色信息 * 设置不展示的角色信息
* @param {Object} state * @param {Object} state

13
src/store/user/getters.js

@ -1,3 +1,14 @@
const getters = {}; const getters = {
// 获取用户的id
userId({ user }) {
try {
if (!user) return '';
return user.id;
} catch (error) {
console.warn("user's getters 获取userId失败", error);
return '';
}
},
};
export default getters; export default getters;

Loading…
Cancel
Save