allinssl/frontend/apps/vue-flow/components/configs/NotifyNodeConfig.tsx

86 lines
2.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { defineComponent, ref } from 'vue'
import { useWorkflowStore } from '../../store/workflow'
import { NotifyNodeData } from '../../types'
import configStyles from './Config.module.css'
export default defineComponent({
name: 'NotifyNodeConfig',
props: {
nodeId: {
type: String,
required: true,
},
nodeData: {
type: Object as () => NotifyNodeData,
required: true,
},
},
setup(props) {
const workflowStore = useWorkflowStore()
const message = ref(props.nodeData.message || '')
const notifyType = ref(props.nodeData.notifyType || 'email')
// 更新节点标签
const updateNodeLabel = (value: string) => {
workflowStore.updateNodeData(props.nodeId, { label: value })
}
// 更新通知消息
const updateMessage = (value: string) => {
message.value = value
workflowStore.updateNodeData(props.nodeId, { message: value })
}
// 更新通知类型
const updateNotifyType = (value: string) => {
notifyType.value = value
workflowStore.updateNodeData(props.nodeId, { notifyType: value })
}
return () => (
<div class={configStyles.configContainer}>
<div class={configStyles.configField}>
<div class={configStyles.configLabel}></div>
<input
type="text"
value={props.nodeData.label}
onInput={(e) => updateNodeLabel((e.target as HTMLInputElement).value)}
class={configStyles.configInput}
/>
</div>
<div class={configStyles.configField}>
<div class={configStyles.configLabel}></div>
<select
value={notifyType.value}
onChange={(e) => updateNotifyType((e.target as HTMLSelectElement).value)}
class={configStyles.configSelect}
>
<option value="email"></option>
<option value="sms"></option>
<option value="wechat"></option>
<option value="dingding"></option>
</select>
</div>
<div class={configStyles.configField}>
<div class={configStyles.configLabel}></div>
<textarea
value={message.value}
onInput={(e) => updateMessage((e.target as HTMLTextAreaElement).value)}
class={configStyles.configTextarea}
placeholder="请输入通知内容"
></textarea>
</div>
<div class={configStyles.configInfo}>
<div class={configStyles.configInfoTitle}></div>
<div class={configStyles.configInfoContent}>
</div>
</div>
</div>
)
},
})