Table 表格
大部分功能同list一致,增加了展开行/子表
、合并行
、表头配置
等功能
基础用法
{
"type": "table",
"resource": {
"api": {
"prefix": "https://easy-mock.com/mock/5bf25b2b34392218c898a5fd/",
"list": "list"
},
"fields": {
"id": {
"type": "text",
"label": "序号",
"on": {
"change": function() {
for (var e = arguments.length, a = new Array(e), t = 0; t < e; t++) a[t] = arguments[t];
console.log("text change", a, this)
}
}
},
"grade1": {
"type": "text",
"label": "一级品类",
"rules": [{
"required": true,
"message": "请输入活动名称",
"trigger": "blur"
}, {
"min": 3,
"max": 5,
"message": "长度在 3 到 5 个字符",
"trigger": "blur"
}],
"props": {
"suffix-icon": "el-icon-service"
}
},
"grade2": {
"type": "text",
"label": "二级品类"
},
"day1": {
"type": "text",
"label": "第1天"
},
"day2": {
"type": "text",
"label": "第2天"
},
"day3": {
"type": "text",
"label": "第3天"
},
"day4": {
"type": "text",
"label": "第4天"
},
"day5": {
"type": "text",
"label": "第5天"
},
"day6": {
"type": "text",
"label": "第6天"
},
"day7": {
"type": "text",
"label": "第7天"
},
"week": {
"type": "text",
"label": "前7天"
}
}
},
"ctx": "view",
"sorts": {
"id": true,
"week": true
},
"searchs": {
"id": true,
"grade1": true
},
"data": {
"list": [],
"pageSize": 10
},
"options": {
"span-merge": {
"grade1": true,
"grade2": true
},
"expand-row": {
"valueKey": "rowchildren",
"remoteConfig": {
"action": "https://easy-mock.com/mock/5bf25b2b34392218c898a5fd/table-expand",
"queryName": "chidTableId",
"queryValue": "id"
}
},
"table-column": [{
"label": "序号",
"name": "id"
}, {
"label": "",
"children": [{
"label": "一级品类",
"name": "grade1",
"slot-header": {
"type": "tooltip",
"content": "这里是一级品类信息<br/>第二行信息"
}
}, {
"label": "二级品类",
"name": "grade2",
"slot-header": {
"type": "tooltip",
"content": "这里是二级品类信息<br/>第二行信息"
}
}]
}, {
"label": "收入",
"slot-header": {
"type": "tooltip",
"content": "提示框信息<br/>第二行信息"
},
"children": [{
"label": "第1天",
"name": "day1"
}, {
"label": "第2天",
"name": "day2"
}, {
"label": "第3天",
"name": "day3"
}, {
"label": "第4天",
"name": "day4"
}, {
"label": "第5天",
"name": "day5"
}, {
"label": "第6天",
"name": "day6"
}, {
"label": "第7天",
"name": "day7"
}, {
"label": "前7天",
"name": "week",
"slot-header": {
"type": "collapse",
"collapseColumn": ["day1", "day2", "day3", "day4", "day5", "day6", "day7"]
}
}]
}]
},
"on": {
"cell-click": function(e, a, t, l) {},
"header-click": function(e, a) {}
},
"events": {
"init": "@list"
}
}
显示配置
结构
export interface Data { [field: string]: any }
export interface FormBlock {
type: 'table',
resource: string,
ctx: 'edit' | 'view',
pageSize?: number,
filters?: { [field: string]: {
multiple?: boolean,
remote?: boolean
}},
fields?: { [field: string]: Data | false },
sorts?: { [field: string]: boolean },
style?: Data,
data?: Data,
events?: Data,
actions?: { [field: string]: () => any },
options?: Data,
operations?: { [field: string]: Data },
render?: boolean | string
}
配置
可用配置项表
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
type | string | 是 | block类型,固定值为table |
resource | string | 否 | 指定resource |
ctx | string | 否 | 表单的显示类型 |
style | object | 否 | block添加样式 |
data | object | 否 | block为table时,参考list的data数据要求,详见data |
events | object | 否 | 事件定义 |
actions | object | 否 | 自定义actions,可被events中使用 |
fields | object | 否 | block级别作用域的fields,重置resource中的默认配置 |
options | object | 是 | table配置,内有span-merge 、expand-row 、table-column 配置 |
expand-row | object | 否 | 展开行/子表配置 |
span-merge | object | 否 | 合并行配置,设置对应的行的field为true , 自动合并相同行表格 |
table-column | array | 否 | 表头配置, 数组格式,多级表头用children嵌套 |
operations | object | 否 | 操作项配置 |
blocks | object | 否 | 嵌套的blocks |
render | boolean | string | 指定渲染方式 |
filters | object | 否 | 过滤条件 同列表 |
sorts | object | 否 | 列表排序设置 同列表 |
searchs | object | 否 | 列表搜索设置 同列表 |
searchsOptions | object | 否 | 列表的搜索栏操作项设置 同列表 |
pageSize | number | 否 | 设置分页每页的条数 同列表 |