Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
xuhaihui 2025-06-17 18:04:12 +08:00
commit e49011a7e7
2 changed files with 232 additions and 77 deletions

View File

@ -11,6 +11,7 @@ import kd.bos.entity.datamodel.ListSelectedRow;
import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.datamodel.ListSelectedRowCollection;
import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.CloseCallBack; import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowFormHelper; import kd.bos.form.ShowFormHelper;
import kd.bos.form.ShowType; import kd.bos.form.ShowType;
import kd.bos.form.control.EntryGrid; import kd.bos.form.control.EntryGrid;
@ -51,6 +52,8 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
this.showInvoiceImport(args); this.showInvoiceImport(args);
} else if (key.equals("deletesubentry")) { } else if (key.equals("deletesubentry")) {
this.beforeDeleteSubEntry(args); this.beforeDeleteSubEntry(args);
} else if (key.equals("addnewentry")) {
this.beforeAddNewEntry(args);
} }
} }
@ -62,6 +65,8 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
this.invoiceCloseCallBack(event); this.invoiceCloseCallBack(event);
} else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) { } else if (actionId.toLowerCase().startsWith("selectinvoice") && returnData != null) {
this.importInvoiceCallBack(returnData); this.importInvoiceCallBack(returnData);
} else if (actionId.toLowerCase().startsWith("tb_new") && returnData != null) {
this.importMaintenanceCallBack(returnData);
} }
} }
@ -320,6 +325,59 @@ public class MaintenanceAckBillPlugin extends AbstractBillPlugIn implements Plug
} }
//删除发票 结束 //删除发票 结束
protected void beforeAddNewEntry(BeforeDoOperationEventArgs args) {
Object value = this.getModel().getValue("zcgj_maintenance");
if (value != null) {
DynamicObject maintenance = (DynamicObject) value;
QFilter filter = new QFilter("zcgj_maintenance.id", QCP.equals, maintenance.getLong("id"));
DynamicObject[] maintenanceackbill = BusinessDataServiceHelper.load("zcgj_maintenanceackbill", "entryentity.zcgj_sourceid", new QFilter[]{filter});
Set set = new HashSet();
set.add("9999999");
for (DynamicObject dynamicObject : maintenanceackbill) {
for (DynamicObject object : dynamicObject.getDynamicObjectCollection("entryentity")) {
set.add(object.getString("zcgj_sourceid"));
}
}
DynamicObjectCollection entryentity = (DynamicObjectCollection) getModel().getEntryEntity("entryentity");
for (DynamicObject dynamicObject : entryentity) {
String sourceid = dynamicObject.getString("zcgj_sourceid");
set.add(sourceid);
}
FormShowParameter formShowParameter = new FormShowParameter();
// 弹窗案例-动态表单 页面标识
formShowParameter.setFormId("zcgj_repairselection");
// 自定义传参把当前单据的文本字段传过去
formShowParameter.setCustomParam("set", set);
formShowParameter.setCustomParam("id", maintenance.getLong("id"));
// 设置回调事件回调插件为当前插件标识为zcgj_
formShowParameter.setCloseCallBack(new CloseCallBack(this, "tb_new"));
// 设置打开类型为模态框不设置的话指令参数缺失没办法打开页面
formShowParameter.getOpenStyle().setShowType(ShowType.Modal);
// 当前页面发送showform指令注意也可以从其他页面发送指令后续有文章介绍
this.getView().showForm(formShowParameter);
}else{
this.getView().showErrorNotification("请先选择关联维修申请单!");
args.setCancel(true);
}
}
protected void importMaintenanceCallBack(Object returnData) {
if (returnData!=null){
DynamicObjectCollection data = (DynamicObjectCollection) returnData;
for (DynamicObject datum : data) {
int i = this.getModel().createNewEntryRow("entryentity");
this.getModel().setValue("zcgj_equipment", datum.getDynamicObject("zcgj_equipment"), i);
this.getModel().setValue("zcgj_fault", datum.getString("zcgj_fault"), i);
this.getModel().setValue("zcgj_faultreason", datum.getString("zcgj_faultreason"), i);
this.getModel().setValue("zcgj_amount", datum.getBigDecimal("zcgj_amount"), i);
this.getModel().setValue("zcgj_contacts", datum.getString("zcgj_contacts"), i);
this.getModel().setValue("zcgj_supplier", datum.getDynamicObject("zcgj_supplier"), i);
this.getModel().setValue("zcgj_sourceid", datum.getString("zcgj_sourceid"), i);
}
}
}
@Override @Override
public void propertyChanged(PropertyChangedArgs e) { public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e); super.propertyChanged(e);

