This commit is contained in:
梁灏 2017-03-29 09:33:31 +08:00
parent d270488b82
commit cc41949990
2 changed files with 62 additions and 15 deletions

View file

@ -266,11 +266,11 @@
<template>
<div>
<Form ref="DateForm" :model="form" :rules="rules" :label-width="80" style="width: 400px;">
<Form-item label="选择日期" prop="date">
<Date-picker v-model="form.date" type="datetime"></Date-picker>
<Form-item label="选择日期" prop="value1">
<Cascader :data="form.data" v-model="form.value1"></Cascader>
</Form-item>
<Form-item>
<Button type="primary" @click.native="handleClick">确定</Button>
<Button type="primary" @click="handleClick">确定</Button>
</Form-item>
</Form>
</div>
@ -280,12 +280,62 @@
data () {
return {
form: {
date: ''
value1: [],
data: [{
value: 'beijing',
label: '北京',
children: [
{
value: 'gugong',
label: '故宫'
},
{
value: 'tiantan',
label: '天坛'
},
{
value: 'wangfujing',
label: '王府井'
}
]
}, {
value: 'jiangsu',
label: '江苏',
children: [
{
value: 'nanjing',
label: '南京',
children: [
{
value: 'fuzimiao',
label: '夫子庙',
}
]
},
{
value: 'suzhou',
label: '苏州',
children: [
{
value: 'zhuozhengyuan',
label: '拙政园',
},
{
value: 'shizilin',
label: '狮子林',
}
]
}
],
}]
},
rules: {
date: [
{ required: true, type: 'date', message: '不能为空', trigger: 'change' },
{ type: 'date', message: '日期格式不正确', trigger: 'change'}
value1: [
{
required: true,
type: 'array',
message: '没有填写'
}
]
}
}
@ -294,11 +344,6 @@
handleClick() {
this.$refs.DateForm.validate();
}
},
watch: {
'form.date' (val) {
console.log(val);
}
}
}
</script>

View file

@ -162,9 +162,11 @@
emitValue (val, oldVal) {
if (JSON.stringify(val) !== oldVal) {
this.$emit('on-change', this.currentValue, JSON.parse(JSON.stringify(this.selected)));
this.dispatch('FormItem', 'on-form-change', {
value: this.currentValue,
selected: JSON.parse(JSON.stringify(this.selected))
this.$nextTick(() => {
this.dispatch('FormItem', 'on-form-change', {
value: this.currentValue,
selected: JSON.parse(JSON.stringify(this.selected))
});
});
}
}