feat(itops): 创建 IT 运维服务台插件 — 4 实体/8 权限/4 页面
This commit is contained in:
@@ -14,6 +14,7 @@ members = [
|
||||
"crates/erp-plugin-crm",
|
||||
"crates/erp-plugin-inventory",
|
||||
"crates/erp-plugin-freelance",
|
||||
"crates/erp-plugin-itops",
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
|
||||
11
crates/erp-plugin-itops/Cargo.toml
Normal file
11
crates/erp-plugin-itops/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "erp-plugin-itops"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
description = "IT 运维服务台 WASM 插件"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
wit-bindgen = "0.55"
|
||||
524
crates/erp-plugin-itops/plugin.toml
Normal file
524
crates/erp-plugin-itops/plugin.toml
Normal file
@@ -0,0 +1,524 @@
|
||||
# IT 运维服务台 — plugin.toml
|
||||
# 汕头市智界科技有限公司 IT 服务行业插件
|
||||
|
||||
[metadata]
|
||||
id = "erp-itops"
|
||||
name = "IT 运维服务台"
|
||||
version = "0.1.0"
|
||||
description = "IT 运维工单管理 + SLA 追踪 + 定期巡检"
|
||||
author = "ERP Platform"
|
||||
min_platform_version = "0.1.0"
|
||||
|
||||
# ── 权限声明(4 实体 × 2 = 8 个权限码)──
|
||||
|
||||
[[permissions]]
|
||||
code = "service_contract.list"
|
||||
name = "查看维保合同"
|
||||
description = "查看维保合同列表和详情"
|
||||
|
||||
[[permissions]]
|
||||
code = "service_contract.manage"
|
||||
name = "管理维保合同"
|
||||
description = "创建、编辑、删除维保合同"
|
||||
|
||||
[[permissions]]
|
||||
code = "ticket.list"
|
||||
name = "查看工单"
|
||||
description = "查看工单列表和详情"
|
||||
|
||||
[[permissions]]
|
||||
code = "ticket.manage"
|
||||
name = "管理工单"
|
||||
description = "创建、编辑、删除工单"
|
||||
|
||||
[[permissions]]
|
||||
code = "check_plan.list"
|
||||
name = "查看巡检计划"
|
||||
description = "查看巡检计划列表和详情"
|
||||
|
||||
[[permissions]]
|
||||
code = "check_plan.manage"
|
||||
name = "管理巡检计划"
|
||||
description = "创建、编辑、删除巡检计划"
|
||||
|
||||
[[permissions]]
|
||||
code = "check_record.list"
|
||||
name = "查看巡检记录"
|
||||
description = "查看巡检记录列表"
|
||||
|
||||
[[permissions]]
|
||||
code = "check_record.manage"
|
||||
name = "管理巡检记录"
|
||||
description = "创建、编辑、删除巡检记录"
|
||||
|
||||
# ── 实体定义 ──
|
||||
|
||||
# ── 3.3.1 service_contract(维保合同)──
|
||||
|
||||
[[schema.entities]]
|
||||
name = "service_contract"
|
||||
display_name = "维保合同"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "client_id"
|
||||
field_type = "uuid"
|
||||
display_name = "客户"
|
||||
ui_widget = "entity_select"
|
||||
ref_plugin = "erp-freelance"
|
||||
ref_entity = "client"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
ref_fallback_label = "外部客户"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "contract_number"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "合同编号"
|
||||
unique = true
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "name"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "合同名称"
|
||||
searchable = true
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "service_scope"
|
||||
field_type = "string"
|
||||
display_name = "服务范围"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "sla_level"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "SLA 等级"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
default = "standard"
|
||||
options = [
|
||||
{ label = "标准", value = "standard" },
|
||||
{ label = "银牌", value = "silver" },
|
||||
{ label = "金牌", value = "gold" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "sla_response_hours"
|
||||
field_type = "integer"
|
||||
display_name = "SLA 响应时间(小时)"
|
||||
default = 8
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "sla_resolve_hours"
|
||||
field_type = "integer"
|
||||
display_name = "SLA 解决时间(小时)"
|
||||
default = 48
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "status"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "状态"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
default = "active"
|
||||
options = [
|
||||
{ label = "生效中", value = "active" },
|
||||
{ label = "即将到期", value = "expiring" },
|
||||
{ label = "已过期", value = "expired" },
|
||||
{ label = "已终止", value = "terminated" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "start_date"
|
||||
field_type = "date"
|
||||
required = true
|
||||
display_name = "开始日期"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "end_date"
|
||||
field_type = "date"
|
||||
required = true
|
||||
display_name = "结束日期"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "amount"
|
||||
field_type = "decimal"
|
||||
display_name = "合同金额"
|
||||
sortable = true
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "payment_terms"
|
||||
field_type = "string"
|
||||
display_name = "付款条款"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "notes"
|
||||
field_type = "string"
|
||||
display_name = "备注"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.relations]]
|
||||
entity = "ticket"
|
||||
foreign_key = "contract_id"
|
||||
on_delete = "nullify"
|
||||
name = "tickets"
|
||||
type = "one_to_many"
|
||||
display_field = "title"
|
||||
|
||||
[[schema.entities.relations]]
|
||||
entity = "check_plan"
|
||||
foreign_key = "contract_id"
|
||||
on_delete = "cascade"
|
||||
name = "check_plans"
|
||||
type = "one_to_many"
|
||||
display_field = "name"
|
||||
|
||||
# ── 3.3.2 ticket(工单)──
|
||||
|
||||
[[schema.entities]]
|
||||
name = "ticket"
|
||||
display_name = "工单"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "contract_id"
|
||||
field_type = "uuid"
|
||||
display_name = "维保合同"
|
||||
ui_widget = "entity_select"
|
||||
ref_entity = "service_contract"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "client_id"
|
||||
field_type = "uuid"
|
||||
display_name = "客户"
|
||||
ui_widget = "entity_select"
|
||||
ref_plugin = "erp-freelance"
|
||||
ref_entity = "client"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
ref_fallback_label = "外部客户"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "title"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "工单标题"
|
||||
searchable = true
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "type"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "类型"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
default = "fault"
|
||||
options = [
|
||||
{ label = "故障", value = "fault" },
|
||||
{ label = "巡检", value = "check" },
|
||||
{ label = "咨询", value = "consult" },
|
||||
{ label = "变更", value = "change" },
|
||||
{ label = "其他", value = "other" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "priority"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "优先级"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
default = "medium"
|
||||
options = [
|
||||
{ label = "紧急", value = "urgent" },
|
||||
{ label = "高", value = "high" },
|
||||
{ label = "中", value = "medium" },
|
||||
{ label = "低", value = "low" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "status"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "状态"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
default = "open"
|
||||
options = [
|
||||
{ label = "待处理", value = "open" },
|
||||
{ label = "处理中", value = "in_progress" },
|
||||
{ label = "等待客户", value = "waiting_client" },
|
||||
{ label = "已解决", value = "resolved" },
|
||||
{ label = "已关闭", value = "closed" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "channel"
|
||||
field_type = "string"
|
||||
display_name = "来源渠道"
|
||||
ui_widget = "select"
|
||||
options = [
|
||||
{ label = "电话", value = "phone" },
|
||||
{ label = "微信", value = "wechat" },
|
||||
{ label = "邮件", value = "email" },
|
||||
{ label = "系统", value = "system" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "description"
|
||||
field_type = "string"
|
||||
display_name = "问题描述"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "resolution"
|
||||
field_type = "string"
|
||||
display_name = "解决方案"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "responded_at"
|
||||
field_type = "date_time"
|
||||
display_name = "首次响应时间"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "resolved_at"
|
||||
field_type = "date_time"
|
||||
display_name = "解决时间"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "closed_at"
|
||||
field_type = "date_time"
|
||||
display_name = "关闭时间"
|
||||
|
||||
# ── 3.3.3 check_plan(巡检计划)──
|
||||
|
||||
[[schema.entities]]
|
||||
name = "check_plan"
|
||||
display_name = "巡检计划"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "contract_id"
|
||||
field_type = "uuid"
|
||||
required = true
|
||||
display_name = "维保合同"
|
||||
ui_widget = "entity_select"
|
||||
ref_entity = "service_contract"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "client_id"
|
||||
field_type = "uuid"
|
||||
display_name = "客户"
|
||||
ui_widget = "entity_select"
|
||||
ref_plugin = "erp-freelance"
|
||||
ref_entity = "client"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
ref_fallback_label = "外部客户"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "name"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "计划名称"
|
||||
searchable = true
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "frequency"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "巡检频率"
|
||||
ui_widget = "select"
|
||||
options = [
|
||||
{ label = "每周", value = "weekly" },
|
||||
{ label = "每两周", value = "biweekly" },
|
||||
{ label = "每月", value = "monthly" },
|
||||
{ label = "每季度", value = "quarterly" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "check_items"
|
||||
field_type = "json"
|
||||
display_name = "检查项"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "status"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "状态"
|
||||
ui_widget = "select"
|
||||
default = "active"
|
||||
options = [
|
||||
{ label = "启用", value = "active" },
|
||||
{ label = "停用", value = "inactive" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "next_check_date"
|
||||
field_type = "date"
|
||||
display_name = "下次巡检日期"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "notes"
|
||||
field_type = "string"
|
||||
display_name = "备注"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.relations]]
|
||||
entity = "check_record"
|
||||
foreign_key = "plan_id"
|
||||
on_delete = "cascade"
|
||||
name = "records"
|
||||
type = "one_to_many"
|
||||
display_field = "check_date"
|
||||
|
||||
# ── 3.3.4 check_record(巡检记录)──
|
||||
|
||||
[[schema.entities]]
|
||||
name = "check_record"
|
||||
display_name = "巡检记录"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "plan_id"
|
||||
field_type = "uuid"
|
||||
required = true
|
||||
display_name = "巡检计划"
|
||||
ui_widget = "entity_select"
|
||||
ref_entity = "check_plan"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "contract_id"
|
||||
field_type = "uuid"
|
||||
display_name = "维保合同"
|
||||
ref_entity = "service_contract"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "client_id"
|
||||
field_type = "uuid"
|
||||
display_name = "客户"
|
||||
ui_widget = "entity_select"
|
||||
ref_plugin = "erp-freelance"
|
||||
ref_entity = "client"
|
||||
ref_label_field = "name"
|
||||
ref_search_fields = ["name"]
|
||||
ref_fallback_label = "外部客户"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "check_date"
|
||||
field_type = "date"
|
||||
required = true
|
||||
display_name = "巡检日期"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "result"
|
||||
field_type = "string"
|
||||
required = true
|
||||
display_name = "结果"
|
||||
ui_widget = "select"
|
||||
filterable = true
|
||||
options = [
|
||||
{ label = "正常", value = "normal" },
|
||||
{ label = "有异常", value = "abnormal" }
|
||||
]
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "items_data"
|
||||
field_type = "json"
|
||||
display_name = "检查项结果"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "issues_found"
|
||||
field_type = "string"
|
||||
display_name = "发现的问题"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "actions_taken"
|
||||
field_type = "string"
|
||||
display_name = "采取措施"
|
||||
ui_widget = "textarea"
|
||||
|
||||
[[schema.entities.fields]]
|
||||
name = "notes"
|
||||
field_type = "string"
|
||||
display_name = "备注"
|
||||
ui_widget = "textarea"
|
||||
|
||||
# ── 编号规则 ──
|
||||
|
||||
[[numbering]]
|
||||
entity = "service_contract"
|
||||
field = "contract_number"
|
||||
prefix = "SC"
|
||||
format = "{PREFIX}-{YEAR}-{SEQ}"
|
||||
seq_length = 4
|
||||
|
||||
# ── 页面设计 ──
|
||||
|
||||
# 页面 1:合同管理 + 详情
|
||||
[[ui.pages]]
|
||||
type = "crud"
|
||||
entity = "service_contract"
|
||||
label = "合同管理"
|
||||
icon = "file-text"
|
||||
enable_search = true
|
||||
|
||||
[[ui.pages]]
|
||||
type = "detail"
|
||||
entity = "service_contract"
|
||||
label = "合同详情"
|
||||
|
||||
[[ui.pages.sections]]
|
||||
type = "fields"
|
||||
label = "合同信息"
|
||||
fields = ["name", "client_id", "service_scope", "sla_level", "sla_response_hours", "sla_resolve_hours", "status", "start_date", "end_date", "amount", "payment_terms", "notes"]
|
||||
|
||||
[[ui.pages.sections]]
|
||||
type = "crud"
|
||||
label = "工单"
|
||||
entity = "ticket"
|
||||
filter_field = "contract_id"
|
||||
|
||||
[[ui.pages.sections]]
|
||||
type = "crud"
|
||||
label = "巡检计划"
|
||||
entity = "check_plan"
|
||||
filter_field = "contract_id"
|
||||
|
||||
[[ui.pages.sections]]
|
||||
type = "crud"
|
||||
label = "巡检记录"
|
||||
entity = "check_record"
|
||||
filter_field = "contract_id"
|
||||
|
||||
# 页面 2:工单中心
|
||||
[[ui.pages]]
|
||||
type = "tabs"
|
||||
label = "工单中心"
|
||||
icon = "tool"
|
||||
|
||||
[[ui.pages.tabs]]
|
||||
label = "工单列表"
|
||||
type = "crud"
|
||||
entity = "ticket"
|
||||
enable_search = true
|
||||
|
||||
[[ui.pages.tabs]]
|
||||
label = "巡检计划"
|
||||
type = "crud"
|
||||
entity = "check_plan"
|
||||
enable_search = true
|
||||
|
||||
[[ui.pages.tabs]]
|
||||
label = "巡检记录"
|
||||
type = "crud"
|
||||
entity = "check_record"
|
||||
enable_search = true
|
||||
26
crates/erp-plugin-itops/src/lib.rs
Normal file
26
crates/erp-plugin-itops/src/lib.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
//! IT 运维服务台 WASM 插件
|
||||
|
||||
wit_bindgen::generate!({
|
||||
path: "../erp-plugin-prototype/wit/plugin.wit",
|
||||
world: "plugin-world",
|
||||
});
|
||||
|
||||
use crate::exports::erp::plugin::plugin_api::Guest;
|
||||
|
||||
struct ItopsPlugin;
|
||||
|
||||
impl Guest for ItopsPlugin {
|
||||
fn init() -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_tenant_created(_tenant_id: String) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn handle_event(_event_type: String, _payload: Vec<u8>) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
export!(ItopsPlugin);
|
||||
Reference in New Issue
Block a user