feat(timesheetReport): 将日期范围选择器更改为月份范围选择器

- 将项目工时报表中的日期范围选择器替换为月份范围选择器
- 更新数据绑定从 dateRange 到 monthRange
- 修改时间格式从 YYYY-MM-DD 到 YYYYMM
- 移除日期禁用逻辑和周一/周日限制功能
- 更新表单重置方法使用 Element Plus 的 resetFields
- 在项目人员报表中同步实现月份范围选择器变更
- 移除已废弃的日期验证函数和监听器代码
dev
yangk 4 weeks ago
parent 7cb060e3de
commit 9a65dc5dc6

@ -17,24 +17,10 @@
<el-option v-for="dict in project_category" :key="dict.value" :label="dict.label" :value="dict.value" /> <el-option v-for="dict in project_category" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="起止日期"> <el-form-item label="月份范围">
<el-date-picker <el-date-picker v-model="monthRange[0]" type="month" value-format="YYYYMM" placeholder="起始月份" style="width: 150px" />
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> <span class="el-range-separator" style="margin: 0 5px">-</span>
<el-date-picker <el-date-picker v-model="monthRange[1]" type="month" value-format="YYYYMM" placeholder="结束月份" style="width: 150px" />
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-form-item> <el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button> <el-button type="primary" icon="Search" @click="handleQuery"></el-button>
@ -82,6 +68,7 @@ import {
} from '@/api/oa/erp/timesheetReport'; } from '@/api/oa/erp/timesheetReport';
import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo'; import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo';
import { allListDept, listDept } from '@/api/system/dept'; import { allListDept, listDept } from '@/api/system/dept';
import { FormInstance } from 'element-plus';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { project_category } = toRefs<any>(proxy?.useDict('project_category')); const { project_category } = toRefs<any>(proxy?.useDict('project_category'));
@ -92,11 +79,12 @@ const showSearch = ref(true);
const ids = ref<Array<string | number>>([]); const ids = ref<Array<string | number>>([]);
const single = ref(true); const single = ref(true);
const multiple = ref(true); const multiple = ref(true);
const dateRange = ref<[string, string]>(['', '']); const monthRange = ref<[string, string]>(['', '']);
const projectOptions = ref<any[]>([]); const projectOptions = ref<any[]>([]);
const deptOptions = ref<any[]>([]); const deptOptions = ref<any[]>([]);
const projectLoading = ref(false); const projectLoading = ref(false);
const queryRef = ref<FormInstance>();
const queryParams = ref<ProjectManHourReportQuery>({ const queryParams = ref<ProjectManHourReportQuery>({
pageNum: 1, pageNum: 1,
@ -108,19 +96,22 @@ const queryParams = ref<ProjectManHourReportQuery>({
}); });
const totalHoursLabel = computed(() => { const totalHoursLabel = computed(() => {
if (dateRange.value && dateRange.value[0] && dateRange.value[1]) { if (monthRange.value && monthRange.value[0] && monthRange.value[1]) {
return `当月工时 (${dateRange.value[0]}${dateRange.value[1]})`; const start = monthRange.value[0];
const end = monthRange.value[1];
const fmt = (m: string) => m.substring(0, 4) + '年' + m.substring(4) + '月';
return `工时 (${fmt(start)}${fmt(end)})`;
} }
return '当月工时'; return '工时';
}); });
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const params = { ...queryParams.value }; const params = { ...queryParams.value };
if (dateRange.value) { if (monthRange.value && monthRange.value[0] && monthRange.value[1]) {
params.startTime = dateRange.value[0]; params.startTime = monthRange.value[0];
params.endTime = dateRange.value[1]; params.endTime = monthRange.value[1];
} }
const res = await listProjectManHourReport(params); const res = await listProjectManHourReport(params);
reportList.value = res.data; reportList.value = res.data;
@ -146,17 +137,17 @@ const handleSelectionChange = (selection: ProjectManHourReportVO[]) => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; monthRange.value = ['', ''];
(proxy as any)?.resetForm('queryRef'); queryRef.value?.resetFields();
handleQuery(); handleQuery();
}; };
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
const params = { ...queryParams.value }; const params = { ...queryParams.value };
if (dateRange.value) { if (monthRange.value && monthRange.value[0] && monthRange.value[1]) {
params.startTime = dateRange.value[0]; params.startTime = monthRange.value[0];
params.endTime = dateRange.value[1]; params.endTime = monthRange.value[1];
} }
proxy?.download('/oa/erp/timesheetReport/exportProjectManHour', params, `项目工时统计报表_${new Date().getTime()}.xlsx`); proxy?.download('/oa/erp/timesheetReport/exportProjectManHour', params, `项目工时统计报表_${new Date().getTime()}.xlsx`);
}; };
@ -213,16 +204,6 @@ const getDeptList = async () => {
deptOptions.value = res.data || res.rows || []; 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 spanArr = ref<number[]>([]);
const pos = ref(0); const pos = ref(0);

@ -6,22 +6,20 @@
<el-option v-for="item in deptOptions" :key="item.deptId" :label="item.deptName" :value="item.deptId" /> <el-option v-for="item in deptOptions" :key="item.deptId" :label="item.deptName" :value="item.deptId" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="起止日期"> <el-form-item label="月份范围">
<el-date-picker <el-date-picker
v-model="dateRange[0]" v-model="monthRange[0]"
type="date" type="month"
value-format="YYYY-MM-DD" value-format="YYYYMM"
placeholder="开始日期" placeholder="起始月份"
:disabled-date="disabledDateStart"
style="width: 150px" style="width: 150px"
/> />
<span class="el-range-separator" style="margin: 0 5px">-</span> <span class="el-range-separator" style="margin: 0 5px">-</span>
<el-date-picker <el-date-picker
v-model="dateRange[1]" v-model="monthRange[1]"
type="date" type="month"
value-format="YYYY-MM-DD" value-format="YYYYMM"
placeholder="结束日期" placeholder="结束月份"
:disabled-date="disabledDateEnd"
style="width: 150px" style="width: 150px"
/> />
</el-form-item> </el-form-item>
@ -74,15 +72,18 @@
</template> </template>
<script setup name="ProjectPersonnelReport" lang="ts"> <script setup name="ProjectPersonnelReport" lang="ts">
import { allListDept, listDept } from '@/api/system/dept'; import { allListDept } from '@/api/system/dept';
import { getProjectPersonnelReport, ProjectPersonnelReportVO } from '@/api/oa/erp/timesheetReport'; import { getProjectPersonnelReport } from '@/api/oa/erp/timesheetReport';
import { FormInstance } from 'element-plus';
import { ComponentInternalInstance } from 'vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(false); const loading = ref(false);
const showSearch = ref(true); const showSearch = ref(true);
const deptOptions = ref<any[]>([]); const deptOptions = ref<any[]>([]);
const dateRange = ref<[string, string]>(['', '']); const monthRange = ref<[string, string]>(['', '']);
const queryRef = ref<FormInstance>();
const columns = ref<Array<{ label: string; prop: string }>>([]); const columns = ref<Array<{ label: string; prop: string }>>([]);
const tableData = ref<Array<any>>([]); const tableData = ref<Array<any>>([]);
@ -91,11 +92,6 @@ const queryParams = ref({
deptId: undefined deptId: undefined
}); });
//
// watch(() => queryParams.value.deptId, (newVal) => {
// if (newVal) handleQuery();
// });
/** 获取部门 */ /** 获取部门 */
const getDeptList = async () => { const getDeptList = async () => {
const res = await allListDept({ deptCategory: '03' } as any); const res = await allListDept({ deptCategory: '03' } as any);
@ -111,8 +107,8 @@ const getList = async () => {
loading.value = true; loading.value = true;
const params = { const params = {
deptId: queryParams.value.deptId, deptId: queryParams.value.deptId,
startTime: dateRange.value[0], startTime: monthRange.value[0],
endTime: dateRange.value[1] endTime: monthRange.value[1]
}; };
try { try {
@ -133,11 +129,10 @@ const handleQuery = () => {
getList(); getList();
}; };
/** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
dateRange.value = ['', '']; monthRange.value = ['', ''];
(proxy as any)?.resetForm('queryRef'); handleQuery();
tableData.value = [];
columns.value = [];
}; };
const handleExport = () => { const handleExport = () => {
@ -145,8 +140,8 @@ const handleExport = () => {
'oa/erp/timesheetReport/exportProjectPersonnel', 'oa/erp/timesheetReport/exportProjectPersonnel',
{ {
deptId: queryParams.value.deptId, deptId: queryParams.value.deptId,
startTime: dateRange.value[0], startTime: monthRange.value[0],
endTime: dateRange.value[1] endTime: monthRange.value[1]
}, },
`项目人员工时统计报表_${new Date().getTime()}.xlsx` `项目人员工时统计报表_${new Date().getTime()}.xlsx`
); );
@ -202,13 +197,7 @@ const getSummaries = (param: any) => {
return sums; return sums;
}; };
// /
const disabledDateStart = (date: Date) => {
return date.getDay() !== 1;
};
const disabledDateEnd = (date: Date) => {
return date.getDay() !== 0;
};
onMounted(() => { onMounted(() => {
getDeptList(); getDeptList();

Loading…
Cancel
Save