添加二维码复用
This commit is contained in:
parent
f4818e3a29
commit
0743f82756
|
|
@ -24,19 +24,20 @@ procedure SetQrCodePath(Cds: TclientDataSet; FQrCodeField: string);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure SetQrCodePath(Cds: TclientDataSet; FQrCodeField: string);
|
procedure SetQrCodePath(Cds: TClientDataSet; FQrCodeField: string);
|
||||||
var
|
var
|
||||||
QrCodeIdField: TField;
|
QrCodeIdField: TField;
|
||||||
|
CurrentQrCodeId, LastQrCodeId, LastQrCodePath: string;
|
||||||
begin
|
begin
|
||||||
// 检查是否存在二维码ID字段
|
// 检查二维码ID字段是否存在
|
||||||
if Trim(FQrCodeField) = '' then
|
|
||||||
Exit;
|
|
||||||
|
|
||||||
QrCodeIdField := Cds.FindField(FQrCodeField);
|
QrCodeIdField := Cds.FindField(FQrCodeField);
|
||||||
if QrCodeIdField = nil then
|
if QrCodeIdField = nil then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
// 生成二维码并绑定到ClientDataSet
|
// 初始化变量
|
||||||
|
LastQrCodeId := '';
|
||||||
|
LastQrCodePath := '';
|
||||||
|
|
||||||
with Cds do
|
with Cds do
|
||||||
begin
|
begin
|
||||||
DisableControls;
|
DisableControls;
|
||||||
|
|
@ -44,9 +45,25 @@ begin
|
||||||
First;
|
First;
|
||||||
while not Eof do
|
while not Eof do
|
||||||
begin
|
begin
|
||||||
Edit;
|
CurrentQrCodeId := QrCodeIdField.AsString;
|
||||||
FieldByName('QRBARCODE').AsString := GetQrCode(QrCodeIdField.AsString);
|
|
||||||
Post;
|
// 如果当前内容与上一条相同,则复用二维码路径
|
||||||
|
if (CurrentQrCodeId = LastQrCodeId) and (LastQrCodePath <> '') then
|
||||||
|
begin
|
||||||
|
Edit;
|
||||||
|
FieldByName('QRBARCODE').AsString := LastQrCodePath;
|
||||||
|
Post;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
// 生成新的二维码并记录路径
|
||||||
|
Edit;
|
||||||
|
LastQrCodePath := GetQrCode(CurrentQrCodeId);
|
||||||
|
FieldByName('QRBARCODE').AsString := LastQrCodePath;
|
||||||
|
Post;
|
||||||
|
LastQrCodeId := CurrentQrCodeId;
|
||||||
|
end;
|
||||||
|
|
||||||
Next;
|
Next;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user