1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

Update home page layout, update work card layout.

Optimize t_work table queries.
This commit is contained in:
GGB
2023-05-19 17:02:22 +08:00
parent 523b0faa88
commit ef878f7edf
5 changed files with 139 additions and 118 deletions

View File

@@ -52,8 +52,8 @@ public class WorkController {
@GetMapping("/card") @GetMapping("/card")
public ResponseResult getCard() { public ResponseResult getCard() {
// Long userId = WebUtil.getLoginUser().getUser().getId(); Long userId = WebUtil.getLoginUser().getUser().getId();
long userId = 1; // long userId = 1;
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getCard(userId)); return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getCard(userId));
} }

View File

@@ -39,43 +39,43 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
private UserMapper userMapper; private UserMapper userMapper;
@Override @Override
public List<Work> getAll() { public List<Work> getAll() {
List<Work> workList = workMapper.getAll(); // List<Work> workList = workMapper.getAll();
for (Work work: // for (Work work:
workList) { // workList) {
work.setProgress(getProgress(work.getId())); // work.setProgress(getProgress(work.getId()));
work.setPublisherName(getUserName(work.getPublisherId())); // work.setPublisherName(getUserName(work.getPublisherId()));
} // }
return workList; return workMapper.getAll();
} }
@Override @Override
public List<Work> getTodo(Long userId) { public List<Work> getTodo(Long userId) {
List<Work> workList = workMapper.getTodo(userId); // List<Work> workList = workMapper.getTodo(userId);
for (Work work: // for (Work work:
workList) { // workList) {
work.setPublisherName(getUserName(work.getPublisherId())); // work.setPublisherName(getUserName(work.getPublisherId()));
} // }
return workList; return workMapper.getTodo(userId);
} }
@Override @Override
public List<Work> getCard(Long userId) { public List<Work> getCard(Long userId) {
List<Work> workList = workMapper.getCard(userId); // List<Work> workList = workMapper.getCard(userId);
for (Work work: // for (Work work:
workList) { // workList) {
work.setPublisherName(getUserName(work.getPublisherId())); // work.setPublisherName(getUserName(work.getPublisherId()));
} // }
return workList; return workMapper.getCard(userId);
} }
@Override @Override
public List<Work> getComplete(Long userId) { public List<Work> getComplete(Long userId) {
List<Work> workList = workMapper.getComplete(userId); // List<Work> workList = workMapper.getComplete(userId);
for (Work work: // for (Work work:
workList) { // workList) {
work.setPublisherName(getUserName(work.getPublisherId())); // work.setPublisherName(getUserName(work.getPublisherId()));
} // }
return workList; return workMapper.getComplete(userId);
} }
@Override @Override
@@ -88,13 +88,13 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
@Override @Override
public List<Work> getWorkByContent(String content) { public List<Work> getWorkByContent(String content) {
List<Work> workList = workMapper.getWorkByContent(content); // List<Work> workList = workMapper.getWorkByContent(content);
for (Work work: // for (Work work:
workList) { // workList) {
work.setProgress(getProgress(work.getId())); // work.setProgress(getProgress(work.getId()));
work.setPublisherName(getUserName(work.getPublisherId())); // work.setPublisherName(getUserName(work.getPublisherId()));
} // }
return workList; return workMapper.getWorkByContent(content);
} }
@Override @Override

View File

@@ -5,6 +5,7 @@
<id property="id" column="id"/> <id property="id" column="id"/>
<result property="content" column="content"/> <result property="content" column="content"/>
<result property="publisherId" column="publisher_id"/> <result property="publisherId" column="publisher_id"/>
<result property="publisherName" column="publisher_name"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="deadline" column="deadline"/> <result property="deadline" column="deadline"/>
<collection property="userWorkList" ofType="userWork"> <collection property="userWorkList" ofType="userWork">
@@ -20,97 +21,93 @@
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, tu.username worker_name,
tuw.status status, tuw.status status,
tuw.complete_time complete_time tuw.complete_time complete_time
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
where w.id = tuw.work_id left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
and tuw.user_id = u.id where w.deleted = 0
and w.deleted = 0
and tuw.deleted = 0
order by w.id desc; order by w.id desc;
</select> </select>
<select id="getWork" parameterType="long" resultMap="workMap"> <select id="getWork" parameterType="long" resultMap="workMap">
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, tu.username worker_name,
tuw.status status, tuw.status status,
tuw.complete_time completeTime tuw.complete_time completeTime
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
where w.id = #{id} where w.id = #{id}
and w.id = tuw.work_id and w.deleted = 0;
and tuw.user_id = u.id
and w.deleted = 0
and tuw.deleted = 0;
</select> </select>
<select id="getWorkByContent" parameterType="String" resultMap="workMap"> <select id="getWorkByContent" parameterType="String" resultMap="workMap">
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, tu.username worker_name,
tuw.status status, tuw.status status,
tuw.complete_time completeTime tuw.complete_time completeTime
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
where w.content like '%${content}%' where w.content like '%${content}%'
and w.id = tuw.work_id and w.deleted = 0;
and tuw.user_id = u.id
and w.deleted = 0
and tuw.deleted = 0;
</select> </select>
<select id="getTodo" parameterType="long" resultMap="workMap"> <select id="getTodo" parameterType="long" resultMap="workMap">
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, tu.username worker_name,
tuw.status status tuw.status status
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
where w.id = tuw.work_id left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
and tuw.user_id = u.id where
and tuw.user_id = #{userId} tuw.user_id = #{userId}
and status = false and status = false
and w.deleted = 0 and w.deleted = 0
and tuw.deleted = 0
order by w.deadline asc, w.id desc; order by w.deadline asc, w.id desc;
</select> </select>
<select id="getCard" parameterType="long" resultMap="workMap"> <select id="getCard" parameterType="long" resultMap="workMap">
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, tu.username worker_name,
tuw.status status tuw.status status
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
where w.id = tuw.work_id left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
and tuw.user_id = u.id where tuw.user_id = #{userId}
and tuw.user_id = #{userId}
and status = false and status = false
and w.deleted = 0 and w.deleted = 0
and tuw.deleted = 0
order by w.deadline asc, w.id desc order by w.deadline asc, w.id desc
limit 5; limit 5;
@@ -119,21 +116,20 @@
select w.id, select w.id,
content, content,
publisher_id, publisher_id,
u.username publisher_name,
create_time, create_time,
deadline, deadline,
tuw.user_id worker_id, tuw.user_id worker_id,
u.username worker_name, u.username worker_name,
tuw.status status, tuw.status status,
tuw.complete_time complete_time tuw.complete_time complete_time
from t_work w, from t_work w
t_user u, left join (select * from t_user where deleted = 0) as u on w.publisher_id = u.id
t_user_work tuw left join (select * from t_user_work where deleted = 0) as tuw on w.id = tuw.work_id
left join (select * from t_user where deleted = 0) as tu on tuw.user_id = tu.id
where tuw.user_id = #{userId} where tuw.user_id = #{userId}
and tuw.user_id = u.id
and w.id = tuw.work_id
and tuw.status = true and tuw.status = true
and w.deleted = 0 and w.deleted = 0
and tuw.deleted = 0
order by w.id desc; order by w.id desc;
</select> </select>

