|
@@ -1,26 +1,42 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="table-layout">
|
|
<div class="table-layout">
|
|
|
- <ul class="t-header" :class="{line:showLine}">
|
|
|
|
|
|
|
+ <!-- 表头 -->
|
|
|
|
|
+ <ul class="t-header" :class="{'bottom-line':showLine}">
|
|
|
|
|
+ <!-- 复选框 -->
|
|
|
<li v-if="selection" class="check-cls"><span @click="lock=false,selectAll=!selectAll" class="fdcheck" :class="{check_active:selectAll}"></span></li>
|
|
<li v-if="selection" class="check-cls"><span @click="lock=false,selectAll=!selectAll" class="fdcheck" :class="{check_active:selectAll}"></span></li>
|
|
|
- <li v-for="(item,i) in header" :key="i" :style="{textAlign:item.textAlign,width:item.width ?item.width+'px':(100/header.length)+'%'}">
|
|
|
|
|
|
|
+ <!-- -->
|
|
|
|
|
+ <li v-for="(item,i) in header" :key="i" :style="{textAlign: item.textAlign, width:item.width ?item.width+'px':(100/header.length)+'%'}">
|
|
|
<slot :data='item' name='header'></slot>
|
|
<slot :data='item' name='header'></slot>
|
|
|
</li>
|
|
</li>
|
|
|
</ul>
|
|
</ul>
|
|
|
|
|
+ <!-- 表格内容区域 -->
|
|
|
<div class="t-con">
|
|
<div class="t-con">
|
|
|
- <ul class="t-item" active-txt :class="{line:showLine}" v-for="(item,i) in fixdata" :key="i">
|
|
|
|
|
|
|
+ <ul class="t-item" active-txt :class="{'bottom-line': showLine}" v-for="(item, i) in fixdata" :key="i">
|
|
|
|
|
+ <!-- 复选框 -->
|
|
|
<li v-if="selection" class="check-cls" ><span @click="selectItem(item,i)" class="fdcheck" :class="{check_active:item.hasAuth}"></span></li>
|
|
<li v-if="selection" class="check-cls" ><span @click="selectItem(item,i)" class="fdcheck" :class="{check_active:item.hasAuth}"></span></li>
|
|
|
- <li :class="{themetxt:sub.fontweight}" v-for="(sub,j) in header" :key='j' :style="{textAlign:item.textAlign,width:sub.width ? sub.width+'px':(100/header.length)+'%'}">
|
|
|
|
|
|
|
+ <!-- -->
|
|
|
|
|
+ <li v-for="(sub,j) in header" :class="{ themetxt: sub.fontweight }" :key='j' :style="{textAlign:item.textAlign, width:sub.width ? sub.width+'px':(100/header.length)+'%'}">
|
|
|
<slot :data='item[sub.key]' :item="item" :sub='sub' name='item'></slot>
|
|
<slot :data='item[sub.key]' :item="item" :sub='sub' name='item'></slot>
|
|
|
</li>
|
|
</li>
|
|
|
</ul>
|
|
</ul>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+
|
|
|
<script>
|
|
<script>
|
|
|
import { mapState } from 'vuex'
|
|
import { mapState } from 'vuex'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
- props: ['data', 'header', 'selection', 'showLine'],
|
|
|
|
|
|
|
+ props: [
|
|
|
|
|
+ // 每一项可配置textAlign
|
|
|
|
|
+ 'data',
|
|
|
|
|
+ // 表头数据:各列名称和格列的配置(fontweight: Boolean,某一列是否是关键列;canclick: Booean, 是否可进行各种操作;)。
|
|
|
|
|
+ 'header',
|
|
|
|
|
+ // 是否显示复选框
|
|
|
|
|
+ 'selection',
|
|
|
|
|
+ // 是否显示每行之间的分隔线
|
|
|
|
|
+ 'showLine'
|
|
|
|
|
+ ],
|
|
|
data () {
|
|
data () {
|
|
|
return {
|
|
return {
|
|
|
innerW: window.innerWidth,
|
|
innerW: window.innerWidth,
|
|
@@ -30,6 +46,7 @@ export default {
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
...mapState({
|
|
...mapState({
|
|
|
|
|
+ // props中data中hasAuth一律写成false,即未选中。
|
|
|
fixdata () {
|
|
fixdata () {
|
|
|
let data = this.data && this.data.map(item => {
|
|
let data = this.data && this.data.map(item => {
|
|
|
item.hasAuth = false
|
|
item.hasAuth = false
|