5 changed files with 329 additions and 3 deletions
@ -0,0 +1,226 @@ |
|||||
|
<!-- |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-21 10:49:07 |
||||
|
@ 备注: 岗位组件 |
||||
|
--> |
||||
|
<script lang='ts' setup> |
||||
|
import { orgInfo } from '@/api/hr/org/type' |
||||
|
import { basis_org_postList,getOrgTreeList,getgovcont,getpositioncont } from "@/api/hr/org/index"; |
||||
|
const props = withDefaults( |
||||
|
defineProps<{ |
||||
|
data: FormList |
||||
|
tablekey: any |
||||
|
numrun?: number |
||||
|
modelValue?: any // 子表和弹性布局时时有传 |
||||
|
tProp?: string // 子表时的form-item的prop值,用于子表校验用 |
||||
|
}>(), |
||||
|
{} |
||||
|
) |
||||
|
const emits = defineEmits<{ |
||||
|
(e: 'update:modelValue', numVal: any): void |
||||
|
}>() |
||||
|
|
||||
|
const value = computed({ |
||||
|
get: () => { |
||||
|
if (props.modelValue != "" && props.modelValue != undefined) { |
||||
|
console.log("初始结果", props.modelValue); |
||||
|
let ads = props.modelValue.split("#@#"); |
||||
|
console.log("初始结果", ads); |
||||
|
if (ads.length >= 2) { |
||||
|
orgPostInfo.orgId = ads[0] * 1; |
||||
|
orgPostInfo.postId = ads[1] * 1; |
||||
|
orgChange(ads[0] * 1); |
||||
|
} else if (ads.length == 1) { |
||||
|
orgPostInfo.orgId = ads[0] * 1; |
||||
|
orgChange(ads[0] * 1); |
||||
|
} else { |
||||
|
orgPostInfo.orgId = ""; |
||||
|
orgPostInfo.postId = ""; |
||||
|
} |
||||
|
// if (props.type == 4) { |
||||
|
// writeInfo(props.modelValue); |
||||
|
// return valueHtml; |
||||
|
// } else { |
||||
|
// return props.modelValue; |
||||
|
// } |
||||
|
return props.modelValue; |
||||
|
} else { |
||||
|
return props.modelValue; |
||||
|
} |
||||
|
}, |
||||
|
set: (newVal: any) => { |
||||
|
emits("update:modelValue", newVal); |
||||
|
}, |
||||
|
}); |
||||
|
const postOptions = ref([]); |
||||
|
const valueHtml = ref(""); |
||||
|
const valueHtmlPost = ref(""); |
||||
|
const orgTreeList = ref<orgInfo[]>(); |
||||
|
const orgTreeLoading = ref(false); //加载行政组织树 |
||||
|
const orgTreeProps = { |
||||
|
children: "child", |
||||
|
label: "name", |
||||
|
}; //行政组织树对照值 |
||||
|
const orgPostTreeLoading = ref(false); |
||||
|
const orgPostInfo = reactive({ |
||||
|
orgId: "", |
||||
|
postId: "", |
||||
|
}); |
||||
|
|
||||
|
function haveOrgTreeInfo() { |
||||
|
orgTreeLoading.value = true; |
||||
|
getOrgTreeList({ orgid: 309 }) |
||||
|
.then(({ data }) => { |
||||
|
console.log("行政组织树对照值", data); |
||||
|
orgTreeList.value = data; |
||||
|
}) |
||||
|
.finally(() => { |
||||
|
orgTreeLoading.value = false; |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
onBeforeMount(() => { |
||||
|
haveOrgTreeInfo(); |
||||
|
}); |
||||
|
|
||||
|
onMounted(() => { |
||||
|
// console.log("value---1--》",value.value,props.modelValue) |
||||
|
nextTick(() => { |
||||
|
haveOrgTreeInfo(); |
||||
|
if (props.type == 4) { |
||||
|
console.log("value---1--》", props.modelValue); |
||||
|
} |
||||
|
}); |
||||
|
}); |
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-20 14:43:57 |
||||
|
@ 功能: 改变行政组织获取相应岗位 |
||||
|
*/ |
||||
|
const orgChange = (val: any) => { |
||||
|
// console.log("改变行政组织获取相应岗位", val); |
||||
|
orgPostTreeLoading.value = true; |
||||
|
basis_org_postList({ id: [val] }) |
||||
|
.then(({ data }) => { |
||||
|
console.log("改变行政组织获取相应岗位", data); |
||||
|
postOptions.value = data; |
||||
|
}) |
||||
|
.finally(() => { |
||||
|
orgPostTreeLoading.value = false; |
||||
|
}); |
||||
|
}; |
||||
|
watch( |
||||
|
() => orgPostInfo, |
||||
|
(val: any) => { |
||||
|
if (val.orgId != "") { |
||||
|
value.value = val.orgId; |
||||
|
if (val.postId != "") { |
||||
|
value.value = val.orgId + "#@#" + val.postId; |
||||
|
if (props.type == 4) { |
||||
|
if (postOptions.value && postOptions.value.length > 0) { |
||||
|
orgPostInfo.postId.forEach((item: any) => { |
||||
|
if (item.id == val.postId) { |
||||
|
value.value = value.value + item.name; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} else { |
||||
|
value.value = ""; |
||||
|
} |
||||
|
} else { |
||||
|
value.value = ""; |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
deep: true, |
||||
|
} |
||||
|
); |
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-20 16:06:01 |
||||
|
@ 功能: 获取行政组织基本信息 |
||||
|
*/ |
||||
|
const gainOrgCont = (val: string) => { |
||||
|
let name = ""; |
||||
|
getgovcont({ id: val * 1, idstr: val }) |
||||
|
.then(({ data }) => { |
||||
|
console.log("选择行政组织-3->", data, data.name); |
||||
|
// orgName.value = data.name |
||||
|
valueHtml.value = data.name; |
||||
|
}) |
||||
|
.finally(() => {}); |
||||
|
return name; |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-20 16:36:03 |
||||
|
@ 功能: 获取岗位 |
||||
|
*/ |
||||
|
const getPostInfo = (val: string) => { |
||||
|
getpositioncont({ id: val * 1, idstr: val }).then(({ data }) => { |
||||
|
console.log("选择行政组织----4->", data, data.name); |
||||
|
valueHtmlPost.value = data.name; |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
/** |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-20 16:15:48 |
||||
|
@ 功能: 输出结果 |
||||
|
*/ |
||||
|
const writeInfo = (val: any) => { |
||||
|
console.log("输出结果-3->", val); |
||||
|
if (val != "" && val != undefined) { |
||||
|
let ads = val.split("#@#"); |
||||
|
if (ads.length >= 2) { |
||||
|
gainOrgCont(ads[0]); |
||||
|
getPostInfo(ads[1]); |
||||
|
} else if (ads.length == 1) { |
||||
|
gainOrgCont(ads[0]); |
||||
|
} |
||||
|
} |
||||
|
let sendInfo = valueHtml.value; |
||||
|
if (valueHtmlPost.value != "") { |
||||
|
sendInfo = sendInfo + "-" + valueHtmlPost.value; |
||||
|
} |
||||
|
return sendInfo; |
||||
|
}; |
||||
|
</script> |
||||
|
<template> |
||||
|
|
||||
|
<el-tree-select |
||||
|
v-bind="$props" |
||||
|
v-model="orgPostInfo.orgId" |
||||
|
v-loading="orgTreeLoading" |
||||
|
node-key="id" |
||||
|
:props="orgTreeProps" |
||||
|
:data="orgTreeList" |
||||
|
check-strictly |
||||
|
b |
||||
|
:render-after-expand="false" |
||||
|
placeholder="请选择行政组织" |
||||
|
@change="orgChange" |
||||
|
/> |
||||
|
<el-select |
||||
|
v-model="orgPostInfo.postId" |
||||
|
v-loading="orgPostTreeLoading" |
||||
|
placeholder="请选择岗位" |
||||
|
style="margin-top:10px;" |
||||
|
> |
||||
|
<el-option |
||||
|
v-for="item in postOptions" |
||||
|
:key="item.id" |
||||
|
:label="item.name" |
||||
|
:value="item.id" |
||||
|
/> |
||||
|
</el-select> |
||||
|
|
||||
|
<el-input style="display: none" v-model="value" placeholder="请选择" /> |
||||
|
</template> |
||||
|
<style lang="scss" scoped> |
||||
|
.el-row { |
||||
|
width: 100%; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,59 @@ |
|||||
|
<!-- |
||||
|
@ 作者: 秦东 |
||||
|
@ 时间: 2025-03-21 10:48:18 |
||||
|
@ 备注: 角色组件 |
||||
|
--> |
||||
|
<script lang='ts' setup> |
||||
|
import { gainRoleList } from '@/api/hr/org/index' |
||||
|
const props = withDefaults( |
||||
|
defineProps<{ |
||||
|
data: FormList |
||||
|
tablekey: any |
||||
|
numrun?: number |
||||
|
modelValue?: any // 子表和弹性布局时时有传 |
||||
|
tProp?: string // 子表时的form-item的prop值,用于子表校验用 |
||||
|
}>(), |
||||
|
{} |
||||
|
) |
||||
|
const emits = defineEmits<{ |
||||
|
(e: 'update:modelValue', numVal: any): void |
||||
|
}>() |
||||
|
const value = computed({ |
||||
|
get: () => { |
||||
|
if (props.modelValue != "" && props.modelValue != undefined){ |
||||
|
return props.modelValue*1 |
||||
|
}else{ |
||||
|
return props.modelValue |
||||
|
} |
||||
|
}, |
||||
|
set: (newVal: any) => { |
||||
|
emits('update:modelValue', newVal) |
||||
|
}, |
||||
|
}); |
||||
|
const roleLoading = ref(false); //加载行政组织树 |
||||
|
const roleLiet = ref([]); |
||||
|
onBeforeMount(() => { |
||||
|
roleLoading.value = true; |
||||
|
gainRoleList() |
||||
|
.then(({ data }) => { |
||||
|
console.log("角色列表", data); |
||||
|
roleLiet.value = data; |
||||
|
}) |
||||
|
.finally(() => { |
||||
|
roleLoading.value = false; |
||||
|
}); |
||||
|
}); |
||||
|
</script> |
||||
|
<template> |
||||
|
<el-select v-model="value" placeholder="请选择"> |
||||
|
<el-option |
||||
|
v-for="item in roleLiet" |
||||
|
:key="item.id" |
||||
|
:label="item.name" |
||||
|
:value="item.id" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</template> |
||||
|
<style lang='scss' scoped> |
||||
|
|
||||
|
</style> |
||||
Loading…
Reference in new issue