<template>
	<!-- <uni-data-select class="uni-select" :localdata="deptData" @change="change" :clear="true" v-model="departid" placeholder="请选择部门"/> -->
	<uni-combox :candidates="candidates" placeholder="请选择部门"  @input="change" v-model="departid"></uni-combox>
</template>

<script>
	export default {
		data() {
			return {
				departid: '',
				deptData: [],
				candidates:[]
			}
		},
		created() {
			this.getDpartment()
		},
		methods: {
			getDpartment() {
				this.$http.get("Department/GetDeptList",{token: uni.getStorageSync("token")}).then((res)=>{
					if(res.state.toLowerCase()==="success"){
						this.deptData = res.data
						res.data.forEach(v =>{
							this.candidates.push(v.F_DeptName)
						})
						// let resultData = res.data
						// resultData.forEach((element, index) => {
						//   const obj = {}
						//   obj.value = element.F_DeptId
						//   obj.text = element.F_DeptName
						//   this.deptData.push(obj);
						// });
					}
				})
			},
			change(data){
				let departid = ''
				this.deptData.forEach(v => {
					if(v.F_DeptName == data) {
						departid = v.F_DeptId
					}
				})
				this.$emit('post-select-data',departid)
			},
		}
	}
</script>

<style>

</style>
