tableCommon.vue 1.61 KB
<template>
    <!--
        调用: {
            tableData,  // 表格内容数据 array object
            headData,   // 表格表头数据 array object
            tabHeight,  // 是否固定头部 string: no | number: yes
        }
      -->
    <el-table
        class="asis-table"
        :data="tableData"
        header-row-class-name="asis-table-head"
        :height="typeof tabHeight === 'number' ? tabHeight : null"
        style="width: 100%"
        tooltip-effect="light">
            <el-table-column :prop="item.prop" :label="item.label" align="center" v-for="(item,index) in headData" :key="item.prop" :show-overflow-tooltip="index == 0 ? true : false">
                <template slot-scope="scope">
                    <span :style="cellStyle(scope.row[item.prop])">{{ scope.row[item.prop] }}</span>
                </template>
            </el-table-column>
    </el-table>
</template>

<script>
export default {
    props: ['tableData', 'headData', 'tabHeight'],
    data () {
        return {
            // 
        }
    },
    computed: {
        
    },
    methods: {
        i18nFomatter(title){
            let langeuageTitle = 'echartsTitle.' + title;
            return this.$t(langeuageTitle)
        },
        cellStyle(cellValue) {
            // if(/%$/g.test(cellValue)) {
            //     if(cellValue.split('%')[0] > 0) {
            //         return 'color: #0f0'
            //     } else {
            //         return 'color: #f00'
            //     }
            // } else {
            //     return '';
            // }
            return '';
        }
    }
}
</script>

<style scoped>
    
</style>