基于元数据的模型数据规范

@GuoYongfeng 2019-01-23 06:59:56发表于 iuap-design/blog

1、整体输出规范

{
	// 输出请求结果和状态
	code: "",
	// 返回请求消息描述
	message: "",
	// 元数据标准结果
	data: {}
}

2、data 描述规范

{
	// 描述模型的元数据
	viewmodel: {},
	// 描述UI视图的元数据
	viewApplication: {}
}

3、viewmodel 模型元数据定义规范

3.1 viewmodel 整体规范

item 字段 含义
1 iBillId 单据唯一 ID
2 cBillName 单据名称
3 cBillNo 单据编号
4 cBillType 单据类型,如:Voucher
5 bPrintLimited 是否允许打印单据
{
	"iBillId": 1000051923,
	"cBillName": "店存出库单",
	"cBillNo": "st_storeout",
	"bPrintLimited": true,
	"cBillType": "Voucher",
	"cSubId": "ST",
	"bBatchOperate": true,
	// 描述规范请参考3.3
	"entities": [],
	// 描述规范请参考3.4
	"actions": [],
	// 描述规范请参考3.5
	"states": []
}

3.3 entities 定义规范

[
	{
		"cCode": "st_storeout",
		"cEntityName": "店存出库单",
		"cType": "Bill",
		"bIsNull": false,
		"cDataSourceName": "st.storeout.StoreOut",
		"cPrimaryKey": "id",
		"iBillEntityId": 70363,
		"bMain": true,
		"cControlType": "div",
		// 具体描述和定义请参考3.3.1
		"fields": []
	}
]

3.3.1 entities 实体中的 fields 定义规范

  item 字段   含义
1 bShowIt/bHidden 控件显隐
2 cControlType 控件类型
3 cShowCaption 控件标题
4 iMaxLength 文本输入框输入长度
5 bIsNull 是否必填
6 bCanModify 是否只读
7 bNeedSum 是否合计
8 bPrintUpCase 是否转换为大写金额
9 iOrder 排序
{
	"cFieldName": "totalQuantity",
	"cItemName": "totalQuantity",
	"cCaption": "整单数量",
	"cShowCaption": "整单数量",
	"iBillEntityId": 70363,
	"iBillTplGroupId": 521950,
	"iTplId": 58112,
	"iMaxLength": 255,
	"iFieldType": 1,
	"bEnum": false,
	"bMustSelect": false,
	"bHidden": false,
	"bSplit": false,
	"bExtend": false,
	"bCanModify": false,
	"iMaxShowLen": 255,
	"iColWidth": 1,
	"bNeedSum": false,
	"bShowIt": false,
	"bFilter": true,
	"cFormatData": "{\"decimal\":\"\u003c%option.quantitydecimal%\u003e\"}",
	"bIsNull": true,
	"bPrintCaption": true,
	"bJointQuery": false,
	"bPrintUpCase": false,
	"bSelfDefine": false,
	"cTplGroupName": "基本信息数据区",
	"bMain": true,
	"cDataSourceName": "st.storeout.StoreOut",
	"cControlType": "InputNumber",
	"bVmExclude": 0,
	"iOrder": 336,
	"isshoprelated": false,
	"iSystem": 1,
	"authLevel": 3
}

3.4 actions 定义规范

[
	{
		"cCommand": "cmdEditAbandon",
		"cAction": "abandon",
		"cSvcUrl": "/bill/abandon.do",
		"cHttpMethod": "GET",
		"cTarget": "Browstoolbar_left"
	}
]

3.5 states 定义规范

[
	{
		"cCode": "finalaudit",
		"cCondition": "data.auditor",
		// 具体描述和定义请参考3.5.1
		"items": []
	}
]

3.5.1 states 中的 items 定义规范

[
	{
		"bVisible": false,
		"bEnable": false,
		"cName": "btnDelete",
		"cGroup": "toolbaritem"
	}
]

4、viewApplication 视图元数据定义规范

4.1 整体规范

{
	"billid": 1000051923,
	"cBillName": "店存出库单",
	"bPrintLimited": true,
	"cBillType": "Voucher",
	"cBillNo": "st_storeout",
	"bAllowMultiTpl": true,
	"cSubId": "ST",
	// 具体描述请参考4.2
	"view": {},
	// 具体描述请参考4.3
	"extscripturls": []
}

4.2 view 定义规范

item 字段 含义
1 iTplId UI 模板的唯一标识
2 cTemplateName 模板名称
3 iTplMode 模板风格
4 cTemplateTitle 模板显示的标题
{
	"iTplId": 58112,
	"cTemplateName": "店存出库单显示模板",
	"iTplMode": 0,
	"iWidth": 10000,
	"cTemplateTitle": "店存出库单",
	// 具体描述请参考4.2.1
	"containers": []
}

4.2.1 containers 定义规范

[
	{
		"groupId": 521941,
		"cName": "店存出库单",
		"iOrder": 0,
		"bMain": false,
		"cCode": "st_storeout",
		"cDataSourceName": "st.storeout.StoreOut",
		"cControlType": "view",
		"cGroupCode": "st_storeout_view",
		"cAlign": "top",
		"iCols": 0,
		"cStyle": "{\"electronicBalanceField\":\"elecbalance\"}",
		// 会继续有嵌套的 containers 
		"containers": [],
		// controls
		"controls": [],
		"key": "ContainerToolbarListBody",
		"parentKey": "Container502454"
	}
]

4.2.1.1 containers 中的 controls 定义规范

第一种controls :定义组件的交互操作

 [
	 {
		"icon": "audit",
		"cItemName": "btnAudit",
		"cCaption": "提交",
		"cShowCaption": "提交",
		"cControlType": "button",
		"iOrder": 2,
		"iStyle": 0,
		"enterDirection": 0,
		"key": "2735576"
	}
]

第二种controls :定义组件的相关属性

item 字段 含义
0 cFieldName 字段名称
1 iBillEntityId 单据实体ID
2 iBillTplGroupId 模板分组ID
3 iTplId 单据模板ID
4 iFieldType 字段类型
5 bEnum 是否枚举
6 bSplit 是否支持行拆分
7 bExtend 是否扩展字段
8 iMaxShowLen 最大显示长度
9 iColWidth 列宽
10 bFilter 是否过滤字段
11 bMustSelect 是否必选
12 bPrintCaption 是否打印栏目标题
13 bJointQuery 是否支持关联查询
14 bSelfDefine 是否自定义项目
15 bMain 是否主表
16 cDataSourceName 数据源名称
17 bVmExclude bVmExclude
18 iSystem 是否系统定义
19 cRefType 参照类型
20 cRefRetId 参照返回信息
21 refReturn 参照返回值
22 cEnumString 枚举信息
23 enumArray 枚举信息
24 cEnumType 枚举类型
25 cFormatData 格式化串设置
[
	{
		"cItemName": "code",
		"cCaption": "单据编号",
		"cShowCaption": "单据编号",
		"iMaxLength": 255,
		"iFieldType": 1,
		"bEnum": false,
		"bMustSelect": false,
		"bHidden": false,
		"bSplit": false,
		"bExtend": false,
		"iMaxShowLen": 255,
		"iColWidth": 200,
		"cSumType": "group",
		"iAlign": 1,
		"bNeedSum": false,
		"bShowIt": true,
		"bFilter": true,
		"bIsNull": true,
		"bPrintCaption": true,
		"bJointQuery": true,
		"bPrintUpCase": false,
		"bSelfDefine": false,
		"cControlType": "Column",
		"iOrder": 1,
		"bMain": true,
		"id": 2746474,
		"bVmExclude": 0,
		"iBillTplGroupId": 502454,
		"iBillId": 1000047354,
		"iBillEntityId": 63097,
		"iTplId": 53551,
		"cSubId": "ST",
		"iSystem": 1,
		"cName": "code",
		"cFieldName": "code",
		"authLevel": 3,
		"cDataSourceName": "st.storein.StoreIn",
		"enterDirection": 4,
		"cEnumType": ""
	}
]

4.3 extscripturls 定义规范

[]