跳到主要内容
版本:1.1.0

《题型物料协议规范》

版本

1.0.0

版本规范

版本号使用 MAJOR.MINOR.PATCH:

  1. 大版本:协议结构修订且不兼容时使用MAJOR
  2. 小版本:协议结构修订且向下兼容时使用MINOR
  3. 打补丁:协议结构修订问题或者缺陷时使用PATCH

背景

对题型物料组件在问卷搭建中所具备的配置能力和交互行为进行规范化描述。

题组件针对问卷平台接入时可以使用一份统一的描述内容,让不同平台对组件接入的实现保持一致,缩小不同平台接入题型物料组件的成本。

协议概述

基于Schema实现可视化搭建问卷的能力,满足用户自定义配置题目。

{Question}Module\meta.js

协议结构

包含以下三部分内容:

  • 基础信息: 描述题型的基础信息,如题型名称、题型类型。
  • 题型属性配置: 用于题型属性配置能力的描述,即设置器配置。
  • 题型内容配置: 用于题型内容如标题和子标题管理、选项管理等配置描述。

顶级结构

字段类型描述
$schemaStringSchema URL
versionString(Semver)版本号
titleString题型名称
typeString题型标识
formConfigArray题型属性配置
editConfigObject题型内容配置

示例:

{
"$schema": "https://xiaojuwenjuan/schema/draft/2023-08/component-schema.json",
"version": "1.0.0",
"title": "多选题",
"type": "checkbox",
"formConfig": [
{
"name": "basicConfig",
"label": "基础配置",
"type": "CheckboxGroup",
"key": "basicConfig",
"labelStyle": {
"font-weight": "bold"
},
"options": [
{
"label": "必填",
"key": "isRequired"
},
{
"label": "显示类型",
"key": "showType"
},
{
"label": "显示序号",
"key": "showIndex"
},
{
"label": "显示分割线",
"key": "showSpliter",
"tip": "题目下方分割线,仅在移动端展示。"
}
],
"valueAdapter": valueAdapter({ moduleConfig }) {

return _pick(moduleConfig, this.options.map(item => item.key))

}

},
{
"name": "optionConfig",
"label": "选项配置",
"type": "Customed",
"key": "optionConfig",
"labelStyle": {
"font-weight": "bold"
},
"content": [
{
"label": "至少选择数",
"type": "InputNumber",
"key": "minNum",
"direction": "horizon",
"value": "",
"min": 0,
"max": "maxNum",
"exclude": [
"radio-v",
"radio-h",
"appointment",
"matrix-radio",
"combination"
],
"contentClass": "input-number-config"
},
{
"label": "最多选择数",
"type": "InputNumber",
"key": "maxNum",
"direction": "horizon",
"value": "",
"min": "minNum",
"exclude": [
"radio-v",
"radio-h",
"appointment",
"matrix-radio",
"combination"
],
"contentClass": "input-number-config"
}
]
}
],
"editConfig": {
"optionEdit": {
"show": true
},
"optionEditBar": {
"show": true,
"configure": {
"showOthers": true,
"showAdvancedConfig": true
}
}
}
}

基础信息

题型基础字段的描述

字段类型描述
titleEnum<String>题型名称,如单行输入框、单选题、多选题、星级评分题、
typeEnum<String>题型标识,如text、radio、checkbox、radio-star

题型属性配置

题型属性(formConfig)的描述

字段类型说明
nameString配置名称,可作唯一值标识
labelString配置标题
typeString配置所需设置器
keyString配置关联题目字段
contentArray<formConfig>用于实现多个配置的组合,当type = Customed时生效
optionsArray可选、传入的options,具体字段可参考示例
relyFuncJson expression可选、控制配置是否显示
excludeArray可选、不包含该配置的题目列表
valueGetterString可选、配置取值映射
valueSetterString可选、配置设置值的映射
labelStyleObject可选、自定义label样式
contentClassString可选、自定义类名
directionenum可选、布局方向
contentPositionenum可选、label在前还是在后
inlineBoolean可选、是否行内

题型内容配置

题型内容如标题、子标题和选项内容配置(editConfig)的描述

字段类型说明
optionEdit<Configure>配置选项,具体见下表
optionEditBar<Configure>

Configure配置

字段类型说明
showBoolean是否显示
configureObject可选,具体配置项可透传到对应的编辑态组件,具体字段可参考示例