Files
laws_chery_client/src/components/selection/UserSelectByContact.vue
T
2024-06-11 15:39:01 +08:00

134 lines
2.7 KiB
Vue

<template>
<div>
<div class="user-organ-wrap">
<a-input
:type="inputType"
:autoSize="true"
:rows="1"
readOnly
:disabled="disabled"
:class="{
'input-readonly': !disabled,
'user-input': showBtn
}"
:placeholder="placeholder"
:value="checkedValue"
@click="selectClick"
:title="checkedValue"
>
</a-input>
<a-button type="primary" class="button-box" @click="selectClick" :disabled="disabled" v-if="showBtn && !disabled">
{{ $t('userSelect.select') }}
</a-button>
</div>
<user-select-by-contact-modal v-bind="$attrs" :nameStr="nameStr" ref="selectModal" @change="selectChange" @listChange="listChange" @nameChange="nameChange"></user-select-by-contact-modal>
</div>
</template>
<script>
import UserSelectByContactModal from './UserSelectByContactModal'
export default {
name: 'UserSelectByContact',
components: { UserSelectByContactModal },
props: {
disabled: {
type: Boolean,
default: false
},
placeholder: {
type: String,
default: ''
},
value: {
type: String,
default: () => {
return ''
}
},
// 名字字符串
nameStr: {
type: String,
default: ''
},
// 修改的字段名
filedName: {
type: [String, Number],
default: ''
},
// 回显输入框的类型,默认是input
inputType: {
type: String,
required: false,
default: 'text'
},
// 是否展示按钮
showBtn: {
type: Boolean,
required: false,
default: true
}
},
watch: {
nameStr: {
immediate: true,
handler (val) {
this.checkedValue = val
}
}
},
data () {
return {
checkedValue: ''
}
},
methods: {
selectClick () {
// 禁用后不弹框
if (this.disabled) {
return
}
this.$refs.selectModal.open(this.value)
},
selectChange (ids) {
this.$emit('change', ids)
},
listChange (value) {
this.$emit('listChange', value)
},
nameChange (value) {
this.checkedValue = value
this.$emit('nameChange', value, this.filedName)
}
},
model: {
prop: 'value',
event: 'change'
}
}
</script>
<style scoped lang="less">
.user-organ-wrap {
width: 100%;
position: relative;
display: flex;
align-items: center;
//height: 39.98px;
.user-input {
resize: none;
width: calc(100% - 70px);
}
// 因为需要加title,所以不能把鼠标事件去掉
/deep/ .input-readonly.ant-input-disabled {
background: #fff;
color: rgba(0, 0, 0, 0.65);
cursor: default;
}
.button-box {
margin-left: 5px;
}
}
</style>