Commit ab59ece0 authored by 李俊赕's avatar 李俊赕

select-组件

parent 67336a61
...@@ -29,7 +29,10 @@ export default [{ ...@@ -29,7 +29,10 @@ export default [{
"cat": 10 "cat": 10
}, },
{ {
"fieldsTitle": "衬衫", "fieldsTitle": "选择框",
"fieldsName": "select",
"fieldsType": "select",
"settings": ['车主电', '物业电', '国电'],
"key": "衬衫", "key": "衬衫",
"icon": "https://cdn.uviewui.com/uview/common/classify/1/4.jpg", "icon": "https://cdn.uviewui.com/uview/common/classify/1/4.jpg",
"cat": 10 "cat": 10
......
<template>
<view class="list">
<view v-for="(item,index) in settings" :key="index" :class="{'txt':true,'active':item===dataValue}"
@click="setValue(item)">{{item}}</view>
</view>
</template>
<script>
import stringMixin from './stringMixin'
export default {
name: 'XhRadio',
components: {},
mixins: [stringMixin],
props: {},
data() {
return {}
},
computed: {
settings(){
return this.item.settings || []
}
},
watch: {},
mounted() {},
methods: {
setValue(txt){
this.dataValue = txt
this.valueChange(txt)
}
}
}
</script>
<style lang="scss" scoped>
.list{
display: flex;
.txt{
color:#666;
padding:10rpx;
&.active{
background-color: red;
color:#fff;
}
}
}
</style>
<template> <template>
<view> <view>
<u-input v-model="item.fieldsValue" /> <u-input v-model="dataValue" readOnly @click="show=true" type="select" />
<u-action-sheet :list="settings" v-model="show" @click="actionSheetCallback"></u-action-sheet>
</view> </view>
</template> </template>
<script> <script>
import stringMixin from './stringMixin'
export default { export default {
name: 'xhInput', name: 'XhSelect',
props: { components: {},
item: { mixins: [stringMixin],
type: Object, props: {},
default () { data() {
return [{}] return {
show: false
}
},
computed: {
type() {
if (this.item && this.item.fieldsType == 'password') {
return this.item.fieldsType
} else {
return 'text'
} }
}, },
settings() {
let result = []
let settings = this.item.settings || []
result = settings.map(item => {
return {
text: item
}
})
return result
}
}, },
data() { watch: {},
return { mounted() {},
value: '', methods: {
type: 'text', actionSheetCallback(index) {
border: true, let txt = this.settings[index].text;
this.dataValue = txt
this.valueChange(txt)
} }
} }
} }
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
<xh-checkbox v-if="item.fieldsType==='checkbox'" :groupIndex="groupIndex" <xh-checkbox v-if="item.fieldsType==='checkbox'" :groupIndex="groupIndex"
:itemIndex="itemIndex" :item="item" @value-change="fieldValueChange"> :itemIndex="itemIndex" :item="item" @value-change="fieldValueChange">
</xh-checkbox> </xh-checkbox>
<xh-select v-if="item.fieldsType==='select'" :groupIndex="groupIndex"
:itemIndex="itemIndex" :item="item" @value-change="fieldValueChange">
</xh-select>
</template> </template>
</u-form-item> </u-form-item>
</view> </view>
...@@ -54,6 +57,7 @@ ...@@ -54,6 +57,7 @@
import XhInput from '@/components/createCom/XhInput.vue' import XhInput from '@/components/createCom/XhInput.vue'
import XhRadio from '@/components/createCom/XhRadio.vue' import XhRadio from '@/components/createCom/XhRadio.vue'
import XhCheckbox from '@/components/createCom/XhCheckbox.vue' import XhCheckbox from '@/components/createCom/XhCheckbox.vue'
import XhSelect from '@/components/createCom/XhSelect.vue'
// import XhRadio from '@/components/createCom/XhRadio.vue' // import XhRadio from '@/components/createCom/XhRadio.vue'
export default { export default {
data() { data() {
...@@ -104,7 +108,8 @@ ...@@ -104,7 +108,8 @@
components: { components: {
XhInput, XhInput,
XhRadio, XhRadio,
XhCheckbox XhCheckbox,
XhSelect
// formCom // formCom
}, },
created() { created() {
......
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