import { t as e } from "./bpMliuchengdingyidexinxibiaokongzhiqi-DHqibwmz.mjs";
import { a as t, i as n } from "./guanlihoutailiuchengshili-C0b2OnM9.mjs";
import { n as r } from "./enum-DwLgP6qZ.mjs";
import { t as i } from "./timeLine-DVfBWuOc.mjs";
import { t as a } from "./registerComponent-DnH71wDV.mjs";
import { createElementBlock as o, createElementVNode as s, createVNode as c, defineComponent as l, onMounted as u, openBlock as d, ref as f, shallowRef as p, unref as m } from "vue";
import { useRoute as h, useRouter as g } from "vue-router";
import { message as _ } from "ant-design-vue";
//#region src/pages/yewu/create.vue?vue&type=script&setup=true&lang.ts
var v = {
	"py-10px": "",
	"px-10px": "",
	"w-full": "",
	"h-full": ""
}, y = {
	"size-full": "",
	"rd-4px": "",
	bg: "#fff",
	"p-30px": "",
	flex: ""
}, b = {
	key: 0,
	"flex-1": ""
}, x = {
	key: 1,
	"flex-1": ""
}, S = {
	class: "w-40%",
	"pl-40px": "",
	"pt-40px": ""
}, C = /* @__PURE__ */ l({
	name: "YewuProcessCreate",
	__name: "create",
	setup(l) {
		let C = g(), w = f(""), T = f([]), E = f([]), D = f({}), O = f({}), k = f(!1), A = f([]), j = h(), M = f(""), N = f(""), P = p(null), F = f("");
		async function I() {
			let e = await t({
				processDefinitionId: w.value,
				activityId: "StartUserNode",
				processVariablesStr: F.value
			});
			if (e.success) {
				if (e.data?.nextFlows && e.data.nextFlows.length > 0) {
					let t = e.data.nextFlows;
					t[0].optionName === "approveResult" ? (k.value = !0, A.value = t.map((e) => ({
						label: e.flowName,
						value: e.flowId
					}))) : k.value = !1;
				}
				if (E.value = e.data?.activityNodes ?? [], T.value = E.value.filter((e) => r.START_USER_SELECT === e.candidateStrategy), T.value?.length > 0) for (let e of T.value) O.value[e.id] && O.value[e.id].length > 0 ? D.value[e.id] = O.value[e.id] : D.value[e.id] = [];
			} else _.error("查询不到审批详情信息！");
		}
		u(async () => {
			M.value = j.query.key || "", N.value = j.query.createPath || "", P.value = a(N.value);
			let t = await e({
				id: void 0,
				key: M.value
			});
			if (t.success) {
				let e = t.data;
				if (!e) {
					_.error("流程模型未配置，请检查！");
					return;
				}
				w.value = e.id;
			}
			await I();
		});
		function L(e) {
			e && Object.keys(e).length > 0 && (O.value = D.value, D.value = {}, F.value = JSON.stringify(e), I());
		}
		function R(e, t) {
			D.value[e] = t?.map((e) => e.id);
		}
		async function z(e) {
			if (T.value?.length > 0) {
				for (let e of T.value) if (Array.isArray(D.value[e.id]) && D.value[e.id].length === 0) return _.warning(`请选择${e.name}的审批人`);
			}
			n({
				processDefinitionId: w.value,
				variables: e,
				startUserSelectAssignees: D.value
			}).then((e) => {
				e.success && (_.success("提交申请成功"), C.push({ name: "myProcessList" }));
			});
		}
		return (e, t) => (d(), o("div", v, [s("div", y, [m(P) ? (d(), o("div", b, [c(m(P), {
			"is-approve-result": m(k),
			"approve-options": m(A),
			onUpdateFormData: L,
			onSubmit: z
		}, null, 8, ["is-approve-result", "approve-options"])])) : (d(), o("div", x, [...t[0] ||= [s("div", { "text-20px": "" }, " 未找到表单 ", -1)]])), s("div", S, [c(i, {
			"activity-nodes": m(E),
			onSelectUserConfirm: R
		}, null, 8, ["activity-nodes"])])])]));
	}
});
//#endregion
export { C as default };
