Commit 40b6cf9e authored by Jenny's avatar Jenny

feat: table style

parent 5c8596fb
<template> <template>
<view > <view >
<!-- <BasicText :elementInfo="elementInfo"></BasicText> -->
<NormalTitle :elementInfo="elementInfo"></NormalTitle> <NormalTitle :elementInfo="elementInfo"></NormalTitle>
<scroll-view scroll-x="true" > <scroll-view scroll-x="true" >
<view class="scroll-view_H"> <view class="scroll-view_H">
<u-table > <u-table
<u-tr v-if="elementInfo.table.tableHeader.showHeader" :style="[headerStyle]"> class="normal-table"
:border-width="elementInfo.table.frameWidth"
:border-color="elementInfo.table.frameColor"
:border-style="elementInfo.table.frameStyle"
:bg-color="elementInfo.table.tableCell.backgroundColor"
:color="elementInfo.table.tableCell.titleColor"
:font-size="$u.common.pxToRpx(elementInfo.table.tableCell.titleFontSize)"
:align="elementInfo.table.tableCell.titlePostion"
:th-style="headerStyle"
>
<u-tr v-if="elementInfo.table.tableHeader.showHeader">
<u-th v-for="(item, index) in columns" :key="index">{{item.title}}</u-th> <u-th v-for="(item, index) in columns" :key="index">{{item.title}}</u-th>
</u-tr> </u-tr>
<u-tr v-for="(cell, cellIndex) in chartTables" :key="cellIndex" @tap="cellClick(cell)"> <u-tr v-for="(cell, cellIndex) in chartTables" :key="cellIndex" @tap="cellClick(cell)">
<u-td style="width: 150px;" v-for="(item, index) in columns" :key="index"> <u-td v-for="(item, index) in columns" :key="index">
{{cell[item.dataIndex]}} {{cell[item.dataIndex]}}
</u-td> </u-td>
</u-tr> </u-tr>
</u-table> </u-table>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</template> </template>
...@@ -38,11 +45,13 @@ ...@@ -38,11 +45,13 @@
}, },
computed: { computed: {
headerStyle() { headerStyle() {
const { headerRowHeight, titleColor, backgroundColor, titlePostion, titleFontSize } = this.elementInfo.table.tableHeader
return { return {
'width': '150rpx', 'height': `${this.$u.common.pxToRpx(headerRowHeight)}rpx`,
'height': this.elementInfo.table.tableHeader.headerRowHeight + 'px', 'color': titleColor,
'color': this.elementInfo.table.tableHeader.titleColor, 'background-color': backgroundColor,
'background-color': this.elementInfo.table.tableHeader.backgroundColor, 'text-align': titlePostion,
'font-size': `${this.$u.common.pxToRpx(titleFontSize)}rpx`
} }
} }
}, },
...@@ -64,11 +73,12 @@ ...@@ -64,11 +73,12 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.scroll-view_H {
.scroll-view_H {
width: 100%; width: 100%;
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
} }
.normal-table {
width: 100%;
}
</style> </style>
...@@ -27,6 +27,14 @@ ...@@ -27,6 +27,14 @@
type: String, type: String,
default: '#e4e7ed' default: '#e4e7ed'
}, },
borderWidth: {
type: Number,
default: 1
},
borderStyle: {
type: String,
default: 'solid'
},
align: { align: {
type: String, type: String,
default: 'center' default: 'center'
...@@ -65,9 +73,9 @@ ...@@ -65,9 +73,9 @@
computed: { computed: {
tableStyle() { tableStyle() {
let style = {}; let style = {};
style.borderLeft = `solid 1px ${this.borderColor}`; style.borderLeft = `${this.borderStyle} ${this.borderWidth}px ${this.borderColor}`;
style.borderTop = `solid 1px ${this.borderColor}`; style.borderTop = `${this.borderStyle} ${this.borderWidth}px ${this.borderColor}`;
style.backgroundColor = this.bgColor;; style.backgroundColor = this.bgColor;
return style; return style;
} }
} }
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
style.textAlign = this.parent.align; style.textAlign = this.parent.align;
style.fontSize = this.parent.fontSize + 'rpx'; style.fontSize = this.parent.fontSize + 'rpx';
style.padding = this.parent.padding; style.padding = this.parent.padding;
style.borderBottom = `solid 1px ${this.parent.borderColor}`; style.borderBottom = `${this.parent.borderStyle} ${this.parent.borderWidth}px ${this.parent.borderColor}`;
style.borderRight = `solid 1px ${this.parent.borderColor}`; style.borderRight = `${this.parent.borderStyle} ${this.parent.borderWidth}px ${this.parent.borderColor}`;
style.color = this.parent.color; style.color = this.parent.color;
this.tdStyle = style; this.tdStyle = style;
} }
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
if (this.width) style.flex = `0 0 ${this.width}`; if (this.width) style.flex = `0 0 ${this.width}`;
style.textAlign = this.parent.align; style.textAlign = this.parent.align;
style.padding = this.parent.padding; style.padding = this.parent.padding;
style.borderBottom = `solid 1px ${this.parent.borderColor}`; style.borderBottom = `${this.parent.borderStyle} ${this.parent.borderWidth}px ${this.parent.borderColor}`;
style.borderRight = `solid 1px ${this.parent.borderColor}`; style.borderRight = `${this.parent.borderStyle} ${this.parent.borderWidth}px ${this.parent.borderColor}`;
Object.assign(style, this.parent.style); Object.assign(style, this.parent.thStyle);
this.thStyle = style; this.thStyle = style;
} }
} }
......
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