update Checkbox
when use Checkbox single, can hide default slot
This commit is contained in:
parent
67f4d8e763
commit
7c2ed52c61
2 changed files with 38 additions and 3 deletions
|
@ -11,6 +11,13 @@
|
||||||
<Form-item prop="user">
|
<Form-item prop="user">
|
||||||
<Input v-model="formInline.user"></Input>
|
<Input v-model="formInline.user"></Input>
|
||||||
</Form-item>
|
</Form-item>
|
||||||
|
<Form-item>
|
||||||
|
<Transfer
|
||||||
|
:data="formInline.data1"
|
||||||
|
:target-keys="formInline.targetKeys1"
|
||||||
|
:render-format="render1"
|
||||||
|
@on-change="handleChange1"></Transfer>
|
||||||
|
</Form-item>
|
||||||
<Form-item>
|
<Form-item>
|
||||||
<i-button type="primary" @click.native="handleSubmit('formInline')">登录</i-button>
|
<i-button type="primary" @click.native="handleSubmit('formInline')">登录</i-button>
|
||||||
</Form-item>
|
</Form-item>
|
||||||
|
@ -22,6 +29,8 @@
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
formInline: {
|
formInline: {
|
||||||
|
data1: this.getMockData(),
|
||||||
|
targetKeys1: this.getTargetKeys(),
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
user: '',
|
user: '',
|
||||||
value2: [],
|
value2: [],
|
||||||
|
@ -118,6 +127,32 @@
|
||||||
},
|
},
|
||||||
handleInput (val) {
|
handleInput (val) {
|
||||||
console.log(val)
|
console.log(val)
|
||||||
|
},
|
||||||
|
getMockData () {
|
||||||
|
let mockData = [];
|
||||||
|
for (let i = 1; i <= 20; i++) {
|
||||||
|
mockData.push({
|
||||||
|
key: i.toString(),
|
||||||
|
label: '内容' + i,
|
||||||
|
description: '内容' + i + '的描述信息',
|
||||||
|
disabled: Math.random() * 3 < 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return mockData;
|
||||||
|
},
|
||||||
|
getTargetKeys () {
|
||||||
|
return this.getMockData()
|
||||||
|
.filter(() => Math.random() * 2 > 1)
|
||||||
|
.map(item => item.key);
|
||||||
|
},
|
||||||
|
render1 (item) {
|
||||||
|
return item.label;
|
||||||
|
},
|
||||||
|
handleChange1 (newTargetKeys, direction, moveKeys) {
|
||||||
|
console.log(newTargetKeys);
|
||||||
|
console.log(direction);
|
||||||
|
console.log(moveKeys);
|
||||||
|
this.formInline.targetKeys1 = newTargetKeys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
:checked="currentValue"
|
:checked="currentValue"
|
||||||
@change="change">
|
@change="change">
|
||||||
</span>
|
</span>
|
||||||
<slot v-if="showSlot"><span ref="slot">{{ label }}</span></slot>
|
<slot><span v-if="showSlot">{{ label }}</span></slot>
|
||||||
</label>
|
</label>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
if (this.parent) this.group = true;
|
if (this.parent) this.group = true;
|
||||||
if (!this.group) {
|
if (!this.group) {
|
||||||
this.updateModel();
|
this.updateModel();
|
||||||
this.showSlot = this.$slots.default === undefined;
|
this.showSlot = this.$slots.default !== undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
this.$emit('input', checked);
|
this.$emit('input', checked);
|
||||||
|
|
||||||
if (this.group) {
|
if (this.group) {
|
||||||
this.parent.change(this.model);
|
this.$parent.change(this.model);
|
||||||
} else {
|
} else {
|
||||||
this.$emit('on-change', checked);
|
this.$emit('on-change', checked);
|
||||||
this.dispatch('FormItem', 'on-form-change', checked);
|
this.dispatch('FormItem', 'on-form-change', checked);
|
||||||
|
|
Loading…
Add table
Reference in a new issue