<!--
@ 作者: 秦东
@ 时间: 2024-09-12 10:03:22
@ 备注: 行政组织选择
-->
<script lang='ts' setup>
import { orgInfo } from '@/api/hr/org/type'
import { getOrgTreeList } from '@/api/hr/org/index'

const props = withDefaults(
    defineProps<{
		modelValue?: string
		disabled?: boolean
    }>(),
    {}
)
const emits = defineEmits<{
    (e: 'update:modelValue', value: string): 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)
			// let newValJson:criteriaForPeopleList[] = JSON.parse(newVal)
			// if(newValJson.length > 0){
			// 	let userAry = new Array
			// 	let userKeyAry = new Array
			// 	newValJson.forEach(item =>{
			// 		userAry.push(item.name+"("+item.number+")")
			// 		userKeyAry.push(item.userkey.toString())
			// 	})
			// 	emits('update:modelValue', userAry.join(','))
			// 	// userlist.value = userAry.join(',')
			// 	// 
			// }else{
			// 	emits('update:modelValue', "")
			// }
	},
});
const orgTreeList = ref<orgInfo[]>();	
const orgTreeLoading = ref(false);	//加载行政组织树
const orgTreeProps ={
  children: 'child',
  label: 'name',
}	//行政组织树对照值

function haveOrgTreeInfo(){
	orgTreeLoading.value = true;
	getOrgTreeList({"orgid": 309})
		.then(({ data })=>{
			orgTreeList.value = data
		}).finally(()=>{orgTreeLoading.value = false;})
}

onBeforeMount(() => {
	haveOrgTreeInfo();
})






onMounted(() => {
	// console.log("value---1--》",value.value,props.modelValue)
    nextTick(() => {})
})
</script>
<template>
	<el-tree-select
		v-bind="$props"
		v-model="value"
		v-loading="orgTreeLoading" 
		node-key="id"
		:props="orgTreeProps" 
		:data="orgTreeList"
		check-strictly
		:render-after-expand="false"
	/>
</template>
<style  lang='scss' scoped>

</style>
