"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                             */
;/* empty css                                                                */
const Vue = require("vue");
const Node = require("./Node.vue2.js");
const index = require("../../../../../node_modules/element-plus/es/components/text/index.js");
const _sfc_main = {
  __name: "CcNode",
  props: {
    node: Object
  },
  setup(__props) {
    const { fields, nodesError } = Vue.inject("flowDesign", { fields: Vue.ref([]), nodesError: Vue.ref({}) });
    const props = __props;
    const content = Vue.ref("");
    Vue.watchEffect(() => {
      var _a, _b;
      const errors = [];
      const { id, assigneeType, name, users, roles, leader, choice, formUser, formRole, orgLeader } = props.node;
      if (assigneeType === "user") {
        if (users.length > 0) {
          const all = users.map((user) => getByUsername(user));
          Promise.all(all).then((users2) => {
            content.value = users2.map((user) => user.data.name).join("、");
          });
        } else {
          errors.push({ id, name, message: "未指定人员" });
          content.value = "未指定人员";
        }
      } else if (assigneeType === "choice") {
        content.value = `发起人自选（${choice ? "多选" : "单选"}）`;
      } else if (assigneeType === "self") {
        content.value = "发起人自己";
      } else if (assigneeType === "leader") {
        content.value = leader === 1 ? "直属上级" : `${leader}级上级`;
      } else if (assigneeType === "orgLeader") {
        content.value = orgLeader === 1 ? "直属主管" : `${orgLeader}级主管`;
      } else if (assigneeType === "formUser") {
        if (!formUser) {
          errors.push({ id, name, message: "未指定表单内人员" });
        }
        const title = ((_a = fields.value.find((e) => e.id === formUser)) == null ? void 0 : _a.label) || formUser || "?";
        content.value = `表单内（${title}）人员`;
      } else if (assigneeType === "formRole") {
        if (!formRole) {
          errors.push({ id, name, message: "未指定表单内角色" });
        }
        const title = ((_b = fields.value.find((e) => e.id === formRole)) == null ? void 0 : _b.label) || formRole || "?";
        content.value = `表单内（${title}）角色`;
      } else if (assigneeType === "role") {
        if (roles.length > 0) {
          const all = roles.map((id2) => getById(id2));
          Promise.all(all).then((roles2) => {
            content.value = roles2.map((res) => res.data.name).join("、");
          });
        } else {
          errors.push({ id, name, message: "未指定角色" });
          content.value = "未指定角色";
        }
      } else {
        errors.push({ id, name, message: "未知错误" });
        content.value = name;
      }
      if (errors.length > 0) {
        nodesError.value[id] = errors;
      } else {
        delete nodesError.value[id];
      }
    });
    return (_ctx, _cache) => {
      const _component_el_text = index.ElText;
      return Vue.openBlock(), Vue.createBlock(Node.default, Vue.mergeProps(_ctx.$attrs, {
        icon: "el:Promotion",
        color: "rgb(50, 150, 250)",
        node: __props.node
      }), {
        default: Vue.withCtx(() => [
          Vue.createVNode(_component_el_text, null, {
            default: Vue.withCtx(() => [
              Vue.createTextVNode(Vue.toDisplayString(Vue.unref(content)), 1)
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 16, ["node"]);
    };
  }
};
exports.default = _sfc_main;
