import { n as e } from "./chunk-TYymryXo.mjs";
import { t } from "./request-B-Pg79ns.mjs";
import { n, t as r } from "./selectedInfo-CT8ehCR8.mjs";
import { i } from "./bpMliuchengfenleikongzhiqi-BXcBcxU0.mjs";
import { i as a, n as o, t as s } from "./enum-DwLgP6qZ.mjs";
import { t as c } from "./drawerExpression-DXbXMM4R.mjs";
import { Fragment as l, computed as u, createBlock as d, createCommentVNode as f, createElementBlock as p, createTextVNode as m, createVNode as h, defineComponent as g, inject as _, onMounted as v, openBlock as y, ref as b, renderList as x, toDisplayString as S, unref as C, watch as w, withCtx as T } from "vue";
import { Button as E, Form as D, FormItem as O, Select as k, Tag as A, Textarea as j } from "ant-design-vue/es";
import { selectOrg as M, selectUser as ee } from "@pubinfo/module-rbac";
//#region src/api/modules/assist/qunzujiekou.ts
function N(e, n) {
	return t.Post("/group/findPage", e, {
		headers: { "Content-Type": "application/json" },
		...n || {}
	});
}
//#endregion
//#region src/api/modules/rbac/gangweijiekou.ts
function P(e, n) {
	return t.Post("/rbac/post/findPage", e, {
		headers: { "Content-Type": "application/json" },
		...n || {}
	});
}
//#endregion
//#region src/api/modules/rbac/jiaosejiekou.ts
function F(e, n) {
	return t.Post("/rbac/role/rolePage", e, {
		headers: { "Content-Type": "application/json" },
		...n || {}
	});
}
//#endregion
//#region src/api/modules/rbac/zuzhijiekou.ts
function I(e, n) {
	return t.Post("/rbac/org/searchOrgByIds", e, {
		headers: { "Content-Type": "application/json" },
		...n || {}
	});
}
//#endregion
//#region src/pages/flow-create/flow-model/createComponents/flow/right-panel/components/userTask.vue?vue&type=script&setup=true&lang.ts
var L = /* @__PURE__ */ g({
	name: "UserTask",
	__name: "userTask",
	setup(e) {
		let t = _("lf"), g = n(), L = r(), R = b({}), z = b(), B = b([]), V = b([]);
		v(async () => {
			K(), J(), Q(), te();
			let e = g.getElementById(L.selectId) || {};
			if (R.value = e.userTask ?? {
				candidateStrategy: "",
				userIds: [],
				roleIds: [],
				postIds: [],
				bmzd: "",
				deptIds: [],
				levelId: "",
				groupIds: [],
				yhzd: "",
				flowVar: "",
				skipExpression: "",
				rangeId: "1",
				deptLevelId: "",
				deptGrounpId: "",
				roleId: ""
			}, e.userTask.userIds.length > 0) {
				let t = await i(e.userTask.userIds);
				t.success && (B.value = (t.data || []).map((e) => ({
					userId: e.id,
					userName: e.nickname,
					orgId: e.deptId
				})));
			}
			if (e.userTask.deptIds.length > 0) {
				let t = await I(e.userTask.deptIds);
				t.success && (V.value = (t.data || []).map((e) => ({
					orgId: e.id,
					orgName: e.name
				})));
			}
		});
		let H = u(() => R.value.candidateStrategy === o.MULTI_LEVEL_DEPT_LEADER ? "指定部门向上" : R.value.candidateStrategy === o.FORM_DEPT_LEADER ? "表单内部门向上" : "发起人部门向上");
		function U() {
			ee({
				modelValue: B.value,
				multiple: !0,
				onSubmit(e = []) {
					B.value = e.map((e) => ({
						orgId: e.orgId,
						userId: e.userId,
						userName: e.userName
					}));
				}
			});
		}
		function W(e) {
			B.value = B.value.filter((t) => t.userId !== e.userId);
		}
		w(() => B.value, (e) => {
			R.value.userIds = e.map((e) => e.userId);
		}, { deep: !0 });
		let G = b([]);
		function K() {
			F({
				currentPage: 1,
				pageSize: 1e3
			}).then((e) => {
				e.success && (G.value = (e.data?.records ?? []).map((e) => ({
					label: e.name,
					value: e.id
				})) || []);
			});
		}
		let q = b([]);
		function J() {
			P({
				currentPage: 1,
				pageSize: 1e3
			}).then((e) => {
				e.success && (q.value = (e.data?.records ?? []).map((e) => ({
					label: e.name,
					value: e.id
				})) || []);
			});
		}
		function Y() {
			M({
				multiple: !0,
				modelValue: V.value,
				onSubmit: (e) => {
					V.value = e.map((e) => ({
						orgId: e.orgId,
						orgName: e.orgName
					}));
				}
			});
		}
		function X(e) {
			V.value = V.value.filter((t) => t.orgId !== e.orgId);
		}
		w(() => V.value, (e) => {
			R.value.deptIds = e.map((e) => e.orgId);
		}, { deep: !0 });
		let Z = b([]);
		function Q() {
			N({
				currentPage: 1,
				pageSize: 1e3,
				type: "2"
			}).then((e) => {
				e.success && (Z.value = (e.data?.records ?? []).map((e) => ({
					label: e.name,
					value: e.id
				})) || []);
			});
		}
		let $ = b([]);
		function te() {
			N({
				currentPage: 1,
				pageSize: 1e3,
				type: "1"
			}).then((e) => {
				e.success && ($.value = (e.data?.records ?? []).map((e) => ({
					label: e.name,
					value: e.id
				})) || []);
			});
		}
		let ne = b([]), re = b([]);
		function ie() {
			(R.value.candidateStrategy === o.DEPT_MEMBER || R.value.candidateStrategy === o.DEPT_LEADER) && (R.value.deptIds = [], V.value = []), R.value.candidateStrategy === o.MULTI_LEVEL_DEPT_LEADER && (R.value.deptIds = [], V.value = [], R.value.levelId = 1), (R.value.candidateStrategy === o.START_USER_DEPT_LEADER || R.value.candidateStrategy === o.START_USER_MULTI_LEVEL_DEPT_LEADER || R.value.candidateStrategy === o.FORM_DEPT_LEADER) && (R.value.levelId = 1), R.value.candidateStrategy === o.ROLE_IN_START_USER_DEPT && (R.value.rangeId = "1", R.value.deptLevelId = "", R.value.deptGrounpId = "", R.value.roleIds = []);
		}
		function ae() {
			R.value.rangeId === "1" && (R.value.deptLevelId = 1), R.value.rangeId === "2" && (R.value.deptGrounpId = "");
		}
		function oe(e) {
			R.value.flowVar = e;
		}
		function se() {
			let e = {
				candidateStrategy: R.value.candidateStrategy,
				candidateParam: "",
				skipExpression: R.value.skipExpression || ""
			};
			switch (R.value.candidateStrategy) {
				case o.ROLE:
					e.candidateParam = R.value.roleIds.join(",");
					break;
				case o.DEPT_MEMBER:
				case o.DEPT_LEADER:
					e.candidateParam = R.value.deptIds.join(",");
					break;
				case o.POST:
					e.candidateParam = R.value.postIds.join(",");
					break;
				case o.MULTI_LEVEL_DEPT_LEADER:
					e.candidateParam = `${R.value.deptIds.join(",")}|${R.value.levelId}`;
					break;
				case o.USER:
					e.candidateParam = R.value.userIds.join(",");
					break;
				case o.START_USER_DEPT_LEADER:
				case o.START_USER_MULTI_LEVEL_DEPT_LEADER:
					e.candidateParam = R.value.levelId;
					break;
				case o.USER_GROUP:
					e.candidateParam = R.value.groupIds.join(",");
					break;
				case o.FORM_USER:
					e.candidateParam = R.value.yhzd;
					break;
				case o.FORM_DEPT_LEADER:
					e.candidateParam = `${R.value.bmzd}|${R.value.levelId}`;
					break;
				case o.EXPRESSION:
					e.candidateParam = R.value.flowVar;
					break;
				case o.ROLE_IN_START_USER_DEPT:
					R.value.rangeId === "1" ? e.candidateParam = `1|${R.value.deptLevelId}|${R.value.roleId}` : e.candidateParam = `2|${R.value.deptGrounpId}|${R.value.roleId}`;
					break;
				default: e.candidateParam = "";
			}
			return e;
		}
		return w(() => R, (e) => {
			let n = se();
			g.updateElement(L.selectId, { userTask: e }), t.value.setProperties(L.selectId, { userTask: n });
		}, { deep: !0 }), (e, t) => {
			let n = k, r = O, i = A, u = E, g = j, _ = D;
			return y(), d(_, {
				model: C(R),
				name: "basic",
				"label-col": { style: { width: "130px" } },
				autocomplete: "off"
			}, {
				default: T(() => [
					h(r, {
						label: "规则类型",
						name: "candidateStrategy"
					}, {
						default: T(() => [h(n, {
							value: C(R).candidateStrategy,
							"onUpdate:value": t[0] ||= (e) => C(R).candidateStrategy = e,
							options: C(s),
							onChange: ie
						}, null, 8, ["value", "options"])]),
						_: 1
					}),
					C(R).candidateStrategy === C(o).USER ? (y(), d(r, {
						key: 0,
						label: "指定用户",
						name: "userIds"
					}, {
						default: T(() => [(y(!0), p(l, null, x(C(B), (e, t) => (y(), d(i, {
							key: t,
							class: "mb-4px!",
							closable: "",
							onClose: (t) => W(e)
						}, {
							default: T(() => [m(S(e.userName), 1)]),
							_: 2
						}, 1032, ["onClose"]))), 128)), h(u, {
							size: "small",
							type: "primary",
							onClick: U
						}, {
							default: T(() => [...t[14] ||= [m(" 选择人员 ", -1)]]),
							_: 1
						})]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).ROLE_IN_START_USER_DEPT ? (y(), d(r, {
						key: 1,
						label: "类型",
						name: "rangeId"
					}, {
						default: T(() => [h(n, {
							value: C(R).rangeId,
							"onUpdate:value": t[1] ||= (e) => C(R).rangeId = e,
							style: { width: "100%" },
							placeholder: "请选择类型",
							options: [{
								label: "级别",
								value: "1"
							}, {
								label: "群组",
								value: "2"
							}],
							onChange: ae
						}, null, 8, ["value"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).ROLE_IN_START_USER_DEPT && C(R).rangeId === "1" ? (y(), d(r, {
						key: 2,
						label: "部门级别",
						name: "deptLevelId"
					}, {
						default: T(() => [h(n, {
							value: C(R).deptLevelId,
							"onUpdate:value": t[2] ||= (e) => C(R).deptLevelId = e,
							style: { width: "100%" },
							placeholder: "请选择部门级别",
							options: C(a)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).ROLE_IN_START_USER_DEPT && C(R).rangeId === "2" ? (y(), d(r, {
						key: 3,
						label: "部门群组",
						name: "deptGrounpId"
					}, {
						default: T(() => [h(n, {
							value: C(R).deptGrounpId,
							"onUpdate:value": t[3] ||= (e) => C(R).deptGrounpId = e,
							style: { width: "100%" },
							placeholder: "请选择部门群组",
							options: C($)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).ROLE_IN_START_USER_DEPT ? (y(), d(r, {
						key: 4,
						label: "指定角色",
						name: "roleIds"
					}, {
						default: T(() => [h(n, {
							value: C(R).roleId,
							"onUpdate:value": t[4] ||= (e) => C(R).roleId = e,
							style: { width: "100%" },
							placeholder: "请选择指定角色",
							options: C(G)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).ROLE ? (y(), d(r, {
						key: 5,
						label: "指定角色",
						name: "roleIds"
					}, {
						default: T(() => [h(n, {
							value: C(R).roleIds,
							"onUpdate:value": t[5] ||= (e) => C(R).roleIds = e,
							mode: "tags",
							style: { width: "100%" },
							placeholder: "请选择指定角色",
							options: C(G)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).POST ? (y(), d(r, {
						key: 6,
						label: "指定岗位",
						name: "postIds"
					}, {
						default: T(() => [h(n, {
							value: C(R).postIds,
							"onUpdate:value": t[6] ||= (e) => C(R).postIds = e,
							mode: "tags",
							style: { width: "100%" },
							placeholder: "请选择指定岗位",
							options: C(q)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).DEPT_MEMBER || C(R).candidateStrategy === C(o).DEPT_LEADER || C(R).candidateStrategy === C(o).MULTI_LEVEL_DEPT_LEADER ? (y(), d(r, {
						key: 7,
						label: "指定部门",
						name: "deptIds"
					}, {
						default: T(() => [(y(!0), p(l, null, x(C(V), (e, t) => (y(), d(i, {
							key: t,
							closable: "",
							onClose: (t) => X(e)
						}, {
							default: T(() => [m(S(e.orgName), 1)]),
							_: 2
						}, 1032, ["onClose"]))), 128)), h(u, {
							size: "small",
							type: "primary",
							onClick: Y
						}, {
							default: T(() => [...t[15] ||= [m(" 选择部门 ", -1)]]),
							_: 1
						})]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).FORM_DEPT_LEADER ? (y(), d(r, {
						key: 8,
						label: "表单内部门字段",
						name: "bmzd"
					}, {
						default: T(() => [h(n, {
							value: C(R).bmzd,
							"onUpdate:value": t[7] ||= (e) => C(R).bmzd = e,
							options: C(re)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).MULTI_LEVEL_DEPT_LEADER || C(R).candidateStrategy === C(o).START_USER_DEPT_LEADER || C(R).candidateStrategy === C(o).START_USER_MULTI_LEVEL_DEPT_LEADER || C(R).candidateStrategy === C(o).FORM_DEPT_LEADER ? (y(), d(r, {
						key: 9,
						label: "部门负责人来源",
						name: "levelId",
						tooltip: C(H)
					}, {
						default: T(() => [h(n, {
							value: C(R).levelId,
							"onUpdate:value": t[8] ||= (e) => C(R).levelId = e,
							style: { width: "100%" },
							placeholder: "请选择部门负责人来源",
							options: C(a)
						}, null, 8, ["value", "options"])]),
						_: 1
					}, 8, ["tooltip"])) : f("", !0),
					C(R).candidateStrategy === C(o).USER_GROUP ? (y(), d(r, {
						key: 10,
						label: "指定用户组",
						name: "groupIds"
					}, {
						default: T(() => [h(n, {
							value: C(R).groupIds,
							"onUpdate:value": t[9] ||= (e) => C(R).groupIds = e,
							mode: "tags",
							style: { width: "100%" },
							placeholder: "请选择指定用户组",
							options: C(Z)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).FORM_USER ? (y(), d(r, {
						key: 11,
						label: "表单内用户字段",
						name: "yhzd"
					}, {
						default: T(() => [h(n, {
							value: C(R).yhzd,
							"onUpdate:value": t[10] ||= (e) => C(R).yhzd = e,
							options: C(ne)
						}, null, 8, ["value", "options"])]),
						_: 1
					})) : f("", !0),
					C(R).candidateStrategy === C(o).EXPRESSION ? (y(), d(r, {
						key: 12,
						label: "流程表达式",
						name: "flowVar"
					}, {
						default: T(() => [h(g, {
							value: C(R).flowVar,
							"onUpdate:value": t[11] ||= (e) => C(R).flowVar = e,
							"show-count": "",
							maxlength: 300
						}, null, 8, ["value"]), h(u, {
							type: "link",
							onClick: t[12] ||= (e) => C(z)?.open()
						}, {
							default: T(() => [...t[16] ||= [m(" 选择表达式 ", -1)]]),
							_: 1
						})]),
						_: 1
					})) : f("", !0),
					h(r, {
						label: "跳过表达式",
						name: "skipExpression"
					}, {
						default: T(() => [h(g, {
							value: C(R).skipExpression,
							"onUpdate:value": t[13] ||= (e) => C(R).skipExpression = e,
							"show-count": "",
							maxlength: 300
						}, null, 8, ["value"])]),
						_: 1
					}),
					h(c, {
						ref_key: "drawerExpressionRef",
						ref: z,
						onSubmit: oe
					}, null, 512)
				]),
				_: 1
			}, 8, ["model"]);
		};
	}
}), R = /* @__PURE__ */ e({ default: () => z }), z = L;
//#endregion
export { R as n, z as t };
