Commit f2c7ac32 authored by 周远喜's avatar 周远喜

tree 表格solt支持

parent d0c65d4d
...@@ -143,8 +143,10 @@ ...@@ -143,8 +143,10 @@
</template> </template>
<script> <script>
import ColumnSlot from "./treeGrid/columnSolt";
export default { export default {
name: "DataGrid", name: "DataGrid",
components: { ColumnSlot },
data() { data() {
return { return {
keys: "", keys: "",
...@@ -155,7 +157,7 @@ export default { ...@@ -155,7 +157,7 @@ export default {
pageIndex: 1, pageIndex: 1,
pageSize: 20, pageSize: 20,
sortBy: "id", sortBy: "id",
isDesc:true, isDesc: true,
conditions: [], conditions: [],
}, },
searchConditions: this.search, searchConditions: this.search,
...@@ -294,15 +296,16 @@ export default { ...@@ -294,15 +296,16 @@ export default {
default: "", default: "",
}, },
}, },
provide() {
return {
tableRoot: this.slots,
};
},
created() { created() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
this.columnsCur = this.$u.clone(this.columns);
}, },
mounted() { mounted() {
this.initColumns();
if (this.data && this.data.length > 0) { if (this.data && this.data.length > 0) {
this.list = this.data; this.list = this.data;
return; return;
...@@ -350,7 +353,41 @@ export default { ...@@ -350,7 +353,41 @@ export default {
this.getRoutingHeaderData(); this.getRoutingHeaderData();
this.getAllUser(); //获取所有用户 this.getAllUser(); //获取所有用户
}, },
methods: { methods: {
//列初始化 slot 支持;
slots() {
return this.$scopedSlots;
},
initColumns() {
this.columns.forEach((u) => {
if (!u.hide) {
u.hide = false;
}
});
var items=this.$u.clone(this.columns);
var soct=this.$scopedSlots;
console.warn("that.$scopedSlots()",soct["action"]());
items.forEach((u) => {
if (u.slot) {
u.render = (h, params) => {
return h(
"span",
// soct[u.slot]({
// row: params.row,
// column: params.column,
// index: params.index,
// })
params.row.id
);
};
delete u.slot;
}
});
this.columnsCur = items;
console.log("cur", items,this.columnsCur);
},
//数据加载 //数据加载
load() { load() {
if (this.action) { if (this.action) {
......
export default { export default {
name: 'ColumnSlot', name: 'ColumnSlot',
functional: true, functional: true,
inject: ['slots'], inject: ['tableRoot'],
props: { props: {
row: Object, row: Object,
index: Number, index: Number,
...@@ -11,7 +11,7 @@ export default { ...@@ -11,7 +11,7 @@ export default {
} }
}, },
render: (h, ctx) => { render: (h, ctx) => {
return h('span', ctx.injections.slots()[ctx.props.column.slot]({ return h('span', ctx.injections.tableRoot()[ctx.props.column.slot]({
row: ctx.props.row, row: ctx.props.row,
column: ctx.props.column, column: ctx.props.column,
index: ctx.props.index index: ctx.props.index
......
...@@ -224,11 +224,15 @@ export default { ...@@ -224,11 +224,15 @@ export default {
drag:{ drag:{
type:Boolean, type:Boolean,
default:false default:false
},
spaceWidth:{
type:Number,
default:20
} }
}, },
provide() { provide() {
return { return {
slots: this.chachao, tableRoot: this.slots,
}; };
}, },
data() { data() {
...@@ -310,7 +314,7 @@ export default { ...@@ -310,7 +314,7 @@ export default {
})(); })();
}, },
methods: { methods: {
chachao() { slots() {
return this.$scopedSlots; return this.$scopedSlots;
}, },
//拖拽 //拖拽
...@@ -450,11 +454,7 @@ export default { ...@@ -450,11 +454,7 @@ export default {
// 数据处理 增加自定义属性监听 // 数据处理 增加自定义属性监听
initData(items, level, parent) { initData(items, level, parent) {
// this.initItems = [] // this.initItems = []
let spaceHtml = ""; let spaceHtml = "<i class='ms-tree-space' style='width:"+this.spaceWidth*level+"px'></i>";
for (let i = 1; i < level; i++) {
spaceHtml +=
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class='ms-tree-space'></i>";
}
items.forEach((item, index) => { items.forEach((item, index) => {
item = Object.assign({}, item, { item = Object.assign({}, item, {
parent, parent,
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
</FormItem> </FormItem>
</Form> </Form>
</template> </template>
<template slot-scope="{row,column,index}" slot="action">
<strong>aaaa</strong>
</template>
</DataGrid> </DataGrid>
</div> </div>
</template> </template>
...@@ -62,6 +65,7 @@ export default { ...@@ -62,6 +65,7 @@ export default {
easy: true, easy: true,
sortable:true, sortable:true,
high: true, high: true,
slot:"cardNo",
tooltip: true, tooltip: true,
}, },
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment