|
@@ -1,10 +1,8 @@
|
|
|
<template>
|
|
|
- <picker @change="toChange" :value="index" :range="datalist" range-key="dispName">
|
|
|
- <view style="display: flex;align-items: center;">
|
|
|
- <input class="form-input" :disabled="disabled" v-model="selected" placeholder-class="form-input-placeholder" :placeholder="getPlaceholderText" />
|
|
|
- <uni-icons type="arrowright"></uni-icons>
|
|
|
- </view>
|
|
|
- </picker>
|
|
|
+ <view style="width: 100%;">
|
|
|
+ <u-input :value="selected" :placeholder="placeholder" @click="showPick=true" type="select" />
|
|
|
+ <u-picker mode="selector" v-model="showPick" @confirm="toChange" :default-selector="[0]" :range="datalist" range-key="dispName"></u-picker>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -17,7 +15,8 @@ export default {
|
|
|
datalist: [],
|
|
|
placeholderText: '请选择',
|
|
|
lookUp: [],
|
|
|
- index: 0
|
|
|
+ index: 0,
|
|
|
+ showPick: false
|
|
|
}
|
|
|
},
|
|
|
props: {
|
|
@@ -25,10 +24,6 @@ export default {
|
|
|
type: [Boolean, String],
|
|
|
default: false
|
|
|
},
|
|
|
- multiple: {
|
|
|
- type: [Boolean, String],
|
|
|
- default: false
|
|
|
- },
|
|
|
value: [String, Number, Array],
|
|
|
code: {
|
|
|
type: String,
|
|
@@ -38,22 +33,6 @@ export default {
|
|
|
type: String,
|
|
|
default: ''
|
|
|
},
|
|
|
- size: [String]
|
|
|
- },
|
|
|
- computed: {
|
|
|
- getVal () {
|
|
|
- return this.value
|
|
|
- },
|
|
|
- getPlaceholderText () {
|
|
|
- let _this = this
|
|
|
- for (let i = 0; i < _this.lookUp.length; i++) {
|
|
|
- if (_this.lookUp[i].code == _this.code) {
|
|
|
- if (this.placeholder === '') _this.placeholderText = _this.lookUp[i].name
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- return _this.placeholderText
|
|
|
- }
|
|
|
},
|
|
|
created () {
|
|
|
if (this.code) {
|
|
@@ -66,12 +45,11 @@ export default {
|
|
|
console.log(result, 'result')
|
|
|
if (result && result.status + '' === '200') {
|
|
|
this.datalist = result.data
|
|
|
-
|
|
|
+ // 设置默认值
|
|
|
+ this.setVal(this.value)
|
|
|
}
|
|
|
})
|
|
|
- } else {
|
|
|
- // console.log('请确认传递类型')
|
|
|
- }
|
|
|
+ }
|
|
|
// 获取所有数据字典
|
|
|
this.lookUp = this.$store.state.vuex_allLookUp
|
|
|
},
|
|
@@ -98,21 +76,25 @@ export default {
|
|
|
let index = this.datalist.findIndex(item=>{
|
|
|
return item.code == code
|
|
|
})
|
|
|
- console.log(this.datalist,code,index)
|
|
|
this.index = index
|
|
|
this.selected = this.datalist[index].dispName
|
|
|
},
|
|
|
toChange (e) {
|
|
|
- console.log('picker发送选择改变,携带值为', e.target.value)
|
|
|
- this.index = e.target.value
|
|
|
+ this.index = e[0]
|
|
|
this.selected = this.datalist[this.index].dispName
|
|
|
- this.$emit('itemChange', this.datalist[this.index].code)
|
|
|
+ this.$emit('input', this.datalist[this.index].code)
|
|
|
+ this.$emit('change', this.datalist[this.index].code)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style scoped>
|
|
|
-
|
|
|
+<style lang="scss" scoped>
|
|
|
+.v-select{
|
|
|
+ width: 100%;
|
|
|
+ .form-input{
|
|
|
+ flex-grow: 1;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|