47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
Vue.component("node-schedule-action-box", {
|
|
props: ["value", "v-actions"],
|
|
data: function () {
|
|
let actionConfig = this.value
|
|
if (actionConfig == null) {
|
|
actionConfig = {
|
|
code: "",
|
|
params: {}
|
|
}
|
|
}
|
|
|
|
return {
|
|
actions: this.vActions,
|
|
currentAction: null,
|
|
actionConfig: actionConfig
|
|
}
|
|
},
|
|
watch: {
|
|
"actionConfig.code": function (actionCode) {
|
|
if (actionCode.length == 0) {
|
|
this.currentAction = null
|
|
} else {
|
|
this.currentAction = this.actions.$find(function (k, v) {
|
|
return v.code == actionCode
|
|
})
|
|
}
|
|
this.actionConfig.params = {}
|
|
}
|
|
},
|
|
template: `<div>
|
|
<input type="hidden" name="actionJSON" :value="JSON.stringify(actionConfig)"/>
|
|
<div>
|
|
<div>
|
|
<select class="ui dropdown auto-width" v-model="actionConfig.code">
|
|
<option value="">[选择动作]</option>
|
|
<option v-for="action in actions" :value="action.code">{{action.name}}</option>
|
|
</select>
|
|
</div>
|
|
<p class="comment" v-if="currentAction != null">{{currentAction.description}}</p>
|
|
|
|
<div v-if="actionConfig.code == 'webHook'">
|
|
<input type="text" placeholder="https://..." v-model="actionConfig.params.url"/>
|
|
<p class="comment">接收通知的URL。</p>
|
|
</div>
|
|
</div>
|
|
</div>`
|
|
}) |