Commit 8035ef41 authored by Jenny's avatar Jenny

feat: 选项卡新增属性配置

parent 179e1026
...@@ -11,12 +11,22 @@ ...@@ -11,12 +11,22 @@
@change="handleTabsChange" @change="handleTabsChange"
></u-tabs> ></u-tabs>
<template v-if="elementInfo.option.tabs.type === 'select'"> <template v-if="elementInfo.option.tabs.type === 'select'">
<view class="input-group">
<u-input <u-input
v-model="tabsValue" v-model="tabsValue"
type="select" type="select"
border="true" border="true"
:placeholder="elementInfo.option.tabs.placeholder"
@click="show = true" @click="show = true"
/> />
<u-icon
class="close-icon"
v-if="tabsValue && elementInfo.option.tabs.allowClear"
name="close-circle"
@click.prevent.stop="handleClearValue"
></u-icon>
</view>
<u-select <u-select
v-model="show" v-model="show"
:default-value="defaultValue" :default-value="defaultValue"
...@@ -35,31 +45,37 @@ ...@@ -35,31 +45,37 @@
:indicator-color="'#ccc'" :indicator-color="'#ccc'"
:indicator-active-color="elementInfo.option.tabs.backgroundColor" :indicator-active-color="elementInfo.option.tabs.backgroundColor"
> >
<swiper-item class="tab-group" v-for="(item, index) in tabsGroup" :key="index"> <swiper-item
class="tab-group"
v-for="(item, index) in tabsGroup"
:key="index"
>
<view <view
class="tab-item" class="tab-item"
:class="[tabsValue == tab.value ? 'active': '']" :class="[tabsValue == tab.value ? 'active' : '']"
v-for="tab in item" v-for="tab in item"
:key="tab.value" :key="tab.value"
@click="handleChangeTabValue(tab.value)" @click="handleChangeTabValue(tab.value)"
>{{tab.name}}</view> >
{{ tab.name }}
</view>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
</template> </template>
<script> <script>
import echartElementData from '@/mixins/echartElementData.js' import echartElementData from '@/mixins/echartElementData.js'
export default { export default {
name:"NormalTabs", name: 'NormalTabs',
mixins: [echartElementData], mixins: [echartElementData],
data() { data() {
return { return {
currentTabs: 0, currentTabs: 0,
show: false, show: false,
tabsValue: '', tabsValue: this.elementInfo.option.tabs.defaultValue,
defaultValue: [0] defaultValue: [0]
}; }
}, },
mounted() { mounted() {
uni.$on('handlePullDownRefresh', () => { uni.$on('handlePullDownRefresh', () => {
...@@ -71,17 +87,30 @@ ...@@ -71,17 +87,30 @@
}, },
computed: { computed: {
tabsGroup() { tabsGroup() {
const { type, count} = this.elementInfo.option.tabs const { type, count } = this.elementInfo.option.tabs
if (type === 'group') { if (type === 'group') {
return this.$u.common.chunk(this.elementData.dataList.series, Number(count) * 2) return this.$u.common.chunk(
this.elementData.dataList.series,
Number(count) * 2
)
} }
return [] return []
}, },
tabsStyle() { tabsStyle() {
const { fontSize, color, activeColor, backgroundColor, count, frameWidth, frameColor, frameStyle, itemBackgroundColor } = this.elementInfo.option.tabs const {
fontSize,
color,
activeColor,
backgroundColor,
count,
frameWidth,
frameColor,
frameStyle,
itemBackgroundColor
} = this.elementInfo.option.tabs
return { return {
height: `${this.elementInfo.height}px`, height: `${this.elementInfo.height}px`,
'--width': `${(100 / Number(count)) - 2}%`, '--width': `${100 / Number(count) - 2}%`,
'--font-size': `${fontSize}px`, '--font-size': `${fontSize}px`,
'--color': color, '--color': color,
'--active-color': activeColor, '--active-color': activeColor,
...@@ -103,26 +132,40 @@ ...@@ -103,26 +132,40 @@
}, },
handleSelectChange(e) { handleSelectChange(e) {
this.tabsValue = e[0].value this.tabsValue = e[0].value
this.defaultValue[0] = [this.elementData.dataList.series.findIndex(item => item.value === e[0].value)] this.defaultValue[0] = [
this.elementData.dataList.series.findIndex(
item => item.value === e[0].value
)
]
this.tabsValueChange() this.tabsValueChange()
}, },
handleChangeTabValue(value) { handleChangeTabValue(value) {
this.tabsValue = value this.tabsValue = value
this.tabsValueChange() this.tabsValueChange()
}, },
/** 清除值 */
handleClearValue() {
this.tabsValue = ''
this.tabsValueChange()
},
/** /**
* 改变选项卡的值 * 改变选项卡的值
*/ */
tabsValueChange() { tabsValueChange() {
const { index, paramName, data } = this.elementInfo.child const { index, paramName, data } = this.elementInfo.child
if(this.elementInfo.child.type === 'param') { if (this.elementInfo.child.type === 'param') {
uni.$emit('handleLinkParams', { index, paramName, value: this.tabsValue }) uni.$emit('handleLinkParams', {
} else if(this.elementInfo.child.type === 'comp') { index,
const showData = [], hideData = [] paramName,
value: this.tabsValue
})
} else if (this.elementInfo.child.type === 'comp') {
const showData = [],
hideData = []
data.forEach(element => { data.forEach(element => {
if(element.name == this.tabsValue) showData.push(element.comp) if (element.name == this.tabsValue) showData.push(element.comp)
if(element.name != this.tabsValue) hideData.push(element.comp) if (element.name != this.tabsValue) hideData.push(element.comp)
}); })
uni.$emit('handleLinkComp', { showData, hideData }) uni.$emit('handleLinkComp', { showData, hideData })
} }
} }
...@@ -130,12 +173,12 @@ ...@@ -130,12 +173,12 @@
watch: { watch: {
'elementInfo.child.index': { 'elementInfo.child.index': {
handler(newVal) { handler(newVal) {
if(newVal.length) this.tabsValueChange() if (newVal.length) this.tabsValueChange()
}, },
immediate: true immediate: true
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -165,4 +208,14 @@ ...@@ -165,4 +208,14 @@
border-color: var(--background-color); border-color: var(--background-color);
} }
} }
.input-group {
position: relative;
}
.close-icon {
position: absolute;
right: 5px;
top: 50%;
transform: translateY(-50%);
z-index: 2;
}
</style> </style>
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
* 组件之间关联 * 组件之间关联
*/ */
handleValueChange(index, paramName, value) { handleValueChange(index, paramName, value) {
if(index.length && paramName && value) { if(index.length && paramName) {
const that = this const that = this
that.reportInfo.list = that.reportInfo.list.map(item => { that.reportInfo.list = that.reportInfo.list.map(item => {
const flag = index.includes(item.id) const flag = index.includes(item.id)
......
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
* 组件之间关联 * 组件之间关联
*/ */
handleValueChange(index, paramName, value) { handleValueChange(index, paramName, value) {
if(index.length && paramName && value) { if(index.length && paramName) {
const that = this const that = this
that.reportInfo.list = that.reportInfo.list.map(item => { that.reportInfo.list = that.reportInfo.list.map(item => {
const flag = index.includes(item.id) const flag = index.includes(item.id)
......
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