PowerMobile2 表单配置详细说明

配置说明

{
  "keyword" : "", // 关键词
  "keywordType" : "", // BO(关键词类型BO | ViewEntity)
  "keyField" : "", // 主键, 默认Id
  "name" : "", // 基础信息(页签名称)
  "titleField" : "", // 标题字段
  "statusField" : "", //主表状态字段
  // 事件定义部分 不需要的话可以不用配置
  // 注意 beforeLoad, afterLoad, 还有callback全部都是字符串
  "jsContent": {
     "beforeLoad": "", // string 加载前事件 "function () {}" 
     "afterLoad": "", // string 加载后事件 "function () {}",
     // 自定义事件
     "customizeEvents": [
		{
			"name": "窗体自定义事件1",
      		"callback": "function () {}" // string
		},
		{
			"name": "窗体自定义事件2",
      		"callback": "function () {}" // string
		}
	]
  },
  "fields" : [
    {
      "name":"", // 要显示的字段名
	  "label":"", // 字段描述
	  //controlType代表的是 类型 text(默认普通文本) | number(数字) | 
	  //checkbox(选择框) |  datePicker(日期选择器) | select(下拉框) 
	  "controlType": "", 
	  // format 格式化规则 ''(默认) | n2 (数字千分符) | rate(数字 税率 小数点8位) | 
	  // yyyy-MM-dd (日期格式化) | boolean|number|string (针对checkbox)
	  "format":"",
	  "isReadonly": true, // true(字段只读 查看状态 默认true) | false (编辑和新增状态 默认false) 
	  "groupIndex": 1, // 整形,如1:分组序号,如存在分组,相同分组序号显示在一起,分组之间有灰色线分割
	  "showPlace":"" // showPlace 字段显示的位置,search,tag,title,left,right,center
  	}
  ],
  "tabs": [
    {
        "type": "", // report(报表)| attach(附件)| comment(评论)| url(ifarme内链接)| child(子单,默认)
        "name": "", // 页签标题
        "formId": "", // 子表单的formId(子单需要打开另外的表单的话)
        "keyword": "", // 子表关键词
        "keywordType": "", // BO(关键词类型BO | ViewEntity)
        "keyField": "", // 主键, 默认Id
        "sequField": "", // 排序字段及方式(Sequ desc)
        "connectMap": { // 子表和主表关联关系
         "子表外键":"主表主键"
        },
       "showFields": [
         {
			"name":"", // 要显示的字段名
			"label":"", // 字段描述
			//controlType代表的是 类型 text(默认普通文本) | number(数字) | 
			//checkbox(选择框) |  datePicker(日期选择器) | select(下拉框) 
			"controlType": "", 
			// format 格式化规则 ''(默认) | n2 (数字千分符) | rate(数字 税率 小数点8位) | 
			// yyyy-MM-dd (日期格式化) | boolean|number|string (针对checkbox)
			"format":"",
			"showPlace":"" // showPlace 字段显示的位置,search,tag,title,left,right,center
         }
       ]
    }
  ]
}

fields | showFields 字段中的controlType和format详细说明

{
	"showFields": [
	  {
	  "name":"", 
	  "label":"",
	  "controlType": "",
	  "format":"",
	  "showPlace":""
	  }
  ]
}

上面json中,controlType和format配合使用的,先controlType后format

  1. controlType 之text类型
{
	"controlType": "text",
	"format":"",// 如果controlType是text类型, format字段直接设置空的字符串即可
}
  1. controlType 之number类型
{
	"controlType": "number",
	"format":"",// 如果controlType是number类型, format字段可以设置为"n2" 或者 ""
}
  1. controlType 之checkbox类型
{
	"controlType": "checkbox",
	"format":"",// 如果controlType是checkbox类型, format字段可以设置为"boolean" | "string" | "number"
}
  1. controlType 之datePicker类型
{
	"controlType": "datePicker",
	"format":"",
	// 如果controlType是datePicker类型, 
	// format字段可以设置为
	// "yyyy-MM-dd HH:mm:ss" 
	// "yyyy-MM-ddTHH:mm:ss" 
	// "yyyy-MM-dd" 
}
  1. controlType 之select类型
{
	"controlType": "select",
	"format":"",
	// 如果controlType是select类型, 
	// format字段可以设置为""
	// 但是必须保证在PC端窗体对应的表单中的comboboxdata中要有对应的下拉框的配置
}

