|
|
@@ -84,6 +84,8 @@ public class ContractMiniAppAction extends RequestAbs {
|
|
|
rv = getContractTypeList(json);
|
|
|
} else if ("getPaymentTypeList".equals(task)) {
|
|
|
rv = getPaymentTypeList(json);
|
|
|
+ } else if ("selectClient".equals(task)) {
|
|
|
+ rv = selectClient(json);
|
|
|
} else {
|
|
|
rv = new ResultVo();
|
|
|
rv.setReturnCode("-1");
|
|
|
@@ -269,7 +271,12 @@ public class ContractMiniAppAction extends RequestAbs {
|
|
|
String supplierName = formData.optString("supplierName", "");
|
|
|
if (StringUtils.isNotEmpty(supplierName)) {
|
|
|
contractInfo.setSupplierName(supplierName);
|
|
|
- contractInfo.setSecondparty_name(supplierName);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置供方名称(从 secondparty_name 字段获取)
|
|
|
+ String secondpartyName = formData.optString("secondparty_name", "");
|
|
|
+ if (StringUtils.isNotEmpty(secondpartyName)) {
|
|
|
+ contractInfo.setSecondparty_name(secondpartyName);
|
|
|
}
|
|
|
|
|
|
String contractMoneyStr = formData.optString("contract_money", "");
|
|
|
@@ -676,6 +683,19 @@ public class ContractMiniAppAction extends RequestAbs {
|
|
|
contractInfoJson.put("contract_entrying_operator", contractInfo.getContract_entrying_operator());
|
|
|
contractInfoJson.put("unit_id", contractInfo.getUnit_id());
|
|
|
|
|
|
+ // 添加公司名称字段(用于销售合同时对调需方供方)
|
|
|
+ // 采购合同:firstparty_name=公司,secondparty_name=供应商
|
|
|
+ // 销售合同:firstparty_name=客户,secondparty_name=公司
|
|
|
+ String companyName = "";
|
|
|
+ if (contractInfo.getContract_type() != null && contractInfo.getContract_type() == 1) {
|
|
|
+ // 销售合同:从 secondparty_name 获取公司名称
|
|
|
+ companyName = contractInfo.getSecondparty_name() != null ? contractInfo.getSecondparty_name() : "";
|
|
|
+ } else {
|
|
|
+ // 采购合同或其他:从 firstparty_name 获取公司名称
|
|
|
+ companyName = contractInfo.getFirstparty_name() != null ? contractInfo.getFirstparty_name() : "";
|
|
|
+ }
|
|
|
+ contractInfoJson.put("companyName", companyName);
|
|
|
+
|
|
|
// 添加物料明细列表
|
|
|
JSONArray materialArray = new JSONArray();
|
|
|
if (contractMaterialList != null && !contractMaterialList.isEmpty()) {
|
|
|
@@ -803,6 +823,19 @@ public class ContractMiniAppAction extends RequestAbs {
|
|
|
// 设置录入人信息
|
|
|
contractInfoJson.put("contract_entrying_operator", contractInfo.getContract_entrying_operator());
|
|
|
contractInfoJson.put("unit_id", contractInfo.getUnit_id());
|
|
|
+
|
|
|
+ // 添加公司名称字段(用于销售合同时对调需方供方)
|
|
|
+ // 采购合同:firstparty_name=公司,secondparty_name=供应商
|
|
|
+ // 销售合同:firstparty_name=客户,secondparty_name=公司
|
|
|
+ String companyName = "";
|
|
|
+ if (contractInfo.getContract_type() != null && contractInfo.getContract_type() == 1) {
|
|
|
+ // 销售合同:从 secondparty_name 获取公司名称
|
|
|
+ companyName = contractInfo.getSecondparty_name() != null ? contractInfo.getSecondparty_name() : "";
|
|
|
+ } else {
|
|
|
+ // 采购合同或其他:从 firstparty_name 获取公司名称
|
|
|
+ companyName = contractInfo.getFirstparty_name() != null ? contractInfo.getFirstparty_name() : "";
|
|
|
+ }
|
|
|
+ contractInfoJson.put("companyName", companyName);
|
|
|
|
|
|
// 添加物料明细列表
|
|
|
JSONArray materialArray = new JSONArray();
|
|
|
@@ -1009,6 +1042,46 @@ public class ContractMiniAppAction extends RequestAbs {
|
|
|
return rv;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 选择客户(支持分页搜索)- 参考 PC 端实现
|
|
|
+ */
|
|
|
+ private ResultVo selectClient(JSONObject json) throws Exception {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ User user = getUserFromJson(json);
|
|
|
+
|
|
|
+ // 获取分页参数(参考 selectSupplier)
|
|
|
+ int page = json.optInt("page", 1);
|
|
|
+ int pageSize = json.optInt("pageSize", 20);
|
|
|
+ String clientName = json.optString("clientName", "");
|
|
|
+
|
|
|
+ MesCommonHelper mesCommonHelper = new MesCommonHelper();
|
|
|
+ org.json.JSONObject resp = mesCommonHelper.getClients(page, pageSize, clientName);
|
|
|
+ int total = resp.getInt("total");
|
|
|
+ // 获取 rows 数组
|
|
|
+ org.json.JSONArray rowsArray = resp.getJSONArray("rows");
|
|
|
+
|
|
|
+ // 转换为 List<Map<String, Object>>(参考 selectSupplier)
|
|
|
+ List<Map<String, Object>> clientList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < rowsArray.length(); i++) {
|
|
|
+ org.json.JSONObject jsonObject = rowsArray.getJSONObject(i);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ for (String key : jsonObject.keySet()) {
|
|
|
+ Object value = jsonObject.get(key);
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+ clientList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("list", clientList); // ✅ 返回对象列表,而不是 JSON 字符串
|
|
|
+ resultMap.put("total", total);
|
|
|
+
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(resultMap);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String getServiceId() {
|
|
|
return serviceId;
|