View File

@@ -1,7 +1,7 @@
<template> <template>
<el-card shadow="hover"> <el-card shadow="hover">
<template #header> <template #header>
<div class="card-header"> <div class="card-header" style="height: 20px">
<h2>待办工作</h2> <h2>待办工作</h2>
<el-button class="button" text @click="pushTodo">查看更多</el-button> <el-button class="button" text @click="pushTodo">查看更多</el-button>
</div> </div>
@@ -12,7 +12,7 @@
<el-avatar style="background-color: #409eff" size="default"> <el-avatar style="background-color: #409eff" size="default">
<el-icon <el-icon
color="white" color="white"
:size="SIZE_ICON_LG()" :size="SIZE_ICON_MD()"
style="vertical-align: center" style="vertical-align: center"
> >
<icon-pinnacle-workpage /> <icon-pinnacle-workpage />
@@ -38,15 +38,17 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import request from '@/services'
import { SIZE_ICON_LG, SIZE_ICON_MD } from '@/constants/Common.constants' import { SIZE_ICON_LG, SIZE_ICON_MD } from '@/constants/Common.constants'
export default { export default {
data() { props: {
return { tableData: []
tableData: []
}
}, },
// data() {
// return {
// tableData: []
// }
// },
methods: { methods: {
SIZE_ICON_LG() { SIZE_ICON_LG() {
return SIZE_ICON_LG return SIZE_ICON_LG
@@ -57,22 +59,9 @@ export default {
formatDate(time) { formatDate(time) {
return new Date(time).toLocaleString() return new Date(time).toLocaleString()
}, },
getTableData() {
request
.get('/work/card')
.then((response) => {
this.tableData = response.data.data
})
.catch((reportError) => {
console.log(reportError)
})
},
pushTodo() { pushTodo() {
this.$router.push('/work/task') this.$router.push('/work/task')
} }
},
created() {
this.getTableData()
} }
} }
</script> </script>
@@ -89,6 +78,12 @@ export default {
} }
.item { .item {
margin-bottom: 18px; margin-bottom: 5px;
height: calc(((100vh - 56px - 40px - 20px) / 2 - 56px - 40px) / 5);
min-height: 48px;
}
.el-card {
height: calc((100vh - 56px - 40px - 20px) / 2);
min-height: calc((500px - 56px - 40px - 20px) / 2);
} }
</style> </style>

View File

@@ -1,30 +1,60 @@
<template> <template>
<el-row style="width: 100%" :gutter="20"> <div style="height: calc(100vh - 56px - 40px); min-height: calc(500px - 56px - 40px)">
<el-col :span="12"> <el-row :gutter="20">
<work-card /> <el-col :span="12">
</el-col> <work-card :table-data="tableData" />
<el-col :span="12"> </el-col>
<work-card /> <el-col :span="12">
</el-col> <work-card :table-data="tableData" />
</el-row> </el-col>
<el-row style="width: 100%" :gutter="20"> </el-row>
<el-col :span="12"> <el-row :gutter="20">
<work-card /> <el-col :span="12">
</el-col> <work-card :table-data="tableData" />
<el-col :span="12"> </el-col>
<work-card /> <el-col :span="12">
</el-col> <work-card :table-data="tableData" />
</el-row> </el-col>
</el-row>
</div>
</template> </template>
<script> <script>
import request from '@/services'
export default { export default {
name: 'HomePage' name: 'HomePage',
data() {
return {
tableData: []
}
},
methods: {
getTableData() {
request
.get('/work/card')
.then((response) => {
this.tableData = response.data.data
})
.catch((reportError) => {
console.log(reportError)
})
}
},
created() {
this.getTableData()
},
updated() {
this.getTableData()
}
} }
</script> </script>
<style scoped> <style scoped>
.el-row { .el-row {
width: 100%;
height: calc((100vh - 56px - 40px - 20px) / 2);
min-height: calc((500px - 56px - 40px - 20px) / 2);
margin-bottom: 20px; margin-bottom: 20px;
} }
</style> </style>