Appearance
comm-table
属性
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
columns | 用于配置查询条件和表格列 | ColumnProps[] | null |
res-data | 表格数据 | array | [] |
page | 默认第几页 | number | 1 |
limit | 每页展示大小 | number | 20 |
page-sizes | 分页条设置 | array | [20, 100, 200, 300, 500] |
layout | 分页条部件 | string | total, sizes, prev, pager, next, jumper |
options | 传给表格的额外属性 | TableOptions | |
background | 是否为分页按钮添加背景色 | boolean | true |
autoScroll | 分页查询后是否自动滚动(不生效) | boolean | true |
ColumnProps
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
prop | 字段名 | string | -- |
label | 列名 | string | -- |
align | 对齐方式 | string left/center/right | left |
width | 列宽 | string | -- |
min-width | 最小列宽 | string | -- |
fixed | 列是否固定在左侧或者右侧,true 表示固定在左侧 true, left, right | string, boolean | -- |
sortable | 对应列是否可以排序,如果设置为 'custom',则代表用户希望远程排序,需要监听 Table 的 sort-change 事件 | boolean, string true, false, 'custom' | false |
slot | 插槽名称 | string | -- |
render | 自定义列渲染函数,优先级 render > formatter > formatDate | Function | -- |
formatter | 格式化函数 参数(行,列) | Function | -- |
formatDate | 格式化日期 参数(列值) | Function | -- |
配置参考
js
columns: [
{prop: "itemCode", label: "商品编码", width: "150", sortable: "custom"},
{prop: "skuName", label: "商品名称", width: "230", sortable: "custom"},
{prop: "customerName", label: "所属客户", width: "150", sortable: "custom"},
{prop: "goodsNo", label: "货号", width: "150", sortable: "custom"},
{
prop: "isBatchMgmt", label: "批次管理", width: "100", sortable: "custom", render: (h, ctx) => {
if (ctx.row.isBatchMgmt == "N") {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "isQuoteBatchCode", label: "引用外部批次", width: "100", sortable: "custom", render: (h, ctx) => {
if (ctx.row.isQuoteBatchCode == "N") {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "isShelfLifeMgmt", label: "效期管理", width: "100", sortable: "custom", render: (h, ctx) => {
if (ctx.row.isShelfLifeMgmt == "N") {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "shelfLifeType", label: "管理方式", width: "120", sortable: "custom", formatter: (row) => {
if (row.shelfLifeTypeName == "默认") {
return "";
} else {
return row.shelfLifeTypeName;
}
}
},
{prop: "shelfLife", label: "保质期", width: "100", sortable: "custom"},
{
prop: "batchTimeType", label: "时间类型", width: "120", sortable: "custom", formatter: (row) => {
if (row.batchTimeTypeName == "默认") {
return "";
} else {
return row.batchTimeTypeName;
}
}
},
{
prop: "isSNMgmt", label: "SN管理", width: "100", sortable: "custom", render: (h, ctx) => {
if (ctx.row.isSNMgmt == "N") {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "entryCollectSN", label: "入库采集SN", width: "120", sortable: "custom", render: (h, ctx) => {
if (!ctx.row.entryCollectSN) {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "stockoutCollectSN", label: "出库采集SN", width: "120", sortable: "custom", render: (h, ctx) => {
if (!ctx.row.stockoutCollectSN) {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{
prop: "skuType", label: "商品类型", width: "100", sortable: "custom", formatter: (row) => {
return row.skuTypeName
}
},
{
prop: "createType", label: "来源方式", width: "100", sortable: "custom", formatter: (row) => {
return row.createTypeName
}
},
{prop: "shortName", label: "简称", width: "130", sortable: "custom"},
{prop: "brandName", label: "品牌", width: "150", sortable: "custom"},
{prop: "supplierName", label: "供应商", width: "150", sortable: "custom"},
{prop: "temperatureRangeDesc", label: "温区", width: "80", sortable: "custom"},
{prop: "skuToMarketTime", label: "上市时间", width: "140", sortable: "custom"},
{prop: "originAddress", label: "原产地", width: "120", sortable: "custom"},
{prop: "pcs", label: "规格", width: "80", sortable: "custom"},
{prop: "boxSize", label: "箱规", width: "80", sortable: "custom"},
{prop: "length", label: "长 (厘米)", width: "100", sortable: "custom"},
{prop: "width", label: "宽 (厘米)", width: "100", sortable: "custom"},
{prop: "height", label: "高 (厘米)", width: "100", sortable: "custom"},
{prop: "volume", label: "体积 (cm³)", width: "100", sortable: "custom"},
{prop: "grossWeight", label: "毛重 (千克)", width: "110", sortable: "custom"},
{prop: "categoryName", label: "商品类别", width: "130", sortable: "custom"},
{prop: "safetyStock", label: "安全库存数", width: "120", sortable: "custom"},
{prop: "tagPrice", label: "吊牌价", width: "120", sortable: "custom"},
{prop: "retailPrice", label: "零售价", width: "120", sortable: "custom"},
{prop: "costPrice", label: "成本价", width: "120", sortable: "custom"},
{prop: "purchasePrice", label: "采购价", width: "120", sortable: "custom"},
{
prop: "isHazardousStr", label: "是否危险品", width: "120", sortable: "custom", render: (h, ctx) => {
if (ctx.row.isHazardous == "N") {
return h('div', {class: '', style: "color:green"}, [
h("label", {}, "否")
])
} else {
return h('div', {class: '', style: "color:red"}, [
h("label", {}, "是")
])
}
}
},
{prop: "packaging", label: "包装", width: "120", sortable: "custom"},
{prop: "packagingEnv", label: "包装环境", width: "120", sortable: "custom"},
{prop: "storage", label: "存储", width: "120", sortable: "custom"},
{prop: "storageEnv", label: "存储环境", width: "120", sortable: "custom"},
{prop: "createUserName", label: "创建人", width: "120", sortable: "custom"},
{prop: "createTime", label: "创建时间", width: "140", sortable: "custom"},
{prop: "skuId", label: "编号", width: "140", sortable: "custom"},
{
prop: 'action', label: '操作', align: 'center', minWidth: '100', fixed: "right", render: (h, ctx) => {
return h('div', [
h("el-button", {
props: {type: 'text', size: 'mini'},
on: {click: () => app.editSku(ctx.row.skuId)}
}, "查看")
])
}
}
],
TableOptions
属性名 | 说明 | 类型 | 默认值 |
---|---|---|---|
show-summary | 是否在表尾显示合计行 | boolean | false |
height | Table 的高度 | number | 500 |
stripe | 是否为斑马纹 table | boolean | false |
highlight-current-row | 是否要高亮当前行 | boolean | true |
border | 是否带有纵向边框 | boolean | false |
lazy | 是否懒加载子节点数据 | boolean | false |
total-option | 需要统计的列{ label: '列名', color: 'red' } | array | [] |
muti-select | 是否多选 | boolean | false |
事件
事件名 | 说明 | 回调参数 |
---|---|---|
pagination | 操作分页后触发 | -- |
handle-selection-change | 当选择项发生变化时会触发该事件 | selection |
row-click | 当某一行被点击时会触发该事件 | {row, column, event} |
dblclickRow | 当某一行被双击时会触发该事件 | {row, column, event} |
contextmenu | 当某一行被鼠标右键点击时会触发该事件 | {row, column, event} |
headClick | 当某一列的表头被点击时会触发该事件 | {column, event} |
headcontextmenu | 当某一列的表头被鼠标右键点击时触发该事件 | {column, event} |
row-change | 当表格的当前行发生变化的时候会触发该事件,如果要高亮当前行,请打开表格的 highlight-current-row 属性 | currentRow |
sort-change | 当表格的排序条件发生变化的时候会触发该事件 | -- |
方法
方法名 | 说明 | 参数 |
---|---|---|
mergePage | 将查询参数与分页参数进行合并,返回合并并符合后台规范的参数 | searchParam,type |
- 例子
- mergePage
js
// 查询时 type 不传
// 重置时 type 传 reset
// 导出时 type 传 export
onSearch(type) {
// 调用table中的mergePage方法,获取到请求参数 param:请求后台参数
const param = this.$refs['table'].mergePage(this.search, type)
$.ajax({
url: "/Sku/getCustomerSkuList",
type: "post",
data: JSON.stringify(param),
success: function (res) {
app.tableData = res;
}
})
},