import "../../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                                */
/* empty css                                                                     */
import { ref, inject, watch, createElementBlock, openBlock, Fragment, createCommentVNode, createElementVNode, createBlock, unref, withCtx, createVNode, withModifiers, normalizeClass } from "vue";
import { SubTitle } from "../../forms/subTitle/index.mjs";
import { H2 } from "../../forms/h2/index.mjs";
import _sfc_main$1 from "./timeLine.vue.mjs";
import FecFlowChart from "./flowChart.vue.mjs";
import { parseSingleParamValue } from "../../../utils/parseRouteParams.mjs";
/* empty css                      */
import _export_sfc from "../../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElButton } from "../../../../../../node_modules/element-plus/es/components/button/index.mjs";
const _hoisted_1 = {
  key: 0,
  style: { "height": "60px", "position": "relative" }
};
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "ApprovalHistory",
  props: {
    config: {
      type: Object,
      required: true
    },
    localConfig: {
      type: Object,
      required: true
    },
    formMode: {
      type: String,
      default: ""
    }
  },
  setup(__props) {
    const props = __props;
    const traceNo = ref("");
    const formData = inject("formData");
    inject("rowHeight");
    inject("gridLayout");
    inject("gridLayoutFieldsData");
    const setFormItemHeight = inject("setFormItemHeight");
    const fieldsData = props.localConfig.fieldsData.map((item) => {
      return item.component;
    });
    const hiddenFields = props.localConfig.hiddenFields;
    watch(
      () => props.config.traceNoFieldName,
      (value) => {
        if (value) {
          const busId = parseSingleParamValue(value, formData.value, [
            ...fieldsData,
            ...hiddenFields
          ]);
          traceNo.value = busId;
        }
      },
      { immediate: true }
    );
    const compType = ref(props.config.appHisDefault || "timeLine");
    function changeComp(type) {
      compType.value = type;
    }
    function timelineLoaded(dom) {
      const foundItem = props.localConfig.fieldsData.find(
        (item) => item.id == props.config.id
      );
      const titleHeight = props.config.titleMode != "none" ? 60 : 0;
      if (foundItem) {
        foundItem.fixedH = true;
        foundItem.h = dom.offsetHeight + titleHeight;
        setFormItemHeight(props.config.id, true, dom.offsetHeight + titleHeight);
      }
    }
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      return openBlock(), createElementBlock(Fragment, null, [
        __props.config.titleMode != "none" ? (openBlock(), createElementBlock("div", _hoisted_1, [
          __props.config.titleMode == "label" ? (openBlock(), createBlock(unref(H2), {
            key: 0,
            config: __props.config
          }, {
            default: withCtx(() => [
              createVNode(_component_el_button, {
                onClick: _cache[0] || (_cache[0] = withModifiers(($event) => changeComp("timeLine"), ["stop"])),
                link: "",
                type: "primary"
              }, {
                default: withCtx(() => _cache[2] || (_cache[2] = [
                  createElementVNode("span", null, "时间轴", -1)
                ])),
                _: 1
              }),
              createVNode(_component_el_button, {
                onClick: _cache[1] || (_cache[1] = withModifiers(($event) => changeComp("flowChart"), ["stop"])),
                link: "",
                type: "primary"
              }, {
                default: withCtx(() => _cache[3] || (_cache[3] = [
                  createElementVNode("span", null, "流程图", -1)
                ])),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["config"])) : __props.config.titleMode == "subLabel" ? (openBlock(), createBlock(unref(SubTitle), {
            key: 1,
            config: __props.config
          }, null, 8, ["config"])) : createCommentVNode("", true)
        ])) : createCommentVNode("", true),
        createElementVNode("div", {
          class: normalizeClass(["approval-history-content", unref(compType)])
        }, [
          unref(compType) == "timeLine" ? (openBlock(), createBlock(_sfc_main$1, {
            key: 0,
            traceNo: unref(traceNo),
            onLoaded: timelineLoaded
          }, null, 8, ["traceNo"])) : unref(compType) == "flowChart" ? (openBlock(), createBlock(FecFlowChart, {
            key: 1,
            style: { "height": "400px" },
            traceNo: unref(traceNo),
            onLoaded: timelineLoaded
          }, null, 8, ["traceNo"])) : createCommentVNode("", true)
        ], 2)
      ], 64);
    };
  }
});
const _ApprovalHistory = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-54f88c00"]]);
export {
  _ApprovalHistory as default
};
