import { n as e } from "./fun-U4_ASZRs.mjs";
import { t } from "./enum-B6bAjZjy.mjs";
import { n, o as r } from "./guanlihoutailiuchengshili-C0b2OnM9.mjs";
import { t as i } from "./bpMliuchengfenleikongzhiqi-BXcBcxU0.mjs";
import { Fragment as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, createTextVNode as d, createVNode as f, defineComponent as p, isRef as m, onMounted as h, openBlock as g, ref as _, renderList as v, toDisplayString as y, unref as b, withCtx as x } from "vue";
import { ProTable as S } from "@pubinfo/pro-components";
import { useRouter as C } from "vue-router";
import { Badge as w, Modal as T, Space as E, Tag as D, Textarea as O } from "ant-design-vue/es";
import { message as k } from "ant-design-vue";
//#region src/pages/flow-manage/instance/index.vue?vue&type=script&setup=true&lang.ts
var A = {
	"py-10px": "",
	"px-10px": "",
	"w-full": "",
	"h-full": ""
}, j = { key: 0 }, M = { key: 1 }, N = { key: 2 }, P = { key: 0 }, F = ["onClick"], I = { class: "ml-4px" }, L = ["onClick"], R = { class: "ml-4px text-red-500!" }, z = /* @__PURE__ */ p({
	name: "FlowInstance",
	__name: "index",
	setup(p) {
		let z = _([]), B = [
			{
				label: "审批中",
				value: "1"
			},
			{
				label: "审批通过",
				value: "2"
			},
			{
				label: "审批不通过",
				value: "3"
			},
			{
				label: "已取消",
				value: "4"
			}
		], V = _();
		async function H(e) {
			let { current: t, pageSize: n, ...i } = e, a = await r({
				doSearchTotal: !0,
				currentPage: t,
				pageSize: n,
				...i
			});
			return {
				success: a.success,
				data: a.data?.records ?? [],
				total: a.data?.total ?? 0
			};
		}
		let U = o(() => [
			{
				valueType: "a-input",
				bind: "value",
				title: "流程名称",
				dataIndex: "name",
				ellipsis: !0,
				fixed: "left",
				fieldProps: {
					placeholder: "请输入流程名称",
					allowClear: !0
				}
			},
			{
				valueType: "a-select",
				bind: "value",
				title: "流程分类",
				dataIndex: "category",
				ellipsis: !0,
				fixed: "left",
				fieldProps: {
					placeholder: "请选择流程分类",
					allowClear: !0,
					options: z.value
				}
			},
			{
				valueType: "a-input",
				bind: "value",
				title: "发起人",
				dataIndex: "startUser",
				ellipsis: !0,
				fieldProps: {
					placeholder: "请输入发起人",
					allowClear: !0
				}
			},
			{
				hideInSearch: !0,
				title: "发起部门",
				dataIndex: "startDept",
				ellipsis: !0
			},
			{
				valueType: "a-select",
				title: "流程状态",
				dataIndex: "status",
				ellipsis: !0,
				fieldProps: {
					placeholder: "请选择流程状态",
					allowClear: !0,
					options: B
				}
			},
			{
				hideInTable: !0,
				valueType: "a-input",
				bind: "value",
				title: "所属流程",
				dataIndex: "processDefinitionId",
				ellipsis: !0,
				fieldProps: {
					placeholder: "请输入流程定义的编号",
					allowClear: !0
				}
			},
			{
				valueType: "a-range-picker",
				bind: "value",
				title: "发起时间",
				dataIndex: "startTime",
				ellipsis: !0,
				fieldProps: {
					allowClear: !0,
					style: { width: "100%" }
				}
			},
			{
				hideInSearch: !0,
				title: "结束时间",
				dataIndex: "endTime",
				ellipsis: !0
			},
			{
				hideInSearch: !0,
				title: "耗时",
				dataIndex: "durationInMillis",
				ellipsis: !0
			},
			{
				hideInSearch: !0,
				title: "当前审批任务",
				dataIndex: "tasks"
			},
			{
				hideInSearch: !0,
				title: "流程编号",
				dataIndex: "id",
				ellipsis: !0
			},
			{
				hideInSearch: !0,
				width: 100,
				title: "操作",
				dataIndex: "action",
				fixed: "right"
			}
		]);
		function W() {
			V.value?.reload();
		}
		let G = C(), K = _(!1), q = _(""), J = _("");
		function Y(e, n) {
			switch (e) {
				case t.DETAIL:
					G.push({
						name: "instanceDetail",
						query: {
							type: "view",
							taskId: ""
						},
						params: { processInstanceId: n.id }
					});
					break;
				case t.CANCEL:
					q.value = n.id, K.value = !0;
					break;
			}
		}
		function X() {
			i().then((e) => {
				e && e.data && (z.value = e.data.map((e) => ({
					label: e.name,
					value: e.id
				})));
			});
		}
		function Z() {
			J.value.trim().length === 0 ? k.error("请输入取消原因") : n({
				id: q.value,
				reason: J.value
			}).then((e) => {
				e.success && (k.success("流程已取消"), J.value = "", K.value = !1, W());
			});
		}
		return h(() => {
			X();
		}), (n, r) => {
			let i = w, o = D, p = E, h = O, _ = T;
			return g(), l("div", A, [f(b(S), {
				ref_key: "tableRef",
				ref: V,
				"row-key": "id",
				request: H,
				columns: b(U),
				"auto-height": "",
				scroll: { x: 1100 }
			}, {
				bodyCell: x(({ column: n, record: r }) => [
					n.dataIndex === "startUser" ? (g(), l("span", j, y(r.startUser?.nickname), 1)) : c("", !0),
					n.dataIndex === "startDept" ? (g(), l("span", M, y(r.startUser?.deptName), 1)) : c("", !0),
					n.dataIndex === "startDept" ? (g(), l("span", N, y(r.startUser?.deptName), 1)) : c("", !0),
					n.dataIndex === "status" ? (g(), l(a, { key: 3 }, [
						r.status === 1 ? (g(), s(i, {
							key: 0,
							status: "processing",
							text: "审批中"
						})) : c("", !0),
						r.status === 2 ? (g(), s(i, {
							key: 1,
							status: "success",
							text: "审批通过"
						})) : c("", !0),
						r.status === 3 ? (g(), s(i, {
							key: 2,
							status: "error",
							text: "审批不通过"
						})) : c("", !0),
						r.status === 4 ? (g(), s(i, {
							key: 3,
							status: "default",
							text: "已取消"
						})) : c("", !0)
					], 64)) : c("", !0),
					n.dataIndex === "durationInMillis" ? (g(), l(a, { key: 4 }, [r.durationInMillis ? (g(), l("span", P, y(b(e)(r.durationInMillis)), 1)) : c("", !0)], 64)) : c("", !0),
					n.dataIndex === "tasks" ? (g(!0), l(a, { key: 5 }, v(r.tasks, (e) => (g(), s(o, {
						key: e.id,
						color: "blue"
					}, {
						default: x(() => [d(y(e.name), 1)]),
						_: 2
					}, 1024))), 128)) : c("", !0),
					n.dataIndex === "action" ? (g(), s(p, { key: 6 }, {
						default: x(() => [u("a", {
							class: "flex items-center",
							onClick: (e) => Y(b(t).DETAIL, r)
						}, [u("span", I, y(b(t).DETAIL), 1)], 8, F), r.status === 1 ? (g(), l("a", {
							key: 0,
							class: "flex items-center hover:opacity-80",
							onClick: (e) => Y(b(t).CANCEL, r)
						}, [u("span", R, y(b(t).CANCEL), 1)], 8, L)) : c("", !0)]),
						_: 2
					}, 1024)) : c("", !0)
				]),
				_: 1
			}, 8, ["columns"]), f(_, {
				open: b(K),
				"onUpdate:open": r[1] ||= (e) => m(K) ? K.value = e : null,
				title: "确认取消",
				onOk: Z
			}, {
				default: x(() => [u("div", null, [r[2] ||= u("div", null, "取消原因：", -1), f(h, {
					value: b(J),
					"onUpdate:value": r[0] ||= (e) => m(J) ? J.value = e : null,
					placeholder: "请输入取消原因",
					"auto-size": { minRows: 2 }
				}, null, 8, ["value"])])]),
				_: 1
			}, 8, ["open"])]);
		};
	}
});
//#endregion
export { z as default };
