mirror of
https://github.com/nuintun/command-manager.git
synced 2025-10-20 09:51:31 +08:00
update files
This commit is contained in:
@@ -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 = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -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">     </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">
|
||||
|
Reference in New Issue
Block a user