|
|
|
|
@ -0,0 +1,270 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="app-container">
|
|
|
|
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
|
|
<el-form-item label="项目编号" prop="projectCode">
|
|
|
|
|
<el-input v-model="queryParams.projectCode" placeholder="请输入项目编号" clearable style="width: 240px" @keyup.enter="handleQuery" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="项目名称" prop="projectName">
|
|
|
|
|
<el-select v-model="queryParams.projectName" placeholder="请输入项目名称" filterable clearable style="width: 240px" @change="handleQuery">
|
|
|
|
|
<el-option v-for="item in projectOptions" :key="item.projectId" :label="item.projectName" :value="item.projectName" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="部门" prop="deptName">
|
|
|
|
|
<el-select v-model="queryParams.deptName" placeholder="请输入部门名称" filterable clearable style="width: 240px" @change="handleQuery">
|
|
|
|
|
<el-option v-for="item in deptOptions" :key="item.deptId" :label="item.deptName" :value="item.deptName" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="项目类别" prop="projectCategory">
|
|
|
|
|
<el-select v-model="queryParams.projectCategory" placeholder="请选择项目类别" clearable style="width: 240px">
|
|
|
|
|
<el-option v-for="dict in project_category" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="起止日期">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="dateRange[0]"
|
|
|
|
|
type="date"
|
|
|
|
|
value-format="YYYY-MM-DD"
|
|
|
|
|
placeholder="开始日期(周一)"
|
|
|
|
|
:disabled-date="disabledDateStart"
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
/>
|
|
|
|
|
<span class="el-range-separator" style="margin: 0 5px">-</span>
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="dateRange[1]"
|
|
|
|
|
type="date"
|
|
|
|
|
value-format="YYYY-MM-DD"
|
|
|
|
|
placeholder="结束日期(周日)"
|
|
|
|
|
:disabled-date="disabledDateEnd"
|
|
|
|
|
style="width: 150px"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
|
|
|
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
|
|
|
|
<el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
<el-table
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
:data="reportList"
|
|
|
|
|
show-summary
|
|
|
|
|
:summary-method="getSummary"
|
|
|
|
|
:span-method="objectSpanMethod"
|
|
|
|
|
border
|
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
|
>
|
|
|
|
|
<el-table-column type="selection" width="60" align="center" />
|
|
|
|
|
<el-table-column label="部门" align="center" prop="deptName" />
|
|
|
|
|
<el-table-column label="项目经理" align="center" prop="managerName" />
|
|
|
|
|
<el-table-column label="项目名称" align="center" prop="projectName" />
|
|
|
|
|
<el-table-column label="项目编号" align="center" prop="projectCode" />
|
|
|
|
|
<el-table-column label="项目类别" align="center" prop="projectCategory">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<dict-tag :options="project_category" :value="scope.row.projectCategory" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column :label="totalHoursLabel" align="center" prop="totalHours" />
|
|
|
|
|
<el-table-column label="跨部门工时" align="center" prop="crossDeptHours">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
{{ Number(scope.row.totalHours) === Number(scope.row.crossDeptHours) ? '' : scope.row.crossDeptHours }}
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="ProjectManHourReport" lang="ts">
|
|
|
|
|
import {
|
|
|
|
|
listProjectManHourReport,
|
|
|
|
|
exportProjectManHourReport,
|
|
|
|
|
ProjectManHourReportVO,
|
|
|
|
|
ProjectManHourReportQuery
|
|
|
|
|
} from '@/api/oa/erp/timesheetReport';
|
|
|
|
|
import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo';
|
|
|
|
|
import { listDept } from '@/api/system/dept';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const { project_category } = toRefs<any>(proxy?.useDict('project_category'));
|
|
|
|
|
|
|
|
|
|
const reportList = ref<ProjectManHourReportVO[]>([]);
|
|
|
|
|
const loading = ref(true);
|
|
|
|
|
const showSearch = ref(true);
|
|
|
|
|
const ids = ref<Array<string | number>>([]);
|
|
|
|
|
const single = ref(true);
|
|
|
|
|
const multiple = ref(true);
|
|
|
|
|
const dateRange = ref<[string, string]>(['', '']);
|
|
|
|
|
|
|
|
|
|
const projectOptions = ref<any[]>([]);
|
|
|
|
|
const deptOptions = ref<any[]>([]);
|
|
|
|
|
const projectLoading = ref(false);
|
|
|
|
|
|
|
|
|
|
const queryParams = ref<ProjectManHourReportQuery>({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10000, // 报表暂时不分页或前端分页
|
|
|
|
|
projectCode: undefined,
|
|
|
|
|
projectName: undefined,
|
|
|
|
|
projectCategory: undefined,
|
|
|
|
|
deptName: undefined
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const totalHoursLabel = computed(() => {
|
|
|
|
|
if (dateRange.value && dateRange.value[0] && dateRange.value[1]) {
|
|
|
|
|
return `当月工时 (${dateRange.value[0]} 至 ${dateRange.value[1]})`;
|
|
|
|
|
}
|
|
|
|
|
return '当月工时';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true;
|
|
|
|
|
const params = { ...queryParams.value };
|
|
|
|
|
if (dateRange.value) {
|
|
|
|
|
params.startTime = dateRange.value[0];
|
|
|
|
|
params.endTime = dateRange.value[1];
|
|
|
|
|
}
|
|
|
|
|
const res = await listProjectManHourReport(params);
|
|
|
|
|
reportList.value = res.data;
|
|
|
|
|
|
|
|
|
|
if ((res as any).rows) {
|
|
|
|
|
reportList.value = (res as any).rows;
|
|
|
|
|
} else {
|
|
|
|
|
reportList.value = (res as any).data || [];
|
|
|
|
|
}
|
|
|
|
|
getSpanArr(reportList.value);
|
|
|
|
|
loading.value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
|
getList();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 多选框选中数据 */
|
|
|
|
|
const handleSelectionChange = (selection: ProjectManHourReportVO[]) => {
|
|
|
|
|
console.log('Selection:', selection);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
const resetQuery = () => {
|
|
|
|
|
dateRange.value = ['', ''];
|
|
|
|
|
(proxy as any)?.resetForm('queryRef');
|
|
|
|
|
handleQuery();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
const handleExport = () => {
|
|
|
|
|
const params = { ...queryParams.value };
|
|
|
|
|
if (dateRange.value) {
|
|
|
|
|
params.startTime = dateRange.value[0];
|
|
|
|
|
params.endTime = dateRange.value[1];
|
|
|
|
|
}
|
|
|
|
|
proxy?.download('/oa/erp/timesheetReport/exportProjectManHour', params, `项目工时统计报表_${new Date().getTime()}.xlsx`);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 合计行计算 */
|
|
|
|
|
const getSummary = (param: any) => {
|
|
|
|
|
const { columns, data } = param;
|
|
|
|
|
const sums: string[] = [];
|
|
|
|
|
columns.forEach((column: any, index: number) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
sums[index] = '总计';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 不计算非工时列
|
|
|
|
|
if (!['totalHours'].includes(column.property)) {
|
|
|
|
|
sums[index] = '';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const values = data.map((item: any) => Number(item[column.property]));
|
|
|
|
|
if (!values.every((value: any) => Number.isNaN(value))) {
|
|
|
|
|
const total = values.reduce((prev: any, curr: any) => {
|
|
|
|
|
const value = Number(curr);
|
|
|
|
|
if (!Number.isNaN(value)) {
|
|
|
|
|
return prev + curr;
|
|
|
|
|
} else {
|
|
|
|
|
return prev;
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
sums[index] = total.toFixed(1);
|
|
|
|
|
} else {
|
|
|
|
|
sums[index] = '';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return sums;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getList();
|
|
|
|
|
getDeptList();
|
|
|
|
|
getProjectList();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getProjectList = async () => {
|
|
|
|
|
// 加载所有项目用于前端筛选
|
|
|
|
|
const res = await getErpProjectInfoList({});
|
|
|
|
|
projectOptions.value = res.data || res.rows || [];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getDeptList = async () => {
|
|
|
|
|
// 查询所有部门用于前端筛选
|
|
|
|
|
const res = await listDept();
|
|
|
|
|
deptOptions.value = res.data || res.rows || [];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 禁用非周一的日期 */
|
|
|
|
|
const disabledDateStart = (date: Date) => {
|
|
|
|
|
// getDay() 返回 0=周日, 1=周一
|
|
|
|
|
return date.getDay() !== 1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const disabledDateEnd = (date: Date) => {
|
|
|
|
|
return date.getDay() !== 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const spanArr = ref<number[]>([]);
|
|
|
|
|
const pos = ref(0);
|
|
|
|
|
|
|
|
|
|
const getSpanArr = (data: ProjectManHourReportVO[]) => {
|
|
|
|
|
spanArr.value = [];
|
|
|
|
|
pos.value = 0;
|
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
|
if (i === 0) {
|
|
|
|
|
spanArr.value.push(1);
|
|
|
|
|
pos.value = 0;
|
|
|
|
|
} else {
|
|
|
|
|
// 判断依据:projectId 相同则合并
|
|
|
|
|
if (data[i].projectId === data[i - 1].projectId) {
|
|
|
|
|
spanArr.value[pos.value] += 1;
|
|
|
|
|
spanArr.value.push(0);
|
|
|
|
|
} else {
|
|
|
|
|
spanArr.value.push(1);
|
|
|
|
|
pos.value = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const objectSpanMethod = ({
|
|
|
|
|
row,
|
|
|
|
|
column,
|
|
|
|
|
rowIndex,
|
|
|
|
|
columnIndex
|
|
|
|
|
}: {
|
|
|
|
|
row: ProjectManHourReportVO;
|
|
|
|
|
column: any;
|
|
|
|
|
rowIndex: number;
|
|
|
|
|
columnIndex: number;
|
|
|
|
|
}) => {
|
|
|
|
|
if (columnIndex === 7) {
|
|
|
|
|
const _row = spanArr.value[rowIndex];
|
|
|
|
|
const _col = _row > 0 ? 1 : 0;
|
|
|
|
|
return {
|
|
|
|
|
rowspan: _row,
|
|
|
|
|
colspan: _col
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|