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 {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
path: '',
|
path: '',
|
||||||
_cached: {},
|
|
||||||
submitError: '',
|
submitError: '',
|
||||||
popup: false
|
popup: false
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<label>{{label}}:</label>
|
<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>
|
<a title="选择项目" href="javascript:;" class="icon-ellipsis" @click="open"></a>
|
@ -33,11 +33,21 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
return {
|
return {
|
||||||
name: '',
|
name: '',
|
||||||
value: '',
|
value: '',
|
||||||
_cached: {},
|
|
||||||
nameError: '',
|
nameError: '',
|
||||||
valueError: ''
|
valueError: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
uniqueCache: function (){
|
||||||
|
var cache = {};
|
||||||
|
|
||||||
|
this.items.forEach(function (item){
|
||||||
|
cache[item.name] = true;
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
add: function (){
|
add: function (){
|
||||||
// trim value
|
// trim value
|
||||||
@ -47,7 +57,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
// name error
|
// name error
|
||||||
if (!this.name) {
|
if (!this.name) {
|
||||||
this.nameError = '不能为空';
|
this.nameError = '不能为空';
|
||||||
} else if (this.$data._cached[this.name]) {
|
} else if (this.uniqueCache[this.name]) {
|
||||||
this.nameError = ' ' + this.name + ' 已存在';
|
this.nameError = ' ' + this.name + ' 已存在';
|
||||||
} else {
|
} else {
|
||||||
this.nameError = '';
|
this.nameError = '';
|
||||||
@ -61,9 +71,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add item
|
// add item
|
||||||
if (this.name && this.value && !this.$data._cached[this.name]) {
|
if (this.name && this.value && !this.uniqueCache[this.name]) {
|
||||||
// cache name
|
|
||||||
this.$data._cached[this.name] = true;
|
|
||||||
// add item
|
// add item
|
||||||
this.items.push({ name: this.name, value: this.value });
|
this.items.push({ name: this.name, value: this.value });
|
||||||
|
|
||||||
@ -76,10 +84,7 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
this[key] = '';
|
this[key] = '';
|
||||||
},
|
},
|
||||||
remove: function (index){
|
remove: function (index){
|
||||||
var item = this.items[index];
|
|
||||||
|
|
||||||
this.items.splice(index, 1);
|
this.items.splice(index, 1);
|
||||||
delete this.$data._cached[item.name];
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
@ -87,10 +92,5 @@ module.exports = Vue.component('dynamic-item', {
|
|||||||
this.nameError = '';
|
this.nameError = '';
|
||||||
this.valueError = '';
|
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