format[treeTable]: format code

This commit is contained in:
Pan 2018-01-23 15:03:09 +08:00
parent fea6e5feee
commit 3253a91a7e
5 changed files with 100 additions and 103 deletions

View file

@ -2,23 +2,18 @@
<el-table :data="formatData" :row-style="showRow"> <el-table :data="formatData" :row-style="showRow">
<el-table-column v-if="columns.length===0" width="150"> <el-table-column v-if="columns.length===0" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-for="space in scope.row._level" <span v-for="space in scope.row._level" class="ms-tree-space" :key="space"></span>
class="ms-tree-space"></span> <span class="tree-ctrl" v-if="iconShow(0,scope.row)" @click="toggleExpanded(scope.$index)">
<span class="tree-ctrl" v-if="iconShow(0,scope.row)"
@click="toggleExpanded(scope.$index)">
<i v-if="!scope.row._expanded" class="el-icon-plus"></i> <i v-if="!scope.row._expanded" class="el-icon-plus"></i>
<i v-else class="el-icon-minus"></i> <i v-else class="el-icon-minus"></i>
</span> </span>
{{scope.$index}} {{scope.$index}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column v-else v-for="(column, index) in columns" :key="column.value" <el-table-column v-else v-for="(column, index) in columns" :key="column.value" :label="column.text" :width="column.width">
:label="column.text" :width="column.width">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="index === 0" v-for="space in scope.row._level" <span v-if="index === 0" v-for="space in scope.row._level" class="ms-tree-space" :key="space"></span>
class="ms-tree-space"></span> <span class="tree-ctrl" v-if="iconShow(index,scope.row)" @click="toggleExpanded(scope.$index)">
<span class="tree-ctrl" v-if="iconShow(index,scope.row)"
@click="toggleExpanded(scope.$index)">
<i v-if="!scope.row._expanded" class="el-icon-plus"></i> <i v-if="!scope.row._expanded" class="el-icon-plus"></i>
<i v-else class="el-icon-minus"></i> <i v-else class="el-icon-minus"></i>
</span> </span>
@ -30,10 +25,10 @@
</template> </template>
<script> <script>
/** /**
Auth: Lei.j1ang Auth: Lei.j1ang
Created: 2018/1/19-13:59 Created: 2018/1/19-13:59
*/ */
import treeToArray from './eval' import treeToArray from './eval'
export default { export default {
name: 'treeTable', name: 'treeTable',

View file

@ -1,32 +1,36 @@
## 写在前面 ## 写在前面
此组件仅提供一个创建TreeTable的解决方案 此组件仅提供一个创建TreeTable的解决方案
##prop说明 ##prop说明
###data ###data
必输 **必填**
原始数据,要求是一个数组或者对象 原始数据,要求是一个数组或者对象
```javascript ```javascript
[{ [{
key1:value1, key1: value1,
key2:value2, key2: value2,
children:[{ children: [{
key1:value1 key1: value1
},{ },
key1:value1 {
key1: value1
}] }]
},{ },
key1:value1 {
key1: value1
}] }]
``` ```
或者 或者
```javascript ```javascript
{ {
key1:value1, key1: value1,
key2:value2, key2: value2,
children:[{ children: [{
key1:value1 key1: value1
},{ },
key1:value1 {
key1: value1
}] }]
} }
``` ```
@ -66,6 +70,7 @@
**请注意自定义的解析函数参数第一个为this.data你不需要在evalArgs填写。** **请注意自定义的解析函数参数第一个为this.data你不需要在evalArgs填写。**
如你的解析函数需要的参数为`(this.data,1,2,3,4)`,那么你只需要将`[1,2,3,4]`赋值给`evalArgs`就可以了 如你的解析函数需要的参数为`(this.data,1,2,3,4)`,那么你只需要将`[1,2,3,4]`赋值给`evalArgs`就可以了
## slot ## slot
请参考`customTreeTable` 请参考`customTreeTable`

View file

@ -151,9 +151,9 @@ export const asyncRouterMap = [
{ path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable', meta: { title: 'dynamicTable' }}, { path: 'dynamic-table', component: _import('example/table/dynamicTable/index'), name: 'dynamicTable', meta: { title: 'dynamicTable' }},
{ path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', meta: { title: 'dragTable' }}, { path: 'drag-table', component: _import('example/table/dragTable'), name: 'dragTable', meta: { title: 'dragTable' }},
{ path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', meta: { title: 'inlineEditTable' }}, { path: 'inline-edit-table', component: _import('example/table/inlineEditTable'), name: 'inlineEditTable', meta: { title: 'inlineEditTable' }},
{ path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}, { path: 'tree-table', component: _import('example/table/treeTable/treeTable'), name: 'treeTable', meta: { title: 'treeTable' }},
{ path: 'treeTable', component: _import('example/table/treeTable/treeTable'), name: 'treeTable', meta: { title: 'treeTable' }}, { path: 'custom-tree-table', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTable', meta: { title: 'customTreeTable' }},
{ path: 'customTreeTable', component: _import('example/table/treeTable/customTreeTable'), name: 'customTreeTable', meta: { title: 'customTreeTable' }} { path: 'complex-table', component: _import('example/table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}
] ]
}, },
{ path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', meta: { title: 'tab' }} { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'tab', meta: { title: 'tab' }}

View file

@ -10,7 +10,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-tooltip effect="dark" :content="scope.row.timeLine+'ms'" placement="left"> <el-tooltip effect="dark" :content="scope.row.timeLine+'ms'" placement="left">
<div class="processContainer"> <div class="processContainer">
<div class="process" :style= "{ width:scope.row._width * 500+'px', <div class="process" :style="{ width:scope.row._width * 500+'px',
background:scope.row._width>0.5?'rgba(233,0,0,.5)':'rgba(0,0,233,0.5)', background:scope.row._width>0.5?'rgba(233,0,0,.5)':'rgba(0,0,233,0.5)',
marginLeft:scope.row._marginLeft * 500+'px' }"> marginLeft:scope.row._marginLeft * 500+'px' }">
<span style="display:inline-block"></span> <span style="display:inline-block"></span>
@ -28,12 +28,13 @@
</template> </template>
<script> <script>
/** /**
Auth: Lei.j1ang Auth: Lei.j1ang
Created: 2018/1/19-14:54 Created: 2018/1/19-14:54
*/ */
import treeTable from '@/components/TreeTable' import treeTable from '@/components/TreeTable'
import treeToArray from './customEval' import treeToArray from './customEval'
export default { export default {
name: 'tree', name: 'tree',
components: { treeTable }, components: { treeTable },
@ -125,7 +126,3 @@ export default {
} }
} }
</script> </script>
<style scoped>
</style>

View file

@ -1,14 +1,14 @@
<template> <template>
<tree-table :data="data" :columns="columns"> <tree-table :data="data" :columns="columns"></tree-table>
</tree-table>
</template> </template>
<script> <script>
/** /**
Auth: Lei.j1ang Auth: Lei.j1ang
Created: 2018/1/19-14:54 Created: 2018/1/19-14:54
*/ */
import treeTable from '@/components/TreeTable' import treeTable from '@/components/TreeTable'
export default { export default {
name: 'tree', name: 'tree',
components: { treeTable }, components: { treeTable },