138 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Java
		
	
	
	
			
		
		
	
	
			138 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			Java
		
	
	
	
package tqq9.lc123.cloud.app.plugin.form.sys;
 | 
						|
 | 
						|
import com.alibaba.fastjson.JSON;
 | 
						|
import kd.bos.bill.AbstractBillPlugIn;
 | 
						|
import kd.bos.dataentity.entity.DynamicObject;
 | 
						|
import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
						|
import kd.bos.dataentity.entity.LocaleString;
 | 
						|
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
 | 
						|
import kd.bos.form.control.events.ItemClickEvent;
 | 
						|
import kd.bos.form.field.ComboEdit;
 | 
						|
import kd.bos.form.field.ComboItem;
 | 
						|
import kd.bos.logging.Log;
 | 
						|
import kd.bos.logging.LogFactory;
 | 
						|
import kd.bos.servicehelper.BusinessDataServiceHelper;
 | 
						|
import org.apache.commons.lang3.StringUtils;
 | 
						|
 | 
						|
import java.util.*;
 | 
						|
 | 
						|
/**
 | 
						|
 * 注册证界面插件
 | 
						|
 *      厂商许可证号动态添加下拉框选项
 | 
						|
 */
 | 
						|
public class RegistBillFactoryPlugin extends AbstractBillPlugIn {
 | 
						|
    private final static Log logger = LogFactory.getLog(RegistBillFactoryPlugin.class);
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void registerListener(EventObject e) {
 | 
						|
        super.registerListener(e);
 | 
						|
        this.addItemClickListeners("tqq9_advcontoolbarap");
 | 
						|
    }
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void afterBindData(EventObject e) {
 | 
						|
        super.afterBindData(e);
 | 
						|
        String tqq9_type = (String) this.getModel().getValue("tqq9_type");
 | 
						|
        if("A".equals(tqq9_type)){
 | 
						|
            //如果是总代,加载总代的许可证号
 | 
						|
            String tqq9_proxyno = (String) this.getModel().getValue("tqq9_proxyno");
 | 
						|
            DynamicObject tqq9_supplier = (DynamicObject) this.getModel().getValue("tqq9_proxy");//生产厂家
 | 
						|
            ComboEdit comboEdit = this.getControl("tqq9_proxyno");
 | 
						|
            comboEdit.setText(tqq9_proxyno);
 | 
						|
            setProxyField(tqq9_supplier, "tqq9_proxyno", comboEdit);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void propertyChanged(PropertyChangedArgs e) {
 | 
						|
        super.propertyChanged(e);
 | 
						|
        String name = e.getProperty().getName();
 | 
						|
        if("tqq9_supplier".equals(name)){
 | 
						|
            //动态添加厂商的许可证号
 | 
						|
            ComboEdit comboEdit = this.getControl("tqq9_supno");
 | 
						|
            DynamicObject tqq9_supplier = (DynamicObject) this.getModel().getValue("tqq9_supplier");//生产厂家
 | 
						|
            setProxyField(tqq9_supplier, "tqq9_supno", comboEdit);
 | 
						|
        }else if("tqq9_proxy".equals(name)){
 | 
						|
            //动态添加总代的许可证号
 | 
						|
            ComboEdit comboEdit = this.getControl("tqq9_proxyno");
 | 
						|
            DynamicObject tqq9_supplier = (DynamicObject) this.getModel().getValue("tqq9_proxy");//生产厂家
 | 
						|
            setProxyField(tqq9_supplier, "tqq9_proxyno", comboEdit);
 | 
						|
        }
 | 
						|
 | 
						|
    }
 | 
						|
 | 
						|
    private void setProxyField(DynamicObject tqq9_supplier, String fieldName, ComboEdit comboEdit) {
 | 
						|
        if(tqq9_supplier != null){
 | 
						|
            tqq9_supplier = BusinessDataServiceHelper.loadSingle(tqq9_supplier.getPkValue(), tqq9_supplier.getDynamicObjectType().getName());
 | 
						|
 | 
						|
            String tqq9_taxno = tqq9_supplier.getString("tqq9_taxno");//税号
 | 
						|
            String tqq9_prolicense = tqq9_supplier.getString("tqq9_prolicense");//医疗器械生产许可证号
 | 
						|
            String tqq9_saleno = tqq9_supplier.getString("tqq9_saleno");//医疗器械经营许可证号
 | 
						|
            String tqq9_recordoneno = tqq9_supplier.getString("tqq9_recordoneno");//第一类器械备案号
 | 
						|
            String tqq9_recordtwono = tqq9_supplier.getString("tqq9_recordtwono");//第二类器械备案号
 | 
						|
            String tqq9_safeno = tqq9_supplier.getString("tqq9_safeno");//安全许可证号
 | 
						|
            String tqq9_beautyno = tqq9_supplier.getString("tqq9_beautyno");//化妆品许可证
 | 
						|
            DynamicObjectCollection tqq9_clnentries = tqq9_supplier.getDynamicObjectCollection("tqq9_clnentry");//卫生许可证明细
 | 
						|
 | 
						|
            List<ComboItem> comboItems = new ArrayList<>();
 | 
						|
            addItem(tqq9_taxno, comboItems);
 | 
						|
            addItem(tqq9_prolicense, comboItems);
 | 
						|
            addItem(tqq9_saleno, comboItems);
 | 
						|
            addItem(tqq9_recordoneno, comboItems);
 | 
						|
            addItem(tqq9_recordtwono, comboItems);
 | 
						|
            addItem(tqq9_safeno, comboItems);
 | 
						|
            addItem(tqq9_beautyno, comboItems);
 | 
						|
            for (DynamicObject entry : tqq9_clnentries) {
 | 
						|
                String tqq9_clnno = entry.getString("tqq9_clnno");
 | 
						|
                addItem(tqq9_clnno, comboItems);
 | 
						|
            }
 | 
						|
            comboEdit.setComboItems(comboItems);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    private static void addItem(String value, List<ComboItem> comboItems) {
 | 
						|
        if(StringUtils.isNotBlank(value)){
 | 
						|
            ComboItem comboItem = new ComboItem();
 | 
						|
            comboItem.setCaption(new LocaleString(value));
 | 
						|
            comboItem.setValue(value);
 | 
						|
            comboItems.add(comboItem);
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
    @Override
 | 
						|
    public void itemClick(ItemClickEvent evt) {
 | 
						|
        super.itemClick(evt);
 | 
						|
        String itemKey = evt.getItemKey();
 | 
						|
        if("tqq9_additem".equals(itemKey)){
 | 
						|
            DynamicObject tqq9_supplier = (DynamicObject) this.getModel().getValue("tqq9_supplier");
 | 
						|
            String tqq9_supno = (String) this.getModel().getValue("tqq9_supno");
 | 
						|
            if(tqq9_supplier != null && StringUtils.isNotBlank(tqq9_supno)){
 | 
						|
                DynamicObjectCollection entries = this.getModel().getDataEntity(true).getDynamicObjectCollection("tqq9_entry");
 | 
						|
                Set<Long> eSupIDSet = new HashSet<>();
 | 
						|
                if(entries != null && entries.size() > 0){
 | 
						|
                    for (DynamicObject entry : entries) {
 | 
						|
                        Long eSupID = entry.getDynamicObject("tqq9_e_supplier").getLong("id");
 | 
						|
                        eSupIDSet.add(eSupID);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if(eSupIDSet.contains(tqq9_supplier.getLong("id"))){
 | 
						|
                    this.getView().showTipNotification("已经添加过该厂家,不需要重复添加!");
 | 
						|
                }else{
 | 
						|
                    DynamicObject entry = entries.addNew();
 | 
						|
                    entry.set("tqq9_e_supplier", tqq9_supplier);
 | 
						|
                    entry.set("tqq9_e_supno", tqq9_supno);
 | 
						|
 | 
						|
                    this.getModel().setValue("tqq9_supplier", null);
 | 
						|
                    ComboEdit comboEdit = this.getControl("tqq9_supno");
 | 
						|
                    comboEdit.setComboItems(null);
 | 
						|
                    this.getView().updateView("tqq9_entry");
 | 
						|
                    this.getView().updateView();
 | 
						|
                }
 | 
						|
            }else{
 | 
						|
                this.getView().showTipNotification("请选择生产商和对应的许可证号!");
 | 
						|
            }
 | 
						|
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |