违规记录
This commit is contained in:
@ -23,10 +23,30 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" :offset="0" prop="dept">
|
||||
<el-form-item label="部门">
|
||||
<el-cascader
|
||||
:options="postListAll"
|
||||
v-model="formData.dept"
|
||||
clearable
|
||||
filterable
|
||||
:show-all-levels="false"
|
||||
placeholder="请选择部门"
|
||||
:props="{ expandTrigger: 'hover', checkStrictly: true, value: 'id', emitPath: false, multiple: true }"
|
||||
@change="changeDept"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="岗位" prop="postIdList">
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple>
|
||||
<el-option v-for="dict in postListAll" :key="dict.postId" :label="dict.postName" :value="dict.postId" />
|
||||
<el-select v-model="formData.postIdList" placeholder="请选择岗位" multiple :disabled="!formData.dept">
|
||||
<el-option
|
||||
v-for="dict in formData.postWorkList"
|
||||
:key="dict.postId"
|
||||
:label="dict.deptName + '/' + dict.postName"
|
||||
:value="dict.postId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -60,7 +80,7 @@ const userStore = useUserStoreHook();
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
// Props
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
tourTypeOptions: any[];
|
||||
risxList: any[];
|
||||
postListAll: any[];
|
||||
@ -78,6 +98,7 @@ const loading = ref(false);
|
||||
const formData = reactive({
|
||||
id: undefined,
|
||||
violationLevel: undefined,
|
||||
dept: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined as any,
|
||||
wxOrPc: undefined,
|
||||
@ -88,6 +109,7 @@ const formData = reactive({
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postWorkList: [] as any[],
|
||||
postIdList: [] as any[]
|
||||
});
|
||||
|
||||
@ -127,6 +149,7 @@ const resetForm = () => {
|
||||
violationLevel: undefined,
|
||||
color: undefined,
|
||||
violationType: undefined,
|
||||
dept: undefined,
|
||||
wxOrPc: undefined,
|
||||
createBy: undefined,
|
||||
updateBy: undefined,
|
||||
@ -135,6 +158,7 @@ const resetForm = () => {
|
||||
deletedAt: undefined,
|
||||
projectId: currentProject.value?.id,
|
||||
riskType: '',
|
||||
postWorkList: [] as any[],
|
||||
postIdList: []
|
||||
});
|
||||
};
|
||||
@ -165,6 +189,32 @@ const onSubmit = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const changeDept = (val: any) => {
|
||||
formData.postWorkList = getPostVoListByIds(props.postListAll, val);
|
||||
formData.postIdList = [];
|
||||
console.log(formData.postWorkList, val);
|
||||
};
|
||||
|
||||
function getPostVoListByIds(tree: any[], idList: (string | number)[]): any[] {
|
||||
const idSet = new Set(idList.map(String)); // 用于快速匹配 ID(统一为字符串比较)
|
||||
const result: any[] = [];
|
||||
|
||||
function dfs(nodes: any[]) {
|
||||
for (const node of nodes) {
|
||||
if (idSet.has(String(node.id))) {
|
||||
result.push(...(node.postVoList || []));
|
||||
}
|
||||
|
||||
if (node.children && node.children.length > 0) {
|
||||
dfs(node.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dfs(tree);
|
||||
return result;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
closeDialog
|
||||
|
Reference in New Issue
Block a user