"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 index$2 = require("../../forms/subTitle/index.js");
const index = require("../../forms/h2/index.js");
const timeLine = require("./timeLine.vue.js");
const flowChart = require("./flowChart.vue.js");
const parseRouteParams = require("../../../utils/parseRouteParams.js");
;/* empty css                      */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index$1 = require("../../../../../../node_modules/element-plus/es/components/button/index.js");
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 = Vue.ref("");
    const formData = Vue.inject("formData");
    Vue.inject("rowHeight");
    Vue.inject("gridLayout");
    Vue.inject("gridLayoutFieldsData");
    const setFormItemHeight = Vue.inject("setFormItemHeight");
    const fieldsData = props.localConfig.fieldsData.map((item) => {
      return item.component;
    });
    const hiddenFields = props.localConfig.hiddenFields;
    Vue.watch(
      () => props.config.traceNoFieldName,
      (value) => {
        if (value) {
          const busId = parseRouteParams.parseSingleParamValue(value, formData.value, [
            ...fieldsData,
            ...hiddenFields
          ]);
          traceNo.value = busId;
        }
      },
      { immediate: true }
    );
    const compType = Vue.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 = index$1.ElButton;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        __props.config.titleMode != "none" ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
          __props.config.titleMode == "label" ? (Vue.openBlock(), Vue.createBlock(Vue.unref(index.H2), {
            key: 0,
            config: __props.config
          }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(_component_el_button, {
                onClick: _cache[0] || (_cache[0] = Vue.withModifiers(($event) => changeComp("timeLine"), ["stop"])),
                link: "",
                type: "primary"
              }, {
                default: Vue.withCtx(() => _cache[2] || (_cache[2] = [
                  Vue.createElementVNode("span", null, "时间轴", -1)
                ])),
                _: 1
              }),
              Vue.createVNode(_component_el_button, {
                onClick: _cache[1] || (_cache[1] = Vue.withModifiers(($event) => changeComp("flowChart"), ["stop"])),
                link: "",
                type: "primary"
              }, {
                default: Vue.withCtx(() => _cache[3] || (_cache[3] = [
                  Vue.createElementVNode("span", null, "流程图", -1)
                ])),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["config"])) : __props.config.titleMode == "subLabel" ? (Vue.openBlock(), Vue.createBlock(Vue.unref(index$2.SubTitle), {
            key: 1,
            config: __props.config
          }, null, 8, ["config"])) : Vue.createCommentVNode("", true)
        ])) : Vue.createCommentVNode("", true),
        Vue.createElementVNode("div", {
          class: Vue.normalizeClass(["approval-history-content", Vue.unref(compType)])
        }, [
          Vue.unref(compType) == "timeLine" ? (Vue.openBlock(), Vue.createBlock(timeLine.default, {
            key: 0,
            traceNo: Vue.unref(traceNo),
            onLoaded: timelineLoaded
          }, null, 8, ["traceNo"])) : Vue.unref(compType) == "flowChart" ? (Vue.openBlock(), Vue.createBlock(flowChart.default, {
            key: 1,
            style: { "height": "400px" },
            traceNo: Vue.unref(traceNo),
            onLoaded: timelineLoaded
          }, null, 8, ["traceNo"])) : Vue.createCommentVNode("", true)
        ], 2)
      ], 64);
    };
  }
});
const _ApprovalHistory = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-54f88c00"]]);
exports.default = _ApprovalHistory;
