Files
Sub-Store/web/src/components/RegexSortOperator.vue

114 lines
2.5 KiB
Vue
Raw Normal View History

2020-08-28 15:00:45 +08:00
<template>
<v-card class="ml-1 mr-1 mb-1 mt-1">
<v-card-title>
<v-icon left color="primary">sort</v-icon>
正则排序
2020-08-28 15:00:45 +08:00
<v-spacer></v-spacer>
2020-09-18 11:07:23 +08:00
<v-btn icon @click="$emit('up', idx)">
<v-icon>keyboard_arrow_up</v-icon>
</v-btn>
<v-btn icon @click="$emit('down', idx)">
<v-icon>keyboard_arrow_down</v-icon>
</v-btn>
<v-btn icon @click="$emit('deleteProcess', idx)">
2020-08-28 15:00:45 +08:00
<v-icon color="error">mdi-delete</v-icon>
</v-btn>
<v-dialog>
<template #activator="{on}">
<v-btn icon v-on="on">
<v-icon>help</v-icon>
</v-btn>
</template>
<v-card>
<v-card-title class="headline">
正则排序
2020-08-28 15:00:45 +08:00
</v-card-title>
<v-card-text>
根据给出的正则表达式的顺序对节点进行排序无法匹配的节点将会按照正序排列
2020-08-28 15:00:45 +08:00
</v-card-text>
</v-card>
</v-dialog>
</v-card-title>
<v-card-text>
正则表达式
<v-chip-group
column
2020-08-28 15:00:45 +08:00
>
<v-chip
close
close-icon="mdi-delete"
v-for="(item, idx) in items"
2020-08-28 15:00:45 +08:00
:key="idx"
2020-09-18 11:07:23 +08:00
@click="edit(idx)"
2020-08-28 15:00:45 +08:00
@click:close="remove(idx)"
>
{{ item }}
2020-08-28 15:00:45 +08:00
</v-chip>
</v-chip-group>
<v-text-field
placeholder="添加新正则表达式"
2020-09-21 10:15:05 +08:00
clearable
clear-icon="clear"
2020-08-28 15:00:45 +08:00
solo
v-model="form.item"
2020-08-28 15:00:45 +08:00
append-icon="mdi-send"
@click:append="add(form.item)"
@keyup.enter="add(form.item)"
2020-08-28 15:00:45 +08:00
/>
</v-card-text>
</v-card>
</template>
<script>
export default {
2020-09-18 11:07:23 +08:00
props: ['args'],
2020-08-28 15:00:45 +08:00
data: function () {
return {
2020-09-18 11:07:23 +08:00
idx: this.$vnode.key,
2020-08-28 15:00:45 +08:00
selection: null,
currentTag: null,
form: {
item: ""
2020-08-28 15:00:45 +08:00
},
items: []
2020-08-28 15:00:45 +08:00
}
},
2020-09-18 11:07:23 +08:00
created() {
if (this.args) {
this.items = this.args || [];
2020-09-18 11:07:23 +08:00
}
},
watch: {
items() {
2020-09-18 11:07:23 +08:00
this.save();
},
},
2020-08-28 15:00:45 +08:00
methods: {
add(item) {
if (item) {
this.items.push(item);
this.form.item = "";
2020-08-28 15:00:45 +08:00
} else {
this.$store.commit("SET_ERROR_MESSAGE", "正则表达式不能为空!");
2020-08-28 15:00:45 +08:00
}
},
2020-09-18 11:07:23 +08:00
edit(idx) {
this.form.item = this.items[idx];
2020-09-18 11:07:23 +08:00
this.remove(idx);
},
2020-08-28 15:00:45 +08:00
remove(idx) {
this.items.splice(idx, 1);
2020-08-28 15:00:45 +08:00
},
2020-09-18 11:07:23 +08:00
save() {
this.$emit("dataChanged", {
idx: this.idx,
args: this.items
2020-09-18 11:07:23 +08:00
});
2020-08-28 15:00:45 +08:00
},
}
}
</script>
<style scoped>
</style>