数通智联化工云平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8 KiB

2 years ago
<!--
@ 作者: 秦东
@ 时间: 2023-07-20 13:49:22
@ 备注:
-->
<script lang='ts' setup>
import { computed, onMounted, nextTick } from 'vue'
2 years ago
import { criteriaForPeopleList } from '@/api/hr/org/type'
2 years ago
const props = withDefaults(
defineProps<{
modelValue?: string
disabled?: boolean
}>(),
{}
)
const emits = defineEmits<{
(e: 'update:modelValue', value: string): void
}>()
const userDialogEl = ref()
// const value:any = computed({
// get() {
// return props.modelValue
// },
// set(newVal: string) {
// emits('update:modelValue', newVal)
// }
// })
2 years ago
// const userlist = ref<any>("")
2 years ago
const value = computed({
2 years ago
get: () => {
console.log("value-get",props.modelValue)
// userlist.value = props.modelValue
return props.modelValue
},
2 years ago
set: (newVal: any) => {
2 years ago
console.log("value-set",newVal)
// emits('update:modelValue', newVal)
2 years ago
let newValJson:criteriaForPeopleList[] = JSON.parse(newVal)
2 years ago
console.log("value-newValJson",newValJson)
2 years ago
if(newValJson.length > 0){
let userAry = new Array
2 years ago
let userKeyAry = new Array
2 years ago
newValJson.forEach(item =>{
userAry.push(item.name+"("+item.number+")")
2 years ago
userKeyAry.push(item.userkey.toString())
2 years ago
})
2 years ago
emits('update:modelValue', userAry.join(','))
// userlist.value = userAry.join(',')
//
2 years ago
}
2 years ago
},
});
const openDialog = () => {
2 years ago
// console.log("value-----》",value.value)
2 years ago
userDialogEl.value.open()
}
onMounted(() => {
2 years ago
console.log("value---1--》",value.value,props.modelValue)
2 years ago
nextTick(() => {})
})
2 years ago
2 years ago
</script>
<template>
<el-input
placeholder="请选择用户或输入用户名称"
v-bind="$props"
2 years ago
v-model="value"
2 years ago
@click="openDialog"
>
<template #append>
<i class="icon-user" @click.stop="openDialog"></i>
</template>
</el-input>
<user-dialog ref="userDialogEl" v-model="value" />
</template>
<style lang='scss' scoped>
</style>