diff --git a/crates/erp-plugin-crm/plugin.toml b/crates/erp-plugin-crm/plugin.toml index e1defa6..fec2e7c 100644 --- a/crates/erp-plugin-crm/plugin.toml +++ b/crates/erp-plugin-crm/plugin.toml @@ -37,16 +37,24 @@ code = "communication.manage" name = "管理沟通记录" [[permissions]] -code = "tag.manage" +code = "customer_tag.list" +name = "查看客户标签" +description = "查看客户标签列表" + +[[permissions]] +code = "customer_tag.manage" name = "管理客户标签" +description = "创建、编辑、删除客户标签" [[permissions]] -code = "relationship.list" +code = "customer_relationship.list" name = "查看客户关系" +description = "查看客户关系列表" [[permissions]] -code = "relationship.manage" +code = "customer_relationship.manage" name = "管理客户关系" +description = "创建、编辑、删除客户关系" # ── 实体定义 ── @@ -54,6 +62,7 @@ name = "管理客户关系" name = "customer" display_name = "客户" data_scope = true +is_public = true [[schema.entities.fields]] name = "code" @@ -139,22 +148,35 @@ data_scope = true display_name = "统一社会信用代码" visible_when = "customer_type == 'enterprise'" + [schema.entities.fields.validation] + pattern = "^[0-9A-HJ-NP-RTUW-Y]{2}\\d{6}[0-9A-HJ-NP-RTUW-Y]{10}$" + message = "请输入有效的统一社会信用代码(18位)" + [[schema.entities.fields]] name = "id_number" field_type = "string" display_name = "身份证号" visible_when = "customer_type == 'personal'" + [schema.entities.fields.validation] + pattern = "^\\d{17}[\\dXx]$" + message = "请输入有效的身份证号(18位)" + [[schema.entities.fields]] name = "parent_id" field_type = "uuid" display_name = "上级客户" + ref_entity = "customer" [[schema.entities.fields]] name = "website" field_type = "string" display_name = "网站" + [schema.entities.fields.validation] + pattern = "^https?://[\\w.-]+(?:\\.[\\w.-]+)+[/#?]?.*$" + message = "请输入有效的网址,以 http:// 或 https:// 开头" + [[schema.entities.fields]] name = "address" field_type = "string" @@ -172,6 +194,38 @@ data_scope = true display_name = "负责人" scope_role = "owner" + [[schema.entities.relations]] + entity = "contact" + foreign_key = "customer_id" + on_delete = "cascade" + name = "contacts" + type = "one_to_many" + display_field = "name" + + [[schema.entities.relations]] + entity = "communication" + foreign_key = "customer_id" + on_delete = "cascade" + name = "communications" + type = "one_to_many" + display_field = "subject" + + [[schema.entities.relations]] + entity = "customer_tag" + foreign_key = "customer_id" + on_delete = "cascade" + name = "tags" + type = "one_to_many" + display_field = "tag_name" + + [[schema.entities.relations]] + entity = "customer" + foreign_key = "parent_id" + on_delete = "nullify" + name = "parent" + type = "many_to_one" + display_field = "name" + [[schema.entities]] name = "contact" display_name = "联系人" @@ -182,6 +236,7 @@ display_name = "联系人" required = true display_name = "所属客户" ui_widget = "entity_select" + ref_entity = "customer" ref_label_field = "name" ref_search_fields = ["name", "code"] @@ -207,11 +262,19 @@ display_name = "联系人" field_type = "string" display_name = "手机号" + [schema.entities.fields.validation] + pattern = "^1[3-9]\\d{9}$" + message = "请输入有效的手机号码" + [[schema.entities.fields]] name = "email" field_type = "string" display_name = "邮箱" + [schema.entities.fields.validation] + pattern = "^[\\w.+-]+@[\\w.-]+\\.[a-zA-Z]{2,}$" + message = "请输入有效的邮箱地址" + [[schema.entities.fields]] name = "wechat" field_type = "string" @@ -227,6 +290,14 @@ display_name = "联系人" field_type = "string" display_name = "备注" + [[schema.entities.relations]] + entity = "communication" + foreign_key = "contact_id" + on_delete = "cascade" + name = "communications" + type = "one_to_many" + display_field = "subject" + [[schema.entities]] name = "communication" display_name = "沟通记录" @@ -236,12 +307,14 @@ display_name = "沟通记录" field_type = "uuid" required = true display_name = "关联客户" + ref_entity = "customer" [[schema.entities.fields]] name = "contact_id" field_type = "uuid" display_name = "关联联系人" ui_widget = "entity_select" + ref_entity = "contact" ref_label_field = "name" ref_search_fields = ["name"] cascade_from = "customer_id" @@ -297,6 +370,7 @@ display_name = "客户标签" field_type = "uuid" required = true display_name = "关联客户" + ref_entity = "customer" [[schema.entities.fields]] name = "tag_name" @@ -326,12 +400,14 @@ display_name = "客户关系" field_type = "uuid" required = true display_name = "源客户" + ref_entity = "customer" [[schema.entities.fields]] name = "to_customer_id" field_type = "uuid" required = true display_name = "目标客户" + ref_entity = "customer" [[schema.entities.fields]] name = "relationship_type" diff --git a/crates/erp-plugin-inventory/plugin.toml b/crates/erp-plugin-inventory/plugin.toml index d57b9d6..f97590c 100644 --- a/crates/erp-plugin-inventory/plugin.toml +++ b/crates/erp-plugin-inventory/plugin.toml @@ -1,10 +1,11 @@ [metadata] id = "erp-inventory" name = "进销存管理" -version = "0.1.0" +version = "0.2.0" description = "进销存管理插件 — 产品、仓库、库存、供应商、采购单、销售单" author = "ERP Team" min_platform_version = "0.1.0" +dependencies = ["erp-crm"] # ── 权限声明 ── @@ -294,6 +295,12 @@ display_name = "销售单" name = "customer_id" field_type = "uuid" display_name = "客户" + ui_widget = "entity_select" + ref_plugin = "erp-crm" + ref_entity = "customer" + ref_label_field = "name" + ref_search_fields = ["name", "code"] + ref_fallback_label = "CRM 客户" [[schema.entities.fields]] name = "total_amount"