|
@@ -68,22 +68,22 @@
|
|
|
</main>
|
|
</main>
|
|
|
|
|
|
|
|
<!-- 添加/编辑先进个人对话框 -->
|
|
<!-- 添加/编辑先进个人对话框 -->
|
|
|
- <el-dialog v-model="addDialogVisible" :title="`${isEditMode && normalForm.id ? '编辑' : '添加'}活动报名信息`" width="800px"
|
|
|
|
|
|
|
+ <el-dialog v-model="addDialogVisible" :title="title" width="800px"
|
|
|
:close-on-click-modal="false" @close="handleDialogClose">
|
|
:close-on-click-modal="false" @close="handleDialogClose">
|
|
|
<div class="add-dialog-content">
|
|
<div class="add-dialog-content">
|
|
|
|
|
|
|
|
<!-- 普通部门表单 -->
|
|
<!-- 普通部门表单 -->
|
|
|
<el-form ref="normalFormRef" :model="normalForm" :rules="normalFormRules" label-width="140px">
|
|
<el-form ref="normalFormRef" :model="normalForm" :rules="normalFormRules" label-width="140px">
|
|
|
<el-form-item label="部门名称" prop="employeeDeptName">
|
|
<el-form-item label="部门名称" prop="employeeDeptName">
|
|
|
- <el-cascader style="width: 100%" size="large" :ref="(el) => (cascaderRef['employeeDeptName'] = el)"
|
|
|
|
|
|
|
+ <el-cascader style="width: 100%" size="large" ref="employeeDeptNameRef"
|
|
|
:options="firstLevelDepts" :props="cascaderProp" :show-all-levels="false" placeholder="请选择安全责任部门"
|
|
:options="firstLevelDepts" :props="cascaderProp" :show-all-levels="false" placeholder="请选择安全责任部门"
|
|
|
filterable v-model="normalForm.deptId" @change="(val) => handleChangeDept(val, 'employeeDeptName')" />
|
|
filterable v-model="normalForm.deptId" @change="(val) => handleChangeDept(val, 'employeeDeptName')" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="员工工号:" prop="employeeCode">
|
|
|
|
|
- <el-input v-model="normalForm.employeeCode" placeholder="请输入员工工号" maxlength="50" />
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
|
|
+
|
|
|
<el-form-item label="员工姓名:" prop="employeeName">
|
|
<el-form-item label="员工姓名:" prop="employeeName">
|
|
|
- <el-input v-model="normalForm.employeeName" placeholder="请输入员工姓名" maxlength="50" />
|
|
|
|
|
|
|
+ <el-select v-model="normalForm.employeeName" @change="handleChangeEmployee" size="large" placeholder="请选择员工姓名" style="width: 100%">
|
|
|
|
|
+ <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="员工联系方式:" prop="employeeContact">
|
|
<el-form-item label="员工联系方式:" prop="employeeContact">
|
|
|
<el-input v-model="normalForm.employeeContact" placeholder="请输入11位手机号码" maxlength="11"
|
|
<el-input v-model="normalForm.employeeContact" placeholder="请输入11位手机号码" maxlength="11"
|
|
@@ -130,6 +130,9 @@ import {
|
|
|
type safetyCultureFilePageQuery,
|
|
type safetyCultureFilePageQuery,
|
|
|
} from '@/api/safety-culture';
|
|
} from '@/api/safety-culture';
|
|
|
import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
|
|
import { formatDeptTree } from '@/views/disaster/utils/formatDeptTree';
|
|
|
|
|
+ import {
|
|
|
|
|
+ queryAvailableUserList,
|
|
|
|
|
+ } from '@/api/production-safety/responsibility-implementation';
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
const route = useRoute();
|
|
|
|
|
|
|
@@ -165,6 +168,7 @@ const activityRegistrationDetail = ref<Partial<ActivityRegistrationTargetItem>>(
|
|
|
|
|
|
|
|
// 添加对话框相关
|
|
// 添加对话框相关
|
|
|
const addDialogVisible = ref(false);
|
|
const addDialogVisible = ref(false);
|
|
|
|
|
+const title = ref('')
|
|
|
const isEditMode = ref(false);
|
|
const isEditMode = ref(false);
|
|
|
const currentEditRow = ref<any>(null);
|
|
const currentEditRow = ref<any>(null);
|
|
|
const editDetailData = ref(null);
|
|
const editDetailData = ref(null);
|
|
@@ -273,13 +277,36 @@ const handleReset = () => {
|
|
|
tableQuery.queryParam.deptName = '';
|
|
tableQuery.queryParam.deptName = '';
|
|
|
handleSearch();
|
|
handleSearch();
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+const userOptions = ref<{ value: string; label: string }[]>([]);
|
|
|
// 添加注册活动
|
|
// 添加注册活动
|
|
|
const selectDeptType = () => {
|
|
const selectDeptType = () => {
|
|
|
isEditMode.value = true;
|
|
isEditMode.value = true;
|
|
|
addDialogVisible.value = true;
|
|
addDialogVisible.value = true;
|
|
|
|
|
+ normalFormRef.value?.resetFields();
|
|
|
|
|
+ title.value = '新增活动报名信息';
|
|
|
|
|
+ getUserData(userOptions, normalForm.employeeDeptName);
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+ // 获取用户列表封装
|
|
|
|
|
+ const getUserData = (optionList, deptName='') => {
|
|
|
|
|
+ return queryAvailableUserList({
|
|
|
|
|
+ pageNumber: 1,
|
|
|
|
|
+ pageSize: 200,
|
|
|
|
|
+ queryParam: { deptName },
|
|
|
|
|
+ }).then((res: any) => {
|
|
|
|
|
+ optionList.value = (res.records || []).map((u: any) => ({
|
|
|
|
|
+ value: u.staffNo,
|
|
|
|
|
+ label: u.realname,
|
|
|
|
|
+ }));
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ // 处理员工姓名选择变化
|
|
|
|
|
+ const handleChangeEmployee = (val) => {
|
|
|
|
|
+ const selectedUser = userOptions.value.find(user => user.value === val);
|
|
|
|
|
+ if (selectedUser) {
|
|
|
|
|
+ normalForm.employeeName = selectedUser.label;
|
|
|
|
|
+ normalForm.employeeCode = selectedUser.value;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
// 处理电话号码输入(只允许数字)
|
|
// 处理电话号码输入(只允许数字)
|
|
|
const handlePhoneInput = (value: string) => {
|
|
const handlePhoneInput = (value: string) => {
|
|
|
// 只保留数字
|
|
// 只保留数字
|
|
@@ -324,7 +351,6 @@ const handleSave = async () => {
|
|
|
employeeContact: string;
|
|
employeeContact: string;
|
|
|
remark: string;
|
|
remark: string;
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
const isValid = await validateNormalForm();
|
|
const isValid = await validateNormalForm();
|
|
|
if (!isValid) {
|
|
if (!isValid) {
|
|
|
return;
|
|
return;
|
|
@@ -333,11 +359,12 @@ const handleSave = async () => {
|
|
|
...(normalForm.id && { id: Number(normalForm.id) }),
|
|
...(normalForm.id && { id: Number(normalForm.id) }),
|
|
|
activityId: activityRegistrationDetail.value.id,
|
|
activityId: activityRegistrationDetail.value.id,
|
|
|
deptId: normalForm.deptId ? Number(normalForm.deptId) : undefined,
|
|
deptId: normalForm.deptId ? Number(normalForm.deptId) : undefined,
|
|
|
- employeeId: normalForm.employeeCode.trim(),
|
|
|
|
|
|
|
+ employeeId: normalForm.employeeCode.toString(),
|
|
|
employeeName: normalForm.employeeName.trim(),
|
|
employeeName: normalForm.employeeName.trim(),
|
|
|
employeeContact: normalForm.employeeContact.trim(),
|
|
employeeContact: normalForm.employeeContact.trim(),
|
|
|
remark: normalForm.remark.trim(),
|
|
remark: normalForm.remark.trim(),
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
if (isEditMode.value && normalForm.id) {
|
|
if (isEditMode.value && normalForm.id) {
|
|
|
await updateSafetyCultureActivityManagement(addUsers);
|
|
await updateSafetyCultureActivityManagement(addUsers);
|
|
@@ -355,6 +382,7 @@ const handleSave = async () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleEdit = async (row: any) => {
|
|
const handleEdit = async (row: any) => {
|
|
|
|
|
+ console.log(row,'row');
|
|
|
if (!row.id) {
|
|
if (!row.id) {
|
|
|
ElMessage.error('缺少记录ID,无法编辑');
|
|
ElMessage.error('缺少记录ID,无法编辑');
|
|
|
return;
|
|
return;
|
|
@@ -362,13 +390,16 @@ const handleEdit = async (row: any) => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
isEditMode.value = true;
|
|
isEditMode.value = true;
|
|
|
|
|
+ title.value = '编辑活动报名信息';
|
|
|
addDialogVisible.value = true;
|
|
addDialogVisible.value = true;
|
|
|
normalForm.id = row.id;
|
|
normalForm.id = row.id;
|
|
|
normalForm.deptId = row.deptId;
|
|
normalForm.deptId = row.deptId;
|
|
|
|
|
+ normalForm.employeeDeptName = row.deptName;
|
|
|
normalForm.employeeCode = row.employeeId;
|
|
normalForm.employeeCode = row.employeeId;
|
|
|
normalForm.employeeName = row.employeeName;
|
|
normalForm.employeeName = row.employeeName;
|
|
|
normalForm.employeeContact = row.employeeContact;
|
|
normalForm.employeeContact = row.employeeContact;
|
|
|
normalForm.remark = row.remark;
|
|
normalForm.remark = row.remark;
|
|
|
|
|
+ getUserData(userOptions, row.deptName);
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('获取详情失败:', e);
|
|
console.error('获取详情失败:', e);
|
|
|
ElMessage.error('获取详情失败');
|
|
ElMessage.error('获取详情失败');
|
|
@@ -435,21 +466,45 @@ const getActivityRegistrationDetail = async () => {
|
|
|
|
|
|
|
|
const getDeptData = () => {
|
|
const getDeptData = () => {
|
|
|
getAllDepartments().then((res) => {
|
|
getAllDepartments().then((res) => {
|
|
|
- firstLevelDepts.value = formatDeptTree(res);
|
|
|
|
|
- console.log('@res:', res);
|
|
|
|
|
|
|
+ firstLevelDepts.value = res?.[0]?.children.map(item => ({
|
|
|
|
|
+ ...item,
|
|
|
|
|
+ children: []
|
|
|
|
|
+ })); //formatDeptTree(res);
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleChangeDept = (val, prop) => {
|
|
const handleChangeDept = (val, prop) => {
|
|
|
- const cascader = cascaderRef.value?.[prop];
|
|
|
|
|
- const deptInfo = cascader?.getCheckedNodes();
|
|
|
|
|
- if (deptInfo && deptInfo.length > 0) {
|
|
|
|
|
- normalForm.employeeDeptName = deptInfo[0].label;
|
|
|
|
|
- normalForm.deptId = val[val.length - 1];
|
|
|
|
|
- // normalForm.deptName = deptInfo[0].label;
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ // 每次选择部门时,重置员工姓名和工号
|
|
|
|
|
+ normalForm.employeeName = '';
|
|
|
|
|
+ normalForm.employeeCode = '';
|
|
|
|
|
+ if(prop === 'responsibleDepartmentId'){
|
|
|
|
|
+ tableQuery.queryParam.deptName = '';
|
|
|
|
|
+ const selectedDept = firstLevelDepts.value.find(dept => dept.id === val);
|
|
|
|
|
+ if (selectedDept) {
|
|
|
|
|
+ tableQuery.queryParam.deptName = selectedDept.deptName;
|
|
|
|
|
+ getUserData(userOptions, selectedDept.deptName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(prop === 'employeeDeptName'){
|
|
|
normalForm.employeeDeptName = '';
|
|
normalForm.employeeDeptName = '';
|
|
|
|
|
+ const selectedDept = firstLevelDepts.value.find(dept => dept.id === val);
|
|
|
|
|
+ if (selectedDept) {
|
|
|
|
|
+ normalForm.employeeDeptName = selectedDept.deptName;
|
|
|
|
|
+ normalForm.deptId = val;
|
|
|
|
|
+ getUserData(userOptions, selectedDept.deptName);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// const cascader = cascaderRef.value?.[prop];
|
|
|
|
|
+// const deptInfo = cascader?.getCheckedNodes();
|
|
|
|
|
+// console.log('handleChangeDept', val, prop, deptInfo);
|
|
|
|
|
+// if (deptInfo && deptInfo.length > 0) {
|
|
|
|
|
+// normalForm.employeeDeptName = deptInfo[0].label;
|
|
|
|
|
+// normalForm.deptId = val[val.length - 1];
|
|
|
|
|
+// // normalForm.deptName = deptInfo[0].label;
|
|
|
|
|
+// } else {
|
|
|
|
|
+// normalForm.employeeDeptName = '';
|
|
|
|
|
+// }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|