-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d83090
commit 73ce895
Showing
4 changed files
with
175 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script setup> | ||
const props = defineProps(['trigger']) | ||
import { inject } from 'vue' | ||
const show = inject('show_trigger_editor') | ||
import { storeToRefs } from 'pinia' | ||
import { usePlanStore } from '@/stores/plan' | ||
const plan_store = usePlanStore() | ||
const { sub_plan, backup_plans } = storeToRefs(plan_store) | ||
function update_trigger(data) { | ||
console.log(data) | ||
backup_plans.value[sub_plan.value].trigger = data | ||
} | ||
</script> | ||
|
||
<template> | ||
<n-modal | ||
v-model:show="show" | ||
preset="card" | ||
title="触发条件" | ||
transform-origin="center" | ||
style="width: 900px" | ||
> | ||
<trigger-editor :data="props.trigger" @update="update_trigger" /> | ||
</n-modal> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<script setup> | ||
const props = defineProps(['data']) | ||
const emit = defineEmits(['update']) | ||
import { ref, watch } from 'vue' | ||
const left = ref(props.data.left) | ||
const operator = ref(props.data.operator) | ||
const right = ref(props.data.right) | ||
function generate() { | ||
const result = { left: left.value, operator: operator.value, right: right.value } | ||
emit('update', result) | ||
} | ||
watch([left, operator, right], () => { | ||
console.log(left.value, operator.value, right.value) | ||
generate() | ||
}) | ||
const le_options = [ | ||
{ label: '表达式', value: 'expression' }, | ||
{ label: '字符串', value: 'string' } | ||
] | ||
</script> | ||
|
||
<template> | ||
<table> | ||
<tr> | ||
<td> | ||
<div class="label"> | ||
左 | ||
<n-select | ||
:default-value="typeof left == 'object' ? 'expression' : 'string'" | ||
:on-update:value=" | ||
(v) => { | ||
left = v == 'string' ? '' : {} | ||
} | ||
" | ||
:options="le_options" | ||
/> | ||
</div> | ||
</td> | ||
<td> | ||
<trigger-editor v-if="typeof left == 'object'" :data="left" @update="(d) => (left = d)" /> | ||
<n-input v-else v-model:value="left" /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>运算符</td> | ||
<td> | ||
<n-input v-model:value="operator" /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<div class="label"> | ||
右 | ||
<n-select | ||
:default-value="typeof right == 'object' ? 'expression' : 'string'" | ||
:on-update:value=" | ||
(v) => { | ||
right = v == 'string' ? '' : {} | ||
} | ||
" | ||
:options="le_options" | ||
/> | ||
</div> | ||
</td> | ||
|
||
<td> | ||
<trigger-editor | ||
v-if="typeof right == 'object'" | ||
:data="right" | ||
@update="(d) => (right = d)" | ||
/> | ||
<n-input v-else v-model:value="right" /> | ||
</td> | ||
</tr> | ||
</table> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
table { | ||
width: 100%; | ||
td { | ||
width: 120px; | ||
} | ||
td:last-child { | ||
width: auto; | ||
} | ||
} | ||
.label { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
gap: 6px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters