"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
require("../../forms/h2/index.js");
const getInstance = require("../../../utils/getInstance.js");
const parseRouteParams = require("../../../utils/parseRouteParams.js");
const common = require("../../../utils/common.js");
const eventBus = require("../../../utils/eventBus.js");
const _hoisted_1 = { class: "contract-content" };
const path = "/tech/ctr/components/DocCtrInfoComponent";
const _sfc_main = /* @__PURE__ */ Object.assign({
  inheritAttrs: false
}, {
  __name: "Contract",
  props: {
    config: {
      type: Object,
      required: true
    },
    localConfig: {
      type: Object,
      required: true
    },
    formMode: {
      type: String,
      default: ""
    }
  },
  setup(__props) {
    const props = __props;
    const ctx = getInstance.getCurrentVueInstance();
    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;
    const parsedParams = parseRouteParams.parseRouteParams(props.config.params, formData.value, [
      ...fieldsData,
      ...hiddenFields
    ]);
    const busNo = parseRouteParams.parseSingleParamValue(props.config.busNo, formData.value, [
      ...fieldsData,
      ...hiddenFields
    ]);
    const contNo = parseRouteParams.parseSingleParamValue(props.config.contNo, formData.value, [
      ...fieldsData,
      ...hiddenFields
    ]);
    const mode = Vue.computed(() => {
      if (props.formMode == "query") {
        return "view";
      }
      return props.config.mode;
    });
    const currentComponent = Vue.ref(null);
    Vue.onMounted(() => {
      common.loadComponentByPath(path, ctx.$router, currentComponent);
    });
    function loaded(dom, visibleData) {
      const foundItem = props.localConfig.fieldsData.find(
        (item) => item.id == props.config.id
      );
      const titleHeight = 0;
      if (foundItem) {
        foundItem.fixedH = true;
        foundItem.h = dom.offsetHeight + titleHeight;
        setFormItemHeight(props.config.id, true, dom.offsetHeight + titleHeight);
      }
      eventBus.default.emit("onSubTableDataLoaded", {
        subTableConfig: props.config,
        visibleData
      });
    }
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(Vue.unref(currentComponent)), {
          id: `comp_${__props.config.id}`,
          mode: Vue.unref(mode),
          busNo: Vue.unref(busNo),
          contNo: Vue.unref(contNo),
          modeNo: __props.config.busSubject,
          genType: __props.config.genType,
          parmList: Vue.unref(parsedParams),
          onLoaded: loaded
        }, null, 40, ["id", "mode", "busNo", "contNo", "modeNo", "genType", "parmList"]))
      ]);
    };
  }
});
exports.default = _sfc_main;
