mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 19:44:35 +08:00
update files
This commit is contained in:
parent
627d176ea8
commit
9420e3613f
@ -22,7 +22,6 @@ module.exports = Vue.component('app-configure', {
|
||||
return {
|
||||
name: '',
|
||||
path: '',
|
||||
_cached: {},
|
||||
submitError: '',
|
||||
popup: false
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
<label>{{label}}:</label>
|
||||
<input type="text" :title="path" :placeholder="label" v-model="path" lazy/>
|
||||
<input type="text" :title="path" :placeholder="label" :value="path" readonly/>
|
||||
<a title="选择项目" href="javascript:;" class="icon-ellipsis" @click="open"></a>
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user