This commit is contained in:
aihe 2024-05-23 01:48:52 +08:00
parent 10ad30e4ff
commit 70d1b353fe
4 changed files with 32 additions and 34 deletions

View File

@ -2,7 +2,7 @@
<view :class="contClass" :style="styles"> <view :class="contClass" :style="styles">
<u-row custom-style="width: 100%;"> <u-row custom-style="width: 100%;">
<view style="flex: 1;"> <view style="flex: 1;">
<u-text :text="leftText" size="28" :lines="1"></u-text> <tpx-text-dic :value="value" :list="list" :checkedList="checkedList" :text="text" :placeholder="placeholder"></tpx-text-dic>
</view> </view>
<u-row> <u-row>
<u-icon size="22" :name="`${show?'arrow-up':'arrow-down'}`" color="#333"></u-icon> <u-icon size="22" :name="`${show?'arrow-up':'arrow-down'}`" color="#333"></u-icon>
@ -14,13 +14,6 @@
<script> <script>
export default { export default {
computed: { computed: {
leftText() {
let str = this.text || ''
if(!str) {
str = this.placeholder
}
return str
},
contClass() { contClass() {
let pre = ['radius-10'] let pre = ['radius-10']
if (this.isWhite) { if (this.isWhite) {
@ -55,6 +48,21 @@
return false return false
} }
}, },
list: {
default () {
return []
}
},
checkedList: {
default () {
return []
}
},
value: {
default () {
return ""
}
},
text: { text: {
default () { default () {
return '' return ''

View File

@ -4,6 +4,7 @@
<slot v-if="$slots.default"></slot> <slot v-if="$slots.default"></slot>
<template v-else> <template v-else>
<default-select-input v-if="selectTextType == 'input'" :placeholder="placeholder" :show="show" <default-select-input v-if="selectTextType == 'input'" :placeholder="placeholder" :show="show"
:value="value" :list="filDataList" :checkedList="filDatacheckedList"
:isWhite="isWhite" :text="text" :customStyle="customStyle" :isWhite="isWhite" :text="text" :customStyle="customStyle"
></default-select-input> ></default-select-input>
<DefaultSelectText v-if="selectTextType == 'text'"></DefaultSelectText> <DefaultSelectText v-if="selectTextType == 'text'"></DefaultSelectText>

View File

@ -6,30 +6,34 @@
export default { export default {
computed: { computed: {
title() { title() {
let title = this.value
let val = this.value let val = this.value
if(val && this.list) { if(val && this.list) {
if(!Array.isArray(val) && val.split) { if(!Array.isArray(val) && val.split) {
val = val.split(",") val = val.split(",")
} }
title = this.list.filter(t=> t.val == val || (val.indexOf && val.indexOf(t.val) > -1)).map(t=> t.title).join(",") val = this.list.filter(t=> t.val == val || (val.indexOf && val.indexOf(t.val) > -1)).map(t=> t.title).join(",")
} }
if(Array.isArray(this.checkedList)) { if(Array.isArray(this.checkedList)) {
val = this.checkedList.map(t=> t.title).join(',') val = this.checkedList.map(t=> t.title).join(',')
} }
if((!title || title?.length == 0) && (this.list || this.checkedList?.length == 0)) { val = val || this.text || this.placeholder
title = '-' return val
}
return title
} }
}, },
props: { props: {
value: { value: {
}, },
text: {
},
list: { list: {
}, },
checkedList: { checkedList: {
}, },
placeholder: {
default () {
return '-'
}
},
}, },
data() { data() {
return { return {

View File

@ -8,10 +8,11 @@
</view> </view>
<u-row :custom-style="`min-width: ${rightWidth}rpx;`" justify="end" align="center"> <u-row :custom-style="`min-width: ${rightWidth}rpx;`" justify="end" align="center">
<template v-if="!$slots.right"> <template v-if="!$slots.right">
<u-text align="right" margin="0 12rpx 0 0" size="26" <view style="margin-right: 12rpx; flex:1; text-align: right;">
:text="title"></u-text> <tpx-text-dic :value="value" :list="list" :checkedList="checkedList" :placeholder="placeholder"></tpx-text-dic>
</view>
<template v-if="!$slots.rightRcon"> <template v-if="!$slots.rightRcon">
<u-icon v-if="list || checkedList" size="26" name="arrow-right" color="#333"></u-icon> <u-icon size="26" name="arrow-right" color="#333"></u-icon>
</template> </template>
<slot name="rightRcon"></slot> <slot name="rightRcon"></slot>
</template> </template>
@ -23,23 +24,7 @@
<script> <script>
export default { export default {
computed: { computed: {
title() {
let title = this.value
let val = this.value
if(val && this.list) {
if(!Array.isArray(val) && val.split) {
val = val.split(",")
}
title = this.list.filter(t=> t.val == val || (val.indexOf && val.indexOf(t.val) > -1)).map(t=> t.title).join(",")
}
if(Array.isArray(this.checkedList)) {
title = this.checkedList.map(t=> t.title).join(',')
}
if((!title || title?.length == 0) && (this.list || this.checkedList?.length == 0)) {
title = this.placeholder
}
return title
}
}, },
props: { props: {
rightWidth:{ rightWidth:{