智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/53/5355dced934bb5e97720b8bfff8...

55 lines
1.1 KiB

<template>
<uni-form v-on="$listeners">
<span>
<slot />
</span>
</uni-form>
</template>
<script>
import {
listeners
} from 'uni-mixins'
export default {
name: 'Form',
mixins: [listeners],
data () {
return {
childrenList: []
}
},
listeners: {
'@form-submit': '_onSubmit',
'@form-reset': '_onReset',
'@form-group-update': '_formGroupUpdateHandler'
},
methods: {
_onSubmit ($event) {
const data = {}
this.childrenList.forEach(vm => {
if (vm._getFormData && vm._getFormData().key) {
data[vm._getFormData().key] = vm._getFormData().value
}
})
this.$trigger('submit', $event, {
value: data
})
},
_onReset ($event) {
this.$trigger('reset', $event, {})
this.childrenList.forEach(vm => {
vm._resetFormData && vm._resetFormData()
})
},
_formGroupUpdateHandler ($event) {
if ($event.type === 'add') {
this.childrenList.push($event.vm)
} else {
const index = this.childrenList.indexOf($event.vm)
this.childrenList.splice(index, 1)
}
}
}
}
</script>
<style>
</style>