update files

This commit is contained in:
Nuintun 2015-11-20 17:58:30 +08:00
parent 627d176ea8
commit 9420e3613f
3 changed files with 14 additions and 15 deletions

View File

@ -22,7 +22,6 @@ module.exports = Vue.component('app-configure', {
return {
name: '',
path: '',
_cached: {},
submitError: '',
popup: false
}

View File

@ -1,3 +1,3 @@
<label>{{label}}</label>
<input type="text" :title="path" :placeholder="label" v-model="path" lazy/>&nbsp;
<input type="text" :title="path" :placeholder="label" :value="path" readonly/>&nbsp;
<a title="选择项目" href="javascript:;" class="icon-ellipsis" @click="open"></a>

View File

@ -33,11 +33,21 @@ module.exports = Vue.component('dynamic-item', {
return {
name: '',
value: '',
_cached: {},
nameError: '',
valueError: ''
};
},
computed: {
uniqueCache: function (){
var cache = {};
this.items.forEach(function (item){
cache[item.name] = true;
}, this);
return cache;
}
},
methods: {
add: function (){
// trim value
@ -47,7 +57,7 @@ module.exports = Vue.component('dynamic-item', {
// name error
if (!this.name) {
this.nameError = '不能为空';
} else if (this.$data._cached[this.name]) {
} else if (this.uniqueCache[this.name]) {
this.nameError = ' ' + this.name + ' 已存在';
} else {
this.nameError = '';
@ -61,9 +71,7 @@ module.exports = Vue.component('dynamic-item', {
}
// add item
if (this.name && this.value && !this.$data._cached[this.name]) {
// cache name
this.$data._cached[this.name] = true;
if (this.name && this.value && !this.uniqueCache[this.name]) {
// add item
this.items.push({ name: this.name, value: this.value });
@ -76,10 +84,7 @@ module.exports = Vue.component('dynamic-item', {
this[key] = '';
},
remove: function (index){
var item = this.items[index];
this.items.splice(index, 1);
delete this.$data._cached[item.name];
}
},
events: {
@ -87,10 +92,5 @@ module.exports = Vue.component('dynamic-item', {
this.nameError = '';
this.valueError = '';
}
},
created: function (){
this.items.forEach(function (item){
this.$data._cached[item.name] = true;
}, this);
}
});