mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 15:01:23 +08:00
Add fuzzy query function in work items
This commit is contained in:
@@ -35,9 +35,14 @@ public class WorkController {
|
||||
@Autowired
|
||||
private IWorkService workService;
|
||||
@GetMapping
|
||||
public ResponseResult getAll() {
|
||||
public ResponseResult getAll(String content) {
|
||||
if (content != null) {
|
||||
List<Work> workList = workService.getWorkByContent(content);
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success",workList);
|
||||
} else {
|
||||
return ResponseResult.build(ResponseCode.DATABASE_SELECT_OK, "success", workService.getAll());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/todo")
|
||||
public ResponseResult getTodo() {
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.baomidou.mybatisplus.annotation.Version;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
@@ -54,6 +56,10 @@ public class UserWork implements Serializable {
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
@TableField("complete_time")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", timezone = "UTC")
|
||||
private LocalDateTime completeTime;
|
||||
|
||||
@TableField("deleted")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface WorkMapper extends BaseMapper<Work> {
|
||||
|
||||
Work getWork(Long workId);
|
||||
|
||||
List<Work> getWorkByContent(String content);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public interface IWorkService extends IService<Work> {
|
||||
List<Work> getTodo(Long userId);
|
||||
List<Work> getComplete(Long userId);
|
||||
Work getOne(Long workId);
|
||||
|
||||
List<Work> getWorkByContent(String content);
|
||||
double getProgress(Long workId);
|
||||
|
||||
String getUserName(Long userId);
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -71,6 +72,17 @@ public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IW
|
||||
return work;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Work> getWorkByContent(String content) {
|
||||
List<Work> workList = workMapper.getWorkByContent(content);
|
||||
for (Work work:
|
||||
workList) {
|
||||
work.setProgress(getProgress(work.getId()));
|
||||
work.setPublisherName(getUserName(work.getPublisherId()));
|
||||
}
|
||||
return workList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProgress(Long workId) {
|
||||
double workNum = userWorkMapper.selectCount(new QueryWrapper<UserWork>().eq("work_id",workId));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<result property="deadline" column="deadline"/>
|
||||
<collection property="userWorkList" ofType="userWork">
|
||||
<result property="status" column="status"/>
|
||||
<result property="completeTime" column="complete_time"/>
|
||||
</collection>
|
||||
<collection property="worker" ofType="user">
|
||||
<id property="id" column="worker_id"/>
|
||||
@@ -23,7 +24,8 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time complete_time
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
@@ -41,7 +43,8 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time completeTime
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
@@ -51,6 +54,25 @@
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0;
|
||||
</select>
|
||||
<select id="getWorkByContent" parameterType="String" resultMap="workMap">
|
||||
select w.id,
|
||||
content,
|
||||
publisher_id,
|
||||
create_time,
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status,
|
||||
tuw.complete_time completeTime
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
where w.content like '%${content}%'
|
||||
and w.id = tuw.work_id
|
||||
and tuw.user_id = u.id
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0;
|
||||
</select>
|
||||
<select id="getTodo" parameterType="long" resultMap="workMap">
|
||||
select w.id,
|
||||
content,
|
||||
@@ -69,7 +91,7 @@
|
||||
and status = false
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0
|
||||
order by w.id desc;
|
||||
order by w.deadline asc, w.id desc;
|
||||
</select>
|
||||
<select id="getComplete" parameterType="long" resultMap="workMap">
|
||||
select w.id,
|
||||
@@ -79,50 +101,18 @@
|
||||
deadline,
|
||||
tuw.user_id worker_id,
|
||||
u.username worker_name,
|
||||
tuw.status status
|
||||
tuw.status status,
|
||||
tuw.complete_time complete_time
|
||||
from t_work w,
|
||||
t_user u,
|
||||
t_user_work tuw
|
||||
where w.id = tuw.work_id
|
||||
where tuw.user_id = #{userId}
|
||||
and tuw.user_id = u.id
|
||||
and tuw.user_id = #{userId}
|
||||
and status = true
|
||||
and w.id = tuw.work_id
|
||||
and tuw.status = true
|
||||
and w.deleted = 0
|
||||
and tuw.deleted = 0
|
||||
order by w.id desc;
|
||||
</select>
|
||||
<delete id="deleteWorkById" parameterType="int">
|
||||
delete
|
||||
from t_task
|
||||
where id = #{id};
|
||||
</delete>
|
||||
<delete id="deleteWork" parameterType="list">
|
||||
delete
|
||||
from t_task
|
||||
<where>
|
||||
<foreach collection="list" item="id" open="id in(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
</where>
|
||||
</delete>
|
||||
<update id="updateWork" parameterType="Work">
|
||||
update t_task
|
||||
<set>
|
||||
<if test="publisher_id!=null and publisher_id!=0">
|
||||
publisher_id = #{publisher_id}
|
||||
</if>
|
||||
<if test="taskStatus!=null">
|
||||
task_status=#{taskStatus}
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id};
|
||||
</update>
|
||||
<select id="getOneById" resultMap="workMap">
|
||||
select id, user_id, userName, task_content, create_time, deadline, task_status
|
||||
from t_task,
|
||||
t_user
|
||||
where user_id = userID
|
||||
and id = #{id};
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
:root {
|
||||
--main-color: #00d4ff;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
}
|
||||
.main {
|
||||
display: flex;
|
||||
min-width: 600px;
|
||||
@@ -11,6 +14,7 @@
|
||||
display: flex;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.main-add-content {
|
||||
position: fixed;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
>
|
||||
<el-option
|
||||
v-for="item in workers"
|
||||
:key="item.userId"
|
||||
:key="item.id"
|
||||
:label="item.username"
|
||||
:value="item"
|
||||
/>
|
||||
@@ -65,7 +65,7 @@ export default {
|
||||
},
|
||||
workers: [
|
||||
{
|
||||
userId: '',
|
||||
id: '',
|
||||
username: ''
|
||||
}
|
||||
],
|
||||
@@ -9,6 +9,18 @@
|
||||
>
|
||||
<el-table-column fixed prop="publisherName" label="发布者" width="120" />
|
||||
<el-table-column prop="content" label="内容" width="800" />
|
||||
<el-table-column prop="status" label="完成状态" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.tagType">
|
||||
{{ statusTag(scope.row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="completeTime" label="完成时间" width="200" sortable>
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.userWorkList[0].completeTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="deadline" label="结束时间" width="200">
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.deadline) }}
|
||||
@@ -53,13 +65,23 @@ export default {
|
||||
tableData: [],
|
||||
visible: false,
|
||||
taskData: [],
|
||||
loading: true
|
||||
loading: true,
|
||||
tagType: 'info'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDate(deadline) {
|
||||
console.log(new Date(deadline).toLocaleString())
|
||||
return new Date(deadline).toLocaleString()
|
||||
formatDate(time) {
|
||||
console.log(new Date(time).toLocaleString())
|
||||
return new Date(time).toLocaleString()
|
||||
},
|
||||
statusTag(row) {
|
||||
if (row.userWorkList[0].completeTime <= row.deadline) {
|
||||
row.tagType = 'success'
|
||||
return '已完成'
|
||||
} else {
|
||||
row.tagType = 'danger'
|
||||
return '超时完成'
|
||||
}
|
||||
},
|
||||
todoConfirmEvent(row) {
|
||||
const userWork = {
|
||||
@@ -79,6 +101,7 @@ export default {
|
||||
.then((response) => {
|
||||
this.tableData = response.data.data
|
||||
if (this.tableData) {
|
||||
console.log(this.tableData)
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
<template>
|
||||
<div class="head">
|
||||
<el-row style="width: 50%">
|
||||
<el-col :span="17">
|
||||
<el-input
|
||||
v-model="searchContent"
|
||||
placeholder="请输入查询的工作内容"
|
||||
size="default"
|
||||
clearable
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="1" />
|
||||
<el-col :span="3">
|
||||
<el-button size="default" type="primary" @click="searchByContent">搜索</el-button>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-button size="default" @click="addVisible = true">添加</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="main-table">
|
||||
<el-table
|
||||
@@ -22,12 +41,12 @@
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="deadline" label="结束时间" width="200">
|
||||
<el-table-column prop="deadline" label="结束时间" width="200" sortable>
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.deadline) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" prop="progress" label="进度" width="200">
|
||||
<el-table-column fixed="right" prop="progress" label="进度" width="200" sortable>
|
||||
<template #default="scope">
|
||||
<el-progress
|
||||
:text-inside="true"
|
||||
@@ -58,10 +77,6 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="main-add-content">
|
||||
<div class="main-add-box">
|
||||
<el-button size="large" @click="addVisible = true">添加</el-button>
|
||||
</div>
|
||||
<el-dialog v-model="addVisible" width="60%">
|
||||
<edit-work @setDialogVisible="setDialogVisible" @addWork="addWork"></edit-work>
|
||||
</el-dialog>
|
||||
@@ -73,12 +88,11 @@
|
||||
></edit-work>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import request from '@/services'
|
||||
import EditWork from '@/components/EditWork.vue'
|
||||
import EditWork from '@/components/work/EditWork.vue'
|
||||
|
||||
export default {
|
||||
name: 'AllTaskPage',
|
||||
@@ -88,7 +102,8 @@ export default {
|
||||
rowData: [],
|
||||
addVisible: false,
|
||||
editVisible: false,
|
||||
loading: true
|
||||
loading: true,
|
||||
searchContent: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -165,6 +180,19 @@ export default {
|
||||
},
|
||||
formatDate(time) {
|
||||
return new Date(time).toLocaleString()
|
||||
},
|
||||
searchByContent() {
|
||||
request
|
||||
.get('/work', { content: this.searchContent })
|
||||
.then((response) => {
|
||||
this.tableData = response.data.data
|
||||
if (this.tableData) {
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
.catch((reportError) => {
|
||||
console.log(reportError)
|
||||
})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
>
|
||||
<el-table-column fixed prop="publisherName" label="发布者" width="150" />
|
||||
<el-table-column prop="content" label="内容" width="800" />
|
||||
<el-table-column prop="deadline" label="结束时间" width="200">
|
||||
<el-table-column prop="deadline" label="结束时间" width="200" sortable>
|
||||
<template #default="scope">
|
||||
{{ formatDate(scope.row.deadline) }}
|
||||
<span :style="{ color: scope.row.color1 }">{{ formatDate(scope) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作" width="150">
|
||||
@@ -52,12 +52,25 @@ export default {
|
||||
tableData: [],
|
||||
visible: false,
|
||||
taskData: [],
|
||||
loading: true
|
||||
loading: true,
|
||||
color1: '#000000'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDate(time) {
|
||||
return new Date(time).toLocaleString()
|
||||
formatDate(scope) {
|
||||
const deadDate = new Date(scope.row.deadline)
|
||||
const beforeTime = new Date(deadDate)
|
||||
const beforeDate = new Date(beforeTime.setDate(deadDate.getDate() - 3))
|
||||
const nowTime = new Date()
|
||||
console.log(scope)
|
||||
if (nowTime <= beforeDate) {
|
||||
scope.row.color1 = '#909399'
|
||||
} else if (nowTime > beforeDate && nowTime < deadDate) {
|
||||
scope.row.color1 = '#E6A23C'
|
||||
} else if (nowTime >= deadDate) {
|
||||
scope.row.color1 = '#F56C6C'
|
||||
}
|
||||
return new Date(scope.row.deadline).toLocaleString()
|
||||
},
|
||||
completeConfirmEvent(row) {
|
||||
const userWork = {
|
||||
@@ -101,6 +114,7 @@ export default {
|
||||
})
|
||||
},
|
||||
setTaskStatus(userWork) {
|
||||
userWork.completeTime = new Date()
|
||||
console.log(userWork)
|
||||
request
|
||||
.put('/work/setStatus', userWork)
|
||||
|
||||
Reference in New Issue
Block a user