feat(oa/erp): 完善预投工时分配功能

- 添加员工级可分配明细查询接口
- 重构预投工时分配页面界面,优化搜索表单布局
- 替换月份输入框为日期选择器组件
- 添加预投项目下拉选择功能
- 实现工时分配详情表格展示
- 集成员工工时分配去向管理功能
- 添加工时分配验证机制
- 优化表格列显示配置
- 实现已回写单据删除限制功能
- 添加工时格式化显示功能
- 集成项目信息获取接口
- 实现工时分配状态自动计算
- 添加工时超分配警告提示
- 重构表单提交数据构建逻辑
dev
yangk 3 weeks ago
parent 5cb040b560
commit 71478a4818

@ -1,6 +1,6 @@
import request from '@/utils/request'; import request from '@/utils/request';
import { AxiosPromise } from 'axios'; import { AxiosPromise } from 'axios';
import { TimesheetPreAllocVO, TimesheetPreAllocForm, TimesheetPreAllocQuery } from '@/api/oa/erp/timesheetPreAlloc/types'; import { TimesheetPreAllocVO, TimesheetPreAllocForm, TimesheetPreAllocQuery, PreAllocDetailVO } from '@/api/oa/erp/timesheetPreAlloc/types';
/** /**
* *
@ -20,13 +20,24 @@ export const listTimesheetPreAlloc = (query?: TimesheetPreAllocQuery): AxiosProm
* *
* @param allocId * @param allocId
*/ */
export const getTimesheetPreAlloc = (allocId: string | number): AxiosPromise<TimesheetPreAllocVO> => { export const getTimesheetPreAlloc = (allocId: string | number): AxiosPromise<PreAllocDetailVO> => {
return request({ return request({
url: '/oa/erp/timesheetPreAlloc/' + allocId, url: '/oa/erp/timesheetPreAlloc/' + allocId,
method: 'get' method: 'get'
}); });
}; };
/**
*
*/
export const getStaffAllocDetails = (query: { monthCode: string; projectId: string | number }): AxiosPromise<PreAllocDetailVO> => {
return request({
url: '/oa/erp/timesheetPreAlloc/getStaffAllocDetails',
method: 'get',
params: query
});
};
/** /**
* *
* @param data * @param data

@ -20,7 +20,7 @@ export interface TimesheetPreAllocVO {
standardMonthId: string | number; standardMonthId: string | number;
/** /**
* ID() * ID
*/ */
projectId: string | number; projectId: string | number;
@ -98,7 +98,7 @@ export interface TimesheetPreAllocForm extends BaseEntity {
standardMonthId?: string | number; standardMonthId?: string | number;
/** /**
* ID() * ID
*/ */
projectId?: string | number; projectId?: string | number;
@ -152,6 +152,11 @@ export interface TimesheetPreAllocForm extends BaseEntity {
*/ */
remark?: string; remark?: string;
/**
*
*/
staffAllocList?: PreAllocStaffAlloc[];
} }
export interface TimesheetPreAllocQuery extends PageQuery { export interface TimesheetPreAllocQuery extends PageQuery {
@ -172,7 +177,7 @@ export interface TimesheetPreAllocQuery extends PageQuery {
standardMonthId?: string | number; standardMonthId?: string | number;
/** /**
* ID() * ID
*/ */
projectId?: string | number; projectId?: string | number;
@ -227,5 +232,71 @@ export interface TimesheetPreAllocQuery extends PageQuery {
params?: any; params?: any;
} }
export interface PreAllocTarget {
/**
* ID
*/
targetProjectId?: string | number;
/**
*
*/
targetProjectCode?: string;
/**
*
*/
targetProjectName?: string;
/**
* ()
*/
allocHours?: number;
}
export interface PreAllocStaffAlloc {
/**
* ID
*/
staffUserId?: string | number;
/**
*
*/
staffName?: string;
/**
* ()
*/
sourceHours?: number;
/**
* ()
*/
allocatedHours?: number;
/**
* ()
*/
remainingHours?: number;
/**
*
*/
allocItems?: PreAllocTarget[];
}
export interface PreAllocDetailVO extends TimesheetPreAllocVO {
/**
* ()
*/
remainingTotalHours: number;
/**
*
*/
staffAllocList: PreAllocStaffAlloc[];
}

@ -3,60 +3,40 @@
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]"> <div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover"> <el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px"> <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="90px">
<el-form-item label="分配单编号" prop="allocCode"> <el-form-item label="分配单编号" prop="allocCode">
<el-input v-model="queryParams.allocCode" placeholder="请输入分配单编号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="月份编码(YYYYMM)" prop="monthCode">
<el-input v-model="queryParams.monthCode" placeholder="请输入月份编码(YYYYMM)" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="关联月标准工时ID(erp_timesheet_standard_month)" prop="standardMonthId">
<el-input <el-input
v-model="queryParams.standardMonthId" v-model="queryParams.allocCode"
placeholder="请输入关联月标准工时ID(erp_timesheet_standard_month)" placeholder="请输入分配单编号"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="项目ID(备件、物流)" prop="projectId"> <el-form-item label="月份" prop="monthCode">
<el-input v-model="queryParams.projectId" placeholder="请输入项目ID(备件、物流)" clearable @keyup.enter="handleQuery" /> <el-date-picker
</el-form-item> v-model="queryParams.monthCode"
<el-form-item label="预投项目编码(冗余)" prop="projectCode"> type="month"
<el-input v-model="queryParams.projectCode" placeholder="请输入预投项目编码(冗余)" clearable @keyup.enter="handleQuery" /> value-format="YYYYMM"
</el-form-item> format="YYYY-MM"
<el-form-item label="预投项目名称(冗余)" prop="projectName">
<el-input v-model="queryParams.projectName" placeholder="请输入预投项目名称(冗余)" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="来源预投工时合计(天,带出汇总)" prop="sourceTotalHours">
<el-input
v-model="queryParams.sourceTotalHours"
placeholder="请输入来源预投工时合计(天,带出汇总)"
clearable clearable
@keyup.enter="handleQuery" placeholder="请选择月份"
/> />
</el-form-item> </el-form-item>
<el-form-item label="已分配合计(天)" prop="allocatedTotalHours"> <el-form-item label="预投项目" prop="projectId">
<el-input v-model="queryParams.allocatedTotalHours" placeholder="请输入已分配合计(天)" clearable @keyup.enter="handleQuery" /> <el-select v-model="queryParams.projectId" filterable clearable placeholder="请选择预投项目" class="project-select">
<el-option
v-for="project in sourceProjectOptions"
:key="project.projectId"
:label="projectLabel(project)"
:value="project.projectId"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="涉及人数" prop="staffCount"> <el-form-item label="分配状态" prop="allocStatus">
<el-input v-model="queryParams.staffCount" placeholder="请输入涉及人数" clearable @keyup.enter="handleQuery" /> <el-select v-model="queryParams.allocStatus" placeholder="请选择分配状态" clearable>
</el-form-item>
<el-form-item label="单据状态" prop="allocStatus">
<el-select v-model="queryParams.allocStatus" placeholder="请选择单据状态" clearable>
<el-option v-for="dict in alloc_status" :key="dict.value" :label="dict.label" :value="dict.value" /> <el-option v-for="dict in alloc_status" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="是否已回写月汇总" prop="appliedFlag">
<el-select v-model="queryParams.appliedFlag" placeholder="请选择是否已回写月汇总" clearable>
<el-option v-for="dict in applied_flag" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
<el-form-item label="回写关联的月汇总主表ID" prop="summaryId">
<el-input v-model="queryParams.summaryId" placeholder="请输入回写关联的月汇总主表ID" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="回写月汇总时间" prop="applyTime">
<el-date-picker clearable v-model="queryParams.applyTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择回写月汇总时间" />
</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>
<el-button icon="Refresh" @click="resetQuery"></el-button> <el-button icon="Refresh" @click="resetQuery"></el-button>
@ -73,64 +53,75 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/erp:timesheetPreAlloc:add']"></el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/erp:timesheetPreAlloc:add']"></el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/erp:timesheetPreAlloc:edit']" <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/erp:timesheetPreAlloc:edit']">
>修改</el-button 修改
> </el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/erp:timesheetPreAlloc:remove']" <el-button
>删除</el-button type="danger"
plain
icon="Delete"
:disabled="multiple || hasAppliedSelected"
@click="handleDelete()"
v-hasPermi="['oa/erp:timesheetPreAlloc:remove']"
> >
删除
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/erp:timesheetPreAlloc:export']"></el-button> <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/erp:timesheetPreAlloc:export']"></el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList" />
</el-row> </el-row>
</template> </template>
<el-table v-loading="loading" border :data="timesheetPreAllocList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" border :data="timesheetPreAllocList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="分配单ID" align="center" prop="allocId" v-if="columns[0].visible" /> <el-table-column label="分配单编号" align="center" prop="allocCode" width="180" v-if="columns[8].visible" />
<el-table-column label="分配单编号" align="center" prop="allocCode" v-if="columns[2].visible" /> <el-table-column label="月份" align="center" prop="monthCode" width="100" v-if="columns[0].visible" />
<el-table-column label="月份编码(YYYYMM)" align="center" prop="monthCode" v-if="columns[3].visible" /> <el-table-column label="来源预投项目" align="center" min-width="260" v-if="columns[1].visible">
<el-table-column label="关联月标准工时ID(erp_timesheet_standard_month)" align="center" prop="standardMonthId" v-if="columns[4].visible" /> <template #default="scope">
<el-table-column label="项目ID(备件、物流)" align="center" prop="projectId" v-if="columns[5].visible" /> <div class="project-cell">
<el-table-column label="预投项目编码(冗余)" align="center" prop="projectCode" v-if="columns[6].visible" /> <span>{{ scope.row.projectCode }}</span>
<el-table-column label="预投项目名称(冗余)" align="center" prop="projectName" v-if="columns[7].visible" /> <span>{{ scope.row.projectName }}</span>
<el-table-column label="来源预投工时合计(天,带出汇总)" align="center" prop="sourceTotalHours" v-if="columns[8].visible" /> </div>
<el-table-column label="已分配合计(天)" align="center" prop="allocatedTotalHours" v-if="columns[9].visible" /> </template>
<el-table-column label="涉及人数" align="center" prop="staffCount" v-if="columns[10].visible" /> </el-table-column>
<el-table-column label="单据状态" align="center" prop="allocStatus" v-if="columns[11].visible"> <el-table-column label="来源工时" align="center" prop="sourceTotalHours" width="110" v-if="columns[2].visible">
<template #default="scope">{{ formatHours(scope.row.sourceTotalHours) }}</template>
</el-table-column>
<el-table-column label="已分配工时" align="center" prop="allocatedTotalHours" width="120" v-if="columns[3].visible">
<template #default="scope">{{ formatHours(scope.row.allocatedTotalHours) }}</template>
</el-table-column>
<el-table-column label="涉及人数" align="center" prop="staffCount" width="100" v-if="columns[4].visible" />
<el-table-column label="分配状态" align="center" prop="allocStatus" width="110" v-if="columns[5].visible">
<template #default="scope"> <template #default="scope">
<dict-tag :options="alloc_status" :value="scope.row.allocStatus" /> <dict-tag :options="alloc_status" :value="scope.row.allocStatus" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="是否已回写月汇总" align="center" prop="appliedFlag" v-if="columns[12].visible"> <el-table-column label="回写时间" align="center" prop="applyTime" width="170" v-if="columns[6].visible">
<template #default="scope">
<dict-tag :options="applied_flag" :value="scope.row.appliedFlag" />
</template>
</el-table-column>
<el-table-column label="回写关联的月汇总主表ID" align="center" prop="summaryId" v-if="columns[13].visible" />
<el-table-column label="回写月汇总时间" align="center" prop="applyTime" width="180" v-if="columns[14].visible">
<template #default="scope"> <template #default="scope">
<span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span> <span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" v-if="columns[15].visible" /> <el-table-column label="备注" align="center" prop="remark" min-width="160" show-overflow-tooltip v-if="columns[7].visible" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" fixed="right" width="110" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="修改" placement="top"> <el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/erp:timesheetPreAlloc:edit']"></el-button> <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/erp:timesheetPreAlloc:edit']" />
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" placement="top"> <el-tooltip content="已回写单据不允许删除" placement="top" :disabled="scope.row.appliedFlag !== '1'">
<span>
<el-button <el-button
link link
type="primary" type="primary"
icon="Delete" icon="Delete"
:disabled="scope.row.appliedFlag === '1'"
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['oa/erp:timesheetPreAlloc:remove']" v-hasPermi="['oa/erp:timesheetPreAlloc:remove']"
></el-button> />
</span>
</el-tooltip> </el-tooltip>
</template> </template>
</el-table-column> </el-table-column>
@ -138,55 +129,106 @@
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card> </el-card>
<!-- 添加或修改预投工时分配对话框 -->
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> <el-dialog :title="dialog.title" v-model="dialog.visible" width="1180px" append-to-body>
<el-form ref="timesheetPreAllocFormRef" :model="form" :rules="rules" label-width="120px"> <el-form ref="timesheetPreAllocFormRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="分配单编号" prop="allocCode"> <el-row :gutter="16">
<el-input v-model="form.allocCode" placeholder="请输入分配单编号" /> <el-col :span="8">
<el-form-item label="月份" prop="monthCode">
<el-date-picker
v-model="form.monthCode"
type="month"
value-format="YYYYMM"
format="YYYY-MM"
clearable
:disabled="Boolean(form.allocId)"
placeholder="请选择月份"
@change="loadStaffAllocDetails"
/>
</el-form-item> </el-form-item>
<el-form-item label="月份编码(YYYYMM)" prop="monthCode"> </el-col>
<el-input v-model="form.monthCode" placeholder="请输入月份编码(YYYYMM)" /> <el-col :span="10">
</el-form-item> <el-form-item label="预投项目" prop="projectId">
<el-form-item label="关联月标准工时ID(erp_timesheet_standard_month)" prop="standardMonthId"> <el-select
<el-input v-model="form.standardMonthId" placeholder="请输入关联月标准工时ID(erp_timesheet_standard_month)" /> v-model="form.projectId"
</el-form-item> filterable
<el-form-item label="项目ID(备件、物流)" prop="projectId"> clearable
<el-input v-model="form.projectId" placeholder="请输入项目ID(备件、物流)" /> :disabled="Boolean(form.allocId)"
</el-form-item> placeholder="请选择来源预投项目"
<el-form-item label="预投项目编码(冗余)" prop="projectCode"> class="full-width"
<el-input v-model="form.projectCode" placeholder="请输入预投项目编码(冗余)" /> @change="loadStaffAllocDetails"
</el-form-item> >
<el-form-item label="预投项目名称(冗余)" prop="projectName"> <el-option
<el-input v-model="form.projectName" placeholder="请输入预投项目名称(冗余)" /> v-for="project in sourceProjectOptions"
</el-form-item> :key="project.projectId"
<el-form-item label="来源预投工时合计(天,带出汇总)" prop="sourceTotalHours"> :label="projectLabel(project)"
<el-input v-model="form.sourceTotalHours" placeholder="请输入来源预投工时合计(天,带出汇总)" /> :value="project.projectId"
</el-form-item> />
<el-form-item label="已分配合计(天)" prop="allocatedTotalHours">
<el-input v-model="form.allocatedTotalHours" placeholder="请输入已分配合计(天)" />
</el-form-item>
<el-form-item label="涉及人数" prop="staffCount">
<el-input v-model="form.staffCount" placeholder="请输入涉及人数" />
</el-form-item>
<el-form-item label="单据状态" prop="allocStatus">
<el-select v-model="form.allocStatus" placeholder="请选择单据状态">
<el-option v-for="dict in alloc_status" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="是否已回写月汇总" prop="appliedFlag"> </el-col>
<el-radio-group v-model="form.appliedFlag"> <el-col :span="6">
<el-radio v-for="dict in applied_flag" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio> <el-form-item label="状态">
</el-radio-group> <dict-tag :options="alloc_status" :value="currentAllocStatus" />
</el-form-item> </el-form-item>
<el-form-item label="回写关联的月汇总主表ID" prop="summaryId"> </el-col>
<el-input v-model="form.summaryId" placeholder="请输入回写关联的月汇总主表ID" /> </el-row>
</el-form-item>
<el-form-item label="回写月汇总时间" prop="applyTime"> <div class="summary-strip">
<el-date-picker clearable v-model="form.applyTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择回写月汇总时间"> <div class="summary-item">
</el-date-picker> <span>来源预投工时</span>
</el-form-item> <strong>{{ formatHours(sourceTotalHours) }}</strong>
<el-form-item label="备注" prop="remark"> </div>
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <div class="summary-item">
<span>已分配工时</span>
<strong>{{ formatHours(allocatedTotalHours) }}</strong>
</div>
<div class="summary-item">
<span>未分配工时</span>
<strong :class="{ 'hour-warn': remainingTotalHours < 0 }">{{ formatHours(remainingTotalHours) }}</strong>
</div>
<div class="summary-item">
<span>涉及人数</span>
<strong>{{ staffCount }}</strong>
</div>
</div>
<el-table v-loading="detailLoading" border :data="form.staffAllocList || []" class="alloc-table" empty-text="请选择月份和预投项目">
<el-table-column label="员工" prop="staffName" width="140" />
<el-table-column label="原预投工时" align="right" width="120">
<template #default="scope">{{ formatHours(scope.row.sourceHours) }}</template>
</el-table-column>
<el-table-column label="已分配" align="right" width="110">
<template #default="scope">{{ formatHours(calcStaffAllocated(scope.row)) }}</template>
</el-table-column>
<el-table-column label="未分配" align="right" width="110">
<template #default="scope">
<span :class="{ 'hour-warn': calcStaffRemaining(scope.row) < 0 }">{{ formatHours(calcStaffRemaining(scope.row)) }}</span>
</template>
</el-table-column>
<el-table-column label="分配去向" min-width="560">
<template #default="scope">
<div class="target-list">
<div v-for="(allocItem, index) in scope.row.allocItems" :key="index" class="target-row">
<el-select v-model="allocItem.targetProjectId" filterable placeholder="目标物流/备件项目" class="target-project-select">
<el-option
v-for="project in targetProjectOptions"
:key="project.projectId"
:label="projectLabel(project)"
:value="project.projectId"
/>
</el-select>
<el-input-number v-model="allocItem.allocHours" :precision="2" :step="0.5" :min="0" controls-position="right" />
<el-button link type="danger" icon="Delete" @click="removeTarget(scope.row, index)" />
</div>
<el-button link type="primary" icon="Plus" @click="addTarget(scope.row)"></el-button>
</div>
</template>
</el-table-column>
</el-table>
<el-form-item label="备注" prop="remark" class="mt-4">
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -205,16 +247,36 @@ import {
getTimesheetPreAlloc, getTimesheetPreAlloc,
delTimesheetPreAlloc, delTimesheetPreAlloc,
addTimesheetPreAlloc, addTimesheetPreAlloc,
updateTimesheetPreAlloc updateTimesheetPreAlloc,
getStaffAllocDetails
} from '@/api/oa/erp/timesheetPreAlloc'; } from '@/api/oa/erp/timesheetPreAlloc';
import { TimesheetPreAllocVO, TimesheetPreAllocQuery, TimesheetPreAllocForm } from '@/api/oa/erp/timesheetPreAlloc/types'; import {
TimesheetPreAllocVO,
TimesheetPreAllocQuery,
TimesheetPreAllocForm,
PreAllocStaffAlloc,
PreAllocTarget,
PreAllocDetailVO
} from '@/api/oa/erp/timesheetPreAlloc/types';
import { getErpProjectInfoList } from '@/api/oa/erp/projectInfo';
interface ProjectOption {
projectId: string;
projectCode?: string;
projectName?: string;
projectCategory?: string;
}
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { alloc_status, applied_flag } = toRefs<any>(proxy?.useDict('alloc_status', 'applied_flag')); const { alloc_status } = toRefs<any>(proxy?.useDict('alloc_status'));
const timesheetPreAllocList = ref<TimesheetPreAllocVO[]>([]); const timesheetPreAllocList = ref<TimesheetPreAllocVO[]>([]);
const selectedRows = ref<TimesheetPreAllocVO[]>([]);
const sourceProjectOptions = ref<ProjectOption[]>([]);
const targetProjectOptions = ref<ProjectOption[]>([]);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
const detailLoading = ref(false);
const showSearch = ref(true); const showSearch = ref(true);
const ids = ref<Array<string | number>>([]); const ids = ref<Array<string | number>>([]);
const single = ref(true); const single = ref(true);
@ -229,166 +291,332 @@ const dialog = reactive<DialogOption>({
title: '' title: ''
}); });
//
const columns = ref<FieldOption[]>([ const columns = ref<FieldOption[]>([
{ key: 0, label: `分配单ID`, visible: true }, { key: 0, label: `月份`, visible: true },
{ key: 1, label: `租户编号`, visible: true }, { key: 1, label: `来源预投项目`, visible: true },
{ key: 2, label: `分配单编号`, visible: true }, { key: 2, label: `来源工时`, visible: true },
{ key: 3, label: `月份编码(YYYYMM)`, visible: true }, { key: 3, label: `已分配工时`, visible: true },
{ key: 4, label: `关联月标准工时ID(erp_timesheet_standard_month)`, visible: true }, { key: 4, label: `涉及人数`, visible: true },
{ key: 5, label: `项目ID(备件、物流)`, visible: true }, { key: 5, label: `分配状态`, visible: true },
{ key: 6, label: `预投项目编码(冗余)`, visible: true }, { key: 6, label: `回写时间`, visible: true },
{ key: 7, label: `预投项目名称(冗余)`, visible: true }, { key: 7, label: `备注`, visible: true },
{ key: 8, label: `来源预投工时合计(天,带出汇总)`, visible: true }, { key: 8, label: `分配单编号`, visible: true }
{ key: 9, label: `已分配合计(天)`, visible: true },
{ key: 10, label: `涉及人数`, visible: true },
{ key: 11, label: `单据状态`, visible: true },
{ key: 12, label: `是否已回写月汇总`, visible: true },
{ key: 13, label: `回写关联的月汇总主表ID`, visible: true },
{ key: 14, label: `回写月汇总时间`, visible: true },
{ key: 15, label: `备注`, visible: true },
{ key: 16, label: `删除标志`, visible: true },
{ key: 17, label: `创建部门`, visible: true },
{ key: 18, label: `创建者`, visible: true },
{ key: 19, label: `创建时间`, visible: true },
{ key: 20, label: `更新者`, visible: true },
{ key: 21, label: `更新时间`, visible: true }
]); ]);
const initFormData: TimesheetPreAllocForm = { const getCurrentMonthCode = () => {
allocId: undefined, const now = new Date();
allocCode: undefined, return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}`;
monthCode: undefined,
standardMonthId: undefined,
projectId: undefined,
projectCode: undefined,
projectName: undefined,
sourceTotalHours: undefined,
allocatedTotalHours: undefined,
staffCount: undefined,
allocStatus: undefined,
appliedFlag: undefined,
summaryId: undefined,
applyTime: undefined,
remark: undefined
}; };
const initFormData = (): TimesheetPreAllocForm => ({
allocId: undefined,
monthCode: getCurrentMonthCode(),
projectId: undefined,
sourceTotalHours: 0,
allocatedTotalHours: 0,
staffCount: 0,
allocStatus: '0',
appliedFlag: '0',
remark: undefined,
staffAllocList: []
});
const data = reactive<PageData<TimesheetPreAllocForm, TimesheetPreAllocQuery>>({ const data = reactive<PageData<TimesheetPreAllocForm, TimesheetPreAllocQuery>>({
form: { ...initFormData }, form: initFormData(),
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
allocCode: undefined, allocCode: undefined,
monthCode: undefined, monthCode: undefined,
standardMonthId: undefined,
projectId: undefined, projectId: undefined,
projectCode: undefined,
projectName: undefined,
sourceTotalHours: undefined,
allocatedTotalHours: undefined,
staffCount: undefined,
allocStatus: undefined, allocStatus: undefined,
appliedFlag: undefined,
summaryId: undefined,
applyTime: undefined,
params: {} params: {}
}, },
rules: { rules: {
allocId: [{ required: true, message: '分配单ID不能为空', trigger: 'blur' }], monthCode: [{ required: true, message: '月份不能为空', trigger: 'change' }],
allocCode: [{ required: true, message: '分配单编号不能为空', trigger: 'blur' }], projectId: [{ required: true, message: '来源预投项目不能为空', trigger: 'change' }]
monthCode: [{ required: true, message: '月份编码(YYYYMM)不能为空', trigger: 'blur' }],
projectId: [{ required: true, message: '项目ID(备件、物流)不能为空', trigger: 'blur' }],
sourceTotalHours: [{ required: true, message: '来源预投工时合计(天,带出汇总)不能为空', trigger: 'blur' }],
allocatedTotalHours: [{ required: true, message: '已分配合计(天)不能为空', trigger: 'blur' }],
allocStatus: [{ required: true, message: '单据状态不能为空', trigger: 'change' }]
} }
}); });
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
/** 查询预投工时分配列表 */ const normalizeProject = (project: any): ProjectOption => ({
projectId: String(project.projectId),
projectCode: project.projectCode,
projectName: project.projectName,
projectCategory: project.projectCategory
});
const projectLabel = (project: ProjectOption) => {
const code = project.projectCode || '';
const name = project.projectName || '';
return code ? `${code} ${name}` : name;
};
const toNumber = (value?: number | string | null) => {
const num = Number(value ?? 0);
return Number.isFinite(num) ? num : 0;
};
const formatHours = (value?: number | string | null) => toNumber(value).toFixed(2);
const calcStaffAllocated = (staff: PreAllocStaffAlloc) => (staff.allocItems || []).reduce((sum, item) => sum + toNumber(item.allocHours), 0);
const calcStaffRemaining = (staff: PreAllocStaffAlloc) => toNumber(staff.sourceHours) - calcStaffAllocated(staff);
const sourceTotalHours = computed(() => (form.value.staffAllocList || []).reduce((sum, staff) => sum + toNumber(staff.sourceHours), 0));
const allocatedTotalHours = computed(() => (form.value.staffAllocList || []).reduce((sum, staff) => sum + calcStaffAllocated(staff), 0));
const remainingTotalHours = computed(() => sourceTotalHours.value - allocatedTotalHours.value);
const staffCount = computed(() => (form.value.staffAllocList || []).filter((staff) => toNumber(staff.sourceHours) > 0).length);
const currentAllocStatus = computed(() => {
if (allocatedTotalHours.value <= 0) {
return '0';
}
return allocatedTotalHours.value < sourceTotalHours.value ? '1' : '2';
});
const hasAppliedSelected = computed(() => selectedRows.value.some((row) => row.appliedFlag === '1'));
const loadProjectOptions = async () => {
if (sourceProjectOptions.value.length === 0) {
const sourceRes: any = await getErpProjectInfoList({ projectCategory: '4' });
sourceProjectOptions.value = (sourceRes.data || []).map(normalizeProject);
}
if (targetProjectOptions.value.length === 0) {
const [logisticsRes, spareRes]: any[] = await Promise.all([
getErpProjectInfoList({ projectCategory: '1' }),
getErpProjectInfoList({ projectCategory: '2' })
]);
const merged = [...(logisticsRes.data || []), ...(spareRes.data || [])].map(normalizeProject);
const uniqueMap = new Map<string, ProjectOption>();
merged.forEach((project) => uniqueMap.set(project.projectId, project));
targetProjectOptions.value = Array.from(uniqueMap.values());
}
};
const normalizeStaffAlloc = (staff: PreAllocStaffAlloc): PreAllocStaffAlloc => ({
staffUserId: staff.staffUserId,
staffName: staff.staffName,
sourceHours: toNumber(staff.sourceHours),
allocatedHours: toNumber(staff.allocatedHours),
remainingHours: toNumber(staff.remainingHours),
allocItems: (staff.allocItems || []).map((item) => ({
targetProjectId: item.targetProjectId ? String(item.targetProjectId) : undefined,
targetProjectCode: item.targetProjectCode,
targetProjectName: item.targetProjectName,
allocHours: toNumber(item.allocHours)
}))
});
const applyDetailToForm = (detail: PreAllocDetailVO) => {
const sourceProjectId = detail.projectId ? String(detail.projectId) : undefined;
if (sourceProjectId && !sourceProjectOptions.value.some((project) => project.projectId === sourceProjectId)) {
sourceProjectOptions.value.push({
projectId: sourceProjectId,
projectCode: detail.projectCode,
projectName: detail.projectName,
projectCategory: '4'
});
}
form.value.allocId = detail.allocId;
form.value.allocCode = detail.allocCode;
form.value.monthCode = detail.monthCode;
form.value.standardMonthId = detail.standardMonthId;
form.value.projectId = sourceProjectId;
form.value.projectCode = detail.projectCode;
form.value.projectName = detail.projectName;
form.value.sourceTotalHours = toNumber(detail.sourceTotalHours);
form.value.allocatedTotalHours = toNumber(detail.allocatedTotalHours);
form.value.staffCount = detail.staffCount;
form.value.allocStatus = detail.allocStatus;
form.value.appliedFlag = detail.appliedFlag;
form.value.summaryId = detail.summaryId;
form.value.applyTime = detail.applyTime;
form.value.remark = detail.remark;
form.value.staffAllocList = (detail.staffAllocList || []).map(normalizeStaffAlloc);
form.value.staffAllocList.forEach((staff) => {
(staff.allocItems || []).forEach((item) => {
const targetProjectId = item.targetProjectId ? String(item.targetProjectId) : undefined;
if (targetProjectId && !targetProjectOptions.value.some((project) => project.projectId === targetProjectId)) {
targetProjectOptions.value.push({
projectId: targetProjectId,
projectCode: item.targetProjectCode,
projectName: item.targetProjectName
});
}
});
});
};
const loadStaffAllocDetails = async () => {
if (!form.value.monthCode || !form.value.projectId) {
form.value.staffAllocList = [];
return;
}
detailLoading.value = true;
try {
const res: any = await getStaffAllocDetails({
monthCode: form.value.monthCode,
projectId: form.value.projectId
});
applyDetailToForm(res.data);
} finally {
detailLoading.value = false;
}
};
const getList = async () => { const getList = async () => {
loading.value = true; loading.value = true;
const res = await listTimesheetPreAlloc(queryParams.value); const params = {
...queryParams.value,
projectId: queryParams.value.projectId || undefined
};
const res: any = await listTimesheetPreAlloc(params);
timesheetPreAllocList.value = res.rows; timesheetPreAllocList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
}; };
/** 取消按钮 */
const cancel = () => { const cancel = () => {
reset(); reset();
dialog.visible = false; dialog.visible = false;
}; };
/** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = initFormData();
timesheetPreAllocFormRef.value?.resetFields(); timesheetPreAllocFormRef.value?.resetFields();
}; };
/** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
}; };
/** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value?.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
}; };
/** 多选框选中数据 */
const handleSelectionChange = (selection: TimesheetPreAllocVO[]) => { const handleSelectionChange = (selection: TimesheetPreAllocVO[]) => {
selectedRows.value = selection;
ids.value = selection.map((item) => item.allocId); ids.value = selection.map((item) => item.allocId);
single.value = selection.length != 1; single.value = selection.length !== 1;
multiple.value = !selection.length; multiple.value = !selection.length;
}; };
/** 新增按钮操作 */ const handleAdd = async () => {
const handleAdd = () => {
reset(); reset();
await loadProjectOptions();
dialog.visible = true; dialog.visible = true;
dialog.title = '添加预投工时分配'; dialog.title = '预投工时分配';
}; };
/** 修改按钮操作 */
const handleUpdate = async (row?: TimesheetPreAllocVO) => { const handleUpdate = async (row?: TimesheetPreAllocVO) => {
reset(); reset();
const _allocId = row?.allocId || ids.value[0]; await loadProjectOptions();
const res = await getTimesheetPreAlloc(_allocId); const allocId = row?.allocId || ids.value[0];
Object.assign(form.value, res.data); const res: any = await getTimesheetPreAlloc(allocId);
applyDetailToForm(res.data);
dialog.visible = true; dialog.visible = true;
dialog.title = '修改预投工时分配'; dialog.title = '预投工时分配';
}; };
/** 提交按钮 */ const addTarget = (staff: PreAllocStaffAlloc) => {
if (!staff.allocItems) {
staff.allocItems = [];
}
staff.allocItems.push({ targetProjectId: undefined, allocHours: 0 });
};
const removeTarget = (staff: PreAllocStaffAlloc, index: number) => {
staff.allocItems?.splice(index, 1);
};
const validateAllocation = () => {
if (sourceTotalHours.value <= 0) {
proxy?.$modal.msgError('本月该预投项目没有可分配工时');
return false;
}
for (const staff of form.value.staffAllocList || []) {
const usedTargets = new Set<string>();
for (const item of staff.allocItems || []) {
if (!item.targetProjectId) {
proxy?.$modal.msgError(`员工[${staff.staffName}]存在未选择目标项目的分配行`);
return false;
}
const targetProjectId = String(item.targetProjectId);
if (usedTargets.has(targetProjectId)) {
proxy?.$modal.msgError(`员工[${staff.staffName}]不能重复选择同一目标项目`);
return false;
}
usedTargets.add(targetProjectId);
if (toNumber(item.allocHours) <= 0) {
proxy?.$modal.msgError(`员工[${staff.staffName}]分配工时必须大于0`);
return false;
}
}
if (calcStaffRemaining(staff) < -0.000001) {
proxy?.$modal.msgError(`员工[${staff.staffName}]分配工时不能超过原预投工时`);
return false;
}
}
return true;
};
const buildSubmitPayload = (): TimesheetPreAllocForm => ({
allocId: form.value.allocId,
monthCode: form.value.monthCode,
projectId: form.value.projectId,
sourceTotalHours: sourceTotalHours.value,
allocatedTotalHours: allocatedTotalHours.value,
staffCount: staffCount.value,
allocStatus: currentAllocStatus.value,
remark: form.value.remark,
staffAllocList: (form.value.staffAllocList || []).map((staff) => ({
staffUserId: staff.staffUserId,
staffName: staff.staffName,
sourceHours: toNumber(staff.sourceHours),
allocItems: (staff.allocItems || []).map((item: PreAllocTarget) => ({
targetProjectId: item.targetProjectId,
allocHours: toNumber(item.allocHours)
}))
}))
});
const submitForm = () => { const submitForm = () => {
timesheetPreAllocFormRef.value?.validate(async (valid: boolean) => { timesheetPreAllocFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (!valid || !validateAllocation()) {
return;
}
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.allocId) { const payload = buildSubmitPayload();
await updateTimesheetPreAlloc(form.value).finally(() => (buttonLoading.value = false)); try {
if (payload.allocId) {
await updateTimesheetPreAlloc(payload);
} else { } else {
await addTimesheetPreAlloc(form.value).finally(() => (buttonLoading.value = false)); await addTimesheetPreAlloc(payload);
} }
proxy?.$modal.msgSuccess('操作成功'); proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false; dialog.visible = false;
await getList(); await getList();
} finally {
buttonLoading.value = false;
} }
}); });
}; };
/** 删除按钮操作 */
const handleDelete = async (row?: TimesheetPreAllocVO) => { const handleDelete = async (row?: TimesheetPreAllocVO) => {
const _allocIds = row?.allocId || ids.value; const deleteRows = row ? [row] : selectedRows.value;
await proxy?.$modal.confirm('是否确认删除预投工时分配编号为"' + _allocIds + '"的数据项?').finally(() => (loading.value = false)); if (deleteRows.some((item) => item.appliedFlag === '1')) {
await delTimesheetPreAlloc(_allocIds); proxy?.$modal.msgError('已回写月汇总的预投工时分配单不允许删除');
return;
}
const allocIds = row?.allocId || ids.value;
await proxy?.$modal.confirm(`是否确认删除预投工时分配编号为"${allocIds}"的数据项?`).finally(() => (loading.value = false));
await delTimesheetPreAlloc(allocIds);
proxy?.$modal.msgSuccess('删除成功'); proxy?.$modal.msgSuccess('删除成功');
await getList(); await getList();
}; };
/** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download( proxy?.download(
'oa/erp/timesheetPreAlloc/export', 'oa/erp/timesheetPreAlloc/export',
@ -399,7 +627,88 @@ const handleExport = () => {
); );
}; };
onMounted(() => { onMounted(async () => {
getList(); await loadProjectOptions();
await getList();
}); });
</script> </script>
<style scoped>
.project-select {
width: 260px;
}
.full-width {
width: 100%;
}
.project-cell {
display: flex;
flex-direction: column;
gap: 2px;
line-height: 1.35;
}
.summary-strip {
display: grid;
grid-template-columns: repeat(4, minmax(120px, 1fr));
gap: 10px;
margin: 4px 0 12px;
}
.summary-item {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 36px;
padding: 6px 10px;
border: 1px solid var(--el-border-color-light);
border-radius: 6px;
background: var(--el-fill-color-lighter);
}
.summary-item span {
color: var(--el-text-color-secondary);
}
.summary-item strong {
font-size: 16px;
}
.alloc-table {
width: 100%;
}
.target-list {
display: flex;
flex-direction: column;
gap: 8px;
padding: 4px 0;
}
.target-row {
display: grid;
grid-template-columns: minmax(260px, 1fr) 150px 32px;
gap: 8px;
align-items: center;
}
.target-project-select {
width: 100%;
}
.hour-warn {
color: var(--el-color-danger);
font-weight: 600;
}
@media (max-width: 900px) {
.summary-strip {
grid-template-columns: repeat(2, minmax(120px, 1fr));
}
.target-row {
grid-template-columns: 1fr;
}
}
</style>

@ -3,7 +3,7 @@
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]"> <div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover"> <el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width='100px'> <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
<el-form-item label="分配单ID" prop="allocId"> <el-form-item label="分配单ID" prop="allocId">
<el-input v-model="queryParams.allocId" placeholder="请输入分配单ID" clearable @keyup.enter="handleQuery" /> <el-input v-model="queryParams.allocId" placeholder="请输入分配单ID" clearable @keyup.enter="handleQuery" />
</el-form-item> </el-form-item>
@ -44,16 +44,9 @@
<template #header> <template #header>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/erp:timesheetPreAllocDetail:add']"></el-button> <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/erp:timesheetPreAllocDetail:export']"
</el-col> >导出</el-button
<el-col :span="1.5"> >
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/erp:timesheetPreAllocDetail:edit']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/erp:timesheetPreAllocDetail:remove']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/erp:timesheetPreAllocDetail:export']"></el-button>
</el-col> </el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar> <right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
@ -72,16 +65,6 @@
<el-table-column label="目标项目名称(冗余)" align="center" prop="targetProjectName" v-if="columns[9].visible" /> <el-table-column label="目标项目名称(冗余)" align="center" prop="targetProjectName" v-if="columns[9].visible" />
<el-table-column label="分配工时(天)" align="center" prop="allocHours" v-if="columns[10].visible" /> <el-table-column label="分配工时(天)" align="center" prop="allocHours" v-if="columns[10].visible" />
<el-table-column label="备注" align="center" prop="remark" v-if="columns[11].visible" /> <el-table-column label="备注" align="center" prop="remark" v-if="columns[11].visible" />
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/erp:timesheetPreAllocDetail:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['oa/erp:timesheetPreAllocDetail:remove']"></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table> </el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" /> <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
@ -131,7 +114,13 @@
</template> </template>
<script setup name="TimesheetPreAllocDetail" lang="ts"> <script setup name="TimesheetPreAllocDetail" lang="ts">
import { listTimesheetPreAllocDetail, getTimesheetPreAllocDetail, delTimesheetPreAllocDetail, addTimesheetPreAllocDetail, updateTimesheetPreAllocDetail } from '@/api/oa/erp/timesheetPreAllocDetail'; import {
listTimesheetPreAllocDetail,
getTimesheetPreAllocDetail,
delTimesheetPreAllocDetail,
addTimesheetPreAllocDetail,
updateTimesheetPreAllocDetail
} from '@/api/oa/erp/timesheetPreAllocDetail';
import { TimesheetPreAllocDetailVO, TimesheetPreAllocDetailQuery, TimesheetPreAllocDetailForm } from '@/api/oa/erp/timesheetPreAllocDetail/types'; import { TimesheetPreAllocDetailVO, TimesheetPreAllocDetailQuery, TimesheetPreAllocDetailForm } from '@/api/oa/erp/timesheetPreAllocDetail/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -172,7 +161,7 @@
{ key: 14, label: `创建者`, visible: true }, { key: 14, label: `创建者`, visible: true },
{ key: 15, label: `创建时间`, visible: true }, { key: 15, label: `创建时间`, visible: true },
{ key: 16, label: `更新者`, visible: true }, { key: 16, label: `更新者`, visible: true },
{ key: 17, label: `更新时间`, visible: true }, { key: 17, label: `更新时间`, visible: true }
]); ]);
const initFormData: TimesheetPreAllocDetailForm = { const initFormData: TimesheetPreAllocDetailForm = {
@ -186,8 +175,8 @@
targetProjectCode: undefined, targetProjectCode: undefined,
targetProjectName: undefined, targetProjectName: undefined,
allocHours: undefined, allocHours: undefined,
remark: undefined, remark: undefined
} };
const data = reactive<PageData<TimesheetPreAllocDetailForm, TimesheetPreAllocDetailQuery>>({ const data = reactive<PageData<TimesheetPreAllocDetailForm, TimesheetPreAllocDetailQuery>>({
form: { ...initFormData }, form: { ...initFormData },
queryParams: { queryParams: {
@ -202,25 +191,14 @@
targetProjectCode: undefined, targetProjectCode: undefined,
targetProjectName: undefined, targetProjectName: undefined,
allocHours: undefined, allocHours: undefined,
params: { params: {}
}
}, },
rules: { rules: {
allocDetailId: [ allocDetailId: [{ required: true, message: '分配明细ID不能为空', trigger: 'blur' }],
{ required: true, message: "分配明细ID不能为空", trigger: "blur" } allocId: [{ required: true, message: '分配单ID不能为空', trigger: 'blur' }],
], originalProjectId: [{ required: true, message: '原项目ID不能为空', trigger: 'blur' }],
allocId: [ targetProjectId: [{ required: true, message: '目标实际项目ID不能为空', trigger: 'blur' }],
{ required: true, message: "分配单ID不能为空", trigger: "blur" } allocHours: [{ required: true, message: '分配工时(天)不能为空', trigger: 'blur' }]
],
originalProjectId: [
{ required: true, message: "原项目ID不能为空", trigger: "blur" }
],
targetProjectId: [
{ required: true, message: "目标实际项目ID不能为空", trigger: "blur" }
],
allocHours: [
{ required: true, message: "分配工时(天)不能为空", trigger: "blur" }
],
} }
}); });
@ -233,55 +211,55 @@
timesheetPreAllocDetailList.value = res.rows; timesheetPreAllocDetailList.value = res.rows;
total.value = res.total; total.value = res.total;
loading.value = false; loading.value = false;
} };
/** 取消按钮 */ /** 取消按钮 */
const cancel = () => { const cancel = () => {
reset(); reset();
dialog.visible = false; dialog.visible = false;
} };
/** 表单重置 */ /** 表单重置 */
const reset = () => { const reset = () => {
form.value = { ...initFormData }; form.value = { ...initFormData };
timesheetPreAllocDetailFormRef.value?.resetFields(); timesheetPreAllocDetailFormRef.value?.resetFields();
} };
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = () => {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
} };
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value?.resetFields(); queryFormRef.value?.resetFields();
handleQuery(); handleQuery();
} };
/** 多选框选中数据 */ /** 多选框选中数据 */
const handleSelectionChange = (selection: TimesheetPreAllocDetailVO[]) => { const handleSelectionChange = (selection: TimesheetPreAllocDetailVO[]) => {
ids.value = selection.map(item => item.allocDetailId); ids.value = selection.map((item) => item.allocDetailId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
} };
/** 新增按钮操作 */ /** 新增按钮操作 */
const handleAdd = () => { const handleAdd = () => {
reset(); reset();
dialog.visible = true; dialog.visible = true;
dialog.title = "添加预投工时分配明细"; dialog.title = '添加预投工时分配明细';
} };
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row?: TimesheetPreAllocDetailVO) => { const handleUpdate = async (row?: TimesheetPreAllocDetailVO) => {
reset(); reset();
const _allocDetailId = row?.allocDetailId || ids.value[0] const _allocDetailId = row?.allocDetailId || ids.value[0];
const res = await getTimesheetPreAllocDetail(_allocDetailId); const res = await getTimesheetPreAllocDetail(_allocDetailId);
Object.assign(form.value, res.data); Object.assign(form.value, res.data);
dialog.visible = true; dialog.visible = true;
dialog.title = "修改预投工时分配明细"; dialog.title = '修改预投工时分配明细';
} };
/** 提交按钮 */ /** 提交按钮 */
const submitForm = () => { const submitForm = () => {
@ -289,32 +267,36 @@
if (valid) { if (valid) {
buttonLoading.value = true; buttonLoading.value = true;
if (form.value.allocDetailId) { if (form.value.allocDetailId) {
await updateTimesheetPreAllocDetail(form.value).finally(() => buttonLoading.value = false); await updateTimesheetPreAllocDetail(form.value).finally(() => (buttonLoading.value = false));
} else { } else {
await addTimesheetPreAllocDetail(form.value).finally(() => buttonLoading.value = false); await addTimesheetPreAllocDetail(form.value).finally(() => (buttonLoading.value = false));
} }
proxy?.$modal.msgSuccess("操作成功"); proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false; dialog.visible = false;
await getList(); await getList();
} }
}); });
} };
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (row?: TimesheetPreAllocDetailVO) => { const handleDelete = async (row?: TimesheetPreAllocDetailVO) => {
const _allocDetailIds = row?.allocDetailId || ids.value; const _allocDetailIds = row?.allocDetailId || ids.value;
await proxy?.$modal.confirm('是否确认删除预投工时分配明细编号为"' + _allocDetailIds + '"的数据项?').finally(() => loading.value = false); await proxy?.$modal.confirm('是否确认删除预投工时分配明细编号为"' + _allocDetailIds + '"的数据项?').finally(() => (loading.value = false));
await delTimesheetPreAllocDetail(_allocDetailIds); await delTimesheetPreAllocDetail(_allocDetailIds);
proxy?.$modal.msgSuccess("删除成功"); proxy?.$modal.msgSuccess('删除成功');
await getList(); await getList();
} };
/** 导出按钮操作 */ /** 导出按钮操作 */
const handleExport = () => { const handleExport = () => {
proxy?.download('oa/erp/timesheetPreAllocDetail/export', { proxy?.download(
'oa/erp/timesheetPreAllocDetail/export',
{
...queryParams.value ...queryParams.value
}, `timesheetPreAllocDetail_${new Date().getTime()}.xlsx`) },
} `timesheetPreAllocDetail_${new Date().getTime()}.xlsx`
);
};
onMounted(() => { onMounted(() => {
getList(); getList();

Loading…
Cancel
Save