View File

@ -0,0 +1,97 @@
package zcgj.zcdev.zcdev.pr.plugin.form;
import com.alibaba.fastjson.JSONArray;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.form.control.Button;
import kd.bos.form.control.Control;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.control.events.CellClickEvent;
import kd.bos.form.control.events.CellClickListener;
import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.EventObject;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class RepairSelectionFromPlugin extends AbstractFormPlugin implements CellClickListener {
@Override
public void cellClick(CellClickEvent cellClickEvent) {
}
@Override
public void cellDoubleClick(CellClickEvent cellClickEvent) {
}
@Override
public void afterCreateNewData(EventObject e) {
super.afterCreateNewData(e);
Map<String, Object> customParams = this.getView().getFormShowParameter().getCustomParams();
Object set = customParams.get("set");
Object id = customParams.get("id");
if (set != null) {
Set source = new HashSet();
JSONArray objects = JSONArray.parseArray(set.toString());
for (Object object : objects) {
source.add(object);
}
QFilter qf = new QFilter("id", QCP.equals, Long.valueOf(id.toString()));
DynamicObject maintenancebill = BusinessDataServiceHelper.loadSingle("zcgj_maintenancebill", new QFilter[]{qf});
DynamicObjectCollection maintenanceentry = maintenancebill.getDynamicObjectCollection("entryentity");
maintenanceentry.removeIf(entry -> source.contains(entry.getString("id")));//去除之前单据已有的数据
DynamicObjectCollection entryentity = (DynamicObjectCollection) getModel().getValue("zcgj_entryentity");
entryentity.clear();
for (int i = 0; i < maintenanceentry.size(); i++) {
DynamicObject object = maintenanceentry.get(i);
i = this.getModel().createNewEntryRow("zcgj_entryentity");
this.getModel().setValue("zcgj_equipment", object.getDynamicObject("zcgj_equipment"), i);
this.getModel().setValue("zcgj_fault", object.getString("zcgj_fault"), i);
this.getModel().setValue("zcgj_faultreason", object.getString("zcgj_faultreason"), i);
this.getModel().setValue("zcgj_amount", object.getBigDecimal("zcgj_amount"), i);
this.getModel().setValue("zcgj_contacts", object.getString("zcgj_contacts"), i);
this.getModel().setValue("zcgj_supplier", object.getDynamicObject("zcgj_supplier"), i);
this.getModel().setValue("zcgj_sourceid", object.getString("id"), i);
}
}
}
@Override
public void registerListener(EventObject e) {
super.registerListener(e);
Button btnok = this.getControl("btnok");//确定
btnok.addClickListener(this);
}
@Override
public void click(EventObject evt) {
super.click(evt);
Control source = (Control) evt.getSource();
String key = source.getKey();
if(key.equals("btnok")){
EntryGrid entryGrid = this.getControl("zcgj_entryentity");
int[] selectRows = entryGrid.getSelectRows();
int count = selectRows.length;
//分录行数只有一条的时候才能通过接下来两个if
if (count == 0) {
this.getView().showErrorNotification("请选择至少一条维修申请信息!");
return;
}
DynamicObjectCollection qeug_entryentity = getModel().getEntryEntity("zcgj_entryentity");//分录
DynamicObjectCollection collection = new DynamicObjectCollection();
for (int selectRow : selectRows) {
collection.add(qeug_entryentity.get(selectRow));
}
this.getView().returnDataToParent(collection);
this.getView().close();
} else if (key.equals("btncancel")) {
this.getView().close();
}
}
}