<script>
data() {
return {
f4_columns2: [
{
// title: "配对商品",
dataIndex: "sku",
key: "sku",
// width: "320px",
ellipsis: true,
slots: { title: "skuTitle" },
scopedSlots: { customRender: "sku" },
},
{
title: "仓库信息",
dataIndex: "warehouse",
key: "warehouse",
width: "240px",
// antd vue2 table组件 实现多行合并+自定义内容
// 注意1:使用了customRender,scopedSlots:{customRender:"xxx"}就不生效了
// 注意2:只允许一个父级标签(渲染多个时用一个div包裹即可)
// 注意3:似乎不能在标签里使用v-if和v-for
// 注意4:标签中vue语法糖冒号写法 :xxx="xxx" 要替换成 xxx={this.xxx}
// 注意5:同上,@click要写成onclick
customRender: (text, row, index) => {
let obj = {
children: (
<div>
<a-select
v-show={this.isWinit}
disabled
options={this.winitWarehouseOptions}
placeholder="选择仓库"
show-search
option-filter-prop="children"
filter-option={this.filterOption}
v-model={this.detailObjEdit.warehouseid}
onChange={this.f4_pre_selectHouseChange}
class="w215"></a-select>
<a-select
v-show={!this.isWinit}
disabled={
this.detailObj.status != 0 &&
this.detailObj.status != 1 &&
this.detailObj.status != 2 &&
this.detailObj.status != 3 &&
this.detailObj.status != 7 &&
this.detailObj.status != 8
}
show-search
options={this.houseDataOptions}
option-filter-prop="children"
filter-option={this.filterOption}
placeholder="选择仓库"
class="w215"
onChange={this.f4_pre_selectHouseChange}
v-model={this.detailObjEdit.warehouseid}></a-select>
</div>
),
attrs: {
rowSpan:
index == 0
? this.detailObj.orderProductList
? this.detailObj.orderProductList.length
: 1
: 0,
},
};
return obj;
},
},
],
}
}
</script>
以上是关键代码,有问题一起讨论
最终效果:(合并行嵌入一个下拉选择框)