| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view
- :class="['t-tr', { header: header }]"
- :style="{
- backgroundColor: backgroundColor
- }"
- >
- <view
- v-if="isCheck"
- class="t-check-box"
- :style="{ 'border-width': thBorder + 'px', 'border-color': borderColor }"
- >
- <checkbox-group @change="checkboxChange">
- <checkbox
- :value="checkboxData.value + ''"
- :checked="checkboxData.checked"
- />
- </checkbox-group>
- </view>
- <slot></slot>
- </view>
- </template>
- <script>
- export default {
- props: {
- header: Boolean,
- fontSize: String,
- color: String,
- align: String
- },
- inject: ["table"],
- provide() {
- return {
- tr: this
- };
- },
- data() {
- return {
- isCheck: false,
- checkboxData: {
- value: 0,
- checked: false
- },
- checked: false,
- thBorder: "1",
- borderColor: "#eeeeee",
- backgroundColor: "#ffffff"
- };
- },
- created() {
- this.thBorder = this.table.border;
- this.borderColor = this.table.borderColor;
- this.table.childrens.push(this);
- this.checkboxData.value = this.table.index++;
- this.isCheck = this.table.isCheck;
- if (this.header && this.table.headerBackgroundColor) {
- this.backgroundColor = this.table.headerBackgroundColor;
- }
- },
- methods: {
- checkboxChange(e) {
- this.checkboxData.checked = !this.checkboxData.checked;
- this.table.childrens[this.checkboxData.value] = this;
- this.table.fire(
- e.detail.value[0] ? true : false,
- this.checkboxData.value,
- this.table.index
- );
- }
- }
- };
- </script>
- <style lang="scss">
- .t-tr {
- width: 100%;
- display: flex;
- align-items: center;
- padding: 20upx 30upx;
- border-bottom: 1upx solid #eeeeee;
- &.header {
- box-shadow: 0upx 1upx 0upx 0upx #eeeeee;
- }
- }
- .t-tr t-th,
- .t-tr t-td {
- display: flex;
- flex: 1;
- }
- .t-tr .t-check-box {
- flex-shrink: 0;
- display: flex;
- justify-content: center;
- align-items: center;
- width: 80upx;
- color: #3b4246;
- border-left: 1upx #d0dee5 solid;
- border-top: 1upx #d0dee5 solid;
- }
- .t-tr .t-check-box checkbox {
- transform: scale(0.8);
- }
- </style>
|