Merge remote-tracking branch 'origin/main'
This commit is contained in:
@ -29,6 +29,8 @@
|
||||
|
||||
显示源窗体中的编辑控件,双击控件节点时,在 [脚本编辑器](#脚本编辑器) 的当前光标位置增加控件名称,支持节点拖动
|
||||
|
||||

|
||||
|
||||
### 脚本编辑区
|
||||
|
||||
编辑脚本的地方。 编辑时支持模糊匹 **配控件区** 的控件名和 **函数/变量区** 的函数或变量名;
|
||||
@ -79,8 +81,30 @@ end.
|
||||
|
||||
显示系统支持的变量和函数,双击节点时,在 **脚本编辑区** 的当前光标位置增加变量或函数名称,鼠标移到树节点时,提示信息窗显示变量类型或函数原型,支持节点拖动
|
||||
|
||||

|
||||

|
||||
|
||||
#### 执行sql获取字符串
|
||||
|
||||
此函数作用为执行 `SQL` 语句,去获取字符串结果
|
||||
|
||||
案例如下
|
||||
|
||||
```delphi
|
||||
chiGetFieldValueBySql('select top 1 usr_sqlmj from pdmitem where usr_sqlmj like ''%' + str + '%''')
|
||||
```
|
||||
|
||||
#### 执行sql填充下拉框
|
||||
|
||||
此函数作用为执行 `SQL` 语句,将获取到的结果作为下拉选项提供给下拉框,需要写入两个参数,第一个为 `SQL` 语句,第二个为要接收结果的控件(接收结果的控件,其 **按钮类型** 必须为 **下拉**,详见 [根据输入内容在数据库中查询,获取查询结果作为下拉列表以供选择](999.Delphi脚本记录.md#根据输入内容在数据库中查询,获取查询结果作为下拉列表以供选择) 说明 )
|
||||
|
||||
案例如下:
|
||||
|
||||
```delphi
|
||||
chiFillComboBox('select distinct top 10 usr_sqlmj from pdmitem where usr_sqlmj like ''%' + str + '%''',fedtusr_sqlmj);
|
||||
```
|
||||
|
||||
### 错误提示区
|
||||
|
||||
执行 **保存** 或 **检查语法正确性** 命令时,如果脚本存在错误,则错误信息被显示在 **错误提示区**,双击错信息行时,在 **脚本编辑区** 中对于的错误行用红色背景标记
|
||||
执行 **保存** 或 **检查语法正确性** 命令时,如果脚本存在错误,则错误信息被显示在 **错误提示区**,双击错信息行时,在 **脚本编辑区** 中对于的错误行用红色背景标记
|
||||
|
||||

|
@ -567,4 +567,98 @@ begin
|
||||
|
||||
fedtFShtName.Text := TempStr; // 直接赋值
|
||||
end.
|
||||
```
|
||||
```
|
||||
|
||||
## 删除文本中的空格
|
||||
|
||||
删除掉指定控件中输入的文本的空格
|
||||
|
||||
```delphi
|
||||
uses
|
||||
MyClass, Variables, BaseUtil, CommonFunc, DataConst, CFFrm, CFSimplePropFrm,
|
||||
Forms, StdCtrls, Variants, SysUtils, Classes, Controls, Dialogs,
|
||||
CHostIntf, ProductClas, DocClas, LoginClas, VirtualTrees, CEntClas, PathClas;
|
||||
|
||||
// 在begin之前定义过程
|
||||
procedure RemoveSpacesFromEdit(EditControl: TCustomEdit);
|
||||
var
|
||||
OriginalText: string;
|
||||
begin
|
||||
OriginalText := EditControl.Text;
|
||||
// 使用StringReplace函数删除所有空格
|
||||
EditControl.Text := StringReplace(OriginalText, ' ', '', [rfReplaceAll]);
|
||||
end;
|
||||
|
||||
begin
|
||||
// 调用过程处理edtSpec控件
|
||||
RemoveSpacesFromEdit(edtSpec);
|
||||
end.
|
||||
```
|
||||
|
||||
### 删除其他空白字符
|
||||
|
||||
如果需要删除其他空白字符(如制表符、换行符),可以修改过程为
|
||||
|
||||
```delphi
|
||||
uses
|
||||
MyClass, Variables, BaseUtil, CommonFunc, DataConst, CFFrm, CFSimplePropFrm,
|
||||
Forms, StdCtrls, Variants, SysUtils, Classes, Controls, Dialogs,
|
||||
CHostIntf, ProductClas, DocClas, LoginClas, VirtualTrees, CEntClas, PathClas;
|
||||
|
||||
// 在begin之前定义过程
|
||||
procedure RemoveSpacesFromEdit(EditControl: TCustomEdit);
|
||||
var
|
||||
OriginalText: string;
|
||||
begin
|
||||
OriginalText := EditControl.Text;
|
||||
// 删除所有空白字符
|
||||
OriginalText := StringReplace(OriginalText, ' ', '', [rfReplaceAll]);
|
||||
// 制表符
|
||||
OriginalText := StringReplace(OriginalText, #9, '', [rfReplaceAll]);
|
||||
// 换行符
|
||||
OriginalText := StringReplace(OriginalText, #13#10, '', [rfReplaceAll]);
|
||||
EditControl.Text := OriginalText;
|
||||
end;
|
||||
|
||||
begin
|
||||
// 调用过程处理edtSpec控件
|
||||
RemoveSpacesFromEdit(edtSpec);
|
||||
end.
|
||||
```
|
||||
|
||||
## 根据输入内容在数据库中查询,获取查询结果作为下拉列表以供选择
|
||||
|
||||
根据在 `fedtusr_sqlmj` 控件中输入的内容,在数据库中进行查询,并将查询结果去重后,列出头十条作为下拉选择,以供 `fedtusr_sqlmj` 控件选择
|
||||
|
||||
```delphi
|
||||
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,
|
||||
CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas;
|
||||
var
|
||||
str:string;
|
||||
begin
|
||||
|
||||
//注释:在下面添加您的脚本代码
|
||||
str := fedtusr_sqlmj.Text;
|
||||
if Length(str) > 0 then
|
||||
begin
|
||||
if Length(chiGetFieldValueBySql('select top 1 usr_sqlmj from pdmitem where usr_sqlmj like ''%' + str + '%''')) > 0 then
|
||||
begin
|
||||
chiFillComboBox('select distinct top 10 usr_sqlmj from pdmitem where usr_sqlmj like ''%' + str + '%''',fedtusr_sqlmj);
|
||||
end
|
||||
else
|
||||
begin
|
||||
chiFillComboBox('select ''''',fedtusr_sqlmj);
|
||||
end;
|
||||
end;
|
||||
end.
|
||||
```
|
||||
|
||||
### 前置要求
|
||||
|
||||
接收下拉选择的控件的 **按钮类型** 必须是 **下拉** 才行(属性的类型可以是文本,也可以是枚举,枚举要求枚举来源为空)
|
||||
|
||||

|
||||
|
||||
此外,脚本必须放在 **按钮** 的 **单击执行** 中
|
||||
|
||||

|
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101403.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101403.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 335 KiB |
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101452.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101452.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 294 KiB |
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101604.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710101604.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 274 KiB |
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104330.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104330.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 423 KiB |
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104426.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104426.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104559.png
Normal file
BIN
SanPinPLM/相关操作/4.0-other/assets/Pasted image 20250710104559.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 245 KiB |
Reference in New Issue
Block a user