Browse Source

Merge pull request 'song' (#20) from song into develop

Reviewed-on: https://dd.tall.wiki/gitea/wally/TALL-MUI-3/pulls/20
develop
wally 4 years ago
parent
commit
c596304b01
  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
--|--|--
- | 测试接口 | [215e074](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215e074)
- | 角色栏文字颜色修改 | [215c6b3](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/215c6b3)
- | 解决警告 | [c932b09](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c932b09)
- | 组件文件夹新建 | [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() {
setTimeout(() => (this.loading = false), 5000);
setTimeout(() => (this.loading = false), 2000);
},
computed: mapState('home', ['isShrink']),
methods: {

9
src/components/Roles/Roles.vue

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

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

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

22
src/components/TimeLine/TimeLine.vue

@ -36,19 +36,6 @@ export default {
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: {
...mapMutations('home', ['setScrollTop', 'setShrink', 'setRoleId']),
@ -62,13 +49,13 @@ export default {
//
handleScrollTop() {
console.log('滚动到顶部');
this.$emit('getTasks', 0);
this.$emit('getTasks', { queryType: 0 });
},
//
handleScrollBottom() {
console.log('滚动到底部');
this.$emit('getTasks', 0);
this.$emit('getTasks', { queryType: 1 });
},
//
@ -78,7 +65,10 @@ export default {
let tasksHeight = 0;
const scrollHeight = document.getElementById('scroll').clientHeight;
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;
}

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

@ -2,9 +2,10 @@
<view class="px-3 pb-10">
<view :key="index" v-for="(item, index) in tasks">
<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>任务时间栏</view>
<view>{{ $u.timeFormat(+item.planStart, 'mm-dd hh:MM') }}</view>
<!-- {{ $u.timeFormat(+item.planDuration, false) }} -->
<view>
<view class="flex justify-between" style="min-width: 180rpx">
<u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon>
@ -16,22 +17,11 @@
</view>
<view class="border-l-2 border-gray-300 ml-3.5 my-2">
<view class="ml-4 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: item.panel.height + 'px' }"
class="h-16"
margin="0"
v-if="item.panel.height"
>
<u-card :show-foot="false" :show-head="false" :style="{ height: setHeight(item.panel) }" class="h-16" margin="0">
<!-- 任务面板插件 -->
<view slot="body">
<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">
<!-- <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-description :item="item" v-if="p.pluginId === 2" />
<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-task-countdown :item="item" v-if="p.pluginId === 8" />
</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>
</u-card>
@ -73,7 +56,18 @@ export default {
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>

34
src/pages/project/project.vue

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

2
src/store/home/actions.js

@ -36,9 +36,9 @@ const actions = {
* @param {string} timeNode 时间基准点 默认当前
* @param {string} timeUnit 时间颗粒度 默认天
*/
// eslint-disable-next-line
async handleRegularTask({ commit }, param) {
try {
console.log('commit: ', commit);
return await uni.$u.api.getRegularTask(param);
} catch (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;

9
src/store/home/mutations.js

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

Loading…
Cancel
Save