yida-create-form-page
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese宜搭表单页面创建与更新技能
Skill for Creating and Updating Yida Form Pages
概述
Overview
本技能描述如何通过 HTTP 请求调用宜搭接口创建或更新表单页面。支持两种模式:
- create 模式:创建新表单页面,定义字段列表、字段类型、选项等。先创建空白表单获取 formUuid,再保存表单 Schema。
- update 模式:更新已有表单页面,支持对字段进行增删改、调整属性等操作。先获取现有 Schema,应用修改后保存。
This skill describes how to call Yida APIs via HTTP requests to create or update form pages. Two modes are supported:
- create mode: Create a new form page, define field lists, field types, options, etc. First create a blank form to get formUuid, then save the form Schema.
- update mode: Update an existing form page, supporting operations like adding, deleting, modifying fields and adjusting attributes. First get the existing Schema, apply modifications and then save.
何时使用
When to Use
当以下场景发生时使用此技能:
- 用户需要在应用中创建数据收集表单(如报名表、调查表)
- 用户需要创建带有字段的表单页面来存储数据
- 用户需要更新已有表单的字段(增删改)
- 已通过 yida-create-app 创建应用后,需要创建表单来收集数据
Use this skill in the following scenarios:
- Users need to create data collection forms (such as registration forms, survey forms) in applications
- Users need to create form pages with fields to store data
- Users need to update fields of existing forms (add, delete, modify)
- After creating an application with yida-create-app, need to create forms to collect data
使用示例
Usage Examples
示例 1:创建新表单
Example 1: Create a New Form
场景:在应用中创建一个简单的用户信息表单
命令:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create "APP_XXX" "用户信息表" '[{"type":"TextField","label":"姓名","required":true},{"type":"SelectField","label":"部门","options":["技术部","产品部"]}]'输出:
json
{"success":true,"formUuid":"FORM-XXX","formTitle":"用户信息表","appType":"APP_XXX","fieldCount":2}Scenario: Create a simple user information form in an application
Command:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create "APP_XXX" "用户信息表" '[{"type":"TextField","label":"姓名","required":true},{"type":"SelectField","label":"部门","options":["技术部","产品部"]}]'Output:
json
{"success":true,"formUuid":"FORM-XXX","formTitle":"用户信息表","appType":"APP_XXX","fieldCount":2}示例 2:更新已有表单
Example 2: Update an Existing Form
场景:为已存在的表单添加新字段
命令:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_XXX" "FORM-XXX" '[{"action":"add","field":{"type":"TextField","label":"备注"}}]'Scenario: Add a new field to an existing form
Command:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_XXX" "FORM-XXX" '[{"action":"add","field":{"type":"TextField","label":"备注"}}]'使用方式
Usage Methods
create 模式(创建新表单)
create mode (Create New Form)
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create <appType> <formTitle> <fieldsJsonOrFile>参数说明:
| 参数 | 必填 | 说明 |
|---|---|---|
| 是 | 应用 ID,如 |
| 是 | 表单名称 |
| 是 | 字段定义,支持两种格式:JSON 字符串(以 |
示例:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create "APP_xxx" "图片生成表" .claude/skills/yida-create-form-page/scripts/fields.json输出:日志输出到 stderr,JSON 结果输出到 stdout:
json
{"success":true,"formUuid":"FORM-XXX","formTitle":"图片生成表","appType":"APP_xxx","fieldCount":4,"url":"{base_url}/APP_xxx/workbench/FORM-XXX"}bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create <appType> <formTitle> <fieldsJsonOrFile>Parameter Description:
| Parameter | Required | Description |
|---|---|---|
| Yes | Application ID, e.g., |
| Yes | Form name |
| Yes | Field definition, supporting two formats: JSON string (starting with |
Example:
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js create "APP_xxx" "图片生成表" .claude/skills/yida-create-form-page/scripts/fields.jsonOutput: Logs are output to stderr, JSON results are output to stdout:
json
{"success":true,"formUuid":"FORM-XXX","formTitle":"图片生成表","appType":"APP_xxx","fieldCount":4,"url":"{base_url}/APP_xxx/workbench/FORM-XXX"}update 模式(更新已有表单)
update mode (Update Existing Form)
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update <appType> <formUuid> <changesJsonOrFile>参数说明:
| 参数 | 必填 | 说明 |
|---|---|---|
| 是 | 应用 ID,如 |
| 是 | 表单页面的唯一标识,如 |
| 是 | 修改定义,支持两种格式:JSON 字符串(以 |
示例(JSON 字符串,推荐):
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_xxx" "FORM-yyy" '[{"action":"add","field":{"type":"TextField","label":"备注"}}]'示例(JSON 文件):
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_xxx" "FORM-yyy" changes.json输出:日志输出到 stderr,JSON 结果输出到 stdout:
json
{"success":true,"formUuid":"FORM-YYY","appType":"APP_XXX","changesApplied":3,"changes":[...],"url":"https://www.aliwork.com/APP_XXX/workbench/FORM-YYY"}bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update <appType> <formUuid> <changesJsonOrFile>Parameter Description:
| Parameter | Required | Description |
|---|---|---|
| Yes | Application ID, e.g., |
| Yes | Unique identifier of the form page, e.g., |
| Yes | Modification definition, supporting two formats: JSON string (automatically recognized if starting with |
Example (JSON string, recommended):
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_xxx" "FORM-yyy" '[{"action":"add","field":{"type":"TextField","label":"备注"}}]'Example (JSON file):
bash
node .claude/skills/yida-create-form-page/scripts/create-form-page.js update "APP_xxx" "FORM-yyy" changes.jsonOutput: Logs are output to stderr, JSON results are output to stdout:
json
{"success":true,"formUuid":"FORM-YYY","appType":"APP_XXX","changesApplied":3,"changes":[...],"url":"https://www.aliwork.com/APP_XXX/workbench/FORM-YYY"}字段定义 JSON 格式
Field Definition JSON Format
字段定义是一个 JSON 数组,每个元素描述一个字段。支持两种格式:
Field definition is a JSON array, where each element describes a field. Two formats are supported:
格式一(推荐)
Format 1 (Recommended)
直接在对象中定义 和 :
typelabeljson
[
{ "type": "TextField", "label": "姓名", "required": true },
{ "type": "SelectField", "label": "部门", "options": ["技术部", "产品部", "设计部"] },
{ "type": "DateField", "label": "入职日期" }
]Define and directly in the object:
typelabeljson
[
{ "type": "TextField", "label": "姓名", "required": true },
{ "type": "SelectField", "label": "部门", "options": ["技术部", "产品部", "设计部"] },
{ "type": "DateField", "label": "入职日期" }
]格式二(兼容)
Format 2 (Compatible)
将字段属性放在 子对象中:
fieldjson
[
{ "field": { "type": "TextField", "label": "姓名" }, "required": true },
{ "field": { "type": "SelectField", "label": "部门", "options": ["技术部"] } }
]两种格式效果相同,推荐使用格式一,更简洁。
字段属性:
| 属性 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 字段类型(见下方支持的字段类型) |
| String | 是 | 字段标签 |
| Boolean | 否 | 是否必填,默认 |
| String | 否 | 占位提示文本 |
| String | 否 | 字段行为, |
| String[] | 否 | 显示端, |
| String | 否 | 标签对齐方式, |
| String[] | 条件必填 | 选项列表,选项类字段必填 |
| Boolean | 否 | 是否多选, |
| Object[] | 条件必填 | 子字段列表, |
| Object | 条件必填 | 关联表单配置对象, |
Place field properties in the sub-object:
fieldjson
[
{ "field": { "type": "TextField", "label": "姓名" }, "required": true },
{ "field": { "type": "SelectField", "label": "部门", "options": ["技术部"] } }
]Both formats have the same effect, Format 1 is recommended for its simplicity.
Field Properties:
| Property | Type | Required | Description |
|---|---|---|---|
| String | Yes | Field type (see supported field types below) |
| String | Yes | Field label |
| Boolean | No | Whether it is required, default |
| String | No | Placeholder prompt text |
| String | No | Field behavior, |
| String[] | No | Display terminals, |
| String | No | Label alignment, |
| String[] | Conditionally required | Option list, required for option-type fields |
| Boolean | No | Whether multiple selection is allowed, available for |
| Object[] | Conditionally required | Sub-field list, required for |
| Object | Conditionally required | Associated form configuration object, required for |
各字段类型默认属性
Default Properties of Each Field Type
以下列出各字段类型创建时自动设置的特有默认属性(通用属性如 、、、 等所有字段共享,不再重复列出)。
fieldIdlabelbehaviorvisibilityThe following lists the unique default properties automatically set when creating each field type (common properties like , , , are shared by all fields and will not be repeated).
fieldIdlabelbehaviorvisibilityTextField / TextareaField
TextField / TextareaField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 校验类型 |
| | 最大字符数 |
| | 显示清除按钮 |
| | 自定义存储 |
| | 扫码输入 |
| Property | Default Value | Description |
|---|---|---|
| | Validation type |
| | Maximum number of characters |
| | Show clear button |
| | Custom storage |
| | Scan code input |
NumberField
NumberField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 小数位数 |
| | 步进值 |
| | 千分位分隔符 |
| | 自定义存储 |
| "" | 单位 |
| Property | Default Value | Description |
|---|---|---|
| | Number of decimal places |
| | Step value |
| | Thousands separator |
| | Custom storage |
| "" | Unit |
RateField
RateField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 星级总数 |
| | 允许半星 |
| | 显示等级文案 |
| Property | Default Value | Description |
|---|---|---|
| | Total number of stars |
| | Allow half stars |
| | Show grade text |
RadioField / CheckboxField
RadioField / CheckboxField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 数据源类型 |
| | 值类型 |
| Property | Default Value | Description |
|---|---|---|
| | Data source type |
| | Value type |
SelectField / MultiSelectField
SelectField / MultiSelectField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 支持搜索 |
| | 自动宽度 |
| | 本地过滤 |
| | 选择模式 |
| Property | Default Value | Description |
|---|---|---|
| | Support search |
| | Auto width |
| | Local filtering |
| | Selection mode |
DateField
DateField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 日期格式 |
| | 显示清除按钮 |
| | 重置时间 |
| | 禁用日期规则 |
| format 格式: |
- :年
"YYYY" - :年-月
"YYYY-MM" - :年-月-日
"YYYY-MM-DD" - :年-月-日 时分
"YYYY-MM-DD HH:mm" - :年-月-日 时分秒
"YYYY-MM-DD HH:mm:ss"
| Property | Default Value | Description |
|---|---|---|
| | Date format |
| | Show clear button |
| | Reset time |
| | Disabled date rule |
| format options: |
- : Year
"YYYY" - : Year-Month
"YYYY-MM" - : Year-Month-Day
"YYYY-MM-DD" - : Year-Month-Day Hour:Minute
"YYYY-MM-DD HH:mm" - : Year-Month-Day Hour:Minute:Second
"YYYY-MM-DD HH:mm:ss"
CascadeDateField
CascadeDateField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 日期格式 |
| | 显示清除按钮 |
| | 重置时间 |
| format 格式: |
- :年
"YYYY" - :年-月
"YYYY-MM" - :年-月-日
"YYYY-MM-DD" - :年-月-日 时分
"YYYY-MM-DD HH:mm" - :年-月-日 时分秒
"YYYY-MM-DD HH:mm:ss"
| Property | Default Value | Description |
|---|---|---|
| | Date format |
| | Show clear button |
| | Reset time |
| format options: |
- : Year
"YYYY" - : Year-Month
"YYYY-MM" - : Year-Month-Day
"YYYY-MM-DD" - : Year-Month-Day Hour:Minute
"YYYY-MM-DD HH:mm" - : Year-Month-Day Hour:Minute:Second
"YYYY-MM-DD HH:mm:ss"
EmployeeField
EmployeeField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 人员范围 |
| | 显示方式 |
| | 起始部门 |
| | 查看时渲染链接 |
| | 选择后关闭 |
| Property | Default Value | Description |
|---|---|---|
| | User range |
| | Display method |
| | Starting department |
| | Render link when viewing |
| | Close after selection |
DepartmentSelectField
DepartmentSelectField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 部门范围 |
| | 选择模式 |
| | 显示部门全路径 |
| | 全选按钮 |
| Property | Default Value | Description |
|---|---|---|
| | Department range |
| | Selection mode |
| | Show full department path |
| | Select all button |
CountrySelectField
CountrySelectField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 选择模式 |
| | 支持搜索 |
| | 全选按钮 |
| Property | Default Value | Description |
|---|---|---|
| | Selection mode |
| | Support search |
| | Select all button |
AddressField
AddressField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 国家模式 |
| | 地址类型 |
| | 启用定位 |
| | 显示国家 |
| Property | Default Value | Description |
|---|---|---|
| | Country mode |
| | Address type |
| | Enable location |
| | Show country |
AttachmentField
AttachmentField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 列表展示类型 |
| | 允许多文件 |
| | 最大文件数 |
| | 最大文件大小(MB) |
| | 自动上传 |
| | 在线编辑 |
| Property | Default Value | Description |
|---|---|---|
| | List display type |
| | Allow multiple files |
| | Maximum number of files |
| | Maximum file size (MB) |
| | Auto upload |
| | Online editing |
ImageField
ImageField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 列表展示类型 |
| | 允许多图片 |
| | 最大图片数 |
| | 最大文件大小(MB) |
| | 接受文件类型 |
| | 拍照水印日期 |
| | 拍照水印定位 |
| | 仅拍照上传 |
| Property | Default Value | Description |
|---|---|---|
| | List display type |
| | Allow multiple images |
| | Maximum number of images |
| | Maximum file size (MB) |
| | Accepted file types |
| | Camera watermark date |
| | Camera watermark location |
| | Camera upload only |
TableField
TableField
| 属性 | 默认值 | 说明 |
|---|---|---|
| | 显示行号 |
| | 每页行数 |
| | 最大行数 |
| | 最小行数 |
| | PC 端布局 |
| | 移动端布局 |
| | 表格主题 |
| | 显示操作列 |
| | 显示删除按钮 |
| | 显示复制按钮 |
| | 允许导出 |
| | 允许导入 |
| | 批量删除 |
| | 启用汇总 |
| | 冻结操作列 |
| Property | Default Value | Description |
|---|---|---|
| | Show row numbers |
| | Number of rows per page |
| | Maximum number of rows |
| | Minimum number of rows |
| | PC-side layout |
| | Mobile layout |
| | Table theme |
| | Show action column |
| | Show delete button |
| | Show copy button |
| | Allow export |
| | Allow import |
| | Batch delete |
| | Enable summary |
| | Freeze action column |
AssociationFormField
AssociationFormField
详细用法参考reference/AssociationFormField.md
For detailed usage, refer toreference/AssociationFormField.md
SerialNumberField
SerialNumberField
| 属性 | 默认值 | 说明 |
|---|---|---|
| 默认规则(前缀+自动递增) | 流水号生成规则数组 |
| | 流水号预览 |
| | 重置起始值 |
| | 是否同步流水号配置 |
| 自动生成 | 流水号公式(由系统自动生成,包含 corpId、appType、formUuid、fieldId 和规则配置) |
默认流水号规则:
- 规则1:固定前缀 "serial"(4位)
- 规则2:自动递增数字(5位,从1开始,不重置)
formula 格式(对象格式,不是字符串):
json
{
"formula": {
"expression": "SERIALNUMBER(\"<corpId>\", \"<appType>\", \"<formUuid>\", \"<fieldId>\", \"<escapedRuleJson>\")"
}
}其中 是 的 JSON 字符串,需对双引号转义( → )。
<escapedRuleJson>{ "type": "custom", "value": <serialNumberRule数组> }"\"| Property | Default Value | Description |
|---|---|---|
| Default rule (prefix + auto-increment) | Serial number generation rule array |
| | Serial number preview |
| | Reset starting value |
| | Whether to sync serial number configuration |
| Auto-generated | Serial number formula (automatically generated by the system, including corpId, appType, formUuid, fieldId and rule configuration) |
Default Serial Number Rule:
- Rule 1: Fixed prefix "serial" (4 characters)
- Rule 2: Auto-incrementing numbers (5 digits, starting from 1, no reset)
formula Format (object format, not string):
json
{
"formula": {
"expression": "SERIALNUMBER(\"<corpId>\", \"<appType>\", \"<formUuid>\", \"<fieldId>\", \"<escapedRuleJson>\")"
}
}Where is the JSON string of , with double quotes escaped ( → ).
<escapedRuleJson>{ "type": "custom", "value": <serialNumberRule array> }"\"修改定义 JSON 格式(update 模式)
Modification Definition JSON Format (update mode)
修改定义是一个 JSON 数组,每个元素描述一条修改操作。可以直接作为命令行参数传入 JSON 字符串,也可以写入文件后传入文件路径。
json
[
{ "action": "add", "field": { "type": "TextField", "label": "姓名", "required": true } },
{ "action": "add", "field": { "type": "SelectField", "label": "部门", "options": ["技术部", "产品部"] }, "after": "姓名" },
{ "action": "delete", "label": "备注" },
{ "action": "update", "label": "年龄", "changes": { "required": true, "placeholder": "请输入年龄" } },
{ "action": "update", "label": "状态", "changes": { "label": "审批状态", "options": ["待审批", "已通过", "已拒绝"] } }
]Modification definition is a JSON array, where each element describes a modification operation. It can be directly passed as a JSON string in the command line parameter, or written to a file and then passed as the file path.
json
[
{ "action": "add", "field": { "type": "TextField", "label": "姓名", "required": true } },
{ "action": "add", "field": { "type": "SelectField", "label": "部门", "options": ["技术部", "产品部"] }, "after": "姓名" },
{ "action": "delete", "label": "备注" },
{ "action": "update", "label": "年龄", "changes": { "required": true, "placeholder": "请输入年龄" } },
{ "action": "update", "label": "状态", "changes": { "label": "审批状态", "options": ["待审批", "已通过", "已拒绝"] } }
]操作类型
Operation Types
| 操作 | 必填属性 | 可选属性 | 说明 |
|---|---|---|---|
| | | 新增字段, |
| | — | 删除指定标签的字段 |
| | | 修改指定标签字段的属性;若字段在子表内,需通过 |
| Operation | Required Properties | Optional Properties | Description |
|---|---|---|---|
| | | Add a new field, |
| | — | Delete the field with the specified label |
| | | Modify properties of the field with the specified label; if the field is in a sub-table, specify the parent-child table label via |
update 的 changes 支持的属性
Properties Supported by update's changes
| 属性 | 类型 | 说明 |
|---|---|---|
| String | 修改字段标签 |
| Boolean | 修改是否必填 |
| String | 修改占位提示 |
| String[] | 修改选项列表(选项类字段:RadioField/SelectField/CheckboxField/MultiSelectField) |
| Boolean | 修改是否多选(EmployeeField/DepartmentSelectField/CountrySelectField) |
| String | 修改字段行为: |
| String[] | 修改显示端: |
| String | 修改数字字段单位(仅 |
| Property | Type | Description |
|---|---|---|
| String | Modify field label |
| Boolean | Modify whether it is required |
| String | Modify placeholder prompt |
| String[] | Modify option list (for option-type fields: RadioField/SelectField/CheckboxField/MultiSelectField) |
| Boolean | Modify whether multiple selection is allowed (EmployeeField/DepartmentSelectField/CountrySelectField) |
| String | Modify field behavior: |
| String[] | Modify display terminals: |
| String | Modify number field unit (only available for |
add 的 field 字段定义
Field Definition for add's field
与 create 模式的字段定义格式完全一致,参见上方「字段定义 JSON 格式」章节。
Identical to the field definition format in create mode, refer to the "Field Definition JSON Format" section above.
前置依赖
Prerequisites
- Node.js
- 项目根目录存在 (首次运行会自动触发扫码登录)
.cache/cookies.json
- Node.js
- exists in the project root directory (scan code login will be triggered automatically on first run)
.cache/cookies.json
调用流程
Calling Process
create 模式
create mode
- 准备字段定义 JSON 文件
- 读取项目根目录的 获取登录态(包含 corpId);若不存在则自动调用
.cache/cookies.json触发扫码登录login.py - 调用 接口创建空白表单,获取 formUuid;根据响应体
saveFormSchemaInfo自动处理异常(详见errorCode技能文档「错误处理机制」章节)yida-login - 根据字段定义生成表单 Schema JSON(SerialNumberField 的 formula 会自动使用 corpId、appType、formUuid 和 fieldId 构建)
- 调用 接口保存 Schema;同样根据响应体
saveFormSchema自动处理异常errorCode - 调用 接口更新表单配置(MINI_RESOURCE = 0);同样根据响应体
updateFormConfig自动处理异常errorCode
- Prepare the field definition JSON file
- Read in the project root directory to obtain the login state (including corpId); if it does not exist, automatically call
.cache/cookies.jsonto trigger scan code loginlogin.py - Call the API to create a blank form and get formUuid; automatically handle exceptions according to the
saveFormSchemaInfoin the response body (see the "Error Handling Mechanism" section of the yida-login skill document)errorCode - Generate the form Schema JSON based on the field definition (the formula of SerialNumberField will automatically use corpId, appType, formUuid and fieldId to construct)
- Call the API to save the Schema; also automatically handle exceptions according to the
saveFormSchemain the response bodyerrorCode - Call the API to update the form configuration (MINI_RESOURCE = 0); also automatically handle exceptions according to the
updateFormConfigin the response bodyerrorCode
update 模式
update mode
- 读取项目根目录的 获取登录态(包含 corpId);若不存在则自动调用
.cache/cookies.json触发扫码登录login.py - 调用 接口获取当前表单的完整 Schema;根据响应体
getFormSchema自动处理异常:errorCode- (csrf 校验失败)→ 自动刷新 csrf_token 后重试
errorCode: "TIANSHU_000030" - (登录过期)→ 自动重新登录后重试
errorCode: "307"
- 解析修改定义(JSON 字符串或 JSON 文件)
- 按顺序执行每条修改操作:
- add:构建新字段组件,插入到指定位置(或末尾)
- delete:按标签查找并移除字段
- update:按标签查找字段并更新其属性
- 为所有 SerialNumberField 设置 formula(使用 corpId、appType、formUuid 和 fieldId)
- 调用 接口保存修改后的 Schema;同样根据响应体
saveFormSchema自动处理异常(同上)errorCode - 调用 接口更新表单配置(MINI_RESOURCE = 0);同样根据响应体
updateFormConfig自动处理异常(同上)errorCode
- Read in the project root directory to obtain the login state (including corpId); if it does not exist, automatically call
.cache/cookies.jsonto trigger scan code loginlogin.py - Call the API to obtain the complete Schema of the current form; automatically handle exceptions according to the
getFormSchemain the response body:errorCode- (csrf verification failed) → automatically refresh csrf_token and retry
errorCode: "TIANSHU_000030" - (login expired) → automatically re-login and retry
errorCode: "307"
- Parse the modification definition (JSON string or JSON file)
- Execute each modification operation in order:
- add: Construct a new field component and insert it at the specified position (or at the end)
- delete: Find and remove the field by label
- update: Find the field by label and update its properties
- Set the formula for all SerialNumberField (using corpId, appType, formUuid and fieldId)
- Call the API to save the modified Schema; also automatically handle exceptions according to the
saveFormSchemain the response body (same as above)errorCode - Call the API to update the form configuration (MINI_RESOURCE = 0); also automatically handle exceptions according to the
updateFormConfigin the response body (same as above)errorCode
文件结构
File Structure
yida-create-form-page/
├── SKILL.md # 本文档
└── scripts/
├── create-form-page.js # 表单页面创建 & 更新脚本yida-create-form-page/
├── SKILL.md # This document
└── scripts/
├── create-form-page.js # Form page creation & update script接口说明
API Description
saveFormSchemaInfo(创建空白表单,create 模式)
saveFormSchemaInfo (Create Blank Form, create mode)
- 地址:
POST /dingtalk/web/{appType}/query/formdesign/saveFormSchemaInfo.json - Content-Type:
application/x-www-form-urlencoded - 参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | CSRF Token(由 yida-login 获取) |
| String | 是 | 表单类型,固定 |
| String (JSON) | 是 | 表单名称,i18n 格式: |
- 返回值:
json
{
"content": { "formUuid": "FORM-XXX" },
"success": true
}- URL:
POST /dingtalk/web/{appType}/query/formdesign/saveFormSchemaInfo.json - Content-Type:
application/x-www-form-urlencoded - Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | CSRF Token (obtained from yida-login) |
| String | Yes | Form type, fixed as |
| String (JSON) | Yes | Form name, in i18n format: |
- Return Value:
json
{
"content": { "formUuid": "FORM-XXX" },
"success": true
}getFormSchema(获取表单 Schema,update 模式)
getFormSchema (Obtain Form Schema, update mode)
- 地址:
GET /alibaba/web/{appType}/_view/query/formdesign/getFormSchema.json - 参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单 UUID |
| String | 否 | Schema 版本,默认 |
- 返回值:完整的表单 Schema JSON,包含 数组,结构与
pages保存的格式一致saveFormSchema
- URL:
GET /alibaba/web/{appType}/_view/query/formdesign/getFormSchema.json - Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form UUID |
| String | No | Schema version, default |
- Return Value: Complete form Schema JSON, including array, with the same structure as the format saved by
pagessaveFormSchema
saveFormSchema(保存表单 Schema,两种模式共用)
saveFormSchema (Save Form Schema, shared by both modes)
- 地址:
POST /dingtalk/web/{appType}/_view/query/formdesign/saveFormSchema.json - Content-Type:
application/x-www-form-urlencoded - 参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | CSRF Token(由 yida-login 获取) |
| String | 是 | 表单 UUID |
| String (JSON) | 是 | 表单 Schema 内容( |
| String | 是 | 固定 |
| String | 是 | 固定 |
- 返回值:
json
{ "success": true }- URL:
POST /dingtalk/web/{appType}/_view/query/formdesign/saveFormSchema.json - Content-Type:
application/x-www-form-urlencoded - Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | CSRF Token (obtained from yida-login) |
| String | Yes | Form UUID |
| String (JSON) | Yes | Form Schema content ( |
| String | Yes | Fixed as |
| String | Yes | Fixed as |
- Return Value:
json
{ "success": true }updateFormConfig(更新表单配置)
updateFormConfig (Update Form Configuration)
- 地址:
POST /dingtalk/web/{appType}/query/formdesign/updateFormConfig.json - Content-Type:
application/x-www-form-urlencoded - 参数:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | CSRF Token(由 yida-login 获取) |
| String | 是 | 表单 UUID |
| Number | 是 | 版本号(新创建的表单从 1 开始) |
| String | 是 | 固定 |
| Number | 是 | 固定 |
- 返回值:
json
{
"success": true,
"traceId": null,
"throwable": null,
"errorCode": null,
"content": null,
"errorMsg": null
}- URL:
POST /dingtalk/web/{appType}/query/formdesign/updateFormConfig.json - Content-Type:
application/x-www-form-urlencoded - Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | CSRF Token (obtained from yida-login) |
| String | Yes | Form UUID |
| Number | Yes | Version number (starts from 1 for newly created forms) |
| String | Yes | Fixed as |
| Number | Yes | Fixed as |
- Return Value:
json
{
"success": true,
"traceId": null,
"throwable": null,
"errorCode": null,
"content": null,
"errorMsg": null
}支持的字段类型
Supported Field Types
| 字段类型 | componentName | 说明 | 特殊属性 |
|---|---|---|---|
| TextField | 单行文本,用于姓名、标题、编号等 | — |
| TextareaField | 多行文本,用于描述、备注等 | — |
| RadioField | 单选,用于性别、状态等互斥选项 | |
| SelectField | 下拉单选,适合选项较多(>5)的场景 | |
| CheckboxField | 多选,用于兴趣爱好、技能标签等 | |
| MultiSelectField | 下拉多选,适合选项较多(>5)的场景 | |
| NumberField | 数字,用于金额、数量、年龄等 | — |
| RateField | 评分,用于满意度评价等星级打分 | — |
| DateField | 日期,用于生日、截止日期等 | — |
| CascadeDateField | 级联日期,用于日期范围选择 | — |
| EmployeeField | 成员,选择组织内成员 | |
| DepartmentSelectField | 部门,选择组织内部门 | |
| CountrySelectField | 国家,选择国家/地区 | |
| AddressField | 地址,用于收货地址等 | — |
| AttachmentField | 附件上传 | — |
| ImageField | 图片上传 | — |
| TableField | 表格(子表),用于结构化数据 | |
| AssociationFormField | 关联表单 | |
| SerialNumberField | 流水号,自动生成唯一编号 | |
| Field Type | componentName | Description | Special Properties |
|---|---|---|---|
| TextField | Single-line text, used for names, titles, numbers, etc. | — |
| TextareaField | Multi-line text, used for descriptions, remarks, etc. | — |
| RadioField | Single selection, used for gender, status and other mutually exclusive options | |
| SelectField | Drop-down single selection, suitable for scenarios with many options (>5) | |
| CheckboxField | Multiple selection, used for hobbies, skill tags, etc. | |
| MultiSelectField | Drop-down multiple selection, suitable for scenarios with many options (>5) | |
| NumberField | Number, used for amounts, quantities, ages, etc. | — |
| RateField | Rating, used for satisfaction evaluation and other star rating scenarios | — |
| DateField | Date, used for birthdays, deadlines, etc. | — |
| CascadeDateField | Cascading date, used for date range selection | — |
| EmployeeField | Member, select members within the organization | |
| DepartmentSelectField | Department, select departments within the organization | |
| CountrySelectField | Country, select countries/regions | |
| AddressField | Address, used for shipping addresses, etc. | — |
| AttachmentField | Attachment upload | — |
| ImageField | Image upload | — |
| TableField | Table (sub-table), used for structured data | |
| AssociationFormField | Associated form | |
| SerialNumberField | Serial number, automatically generate unique numbers | |
与其他技能配合
Cooperation with Other Skills
- 创建应用 → 使用 技能获取
yida-create-appappType - 创建表单页面 → 本技能(create 模式),获取 和字段 ID
formUuid - 更新表单页面 → 本技能(update 模式),对已有表单进行字段增删改
- 获取表单 Schema → 可使用 技能预先查看当前表单结构
get-schema - 记录配置 → 将 和字段 ID 写入
formUuidprd/<项目名>.md - 创建自定义页面 → 使用 技能
yida-create-page - 部署页面代码 → 使用 技能
yida-publish
提示:如果需要创建的是自定义展示页面(无字段,用于部署 JSX 代码),请使用技能。yida-create-page
- Create Application → Use skill to get
yida-create-appappType - Create Form Page → This skill (create mode), get and field IDs
formUuid - Update Form Page → This skill (update mode), perform field add/delete/modify on existing forms
- Obtain Form Schema → Use skill to view the current form structure in advance
get-schema - Record Configuration → Write and field IDs to
formUuidprd/<project-name>.md - Create Custom Page → Use skill
yida-create-page - Deploy Page Code → Use skill
yida-publish
Tip: If you need to create a custom display page (no fields, used for deploying JSX code), please use theskill.yida-create-page
表单数据操作 API
Form Data Operation APIs
以下 API 用于在自定义页面或脚本中对表单数据进行增删改查,通过调用,所有接口返回 Promise。this.utils.yida.<方法名>(params)
The following APIs are used to perform add/delete/modify/search operations on form data in custom pages or scripts, called via, all APIs return Promise.this.utils.yida.<method-name>(params)
saveFormData — 新建表单实例
saveFormData — Create New Form Instance
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单 UUID |
| String | 是 | 应用 ID |
| String | 是 | 表单数据(JSON 字符串) |
javascript
this.utils.yida.saveFormData({
formUuid: 'FORM-XXX',
appType: window.pageConfig.appType,
formDataJson: JSON.stringify({
textField_xxx: '单行文本',
numberField_xxx: 100,
}),
}).then(function(res) {
console.log('新建成功,实例ID:', res.result);
}).catch(function(err) {
console.error('新建失败:', err.message);
});| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form UUID |
| String | Yes | Application ID |
| String | Yes | Form data (JSON string) |
javascript
this.utils.yida.saveFormData({
formUuid: 'FORM-XXX',
appType: window.pageConfig.appType,
formDataJson: JSON.stringify({
textField_xxx: 'Single-line text',
numberField_xxx: 100,
}),
}).then(function(res) {
console.log('Created successfully, instance ID:', res.result);
}).catch(function(err) {
console.error('Creation failed:', err.message);
});updateFormData — 更新表单实例
updateFormData — Update Form Instance
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单实例 ID |
| String | 是 | 需要更新的字段(JSON 字符串) |
javascript
this.utils.yida.updateFormData({
formInstId: 'FINST-XXX',
updateFormDataJson: JSON.stringify({ textField_xxx: '新值' }),
});| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form instance ID |
| String | Yes | Fields to be updated (JSON string) |
javascript
this.utils.yida.updateFormData({
formInstId: 'FINST-XXX',
updateFormDataJson: JSON.stringify({ textField_xxx: 'New value' }),
});deleteFormData — 删除表单实例
deleteFormData — Delete Form Instance
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单 UUID |
| String | 是 | 表单实例 ID |
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form UUID |
| String | Yes | Form instance ID |
getFormDataById — 查询单条实例详情
getFormDataById — Query Single Instance Details
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单实例 ID |
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form instance ID |
searchFormDatas — 按条件搜索实例列表
searchFormDatas — Query Instance List by Condition
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单 UUID |
| String | 否 | 按字段值筛选(JSON 字符串) |
| Number | 否 | 当前页,默认 1 |
| Number | 否 | 每页记录数,默认 10,最大 100 |
javascript
this.utils.yida.searchFormDatas({
formUuid: 'FORM-XXX',
searchFieldJson: JSON.stringify({ textField_xxx: '查询值' }),
currentPage: 1,
pageSize: 10,
}).then(function(res) {
// res.data: 实例列表,res.totalCount: 总数
console.log('查询结果:', res.data);
});| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form UUID |
| String | No | Filter by field value (JSON string) |
| Number | No | Current page, default 1 |
| Number | No | Number of records per page, default 10, maximum 100 |
javascript
this.utils.yida.searchFormDatas({
formUuid: 'FORM-XXX',
searchFieldJson: JSON.stringify({ textField_xxx: 'Query value' }),
currentPage: 1,
pageSize: 10,
}).then(function(res) {
// res.data: Instance list, res.totalCount: Total number
console.log('Query results:', res.data);
});searchFormDataIds — 按条件搜索实例 ID 列表
searchFormDataIds — Query Instance ID List by Condition
参数同 ,返回实例 ID 数组(适合批量操作场景)。
searchFormDatasSame parameters as , returns an array of instance IDs (suitable for batch operation scenarios).
searchFormDatasgetFormComponentDefinationList — 获取表单字段定义
getFormComponentDefinationList — Obtain Form Field Definitions
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| String | 是 | 表单 UUID |
| Parameter | Type | Required | Description |
|---|---|---|---|
| String | Yes | Form UUID |
注意事项
Notes
- 临时文件写在当前工程根目录的 .cache 文件夹中,如果没有就创建一个文件夹,注意不要写在系统的其他文件夹中
- update 模式中,修改定义 JSON 的操作按顺序执行,注意操作间的依赖关系(如先删后加)
- 字段匹配基于中文标签(),确保标签名称准确
label.zh_CN - 新增字段时会自动更新 ,无需手动处理
componentsMap - 建议在重要修改前先通过 技能查看当前 Schema 结构
get-schema - 脚本兼容旧的 create 模式调用方式(不带 前缀),但推荐使用新的显式模式参数
create
- Temporary files are written to the .cache folder in the current project root directory; create the folder if it does not exist, do not write to other system folders
- In update mode, the operations in the modification definition JSON are executed in sequence, pay attention to the dependencies between operations (e.g., delete first then add)
- Field matching is based on Chinese labels (), ensure the label name is accurate
label.zh_CN - is automatically updated when adding fields, no manual handling required
componentsMap - It is recommended to view the current Schema structure via the skill before making important modifications
get-schema - The script is compatible with the old create mode calling method (without the prefix), but it is recommended to use the new explicit mode parameter
create
EmployeeField 设置默认值为当前登录人
Set Default Value of EmployeeField to Current Logged-in User
create-form-page.jsThe update mode of does not support directly setting the "current logged-in user" default value for EmployeeField, which needs to be achieved by directly modifying the Schema after update.
create-form-page.js正确的 Schema 配置格式
Correct Schema Configuration Format
宜搭 EmployeeField 设置默认值为当前登录人,需要同时修改以下三个属性(通过 获取 Schema 后直接修改对应字段的 props,再调用 保存):
getFormSchemasaveFormSchemajson
{
"valueType": "variable",
"complexValue": {
"complexType": "formula",
"formula": "USER()",
"value": []
},
"variable": {
"type": "user"
}
}⚠️ 注意:必须是formula,不是"USER()"(后者会被宜搭拒绝,报"表达式解析失败"错误)。"CURRENT_USER()"
To set the default value of Yida EmployeeField to the current logged-in user, the following three properties need to be modified simultaneously (obtain the Schema via , directly modify the props of the corresponding field, then call to save):
getFormSchemasaveFormSchemajson
{
"valueType": "variable",
"complexValue": {
"complexType": "formula",
"formula": "USER()",
"value": []
},
"variable": {
"type": "user"
}
}⚠️ Note:must beformula, not"USER()"(the latter will be rejected by Yida, reporting "Expression parsing failed" error)."CURRENT_USER()"
修改步骤
Modification Steps
- 调用 获取当前 Schema(返回结构为
getFormSchema){ success, content: { pages, ... } } - 在 对象中递归找到目标
content的字段节点fieldId - 将上述三个属性写入该字段节点
- 调用 传入修改后的
saveFormSchema(注意:传的是content对象,不是整个响应体)content - 调用 更新表单配置
updateFormConfig
- Call to obtain the current Schema (return structure is
getFormSchema){ success, content: { pages, ... } } - Recursively find the field node of the target in the
fieldIdobjectcontent - Write the above three properties to the field node
- Call and pass in the modified
saveFormSchema(note: pass thecontentobject, not the entire response body)content - Call to update the form configuration
updateFormConfig
SerialNumberField 流水号规则详解
Detailed Explanation of SerialNumberField Serial Number Rules
默认场景(无自定义需求)
Default Scenario (No Custom Requirements)
只有一条 规则,4 位自增,从 1 开始,不重置:
autoCountjson
{
"serialNumberRule": [
{
"resetPeriod": "noClean",
"dateFormat": "yyyyMMdd",
"ruleType": "autoCount",
"timeZone": "+8",
"__sid": "item_auto_count",
"__hide_delete__": true,
"__sid__": "serial_auto_count",
"digitCount": "4",
"isFixed": true,
"initialValue": 1,
"content": "",
"formField": ""
}
],
"serialNumPreview": "0001"
}⚠️ 注意:默认场景的规则autoCount必须为__hide_delete__(不可删除),true为字符串digitCount。"4"
Only one rule, 4-digit auto-increment, starting from 1, no reset:
autoCountjson
{
"serialNumberRule": [
{
"resetPeriod": "noClean",
"dateFormat": "yyyyMMdd",
"ruleType": "autoCount",
"timeZone": "+8",
"__sid": "item_auto_count",
"__hide_delete__": true,
"__sid__": "serial_auto_count",
"digitCount": "4",
"isFixed": true,
"initialValue": 1,
"content": "",
"formField": ""
}
],
"serialNumPreview": "0001"
}⚠️ Note: For the defaultrule,autoCountmust be__hide_delete__(cannot be deleted), andtrueis the stringdigitCount."4"
自定义场景(多规则组合)
Custom Scenario (Combination of Multiple Rules)
支持以下 4 种规则类型,可任意组合排列:
| 说明 | 关键字段 |
|---|---|---|
| 自动计数(自增数字) | |
| 固定字符 | |
| 提交日期 | |
| 取表单字段值 | |
自定义规则通用结构:
json
{
"resetPeriod": "noClean",
"dateFormat": "yyyyMMdd",
"ruleType": "<类型>",
"timeZone": "+8",
"__sid": "item_<唯一id>",
"__hide_delete__": false,
"__sid__": "serial_<唯一id>",
"digitCount": 4,
"isFixed": true,
"initialValue": 1,
"content": "<固定字符,仅 character 类型填写>",
"formField": "<字段fieldId,仅 form 类型填写>",
"isFixedTips": "",
"resetPeriodTips": ""
}⚠️ 注意:自定义规则中为数字类型(不是字符串),digitCount为__hide_delete__;而默认false规则的autoCount是字符串digitCount,"4"为__hide_delete__。true
resetPeriod| 值 | 说明 |
|---|---|
| 不重置(永久自增) |
| 每天重置 |
| 每月重置 |
| 每年重置 |
dateFormatdate| 值 | 示例 |
|---|---|
| |
| |
| |
| |
示例: 的规则配置:
YY-提交日期-自动计数4位json
{
"serialNumberRule": [
{
"ruleType": "character",
"content": "YY",
"dateFormat": "yyyyMMdd", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_char_yy", "__sid__": "serial_char_yy", "__hide_delete__": false
},
{
"ruleType": "date",
"content": "",
"dateFormat": "yy", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_date_yy", "__sid__": "serial_date_yy", "__hide_delete__": false
},
{
"ruleType": "autoCount",
"content": "",
"dateFormat": "yyyyMMdd", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_auto", "__sid__": "serial_auto", "__hide_delete__": true
}
],
"serialNumPreview": "YY260001"
}The following 4 rule types are supported, which can be combined and arranged arbitrarily:
| Description | Key Fields |
|---|---|---|
| Auto count (auto-incrementing numbers) | |
| Fixed character | |
| Submission date | |
| Get form field value | |
Custom Rule General Structure:
json
{
"resetPeriod": "noClean",
"dateFormat": "yyyyMMdd",
"ruleType": "<type>",
"timeZone": "+8",
"__sid": "item_<unique-id>",
"__hide_delete__": false,
"__sid__": "serial_<unique-id>",
"digitCount": 4,
"isFixed": true,
"initialValue": 1,
"content": "<fixed-character, only fill for character type>",
"formField": "<field-fieldId, only fill for form type>",
"isFixedTips": "",
"resetPeriodTips": ""
}⚠️ Note: In custom rules,is of number type (not string), anddigitCountis__hide_delete__; while in the defaultfalserule,autoCountis the stringdigitCountand"4"is__hide_delete__.true
resetPeriod| Value | Description |
|---|---|
| No reset (permanent auto-increment) |
| Reset daily |
| Reset monthly |
| Reset annually |
dateFormatdate| Value | Example |
|---|---|
| |
| |
| |
| |
Example: Rule Configuration for :
YY-Submission Date-4-digit Auto Countjson
{
"serialNumberRule": [
{
"ruleType": "character",
"content": "YY",
"dateFormat": "yyyyMMdd", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_char_yy", "__sid__": "serial_char_yy", "__hide_delete__": false
},
{
"ruleType": "date",
"content": "",
"dateFormat": "yy", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_date_yy", "__sid__": "serial_date_yy", "__hide_delete__": false
},
{
"ruleType": "autoCount",
"content": "",
"dateFormat": "yyyyMMdd", "timeZone": "+8",
"resetPeriod": "noClean", "digitCount": 4,
"isFixed": true, "initialValue": 1,
"isFixedTips": "", "resetPeriodTips": "",
"formField": "",
"__sid": "item_auto", "__sid__": "serial_auto", "__hide_delete__": true
}
],
"serialNumPreview": "YY260001"
}formula 构建规则
formula Construction Rules
formulaexpression{ "type": "custom", "value": <serialNumberRule数组> }javascript
var ruleJson = JSON.stringify({ type: 'custom', value: serialNumberRule });
var escapedRuleJson = ruleJson.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
var expression = 'SERIALNUMBER("' + corpId + '", "' + appType + '", "' + formUuid + '", "' + fieldId + '", "' + escapedRuleJson + '")';
obj.formula = { expression: expression };formulaexpression{ "type": "custom", "value": <serialNumberRule array> }javascript
var ruleJson = JSON.stringify({ type: 'custom', value: serialNumberRule });
var escapedRuleJson = ruleJson.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
var expression = 'SERIALNUMBER("' + corpId + '", "' + appType + '", "' + formUuid + '", "' + fieldId + '", "' + escapedRuleJson + '")';
obj.formula = { expression: expression };