-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c548b3
commit f8f8e2f
Showing
9 changed files
with
226 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<template> | ||
<div class="sm-component-attribute-panel" :style="[getTextColorStyle]"> | ||
<div v-if="title">{{ title }}</div> | ||
<div v-show="showIcon" class="sm-component-attribute-panel__header"> | ||
<sm-icon | ||
:class="['icon', 'left-icon', currentIndex === 0 && 'disabled']" | ||
type="caret-left" | ||
@click="changeIndex(-1)" | ||
/> | ||
<span class="ellipsis" :title="paginationContent">{{ paginationContent }}</span> | ||
<sm-icon | ||
type="caret-right" | ||
:class="['icon', 'right-icon', currentIndex === total - 1 && 'disabled']" | ||
@click="changeIndex(1)" | ||
/> | ||
</div> | ||
<div class="sm-component-attribute-panel__content"> | ||
<slot></slot> | ||
<div v-if="$scopedSlots && Object.keys($scopedSlots).length && attributes"> | ||
<ul> | ||
<li v-for="(value, key, index) in attributes" :key="index" class="content"> | ||
<div class="left ellipsis" :title="key" style="{width: 110}">{{ key }}</div> | ||
<div class="right ellipsis" :title="value.value || value" style="{width: 170}"> | ||
<slot v-if="fieldsMap[key]" :name="fieldsMap[key]" :value="value"></slot> | ||
<span v-else>{{ value }}</span> | ||
</div> | ||
</li> | ||
</ul> | ||
</div> | ||
<sm-table-popup v-if="!$slots.default && !($scopedSlots && Object.keys($scopedSlots).length) && attributes" v-bind="tablePopupProps" class="sm-component-attribute-panel__self-content" /> | ||
<sm-empty v-if="!$slots.default && !attributes" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Prop, Watch, Mixins } from 'vue-property-decorator'; | ||
import Theme from 'vue-iclient/src/common/_mixin/Theme'; | ||
import SmTablePopup from 'vue-iclient/src/common/table-popup/TablePopup.vue'; | ||
import SmEmpty from 'vue-iclient/src/common/empty/Empty.vue'; | ||
@Component({ | ||
name: 'SmAttributePanel', | ||
components: { SmTablePopup, SmEmpty } | ||
}) | ||
class SmAttributePanel extends Mixins(Theme) { | ||
currentIndex = 0; | ||
@Prop({ default: false }) showIcon: Boolean; | ||
@Prop({ default: 0 }) defaultIndex: number; | ||
@Prop() paginationText: String; | ||
@Prop() total: number; | ||
@Prop() title: String; | ||
@Prop({ | ||
default: () => { | ||
return []; | ||
} | ||
}) | ||
fields: Array<Object>; | ||
@Prop({ | ||
default: () => { | ||
return {}; | ||
} | ||
}) | ||
attributes: Object; | ||
@Prop({ | ||
default: () => { | ||
return []; | ||
} | ||
}) | ||
columns: Array<Object>; | ||
@Watch('defaultIndex') | ||
defaultIndexChanged() { | ||
this.currentIndex = this.defaultIndex; | ||
} | ||
get fieldsMap() { | ||
const attributeMap = {}; | ||
this.fields.forEach((field) => { | ||
// @ts-ignore | ||
attributeMap[field.field] = field.slotName; | ||
}); | ||
return attributeMap; | ||
} | ||
get paginationContent() { | ||
if (this.paginationText) { | ||
return this.paginationText; | ||
} | ||
return `${this.currentIndex + 1}/${this.total}`; | ||
} | ||
get tablePopupProps() { | ||
return { data: [this.attributes], columns: this.columns }; | ||
} | ||
changeIndex(val) { | ||
this.currentIndex += val; | ||
if (this.currentIndex < 0) { | ||
this.currentIndex = 0; | ||
} | ||
this.$emit('change', this.currentIndex); | ||
} | ||
} | ||
export default SmAttributePanel; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import AttributePanel from './AttributePanel'; | ||
import init from 'vue-iclient/src/init'; | ||
|
||
AttributePanel.install = function(Vue, opts) { | ||
init(Vue, opts); | ||
Vue.component(AttributePanel.options ? AttributePanel.options.name : AttributePanel.name, AttributePanel); | ||
}; | ||
|
||
export default AttributePanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@import '../../../common/_utils/style/mixins/mixins.scss'; | ||
@import '../../../common/_utils/style/theme/theme.scss'; | ||
|
||
@include b(attribute-panel) { | ||
min-width: 200px; | ||
height: auto; | ||
padding: 10px; | ||
border-radius: 4px; | ||
@include e(header) { | ||
width: 100%; | ||
display: inline-flex; | ||
align-items: center; | ||
padding: 0px 15px 8px ; | ||
border-bottom: 1px solid $border-color-split; | ||
& .icon { | ||
font-size: 16px; | ||
} | ||
& .left-icon { | ||
padding-right: 5px; | ||
} | ||
& .right-icon { | ||
padding-left: 5px; | ||
} | ||
& .disabled { | ||
color: $disabled-color; | ||
} | ||
& .ellipsis { | ||
max-width: calc(100% - 50px); | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
} | ||
@include e(content) { | ||
width: 100%; | ||
height: auto; | ||
padding-top: 5px; | ||
div > { | ||
ul { | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
overflow: auto; | ||
font-size: 14px; | ||
max-height: 200px; | ||
background: transparent; | ||
li { | ||
> div { | ||
padding: 4px 16px; | ||
} | ||
} | ||
border-collapse: separate; | ||
.content { | ||
display: table-row; | ||
color: white; | ||
.left { | ||
display: table-cell; | ||
} | ||
.right { | ||
display: table-cell; | ||
} | ||
} | ||
.content .ellipsis { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
} | ||
} | ||
|
||
@include e(self-content) { | ||
& .sm-component-table-thead { | ||
display: none; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import 'vue-iclient/src/common/_assets/iconfont/icon-sm-components.css'; | ||
import 'vue-iclient/src/common/_utils/style/common/common.scss'; | ||
|
||
import './attribute-panel.scss'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters