Skip to content

Commit 3e50b1c

Browse files
committed
feat: Save fields
1 parent f82ab47 commit 3e50b1c

File tree

16 files changed

+280
-57
lines changed

16 files changed

+280
-57
lines changed

backend/crm/src/main/java/cn/cordys/common/constants/BusinessModuleField.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,50 @@ public enum BusinessModuleField {
193193
/*------ start: PRODUCT ------*/
194194
PRODUCT_NAME("productName", "name", Set.of("rules.required", "mobile"), FormKey.PRODUCT.getKey()),
195195
PRODUCT_PRICE("productPrice", "price", Set.of(), FormKey.PRODUCT.getKey()),
196-
PRODUCT_STATUS("productStatus", "status", Set.of("rules.required", "mobile"), FormKey.PRODUCT.getKey());
196+
PRODUCT_STATUS("productStatus", "status", Set.of("rules.required", "mobile"), FormKey.PRODUCT.getKey()),
197197
/*------ end: PRODUCT ------*/
198+
199+
/**
200+
* 价格表单
201+
*/
202+
PRICE_NAME("priceName", "name", Set.of("rules.required", "mobile"), FormKey.PRICE.getKey()),
203+
PRICE_STATUS("priceStatus", "status", Set.of("rules.required", "mobile"), FormKey.PRICE.getKey()),
204+
PRICE_PRODUCT_TABLE("priceProducts", "products", Set.of("mobile"), FormKey.PRICE.getKey()),
205+
PRICE_PRODUCT("priceProduct", "product", Set.of("rules.required", "mobile", "dataSourceType"), FormKey.PRICE.getKey()),
206+
PRICE_PRODUCT_AMOUNT("priceProductAmount", "amount", Set.of("rules.required", "mobile"), FormKey.PRICE.getKey()),
207+
208+
/**
209+
* 报价单表单
210+
*/
211+
QUOTATION_NAME("quotationName", "name", Set.of("rules.required", "mobile"), FormKey.QUOTATION.getKey()),
212+
QUOTATION_OPPORTUNITY("quotationOpportunity", "opportunityId", Set.of("rules.required", "mobile"), FormKey.QUOTATION.getKey()),
213+
QUOTATION_PRODUCT_TABLE("quotationProducts", "products", Set.of("mobile"), FormKey.QUOTATION.getKey()),
214+
QUOTATION_PRODUCT("quotationProduct", "product", Set.of("rules.required", "mobile", "dataSourceType"), FormKey.QUOTATION.getKey()),
215+
QUOTATION_PRODUCT_AMOUNT("quotationAmount", "amount", Set.of("rules.required", "mobile"), FormKey.QUOTATION.getKey()),
216+
217+
/**
218+
* 合同回款计划
219+
*/
220+
/*------ start: CONTRACT_PAYMENT_PLAN ------*/
221+
/**
222+
* 负责人
223+
*/
224+
CONTRACT_PAYMENT_PLAN_OWNER("contractPaymentPlanOwner", "owner", Set.of("rules.required", "mobile"), FormKey.CONTRACT_PAYMENT_PLAN.getKey()),
225+
/**
226+
* 合同
227+
*/
228+
CONTRACT_PAYMENT_PLAN_CONTRACT("contractPaymentPlanContract", "contractId", Set.of(), FormKey.CONTRACT_PAYMENT_PLAN.getKey()),
229+
/**
230+
* 计划回款金额
231+
*/
232+
CONTRACT_PAYMENT_PLAN_PLAN_AMOUNT("contractPaymentPlanPlanAmount", "plan_amount", Set.of(), FormKey.CONTRACT_PAYMENT_PLAN.getKey()),
233+
/**
234+
* 计划回款时间
235+
*/
236+
CONTRACT_PAYMENT_PLAN_PLAN_END_TIME("contractPaymentPlanPlanEndTime", "plan_end_time", Set.of(), FormKey.CONTRACT_PAYMENT_PLAN.getKey());
237+
/*------ end: CONTRACT_PAYMENT_PLAN ------*/
238+
239+
198240
/**
199241
* 业务字段缓存
200242
*/

backend/crm/src/main/java/cn/cordys/common/constants/FormKey.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public enum FormKey {
4848
/**
4949
* 报价单
5050
*/
51-
QUOTATION("quotation");
51+
QUOTATION("quotation"),
52+
/**
53+
* 合同回款计划
54+
*/
55+
CONTRACT_PAYMENT_PLAN("contractPaymentPlan"),;
5256

5357
private final String key;
5458

backend/crm/src/main/java/cn/cordys/common/service/DataInitService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void initOneTime() {
5050
initOneTime(moduleFormService::processOldLinkData, "process.old.link.data");
5151
initOneTime(moduleFormService::initFormScenarioProp, "init.record.form.scenario");
5252
initOneTime(clueService::processTransferredCluePlanAndRecord, "process.transferred.clue");
53-
initOneTime(moduleFormService::initUpgradeForm, "init.upgrade.form.v1.3.4");
53+
initOneTime(moduleFormService::initUpgradeForm, "init.upgrade.form.v1.4.0");
5454
} finally {
5555
lock.unlock();
5656
}

backend/crm/src/main/java/cn/cordys/crm/product/controller/ProductPriceController.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.cordys.crm.product.controller;
22

3+
import cn.cordys.common.constants.FormKey;
34
import cn.cordys.common.constants.PermissionConstants;
45
import cn.cordys.common.pager.PagerWithOption;
56
import cn.cordys.context.OrganizationContext;
@@ -10,6 +11,8 @@
1011
import cn.cordys.crm.product.dto.response.ProductPriceGetResponse;
1112
import cn.cordys.crm.product.dto.response.ProductPriceResponse;
1213
import cn.cordys.crm.product.service.ProductPriceService;
14+
import cn.cordys.crm.system.dto.response.ModuleFormConfigDTO;
15+
import cn.cordys.crm.system.service.ModuleFormCacheService;
1316
import cn.cordys.security.SessionUtils;
1417
import io.swagger.v3.oas.annotations.Operation;
1518
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -30,6 +33,15 @@ public class ProductPriceController {
3033

3134
@Resource
3235
private ProductPriceService priceService;
36+
@Resource
37+
private ModuleFormCacheService moduleFormCacheService;
38+
39+
@GetMapping("/module/form")
40+
@RequiresPermissions(PermissionConstants.PRICE_READ)
41+
@Operation(summary = "获取表单配置")
42+
public ModuleFormConfigDTO getModuleFormConfig() {
43+
return moduleFormCacheService.getBusinessFormConfig(FormKey.PRICE.getKey(), OrganizationContext.getOrganizationId());
44+
}
3345

3446
@PostMapping("/page")
3547
@RequiresPermissions(PermissionConstants.PRICE_READ)

backend/crm/src/main/java/cn/cordys/crm/system/constants/FieldType.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,14 @@ public enum FieldType {
9595
/**
9696
* 行业
9797
*/
98-
INDUSTRY
98+
INDUSTRY,
99+
/**
100+
* 公式
101+
*/
102+
FORMULA,
103+
/**
104+
* 子表-产品, 子表-价格
105+
*/
106+
SUB_PRODUCT,
107+
SUB_PRICE;
99108
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cn.cordys.crm.system.dto.field;
2+
3+
import cn.cordys.crm.system.dto.field.base.BaseField;
4+
import com.fasterxml.jackson.annotation.JsonTypeName;
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import lombok.Data;
7+
import lombok.EqualsAndHashCode;
8+
9+
/**
10+
* 公式字段
11+
* @author song-cc-rock
12+
*/
13+
@Data
14+
@JsonTypeName(value = "FORMULA")
15+
@EqualsAndHashCode(callSuper = true)
16+
public class FormulaField extends BaseField {
17+
18+
@Schema(description = "公式")
19+
private String formula;
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cn.cordys.crm.system.dto.field;
2+
3+
import cn.cordys.crm.system.dto.field.base.BaseField;
4+
import cn.cordys.crm.system.dto.field.base.SubField;
5+
import com.fasterxml.jackson.annotation.JsonTypeName;
6+
import io.swagger.v3.oas.annotations.media.Schema;
7+
import lombok.Data;
8+
import lombok.EqualsAndHashCode;
9+
10+
import java.util.List;
11+
12+
/**
13+
* 产品子表字段
14+
* @author song-cc-rock
15+
*/
16+
@Data
17+
@JsonTypeName(value = "SUB_PRODUCT")
18+
@EqualsAndHashCode(callSuper = true)
19+
public class ProductSubField extends SubField {
20+
21+
22+
}

backend/crm/src/main/java/cn/cordys/crm/system/dto/field/base/BaseField.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
@JsonSubTypes.Type(value = SerialNumberField.class, name = "SERIAL_NUMBER"),
3939
@JsonSubTypes.Type(value = AttachmentField.class, name = "ATTACHMENT"),
4040
@JsonSubTypes.Type(value = LinkField.class, name = "LINK"),
41-
@JsonSubTypes.Type(value = IndustryField.class, name = "INDUSTRY")
41+
@JsonSubTypes.Type(value = IndustryField.class, name = "INDUSTRY"),
42+
@JsonSubTypes.Type(value = ProductSubField.class, name = "SUB_PRODUCT"),
43+
@JsonSubTypes.Type(value = FormulaField.class, name = "FORMULA"),
4244
})
4345
public abstract class BaseField {
4446

@@ -138,7 +140,7 @@ public boolean hasOptions() {
138140

139141
@JsonIgnore
140142
public boolean canImport() {
141-
return !Strings.CS.equalsAny(type, FieldType.SERIAL_NUMBER.name())
143+
return !Strings.CS.equalsAny(type, FieldType.SERIAL_NUMBER.name()) && !Strings.CS.equalsAny(type, FieldType.ATTACHMENT.name())
142144
&& !Strings.CS.equalsAny(type, FieldType.PICTURE.name()) && !Strings.CS.equalsAny(type, FieldType.DIVIDER.name()) && readable;
143145
}
144146

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.cordys.crm.system.dto.field.base;
2+
3+
import io.swagger.v3.oas.annotations.media.Schema;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
7+
import java.util.List;
8+
9+
/**
10+
* 通用子表格字段
11+
* @author song-cc-rock
12+
*/
13+
@Data
14+
@EqualsAndHashCode(callSuper = true)
15+
public class SubField extends BaseField{
16+
17+
18+
@Schema(description = "固定宽度")
19+
private Integer fixedColumn;
20+
21+
@Schema(description = "表格子字段")
22+
private List<? extends BaseField> subFields;
23+
}

backend/crm/src/main/java/cn/cordys/crm/system/service/ModuleFormCacheService.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,11 @@ public ModuleFormConfigDTO getBusinessFormConfig(String formKey, String organiza
6363
ModuleFormConfigDTO businessModuleFormConfig = new ModuleFormConfigDTO();
6464
businessModuleFormConfig.setFormProp(config.getFormProp());
6565

66-
// 获取特殊的业务字段
67-
Map<String, BusinessModuleField> businessModuleFieldMap = Arrays.stream(BusinessModuleField.values()).
68-
collect(Collectors.toMap(BusinessModuleField::getKey, Function.identity()));
69-
70-
businessModuleFormConfig.setFields(
71-
config.getFields()
72-
.stream()
73-
.peek(moduleFieldDTO -> {
74-
BusinessModuleField businessModuleFieldEnum = businessModuleFieldMap.get(moduleFieldDTO.getInternalKey());
75-
if (businessModuleFieldEnum != null) {
76-
// 设置特殊的业务字段 key
77-
moduleFieldDTO.setBusinessKey(businessModuleFieldEnum.getBusinessKey());
78-
moduleFieldDTO.setDisabledProps(businessModuleFieldEnum.getDisabledProps());
79-
}
80-
})
81-
.collect(Collectors.toList())
82-
);
66+
// 设置业务字段参数
67+
businessModuleFormConfig.setFields(config.getFields().stream()
68+
.peek(moduleFormService::setFieldBusinessParam)
69+
.toList()
70+
);
8371
return businessModuleFormConfig;
8472
}
8573
}

0 commit comments

Comments
 (0)