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> <template>
<div> <div>
<Form ref="DateForm" :model="form" :rules="rules" :label-width="80" style="width: 400px;"> <Form ref="DateForm" :model="form" :rules="rules" :label-width="80" style="width: 400px;">
<Form-item label="选择日期" prop="date"> <Form-item label="选择日期" prop="value1">
<Date-picker v-model="form.date" type="datetime"></Date-picker> <Cascader :data="form.data" v-model="form.value1"></Cascader>
</Form-item> </Form-item>
<Form-item> <Form-item>
<Button type="primary" @click.native="handleClick">确定</Button> <Button type="primary" @click="handleClick">确定</Button>
</Form-item> </Form-item>
</Form> </Form>
</div> </div>
@ -280,12 +280,62 @@
data () { data () {
return { return {
form: { 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: { rules: {
date: [ value1: [
{ required: true, type: 'date', message: '不能为空', trigger: 'change' }, {
{ type: 'date', message: '日期格式不正确', trigger: 'change'} required: true,
type: 'array',
message: '没有填写'
}
] ]
} }
} }
@ -294,11 +344,6 @@
handleClick() { handleClick() {
this.$refs.DateForm.validate(); this.$refs.DateForm.validate();
} }
},
watch: {
'form.date' (val) {
console.log(val);
}
} }
} }
</script> </script>

View file

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