import { n as e } from "./chunk-TYymryXo.mjs";
import { t } from "./dist-BWeVpZNn.mjs";
import { t as n } from "./drawerField-DixOrcs0.mjs";
import { Fragment as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, isRef as d, openBlock as f, ref as p, unref as m, withCtx as h } from "vue";
import { Button as g, Divider as _, Drawer as v, Form as y, FormItem as b, Input as x, Select as S, Space as C, Table as w } from "ant-design-vue/es";
//#region src/pages/flow-create/flow-model/createComponents/flow/right-panel/components/drawer/drawerListener.vue?vue&type=script&setup=true&lang.ts
var T = {
	flex: "",
	"items-center": "",
	"justify-between": ""
}, E = ["onClick"], D = ["onClick"], O = /* @__PURE__ */ u({
	name: "DrawerListener",
	__name: "drawerListener",
	emits: ["submit"],
	setup(e, { expose: u, emit: O }) {
		let k = O, A = p(), [j, M] = t(!1), [N, P] = t(!1), F = [
			{
				label: "创建",
				value: "create"
			},
			{
				label: "指派",
				value: "assignment"
			},
			{
				label: "完成",
				value: "complete"
			},
			{
				label: "删除",
				value: "delete"
			},
			{
				label: "更新",
				value: "update"
			},
			{
				label: "超时",
				value: "timeout"
			}
		], I = [{
			label: "start",
			value: "start"
		}, {
			label: "end",
			value: "end"
		}], L = p([]), R = [
			{
				label: "Java类",
				value: "class"
			},
			{
				label: "表达式",
				value: "expression"
			},
			{
				label: "代理表达式",
				value: "delegateExpression"
			},
			{
				label: "脚本",
				value: "scriptFormat"
			}
		], z = [{
			label: "内联脚本",
			value: "inline"
		}, {
			label: "外部脚本",
			value: "external"
		}], B = p({ field: [] }), V = {
			event: [{
				required: !0,
				message: "请选择事件类型",
				trigger: "change"
			}],
			id: [{
				required: !0,
				message: "请输入监听器ID",
				trigger: ["blur"]
			}],
			lType: [{
				required: !0,
				message: "请输入监听器类型",
				trigger: "blur"
			}],
			value: [{
				required: !0,
				message: "请输入",
				trigger: ["blur"]
			}],
			scriptFormat: [{
				required: !0,
				message: "请输入脚本格式",
				trigger: ["blur"]
			}],
			scriptType: [{
				required: !0,
				message: "请选择脚本类型",
				trigger: "change"
			}],
			scriptContent: [{
				required: !0,
				message: "请输入脚本内容",
				trigger: ["blur"]
			}],
			resource: [{
				required: !0,
				message: "请输入资源地址",
				trigger: ["blur"]
			}]
		}, H = [
			{
				title: "序号",
				key: "index",
				customRender: (e) => `${e.index + 1}`
			},
			{
				title: "字段名称",
				dataIndex: "name",
				key: "name"
			},
			{
				title: "字段类型",
				dataIndex: "type",
				key: "type"
			},
			{
				title: "字段值",
				dataIndex: "value",
				key: "value"
			},
			{
				title: "操作",
				key: "action",
				dataIndex: "action",
				width: 90,
				fixed: "right"
			}
		], U = p("");
		async function W(e, t, n, r) {
			U.value = e, L.value = e === "task" ? F : I, M(!0), t === "add" ? B.value = { field: [] } : t === "edit" && n && (B.value = { ...n }, B.value.index = r);
		}
		function G(e) {
			B.value.lType = e;
		}
		function K(e, t, n) {
			e === "add" ? A.value?.open("add") : e === "edit" ? A.value?.open("edit", t, n) : e === "delete" && n !== void 0 && n >= 0 && B.value.field?.splice(n, 1);
		}
		function q() {
			P(!0), k("submit", B.value), P(!1), M(!1);
		}
		function J() {
			M(!1);
		}
		let Y = p(!1);
		function X(e) {
			let t = e.index === void 0 ? -1 : e.index;
			t < 0 ? B.value.field?.push({
				name: e.name,
				type: e.type,
				value: e.value
			}) : B.value.field[t] = {
				name: e.name,
				type: e.type,
				value: e.value
			}, Y.value = !1;
		}
		return u({ open: W }), (e, t) => {
			let u = S, p = b, O = x, k = y, M = _, P = g, F = w, I = C, W = v;
			return f(), i(W, {
				open: m(j),
				"onUpdate:open": t[11] ||= (e) => d(j) ? j.value = e : null,
				title: "执行监听器",
				placement: "right",
				width: 520,
				"destroy-on-close": "",
				"footer-style": { textAlign: "right" },
				onClose: J
			}, {
				footer: h(() => [l(I, null, {
					default: h(() => [l(P, { onClick: J }, {
						default: h(() => [...t[14] ||= [c(" 取消 ", -1)]]),
						_: 1
					}), l(P, {
						type: "primary",
						loading: m(N),
						onClick: q
					}, {
						default: h(() => [...t[15] ||= [c(" 提交 ", -1)]]),
						_: 1
					}, 8, ["loading"])]),
					_: 1
				})]),
				default: h(() => [
					l(k, {
						model: m(B),
						rules: V,
						"label-col": { span: 5 }
					}, {
						default: h(() => [
							l(p, {
								label: "事件类型",
								name: "event"
							}, {
								default: h(() => [l(u, {
									value: m(B).event,
									"onUpdate:value": t[0] ||= (e) => m(B).event = e,
									style: { width: "100%" },
									placeholder: "请选择事件类型",
									options: m(L)
								}, null, 8, ["value", "options"])]),
								_: 1
							}),
							m(U) === "task" ? (f(), i(p, {
								key: 0,
								label: "监听器ID",
								name: "id"
							}, {
								default: h(() => [l(O, {
									value: m(B).id,
									"onUpdate:value": t[1] ||= (e) => m(B).id = e,
									maxlength: 30
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							l(p, {
								label: "监听器类型",
								name: "lType"
							}, {
								default: h(() => [l(u, {
									value: m(B).lType,
									"onUpdate:value": t[2] ||= (e) => m(B).lType = e,
									style: { width: "100%" },
									placeholder: "监听器类型",
									options: R,
									onChange: G
								}, null, 8, ["value"])]),
								_: 1
							}),
							m(B).lType === "class" ? (f(), i(p, {
								key: 1,
								label: "Java类",
								name: "value"
							}, {
								default: h(() => [l(O, {
									value: m(B).value,
									"onUpdate:value": t[3] ||= (e) => m(B).value = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).lType === "expression" ? (f(), i(p, {
								key: 2,
								label: "表达式",
								name: "value"
							}, {
								default: h(() => [l(O, {
									value: m(B).value,
									"onUpdate:value": t[4] ||= (e) => m(B).value = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).lType === "delegateExpression" ? (f(), i(p, {
								key: 3,
								label: "代理表达式",
								name: "value"
							}, {
								default: h(() => [l(O, {
									value: m(B).value,
									"onUpdate:value": t[5] ||= (e) => m(B).value = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).lType === "scriptFormat" ? (f(), i(p, {
								key: 4,
								label: "脚本格式",
								name: "scriptFormat"
							}, {
								default: h(() => [l(O, {
									value: m(B).scriptFormat,
									"onUpdate:value": t[6] ||= (e) => m(B).scriptFormat = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).lType === "scriptFormat" ? (f(), i(p, {
								key: 5,
								label: "脚本类型",
								name: "scriptType"
							}, {
								default: h(() => [l(u, {
									value: m(B).scriptType,
									"onUpdate:value": t[7] ||= (e) => m(B).scriptType = e,
									style: { width: "100%" },
									placeholder: "脚本类型",
									options: z
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).scriptType === "inline" ? (f(), i(p, {
								key: 6,
								label: "脚本内容",
								name: "scriptContent"
							}, {
								default: h(() => [l(O, {
									value: m(B).scriptContent,
									"onUpdate:value": t[8] ||= (e) => m(B).scriptContent = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0),
							m(B).scriptType === "external" ? (f(), i(p, {
								key: 7,
								label: "资源地址",
								name: "resource"
							}, {
								default: h(() => [l(O, {
									value: m(B).resource,
									"onUpdate:value": t[9] ||= (e) => m(B).resource = e,
									maxlength: 1e3
								}, null, 8, ["value"])]),
								_: 1
							})) : a("", !0)
						]),
						_: 1
					}, 8, ["model"]),
					l(M),
					s("div", T, [t[13] ||= s("div", null, "注入字段", -1), l(P, {
						type: "primary",
						size: "small",
						onClick: t[10] ||= (e) => K("add")
					}, {
						default: h(() => [...t[12] ||= [c(" 添加字段 ", -1)]]),
						_: 1
					})]),
					l(F, {
						columns: H,
						"data-source": m(B).field,
						size: "small",
						pagination: !1,
						"row-key": "key"
					}, {
						bodyCell: h(({ column: e, record: t, index: n }) => [e.dataIndex === "action" ? (f(), o(r, { key: 0 }, [s("a", { onClick: (e) => K("edit", t, n) }, "编辑", 8, E), s("a", {
							style: {
								"margin-left": "8px",
								color: "red"
							},
							onClick: (e) => K("delete", t, n)
						}, "删除", 8, D)], 64)) : a("", !0)]),
						_: 1
					}, 8, ["data-source"]),
					l(n, {
						ref_key: "drawerFieldRef",
						ref: A,
						onSubmit: X
					}, null, 512)
				]),
				_: 1
			}, 8, ["open"]);
		};
	}
}), k = /* @__PURE__ */ e({ default: () => A }), A = O;
//#endregion
export { k as n, A as t };
