This commit is contained in:
Maple 2025-07-26 19:35:14 +08:00
parent 5b673f9525
commit 236cf1489b
5 changed files with 140 additions and 86 deletions

View File

@ -6,6 +6,7 @@ import type { AttachInfoData, BusinessTypeResult } from './type'
*
* @param businessType
* @param files
* @returns
*/
export function batchAddAttachment(businessType: string, formData: FormData) {
return request<AttachInfoData[]>({

View File

@ -23,9 +23,9 @@ export function deleteTaskGroup(id: number) {
return http.del(`${BASE_URL}/group/${id}`)
}
/** @desc 查询任务列表 */
export function listTask(query: T.TaskPageQuery) {
return http.get<PageRes<T.TaskResp[]>>(`${BASE_URL}`, query)
/** @desc 查询任务列表(标准导出) */
export const listTask = (params: any) => {
return http.get('/project-task/list', params)
}
/** @desc 获取任务详情 */

View File

@ -56,7 +56,7 @@ export const systemRoutes: RouteRecordRaw[] = [
path: '/organization/hr/workload',
name: 'HRWorkload',
component: () => import('@/views/hr/workload/index.vue'),
meta: { title: '工作量', icon: 'workload', hidden: false },
meta: { title: '任务记录', icon: 'workload', hidden: false },
},
{
path: '/organization/hr/attendance',

View File

@ -1,3 +1,4 @@
<!-- 考勤统计 -->
<template>
<GiPageLayout>
<GiTable

View File

@ -1,8 +1,10 @@
<template>
<h1>>说明任务具体分配给某个人至少简单的任务分配并非项目中的任务列表暂时调用项目中的任务列表并不完全</h1>
<h1>目前需要新建一个任务表表中的内容</h1>
<GiPageLayout>
<GiTable
row-key="id"
title="工作量管理"
title="任务记录"
:data="dataList"
:columns="tableColumns"
:loading="loading"
@ -22,19 +24,10 @@
@reset="reset"
/>
</template>
<template #toolbar-left>
<a-button type="primary" @click="openAddModal">
<template #icon><icon-plus /></template>
<template #default>新增工作量记录</template>
</a-button>
<!-- 任务状态显示 -->
<template #status="{ record }">
<a-tag :color="getTaskStatusColor(record.status)">{{ getTaskStatusText(record.status) }}</a-tag>
</template>
<!-- 工作量显示 -->
<template #workload="{ record }">
<span class="font-medium text-blue-600">{{ record.workload }}小时</span>
</template>
<!-- 操作列 -->
<template #action="{ record }">
<a-space>
@ -50,13 +43,40 @@
import { ref, reactive, onMounted } from 'vue'
import { Message } from '@arco-design/web-vue'
import type { TableColumnData } from '@arco-design/web-vue'
import { listTask } from '@/apis/project/task'
//
// status0123
const statusOptions = [
{ label: '未开始', value: 0 },
{ label: '进行中', value: 1 },
{ label: '已完成', value: 2 },
{ label: '已取消', value: 3 }
]
const getTaskStatusColor = (status: number) => {
const colorMap: Record<number, string> = {
0: 'gray',
1: 'blue',
2: 'green',
3: 'red'
}
return colorMap[status] || 'gray'
}
const getTaskStatusText = (status: number) => {
const textMap: Record<number, string> = {
0: '未开始',
1: '进行中',
2: '已完成',
3: '已取消'
}
return textMap[status] || status
}
//
let searchForm = reactive({
userName: '',
projectName: '',
startDate: '',
endDate: '',
taskName: '',
responsiblePerson: '', // mainUserId
status: '',
page: 1,
size: 10
})
@ -64,119 +84,151 @@ let searchForm = reactive({
//
const queryFormColumns = [
{
field: 'userName',
label: '员工姓名',
field: 'taskName',
label: '任务标题',
type: 'input' as const,
props: {
placeholder: '请输入员工姓名'
placeholder: '请输入任务标题',
style: { width: '200px' }
}
},
{
field: 'projectName',
label: '项目名称',
field: 'responsiblePerson',
label: '分配用户',
type: 'input' as const,
props: {
placeholder: '请输入项目名称'
placeholder: '请输入分配用户',
style: { width: '200px' }
}
},
{
field: 'status',
label: '任务状态',
type: 'select' as const,
props: {
placeholder: '请选择任务状态',
options: statusOptions,
style: { width: '200px' }
}
}
]
//
const tableColumns: TableColumnData[] = [
{ title: '员工姓名', dataIndex: 'userName', width: 120 },
{ title: '部门', dataIndex: 'deptName', width: 120 },
{ title: '项目名称', dataIndex: 'projectName', width: 200, ellipsis: true, tooltip: true },
{ title: '工作内容', dataIndex: 'workContent', width: 250, ellipsis: true, tooltip: true },
{ title: '工作量(小时)', dataIndex: 'workload', slotName: 'workload', width: 120 },
{ title: '工作日期', dataIndex: 'workDate', width: 120 },
{ title: '任务ID', dataIndex: 'taskId', width: 80 },
{ title: '任务标题', dataIndex: 'taskName', width: 200, ellipsis: true, tooltip: true },
{ title: '分配用户', dataIndex: 'mainUserId', width: 120 },
{ title: '分配部门', dataIndex: 'deptName', width: 120 },
{ title: '任务内容', dataIndex: 'remark', width: 250, ellipsis: true, tooltip: true },
{ title: '任务状态', dataIndex: 'status', slotName: 'status', width: 120 },
{ title: '创建时间', dataIndex: 'createTime', width: 160 },
{ title: '操作', slotName: 'action', width: 120, fixed: 'right' }
]
//
const loading = ref(false)
const dataList = ref([
{
id: 1,
userName: '张三',
deptName: '技术部',
projectName: '企业管理系统',
workContent: '前端开发',
workload: 8,
workDate: '2024-01-15',
createTime: '2024-01-15 10:30:00'
},
{
id: 2,
userName: '李四',
deptName: '技术部',
projectName: '移动端应用',
workContent: '后端接口开发',
workload: 6,
workDate: '2024-01-15',
createTime: '2024-01-15 11:20:00'
}
])
const dataList = ref<any[]>([])
const allData = ref<any[]>([])
const pagination = reactive({
current: 1,
pageSize: 10,
total: 2,
total: 0,
showTotal: true,
showPageSize: true
})
//
const search = async () => {
//
const fetchTaskList = async () => {
loading.value = true
// API
setTimeout(() => {
try {
const params: any = {
page: searchForm.page,
pageSize: searchForm.size,
taskName: searchForm.taskName,
mainUserId: searchForm.responsiblePerson,
status: searchForm.status
}
//
Object.keys(params).forEach(key => {
if (params[key] === '' || params[key] === undefined) delete params[key]
})
const res = await listTask(params)
// rowsdata
const rows = res?.rows || res?.data?.rows || []
console.log('后端返回数据:', res) //
allData.value = rows
filterAndPaginate()
pagination.total = rows.length
} catch (e) {
Message.error('获取任务数据失败')
} finally {
loading.value = false
}, 1000)
}
}
const reset = () => {
//
const filterAndPaginate = () => {
let filtered = allData.value
if (searchForm.taskName) {
filtered = filtered.filter((item: any) =>
item.taskName?.toLowerCase().includes(searchForm.taskName.toLowerCase())
)
}
if (searchForm.responsiblePerson) {
filtered = filtered.filter((item: any) =>
item.mainUserId?.toLowerCase().includes(searchForm.responsiblePerson.toLowerCase())
)
}
if (searchForm.status !== '' && searchForm.status !== undefined) {
filtered = filtered.filter((item: any) => String(item.status) === String(searchForm.status))
}
//
const start = (pagination.current - 1) * pagination.pageSize
const end = start + pagination.pageSize
dataList.value = filtered.slice(start, end)
pagination.total = filtered.length
}
//
const search = async () => {
pagination.current = 1
await fetchTaskList()
}
const reset = async () => {
Object.assign(searchForm, {
userName: '',
projectName: '',
startDate: '',
endDate: '',
taskName: '',
responsiblePerson: '',
status: '',
page: 1,
size: 10
})
pagination.current = 1
search()
await fetchTaskList()
}
//
const onPageChange = (page: number) => {
searchForm.page = page
pagination.current = page
search()
filterAndPaginate()
}
const onPageSizeChange = (size: number) => {
searchForm.size = size
searchForm.page = 1
pagination.pageSize = size
pagination.current = 1
search()
filterAndPaginate()
}
//
const openAddModal = () => {
Message.info('新增工作量记录功能开发中...')
}
const editRecord = (record: any) => {
Message.info(`编辑工作量记录: ${record.userName}`)
Message.info(`编辑任务: ${record.taskName}`)
}
const deleteRecord = (record: any) => {
Message.info(`删除工作量记录: ${record.userName}`)
Message.info(`删除任务: ${record.taskName}`)
}
onMounted(() => {
search()
fetchTaskList()
})
</script>