demo示例

{
    "keyword": "SalesExpense",
    "keywordType": "BO",
    "statusField": "Status",
    "titleField": "Title",
    "keyField": "ID",
    "name": "销售费用报销",
	"jsContent": {
		"afterLoad": "function(){var that=this;window.PowerApp.Map.getCurrentCityWeather(function(res){console.log(res)})};",
        "autoEvent“: "function (){console.log('自适应事件')}",
        "customizeEvents": [
            {
                "name": "自定义事件1",
                "callback": "function () {console.log('改变表单相关字段数据');this.customize_formData({Title:'123456'});}"
            },
            {
                "name": "自定义事件2",
                "callback": "function () {console.log('改变主表tab页');this.customize_changeTabs('projectExpense_1','hide');}"
            },
            {
                "name": "自定义事件3",
                "callback": "function () {console.log('对应子表中的现有数据');this.customize_getChildData('projectExpense_1');}"
            },
            {
                "name": "自定义事件4",
                "callback": "function () {console.log('提供表单相关参数');console.log(this.customize_params());}"
            },
        ],
	},
    "fields": [
        {
            "name": "Code",
            "label": "编号",
            "format": "",
            "controlType": "text",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "Status",
            "label": "审批状态",
            "format": "",
            "controlType": "select",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "Title",
            "label": "报销说明",
            "format": "",
            "controlType": "text",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "SalesTaskID",
            "label": "销售任务",
            "format": "",
            "controlType": "wizard",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "ClientName",
            "label": "任务名称",
            "format": "",
            "controlType": "text",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "ThisExpense",
            "label": "本次报销",
            "format": "n2",
            "controlType": "number",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "TotalExpense",
            "label": "已累计报销",
            "format": "n2",
            "controlType": "number",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "RegHumName",
            "label": "报销人",
            "format": "",
            "controlType": "text",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "RegDate",
            "label": "申请日期",
            "format": "yyyy-MM-dd",
            "controlType": "datePicker",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "ApprHumName",
            "label": "批准人名称",
            "format": "",
            "controlType": "text",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "ApprDate",
            "label": "批准日期",
            "format": "yyyy-MM-dd",
            "controlType": "datePicker",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "FafangAmount",
            "label": "发放金额",
            "format": "n2",
            "controlType": "number",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        },
        {
            "name": "FafangDate",
            "label": "发放日期",
            "format": "yyyy-MM-dd",
            "controlType": "datePicker",
            "isReadonly": true,
            "isShow": true,
            "groupIndex": 0
        }
    ],
    "tabs": [
        {
            "type": "child",
            "name": "报销明细",
            "formId": "",
            "keyword": "projectExpense_1",
            "keywordType": "BO",
            "keyField": "ID",
            "connectMap": {
                "ParentId": "ID"
            },
            "showFields": [
                {
                    "name": "ExpenseAccount",
                    "label": "费用类型",
                    "controlType": "text",
                    "format": "",
                    "showPlace": "title"
                },
                {
                    "name": "BeginDate",
                    "label": "开始日期",
                    "controlType": "datePicker",
                    "format": "yyyy-MM-dd",
                    "showPlace": "left"
                },
                {
                    "name": "EndDate",
                    "label": "截止日期",
                    "controlType": "datePicker",
                    "format": "yyyy-MM-dd",
                    "showPlace": "right"
                },
                {
                    "name": "ApplyExpense",
                    "label": "申报费用",
                    "controlType": "number",
                    "format": "n2",
                    "showPlace": "center"
                }
            ]
        }

你可能感兴趣的:(PowerMobile2 表单配置详细说明)