123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <view class="tn-checkbox-group-class tn-checkbox-group">
- <slot></slot>
- </view>
- </template>
- <script>
- import Emitter from '../../libs/utils/emitter.js'
-
- export default {
- mixins: [ Emitter ],
- name: 'tn-checkbox-group',
- props: {
- value: {
- type: Array,
- default() {
- return []
- }
- },
-
- max: {
- type: Number,
- default: 999
- },
-
- name: {
- type: String,
- default: ''
- },
-
- disabled: {
- type: Boolean,
- default: false
- },
-
- disabledLabel: {
- type: Boolean,
- default: false
- },
-
- shape: {
- type: String,
- default: 'square'
- },
-
- activeColor: {
- type: String,
- default: '#01BEFF'
- },
-
- size: {
- type: Number,
- default: 34
- },
-
- width: {
- type: String,
- default: 'auto'
- },
-
- wrap: {
- type: Boolean,
- default: false
- },
-
- iconSize: {
- type: Number,
- default: 20
- }
- },
- computed: {
-
-
-
- parentData() {
- return [this.value, this.disabled, this.disabledLabel, this.shape, this.activeColor, this.size, this.width, this.wrap, this.iconSize]
- }
- },
- data() {
- return {
-
- }
- },
- watch: {
-
- parentData() {
- if (this.children.length) {
- this.children.map(child => {
-
- typeof(child.updateParentData) === 'function' && child.updateParentData()
- })
- }
- }
- },
- created() {
- this.children = []
- },
- methods: {
- initValue(values) {
- this.$emit('input', values)
- },
-
- emitEvent() {
- let values = []
- this.children.map(child => {
- if (child.checkValue) values.push(child.name)
- })
- this.$emit('change', values)
- this.$emit('input', values)
-
-
- setTimeout(() => {
-
- this.dispatch('tn-form-item', 'on-form-change', values)
- }, 60)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
-
- .tn-checkbox-group {
- /* #ifndef MP || APP-NVUE */
- display: inline-flex;
- flex-wrap: wrap;
- /* #endif */
- &::after {
- content: " ";
- display: table;
- clear: both;
- }
- }
- </style>
|