|
|
|
|
@ -181,7 +181,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="12" v-if="!isFormDisabled">
|
|
|
|
|
<el-form-item label="下一步审批人" prop="variables.approverId">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.variables.approverId"
|
|
|
|
|
@ -189,13 +189,19 @@
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
:disabled="isFormDisabled"
|
|
|
|
|
@change="handleApproverSelectChange"
|
|
|
|
|
>
|
|
|
|
|
<el-option v-for="user in userList" :key="user.userId" :label="user.nickName" :value="user.userId" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12" v-if="!isFormDisabled">
|
|
|
|
|
<el-form-item label="抄送人员" prop="copyUserIds">
|
|
|
|
|
<el-select v-model="form.copyUserIds" placeholder="请选择抄送人员" filterable clearable multiple style="width: 100%">
|
|
|
|
|
<el-option v-for="user in userList" :key="user.userId" :label="user.nickName" :value="String(user.userId)" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
@ -227,6 +233,7 @@ import ProjectSelect from '@/components/ProjectSelect/index.vue';
|
|
|
|
|
import { CodeRuleEnum, FlowCodeEnum } from '@/enums/OAEnum';
|
|
|
|
|
import { getInfo } from '@/api/login';
|
|
|
|
|
import { listUser } from '@/api/system/user'; // 导入用户列表API
|
|
|
|
|
import { allListDept } from '@/api/system/dept'; // 导入部门列表API
|
|
|
|
|
import { ProjectInfoVO } from '@/api/oa/erp/projectInfo/types';
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
@ -248,6 +255,10 @@ const projectSelectRef = ref<InstanceType<typeof ProjectSelect>>();
|
|
|
|
|
// const userSelectRef = ref<InstanceType<typeof UserSelect>>(); // 审批人选择 ref
|
|
|
|
|
|
|
|
|
|
const userList = ref<any[]>([]); // 用户列表
|
|
|
|
|
const deptInfoList = ref<any[]>([]); // 部门列表
|
|
|
|
|
|
|
|
|
|
// 默认抄送人员的昵称列表
|
|
|
|
|
const defaultCopyUserNames = ['米兰', '于洋', '张兰艳', '张东辉', '冯俊杰'];
|
|
|
|
|
|
|
|
|
|
// 流程相关数据
|
|
|
|
|
const submitFormData = ref<StartProcessBo>({
|
|
|
|
|
@ -283,7 +294,8 @@ const initFormData: BusinessTripApplyForm = {
|
|
|
|
|
flowStatus: 'draft',
|
|
|
|
|
remark: undefined,
|
|
|
|
|
ossId: undefined,
|
|
|
|
|
variables: {} // 初始化 variables
|
|
|
|
|
variables: {}, // 初始化 variables
|
|
|
|
|
copyUserIds: [] as string[] // 抄送人员ID列表
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const data = reactive({
|
|
|
|
|
@ -327,15 +339,40 @@ onMounted(async () => {
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
const id = routeParams.value.id;
|
|
|
|
|
|
|
|
|
|
// 加载用户列表 (用于审批人选择和抄送人员选择)
|
|
|
|
|
const userRes = await listUser({ pageNum: 1, pageSize: 1000 });
|
|
|
|
|
userList.value = userRes.rows;
|
|
|
|
|
|
|
|
|
|
// 加载部门列表 (用于获取部门负责人和分管副总)
|
|
|
|
|
const deptRes = await allListDept({ deptCategory: '03' } as any);
|
|
|
|
|
deptInfoList.value = deptRes.data || [];
|
|
|
|
|
|
|
|
|
|
// 自动填充申请人信息
|
|
|
|
|
if (!id) {
|
|
|
|
|
try {
|
|
|
|
|
const userRes = await getInfo();
|
|
|
|
|
if (userRes.data?.user) {
|
|
|
|
|
form.value.applicantId = userRes.data.user.userId;
|
|
|
|
|
form.value.applicantName = userRes.data.user.nickName;
|
|
|
|
|
form.value.deptId = userRes.data.user.deptId;
|
|
|
|
|
form.value.deptName = userRes.data.user.deptName;
|
|
|
|
|
const infoRes = await getInfo();
|
|
|
|
|
if (infoRes.data?.user) {
|
|
|
|
|
form.value.applicantId = infoRes.data.user.userId;
|
|
|
|
|
form.value.applicantName = infoRes.data.user.nickName;
|
|
|
|
|
form.value.deptId = infoRes.data.user.deptId;
|
|
|
|
|
form.value.deptName = infoRes.data.user.deptName;
|
|
|
|
|
|
|
|
|
|
// 根据部门ID获取部门负责人和分管副总
|
|
|
|
|
const deptInfo = deptInfoList.value.find((d: any) => d.deptId === infoRes.data.user.deptId);
|
|
|
|
|
if (deptInfo) {
|
|
|
|
|
const deptLeaderId = deptInfo.leader;
|
|
|
|
|
const vicePresidentId = deptInfo.vicePresident;
|
|
|
|
|
// 将部门负责人和分管副总加入默认抄送人员
|
|
|
|
|
const deptCopyIds: string[] = [];
|
|
|
|
|
if (deptLeaderId) deptCopyIds.push(String(deptLeaderId));
|
|
|
|
|
if (vicePresidentId) deptCopyIds.push(String(vicePresidentId));
|
|
|
|
|
|
|
|
|
|
// 根据昵称匹配默认抄送人员
|
|
|
|
|
const defaultCopyIds = userList.value.filter((u: any) => defaultCopyUserNames.includes(u.nickName)).map((u: any) => String(u.userId));
|
|
|
|
|
|
|
|
|
|
// 合并默认抄送人员和部门负责人/分管副总(去重)
|
|
|
|
|
form.value.copyUserIds = [...new Set([...defaultCopyIds, ...deptCopyIds])];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('获取用户信息失败', e);
|
|
|
|
|
@ -346,14 +383,13 @@ onMounted(async () => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载用户列表 (用于审批人选择)
|
|
|
|
|
listUser({ pageNum: 1, pageSize: 1000 }).then((res: any) => {
|
|
|
|
|
userList.value = res.rows;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (id && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
|
|
|
|
|
const res = await getBusinessTripApply(id);
|
|
|
|
|
Object.assign(form.value, res.data);
|
|
|
|
|
// 将抄送人员字符串转换为数组
|
|
|
|
|
if (form.value.copyUserIds && typeof form.value.copyUserIds === 'string') {
|
|
|
|
|
form.value.copyUserIds = (form.value.copyUserIds as string).split(',').filter((id) => id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
@ -426,9 +462,12 @@ const executeSubmit = async (status: string, mode: boolean) => {
|
|
|
|
|
// 提交审批
|
|
|
|
|
form.value.tripStatus = '2'; // 审批中
|
|
|
|
|
form.value.flowStatus = 'waiting';
|
|
|
|
|
// 将抄送人员ID数组转换为逗号分隔字符串
|
|
|
|
|
const copyUserIdsStr = Array.isArray(form.value.copyUserIds) ? form.value.copyUserIds.join(',') : form.value.copyUserIds || '';
|
|
|
|
|
form.value.variables = {
|
|
|
|
|
...form.value.variables,
|
|
|
|
|
tripType: form.value.tripType
|
|
|
|
|
tripType: form.value.tripType,
|
|
|
|
|
businessTripCopyUsers: copyUserIdsStr
|
|
|
|
|
};
|
|
|
|
|
form.value.bizExt = {
|
|
|
|
|
businessTitle: '出差申请',
|
|
|
|
|
|