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

有光标所在内容发生改变的方法吗,目前用contentChange(当前内容发生改变),是整个界面的? #943

Closed
itjbh opened this issue Dec 24, 2024 · 10 comments
Labels
duplicate This issue or pull request already exists

Comments

@itjbh
Copy link

itjbh commented Dec 24, 2024

What problem does this feature solve?

有光标所在内容发生改变的方法吗,目前用contentChange(当前内容发生改变),是整个界面的?

What does the proposed API look like?

是否有类似的方法?

@Hufe921
Copy link
Owner

Hufe921 commented Dec 24, 2024

没有理解你说的意思,举例说明

@itjbh
Copy link
Author

itjbh commented Dec 24, 2024

感谢作者回复,
代码:instance.eventBus.on(
'contentChange',
() => {

            if(context) {
              let changeData = {
                conceptId: 'B1',
                value: 50
              }
              instance.command.executeSetControlValue(changeData)
            }
          }
        ),

需求:就是是否有监听'光标所在内容发生改变'的监听方法呢,目前我用的eventBus监听的contentChange,但是这个方法是看着是监听全局,导致某个文本内容变化时,调用方法改另一个文本内容时,会进入死循环,不知道作者有没看懂呢?

@Hufe921
Copy link
Owner

Hufe921 commented Dec 24, 2024

无法鉴定:光标所在内容发生改变 这个动作。
你可以说一下你的需求

@itjbh
Copy link
Author

itjbh commented Dec 24, 2024

因为医院的话有的需求是类似问卷调查一样的报告,
第一种:
NO1
输入左边子项分数,右边的分数会自动根据公式相加左边的;接着最下面的分数会汇总右边的
第二种:
NO2

点击左边单选或者复选框,根据赋值显示右边分数,接着最下面的分数会汇总右边的(目前这个根据已知文档的监听和方法可以完成

@itjbh
Copy link
Author

itjbh commented Dec 24, 2024

现在第一种我这边暂时没法弄出来 ,第二种用监听单选复选框属性+递归的方式可以弄出来

@MzoroHaHa
Copy link
Contributor

@itjbh 你试试使用监听controlChange, 然后 getControlList 获取所有control, 遍历计算值, 再 executeSetControlValue

@itjbh
Copy link
Author

itjbh commented Dec 25, 2024

看着应该可以,但是有2个问题:
1.首次点击这个文本框获取这个控件的属性之后,填入相关的文本如“ABC”,这时候另一个文本框想要根据'ABC'变更数据,就要去获取这个'ABC'就要去getControlValue获取值,并且无法知道用户什么时候填完数据,只能说等待用下一次的点击事件判断2次的控件是否相同再去更新,
2.无法实时监听和更新,使用contentChange的话全局监听,好像不太适合我上面的应用场景,所以我上面说监听‘光标所在控件’即可.不知道是否可行呢?

@Hufe921
Copy link
Owner

Hufe921 commented Dec 25, 2024

@itjbh 你试试使用监听controlChange, 然后 getControlList 获取所有control, 遍历计算值, 再 executeSetControlValue

可以用这种方式 再失去光标焦点的时候 去做处理。官方的规则配置,等待后续更新。

@Hufe921
Copy link
Owner

Hufe921 commented Dec 25, 2024

重复:#671

@Hufe921 Hufe921 closed this as completed Dec 25, 2024
@Hufe921 Hufe921 added duplicate This issue or pull request already exists and removed Awaiting Details labels Dec 25, 2024
@itjbh
Copy link
Author

itjbh commented Dec 25, 2024

意思就是后期加这个动态控件吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants