import { n as e } from "./chunk-TYymryXo.mjs";
import { a as t, c as n, d as r, f as i, m as a, n as o, o as s, r as c, s as l } from "./guanlihoutailiuchengrenwushili-B2SkD7uU.mjs";
import { r as u } from "./guanlihoutailiuchengshili-C0b2OnM9.mjs";
import { t as d } from "./dist-BWeVpZNn.mjs";
import { a as f } from "./enum-DwLgP6qZ.mjs";
import { Fragment as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createTextVNode as _, createVNode as v, defineComponent as y, isRef as b, openBlock as x, reactive as ee, ref as S, renderList as C, toDisplayString as w, unref as T, withCtx as E } from "vue";
import { Button as D, Drawer as O, Form as te, FormItem as ne, Select as re, SelectOption as ie, Space as k, Tag as A, Textarea as j } from "ant-design-vue/es";
import { message as M } from "ant-design-vue";
import { selectUser as N } from "@pubinfo/module-rbac";
//#region src/pages/flow-manage/components/drawerHandle.vue?vue&type=script&setup=true&lang.ts
var P = {
	key: 0,
	"mb-4px": ""
}, F = /* @__PURE__ */ y({
	name: "DrawerHandle",
	__name: "drawerHandle",
	emits: ["submit"],
	setup(e, { expose: y, emit: F }) {
		let I = F, L = {
			[f.APPROVE]: {
				optType: "通过",
				userType: "",
				textArea: "审批意见"
			},
			[f.REJECT]: {
				optType: "拒绝",
				userType: "",
				textArea: "审批意见"
			},
			[f.COPY]: {
				optType: "抄送",
				userType: "抄送人",
				textArea: "抄送意见"
			},
			[f.TRANSFER]: {
				optType: "转办",
				userType: "新审批人",
				textArea: "转办意见"
			},
			[f.DELEGATE]: {
				optType: "委派",
				userType: "接受人",
				textArea: "委派意见"
			},
			[f.ADD_SIGN]: {
				optType: "加签",
				userType: "加签处理人",
				textArea: "加签意见"
			},
			[f.RETURN]: {
				optType: "退回",
				userType: "",
				textArea: "退回理由"
			},
			[f.DELETE_SIGN]: {
				optType: "减签",
				userType: "减签人员",
				textArea: "减签理由"
			},
			[f.CANCEL]: {
				optType: "取消",
				userType: "",
				textArea: "取消理由"
			}
		}, ae = S(), [R, z] = d(!1), oe = S(), B = ee({
			optType: 0,
			optTypeName: "",
			id: ""
		}), V = S(null), H = S(""), U = S([]), W = S(""), G = S([]), K = S([]), q = S({ reason: "" });
		async function se(e, t, n) {
			B.optType = e, B.optType === f.DELETE_SIGN && (G.value = t?.children || []), B.optType === f.RETURN && (U.value = (await o({ id: t?.id })).data || []), n && (V.value = n), B.optTypeName = L[e]?.optType || "", B.id = t?.id ?? "", K.value = [], q.value.reason = "", z(!0);
		}
		function ce() {
			N({
				multiple: !0,
				modelValue: K.value,
				onSubmit: (e) => {
					K.value = [...e];
				}
			});
		}
		function J(e) {
			K.value = K.value.filter((t) => t.userId !== e.userId);
		}
		function Y(e) {
			let t = e?.assigneeUser?.deptName || e?.ownerUser?.deptName;
			return `${e?.assigneeUser?.nickname || e?.ownerUser?.nickname} ( 所属部门：${t} )`;
		}
		let [X, Z] = d(!1);
		function Q(e) {
			if (K.value.length === 0 && [
				3,
				4,
				5,
				7
			].includes(B.optType)) {
				M.warning("请至少选择一个用户");
				return;
			}
			Z(!0);
			let o, d = {};
			switch (B.optType) {
				case f.APPROVE:
					o = c, d = {
						id: B.id,
						reason: q.value.reason,
						variables: {}
					};
					break;
				case f.REJECT:
					o = r, d = {
						id: B.id,
						reason: q.value.reason
					};
					break;
				case f.COPY:
					o = t, d = {
						id: B.id,
						copyUserIds: K.value.map((e) => e.userId),
						reason: q.value.reason
					};
					break;
				case f.TRANSFER:
					o = a, d = {
						id: B.id,
						assigneeUserId: K.value.map((e) => e.userId).join(","),
						reason: q.value.reason
					};
					break;
				case f.DELEGATE:
					o = l, d = {
						id: B.id,
						delegateUserId: K.value.map((e) => e.userId).join(","),
						reason: q.value.reason
					};
					break;
				case f.ADD_SIGN:
					o = s, d = {
						id: B.id,
						userIds: K.value.map((e) => e.userId),
						reason: q.value.reason,
						type: e
					};
					break;
				case f.DELETE_SIGN:
					o = n, d = {
						id: W.value,
						reason: q.value.reason
					};
					break;
				case f.RETURN:
					o = i, d = {
						id: B.id,
						targetTaskDefinitionKey: H.value,
						reason: q.value.reason
					};
					break;
				case f.CANCEL:
					o = u, d = {
						id: V.value.id,
						reason: q.value.reason
					};
					break;
				default: Z(!1), M.error("未知的操作类型");
			}
			o(d).then(() => {
				M.success("操作成功"), I("submit"), $();
			}).finally(() => {
				Z(!1);
			});
		}
		function $() {
			z(!1);
		}
		return y({ open: se }), (e, t) => {
			let n = A, r = D, i = ne, a = ie, o = re, s = j, c = te, l = k, u = O;
			return x(), m(u, {
				open: T(R),
				"onUpdate:open": t[12] ||= (e) => b(R) ? R.value = e : null,
				title: `流程处理 - ${T(B).optTypeName}`,
				placement: "right",
				width: 520,
				"destroy-on-close": "",
				"footer-style": { textAlign: "right" },
				onClose: $
			}, {
				footer: E(() => [v(l, null, {
					default: E(() => [
						v(r, { onClick: $ }, {
							default: E(() => [...t[14] ||= [_(" 取消 ", -1)]]),
							_: 1
						}),
						T(B).optType === T(f).CANCEL ? (x(), m(r, {
							key: 0,
							type: "primary",
							loading: T(X),
							onClick: t[3] ||= (e) => Q()
						}, {
							default: E(() => [...t[15] ||= [_(" 确定 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).APPROVE ? (x(), m(r, {
							key: 1,
							type: "primary",
							loading: T(X),
							onClick: t[4] ||= (e) => Q()
						}, {
							default: E(() => [...t[16] ||= [_(" 通过 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).REJECT ? (x(), m(r, {
							key: 2,
							type: "primary",
							loading: T(X),
							onClick: t[5] ||= (e) => Q()
						}, {
							default: E(() => [...t[17] ||= [_(" 拒绝 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).COPY ? (x(), m(r, {
							key: 3,
							type: "primary",
							loading: T(X),
							onClick: t[6] ||= (e) => Q()
						}, {
							default: E(() => [...t[18] ||= [_(" 抄送 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).TRANSFER ? (x(), m(r, {
							key: 4,
							type: "primary",
							loading: T(X),
							onClick: t[7] ||= (e) => Q()
						}, {
							default: E(() => [...t[19] ||= [_(" 转办 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).DELEGATE ? (x(), m(r, {
							key: 5,
							type: "primary",
							loading: T(X),
							onClick: t[8] ||= (e) => Q()
						}, {
							default: E(() => [...t[20] ||= [_(" 委派 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).ADD_SIGN ? (x(), m(r, {
							key: 6,
							type: "primary",
							loading: T(X),
							onClick: t[9] ||= (e) => Q("before")
						}, {
							default: E(() => [...t[21] ||= [_(" 向前加签 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).ADD_SIGN ? (x(), m(r, {
							key: 7,
							type: "primary",
							loading: T(X),
							onClick: t[10] ||= (e) => Q("after")
						}, {
							default: E(() => [...t[22] ||= [_(" 向后加签 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0),
						T(B).optType === T(f).RETURN ? (x(), m(r, {
							key: 8,
							type: "primary",
							loading: T(X),
							onClick: t[11] ||= (e) => Q()
						}, {
							default: E(() => [...t[23] ||= [_(" 退回 ", -1)]]),
							_: 1
						}, 8, ["loading"])) : h("", !0)
					]),
					_: 1
				})]),
				default: E(() => [v(c, {
					ref_key: "formRef",
					ref: oe,
					model: T(ae),
					"label-col": { span: 5 }
				}, {
					default: E(() => [
						[
							3,
							4,
							5,
							7
						].includes(T(B).optType) ? (x(), m(i, {
							key: 0,
							label: L[T(B).optType]?.userType,
							name: "name",
							rules: [{ required: !0 }]
						}, {
							default: E(() => [T(K).length > 0 ? (x(), g("div", P, [(x(!0), g(p, null, C(T(K), (e, t) => (x(), m(n, {
								key: t,
								closable: "",
								onClose: (t) => J(e)
							}, {
								default: E(() => [_(w(e.userName), 1)]),
								_: 2
							}, 1032, ["onClose"]))), 128))])) : h("", !0), v(r, {
								type: "primary",
								size: "small",
								onClick: ce
							}, {
								default: E(() => [...t[13] ||= [_(" 添加 ", -1)]]),
								_: 1
							})]),
							_: 1
						}, 8, ["label"])) : h("", !0),
						T(B).optType === T(f).DELETE_SIGN ? (x(), m(i, {
							key: 1,
							label: "减签人员",
							name: "reason",
							rules: [{ required: !0 }]
						}, {
							default: E(() => [v(o, {
								modelValue: T(W),
								"onUpdate:modelValue": t[0] ||= (e) => b(W) ? W.value = e : null,
								clearable: "",
								style: { width: "100%" }
							}, {
								default: E(() => [(x(!0), g(p, null, C(T(G), (e) => (x(), m(a, {
									key: e.id,
									label: Y(e),
									value: e.id
								}, {
									default: E(() => [_(w(Y(e)), 1)]),
									_: 2
								}, 1032, ["label", "value"]))), 128))]),
								_: 1
							}, 8, ["modelValue"])]),
							_: 1
						})) : h("", !0),
						T(B).optType === T(f).RETURN ? (x(), m(i, {
							key: 2,
							label: "退回节点",
							name: "targetTaskDefinitionKey",
							rules: [{ required: !0 }]
						}, {
							default: E(() => [v(o, {
								value: T(H),
								"onUpdate:value": t[1] ||= (e) => b(H) ? H.value = e : null,
								clearable: "",
								style: { width: "100%" }
							}, {
								default: E(() => [(x(!0), g(p, null, C(T(U), (e) => (x(), m(a, {
									key: e.taskDefinitionKey,
									value: e.taskDefinitionKey
								}, {
									default: E(() => [_(w(e.name), 1)]),
									_: 2
								}, 1032, ["value"]))), 128))]),
								_: 1
							}, 8, ["value"])]),
							_: 1
						})) : h("", !0),
						v(i, {
							label: L[T(B).optType]?.textArea,
							name: "reason"
						}, {
							default: E(() => [v(s, {
								value: T(q).reason,
								"onUpdate:value": t[2] ||= (e) => T(q).reason = e,
								rows: 3,
								placeholder: "请输入意见"
							}, null, 8, ["value"])]),
							_: 1
						}, 8, ["label"])
					]),
					_: 1
				}, 8, ["model"])]),
				_: 1
			}, 8, ["open", "title"]);
		};
	}
}), I = /* @__PURE__ */ e({ default: () => L }), L = F;
//#endregion
export { I as n, L as t };
