Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature [uni-data-select] disabled value is show #657

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pages/vue/data-select/data-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</uni-section>
<uni-section title="禁用状态" type="line">
<view class="uni-px-5 uni-pb-5">
<uni-data-select v-model="value" :disabled="true" :localdata="range"></uni-data-select>
<uni-data-select v-model="value" :disabled="true" :disableSVShow='true' :localdata="range"></uni-data-select>
</view>
</uni-section>
<!-- <uni-section title="云端数据" subTitle="连接云服务空间, 且存在相关的数据表才能生效(此处演示, 未连接云服务空间, 故不生效, 且有报错)" type="line">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
<view class="uni-select__selector-empty" v-if="mixinDatacomResData.length === 0">
<text>{{emptyTips}}</text>
</view>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData" :key="index"
@click="change(item)">
<text :class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
<view v-else class="uni-select__selector-item" v-for="(item,index) in mixinDatacomResData"
:key="index" @click="change(item)">
<text
:class="{'uni-select__selector__disabled': item.disable}">{{formatItemName(item)}}</text>
</view>
</scroll-view>
</view>
Expand All @@ -39,6 +40,7 @@
* @property {String} label 左侧标题
* @property {String} placeholder 输入框的提示文字
* @property {Boolean} disabled 是否禁用
* @property {Boolean} disabledSVShow 禁用后选中的默认值是否回显
* @event {Function} change 选中发生变化触发
*/

Expand Down Expand Up @@ -92,6 +94,10 @@
disabled: {
type: Boolean,
default: false
},
disabledSVShow: {
type: Boolean,
default: false
}
},
created() {
Expand Down Expand Up @@ -144,11 +150,11 @@
},
methods: {
// 执行数据库查询
query(){
query() {
this.mixinDatacomEasyGet();
},
// 监听查询条件变更事件
onMixinDatacomPropsChange(){
onMixinDatacomPropsChange() {
this.query();
},
initDefVal() {
Expand Down Expand Up @@ -182,15 +188,15 @@
* 判断用户给的 value 是否同时为禁用状态
*/
isDisabled(value) {
let isDisabled = false;
let isDisabled = false;

this.mixinDatacomResData.forEach(item => {
if (item.value === value) {
isDisabled = item.disable
}
})
this.mixinDatacomResData.forEach(item => {
if (item.value === value && item.disabledSVShow) {
isDisabled = item.disable
}
})

return isDisabled;
return isDisabled;
},

clearVal() {
Expand Down Expand Up @@ -444,4 +450,4 @@
right: 0;
left: 0;
}
</style>
</style>