update files

This commit is contained in:
nuintun
2015-11-24 12:23:27 +08:00
parent a3980af265
commit a058067ed0
12 changed files with 100 additions and 110 deletions

View File

@@ -18,6 +18,10 @@ module.exports = Vue.component('project-base', {
twoWay: true,
default: ''
},
unique: {
type: Object,
required: true
},
path: {
type: String,
twoWay: true,
@@ -31,23 +35,19 @@ module.exports = Vue.component('project-base', {
};
},
methods: {
focus: function (key, event){
if (event.target.type === 'text') {
this[key] = '';
}
}
},
events: {
'reset-error': function (){
this.nameError = '';
this.pathError = '';
focus: function (key){
this[key] = '';
},
'submit': function (){
isValid: function (){
this.name = this.name.trim();
this.path = this.path.trim();
if (this.name) {
this.nameError = '';
if (this.unique[this.name]) {
this.nameError = '项目已存在';
} else {
this.nameError = '';
}
} else {
this.nameError = '项目名称不能为空';
}
@@ -57,6 +57,18 @@ module.exports = Vue.component('project-base', {
} else {
this.pathError = '项目路径不能为空';
}
return !this.nameError && !this.pathError;
}
},
events: {
'reset-error': function (){
this.nameError = '';
this.pathError = '';
},
'reset-input': function (){
this.name = '';
this.path = '';
}
}
});

View File

@@ -1,12 +1,12 @@
<li>
<label>项目名称:</label>
<input type="text" v-model="name" placeholder="项目名称" lazy @focus="focus('nameError', $event)"/>
<input type="text" v-model="name" placeholder="项目名称" lazy @focus="focus('nameError')"/>
</li>
<li v-show="nameError" class="ui-item-error">
<label class="fn-invisible">&emsp;&emsp;&emsp;&emsp;&emsp;</label>
<span>{{ nameError }}</span>
</li>
<li @focusin="focus('pathError', $event)">
<li @focusin="focus('pathError')">
<directory label="项目路径" :path.sync="path"></directory>
</li>
<li v-show="pathError" class="ui-item-error">