123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <view class="u-checkbox-group u-clearfix" :class="uFromData.inputAlign == 'right' ? 'flex-end' : ''"><slot></slot></view>
- </template>
- <script>
- import Emitter from "../../libs/util/emitter.js";
- export default {
- name: "u-checkbox-group",
- emits: ["update:modelValue", "input", "change"],
- mixins: [Emitter],
- props: {
-
- value: {
- type: [String, Number, Array, Boolean],
- default: ""
- },
- modelValue: {
- type: [String, Number, Array, Boolean],
- default: ""
- },
-
- max: {
- type: [Number, String],
- default: 999
- },
-
-
-
-
-
-
-
-
- disabled: {
- type: Boolean,
- default: false
- },
-
- name: {
- type: [Boolean, String],
- default: ""
- },
-
- labelDisabled: {
- type: Boolean,
- default: false
- },
-
- shape: {
- type: String,
- default: "square"
- },
-
- activeColor: {
- type: String,
- default: "#2979ff"
- },
-
- size: {
- type: [String, Number],
- default: 34
- },
-
- width: {
- type: String,
- default: "auto"
- },
-
- wrap: {
- type: Boolean,
- default: false
- },
-
- iconSize: {
- type: [String, Number],
- default: 20
- }
- },
- data() {
- return {
- values: [],
- uFromData: {
- inputAlign: "left"
- }
- };
- },
- created() {
-
- this.children = [];
- },
- mounted() {
-
- let parent = this.$u.$parent.call(this, "u-form");
- if (parent) {
- Object.keys(this.uFromData).map(key => {
- this.uFromData[key] = parent[key];
- });
- }
- },
- methods: {
- emitEvent(obj) {
- let values = this.values || [];
- if (obj.value) {
- let index = values.indexOf(obj.name);
- if (index === -1) {
- values.push(obj.name);
- }
- } else {
- let index = values.indexOf(obj.name);
- if (index > -1) {
- values.splice(index, 1);
- }
- }
- this.$emit("change", values);
-
- this.$emit("input", values);
- this.$emit("update:modelValue", values);
-
-
- setTimeout(() => {
-
- this.dispatch("u-form-item", "onFieldChange", values);
- }, 60);
- },
- _emitEvent(obj) {
- let values = this.values || [];
- if (obj.value) {
- let index = values.indexOf(obj.name);
- if (index === -1) {
- values.push(obj.name);
- }
- } else {
- let index = values.indexOf(obj.name);
- if (index > -1) {
- values.splice(index, 1);
- }
- }
-
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/style.components.scss";
- .u-checkbox-group {
-
- display: inline-flex;
- flex-wrap: wrap;
-
- }
- .u-checkbox-group.flex-end {
-
- display: inline-flex;
- justify-content: flex-end;
- flex-wrap: wrap;
-
- }
- </style>
|