Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛[BUG] ProeditProtable期望select切换为某个值,展示input框提供输入,实例输入input后值被莫名拦截赋值select #8706

Open
huaihuahua-xu opened this issue Sep 5, 2024 · 0 comments

Comments

@huaihuahua-xu
Copy link

问题已解决,写出来当个思路给后来人看看,有权限大佬看到翻转下状态
需求:当 select选中为'3'时,展示input框,输入数据保存
问题:切换为input后,输入除了‘3’,任何值都会将状态赋值给constant.comPanyType,导致input框消失,一直没找到原因
解决方案: input内的onChange事件阻止冒泡e.stopPopagition即可解决,并利用setRowData将值保存到inputVal

const options = [
{ value: '1', label: '股份有限公司' },
{ value: '2', label: '私有公司' },
{ value: '3', label: '其他' }
]

const handleSelect = (val: any, constant: any) => {
ref?.current?.setRowData(constant.recordKey, { comPanyType: val })
}

const columns = [
{
title: '公司类型',
dataIndex: 'companyType',
width: '15%',
renderFormItem: (_: any, constant: any) => {
const {
record: { companyType, inputVal = '' } // 本身没有inputVal,期望用来存input的数据
} = constant
return (


<Select
option={options}
onSelect={(val) => {
handleSelect(val, constant)
}}
showSearch={false}
/>
{companyType === '3' && }

)
}
}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant