package yem.wm.cm.ht.form;

import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.LocaleString;
import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;

/**
 * 条款类型：给名称赋值
 * @author zhangh
 *
 */
public class ClauseTypeFormPlugin extends AbstractBillPlugIn {

	@Override
	public void propertyChanged(PropertyChangedArgs e) {
		String name = e.getProperty().getName();
		switch (name) {
		case "yem_chinanum"://中文序号
		case "yem_clausename"://条款名称
		case "yem_english"://条款英文名称
			this.setClauseName();//给标准名称赋值
			break;
		default:
			break;
		}
	}

	/**
	 * 给标准名称赋值
	 */
	private void setClauseName() {
		IDataModel model = this.getModel();
		String yem_chinanum = (String) this.getModel().getValue("yem_chinanum");
		String yem_clausename = (String) this.getModel().getValue("yem_clausename");
		String yem_english = (String) this.getModel().getValue("yem_english");
		//英文名不为空时
		if (StringUtils.isNotEmpty(yem_english)) {
			LocaleString locStr = new LocaleString();
			locStr.setLocaleValue_zh_CN(yem_chinanum + "、" + yem_clausename);
			locStr.setLocaleValue_en(yem_english);
			this.getModel().setValue("name", locStr);
		}else {
			this.getModel().setValue("name", yem_chinanum + "、" + yem_clausename);
		}
	}
}
