whychw
2020-10-17 230fb762f28f4e3aa61b3a5c5613e6f034265ffd
src/components/AssembleTable.vue
@@ -6,6 +6,7 @@
            border
            size="mini"
            height="100%"
            :cell-class-name="cellClassName"
            header-cell-class-name="blue-header">
                <el-table-column
                v-for="index of len * 2" :key="'prop_' + index"
@@ -57,7 +58,7 @@
        }
    },
    computed: {
        tableData() {
        tableData () {
            let result = [];
            this.data.forEach((item, index)=>{
                let num = index % this.len;
@@ -67,11 +68,37 @@
                let last = result[result.length-1];
                last['prop_' + (num + 1)] = item.text;
                last['value_' + (num + 1)] = item.val;
                last['maxList'] = last['maxList'] || [];
                last['minList'] = last['minList'] || [];
                if (item.isMin) {
                    last['minList'].push(num + 1);
                }
                if (item.isMax) {
                    last['maxList'].push(num + 1);
                }
            });
            // console.log('co')
            return result;
        },
        labelArr () {
            return this.labels.split(',');
        }
    }
    ,methods: {
        cellClassName (obj) {
            let res = '';
            let rowData = obj.row;
            rowData.maxList.forEach((v) => {
                if (obj.column.property.indexOf(v) > -1) {
                    res += 'max-value';
                }
            });
            rowData.minList.forEach((v) => {
                if (obj.column.property.indexOf(v) > -1) {
                    res += (res ? ' min-value' : 'min-value');
                }
            });
            return res;
        }
    }
}
@@ -82,5 +109,11 @@
    width: 100%;
    height: 100%;
}
>>> .max-value {
    background: #900 !important;
}
>>> .min-value {
    background: #090 !important;
}
</style>