|
|
|
@ -2,11 +2,75 @@ package apelet.association.plugin.businessOpportunities; |
|
|
|
|
|
|
|
|
|
|
|
import apelet.common.core.object.ObjectValue; |
|
|
|
import apelet.common.core.object.ObjectValue; |
|
|
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
|
|
|
import apelet.common.online.abstractplugin.ExecutePluginParent; |
|
|
|
|
|
|
|
import apelet.common.online.model.constant.AttributeEnum; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
public class BusinessFromPlugin extends ExecutePluginParent { |
|
|
|
public class BusinessFromPlugin extends ExecutePluginParent { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
|
|
|
public void formCreated(String widgetVariableName, ObjectValue objectValue) { |
|
|
|
super.formCreated(widgetVariableName, objectValue); |
|
|
|
super.formCreated(widgetVariableName, objectValue); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 线索字段(clueId)变更事件 |
|
|
|
|
|
|
|
* 选择线索后,根据传入的线索id查询线索表 member_clue, |
|
|
|
|
|
|
|
* 将线索表与商机表单 business_opportunities 共有的字段反写回表单 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void change(String widgetVariableName, ObjectValue objectValue) { |
|
|
|
|
|
|
|
super.change(widgetVariableName, objectValue); |
|
|
|
|
|
|
|
if (!"clueId".equals(widgetVariableName)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Map masterData = getDto().getModel().getMasterData(); |
|
|
|
|
|
|
|
Object clueIdObj = masterData.get("clue_id"); |
|
|
|
|
|
|
|
if (clueIdObj == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String clueId; |
|
|
|
|
|
|
|
if (clueIdObj instanceof JSONObject) { |
|
|
|
|
|
|
|
Object idObj = ((JSONObject) clueIdObj).get("id"); |
|
|
|
|
|
|
|
if (idObj == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
clueId = idObj.toString(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
clueId = clueIdObj.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ObjectValue clue = ormGenDataSourceUtil().queryOne("member_clue", clueId); |
|
|
|
|
|
|
|
if (clue == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setIfNotBlank("number", clue.getString("number")); |
|
|
|
|
|
|
|
setIfNotBlank("name", clue.getString("name")); |
|
|
|
|
|
|
|
setIfNotBlank("seekType", clue.getString("seek_type")); |
|
|
|
|
|
|
|
setIfNotBlank("seekInfo", clue.getString("seek_info")); |
|
|
|
|
|
|
|
setIfNotBlank("nextPlan", clue.getString("next_plan")); |
|
|
|
|
|
|
|
setIfNotBlank("clueType", clue.getString("clue_type")); |
|
|
|
|
|
|
|
String unitId = clue.getString("unit_id"); |
|
|
|
|
|
|
|
if (unitId != null && !unitId.isEmpty()) { |
|
|
|
|
|
|
|
ObjectValue unit = ormGenDataSourceUtil().queryOne("unit", unitId); |
|
|
|
|
|
|
|
if (unit != null) { |
|
|
|
|
|
|
|
Map<String, Object> unitMap = new HashMap<>(); |
|
|
|
|
|
|
|
unitMap.put("id", unitId); |
|
|
|
|
|
|
|
unitMap.put("name", unit.getString("name")); |
|
|
|
|
|
|
|
this.setWidgetAttribute("unitId", AttributeEnum.VALUE_CHANGE, unitMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 字段有值时才反写,避免空值触发INVALID_DATA_FIELD校验 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param widgetVariableName 表单字段变量名 |
|
|
|
|
|
|
|
* @param value 反写的值 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void setIfNotBlank(String widgetVariableName, Object value) { |
|
|
|
|
|
|
|
if (value != null && !"".equals(value.toString())) { |
|
|
|
|
|
|
|
this.setWidgetAttribute(widgetVariableName, AttributeEnum.VALUE_CHANGE, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|