CRM 工作管理
本技能完全独立,内置登录认证流程,无需加载其他技能。
参考文档索引
| 分类 | 文件 | 说明 | |------|------|------| | 认证 | authentication.md | 登录流程、密码加密、凭据提取 | | 基础 | base.md | 工具函数、编码规范 | | 枚举 | enums.md | 时间常量、dbType、searchCondition 通用结构 | | 日程管理 | schedule.md | 查询/创建日程、日程枚举值 | | 日报/周报/月报 | report-workflow.md | 报告自动生成工作流(直接走此流程,无需查 view/form) |
第一步:收集凭据(每次对话开始时)
尚未获取凭据时,使用 AskUserQuestion 工具一次性收集 4 个参数:
AskUserQuestion({
questions: [
{ header: "平台地址", question: "CRM 平台的 base_url 是什么?",
options: [{ label: "在下方输入平台地址", description: "例如 https://crm.example.com" }] },
{ header: "userId", question: "登录企业账号是什么?",
options: [{ label: "在下方输入企业账号", description: "企业 userId" }] },
{ header: "email", question: "登录账号是什么?",
options: [{ label: "在下方输入账号", description: "登录邮箱或账号" }] },
{ header: "密码", question: "登录密码是什么?",
options: [{ label: "在下方输入密码", description: "明文密码,自动加密" }] },
]
})
收集到凭据后,调用 scripts/crm_login.py 登录,获取 authToken、JSESSIONID、emp_id:
python scripts/crm_login.py \
--base-url <base_url> \
--user-id <userId> \
--email <email> \
--password <password>
登录成功输出 JSON:{"success": true, "authToken": "...", "JSESSIONID": "...", "emp_id": "..."}
凭据在当前会话中复用,不要重复询问。
常见操作速查
| 操作 | 接口 | 参考文档 |
|------|------|---------|
| 查询日程列表 | POST /schedule/list | schedule.md |
| 新增日程 | POST /schedule/insert(通用表单流程) | schedule.md |
| 生成日报 | POST /planSummary/insert | report-workflow.md |
| 生成周报 | POST /planSummary/insert | report-workflow.md |
| 生成月报 | POST /planSummary/insert | report-workflow.md |
报告生成规则(重要)
⚠️ 日报/周报/月报不需要先查 view/form 获取字段。
planSummary/insert的参数已在 report-workflow.md 中完整列出,直接按步骤执行即可。 通用表单流程(view/form → template → insert)仅适用于日程新增等其他业务模块。
报告类型速查
| 用户说 | 数据汇总范围 | type | operationId |
|--------|------------|------|-------------|
| 生成日报 | 当天数据 | 1 | plan_summary_day_add |
| 生成周报 | 本周数据 | 2 | plan_summary_week_add |
| 生成月报 | 本月数据 | 3 | plan_summary_month_add |
脚本工具
crm_login.py — 登录获取凭据
python scripts/crm_login.py \
--base-url https://xxx \
--user-id xxx \
--email xxx \
--password xxx
输出:{"success": true, "authToken": "...", "JSESSIONID": "...", "emp_id": "..."}
crm_query.py — 通用查询(使用凭据)
python scripts/crm_query.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--module-id schedule \
--limit 25
crm_form_submit.py — 通用表单提交(使用凭据)
# 仅查看模板
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id ScheduleAdd \
--template-only
# 提交新增
python scripts/crm_form_submit.py \
--base-url https://xxx \
--jsessionid xxx \
--auth-token xxx \
--view-id ScheduleAdd \
--data '{"name":"测试日程"}'
generate_reports.py — 报告一键生成
python scripts/generate_reports.py day week month \
--base-url <base_url> \
--jsessionid <JSESSIONID> \
--auth-token <authToken> \
--emp-id <emp_id> \
--dry-run # 仅预览,不提交
关键注意事项
- 中文编码:所有含中文的请求必须通过 Python 脚本执行,不能用 Bash 直接 curl(详见 base.md)
- multipart 请求:使用
curl --data-binary @-通过 subprocess 发送 - 日程时间格式:查询参数使用 ISO 8601(
2026-06-01T00:00:00.000Z),与其他模块的Y-m-d H:i:s不同 - 查询本人日程:需附加
owner=emp_id(登录返回的data.id) - 新增日程日期:提交格式必须为
Y-m-d H:i:s(含时间部分) - 响应数据位置:解析时用
resp.get('rows') or resp.get('data') or []
Scan to join WeChat group