import "../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                       */
/* empty css                                                               */
/* empty css                                                            */
/* empty css                                                         */
/* empty css                                                            */
/* empty css                                                                  */
/* empty css                                                            */
/* empty css                                                            */
import { getCurrentInstance, computed, ref, createElementBlock, openBlock, createBlock, unref, withCtx, createTextVNode, createElementVNode, Fragment, renderList, createVNode } from "vue";
import { Plus as plus_default, Delete as delete_default } from "../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import ValueSelector from "./ValueSelector.vue.mjs";
import api from "../api/index.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";
import { ElSelect, ElOption } from "../../../node_modules/element-plus/es/components/select/index.mjs";
const _hoisted_1 = { class: "essential-param-container" };
const _hoisted_2 = {
  key: 1,
  class: "param-table"
};
const _hoisted_3 = { class: "param-body" };
const _hoisted_4 = { class: "param-cell scenario-cell" };
const _hoisted_5 = { class: "param-cell key-cell" };
const _hoisted_6 = { class: "param-cell action-cell" };
const _hoisted_7 = { class: "param-footer" };
const _sfc_main = {
  __name: "DocumentParam",
  props: {
    modelValue: {
      type: Array,
      default: () => []
    }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit: __emit }) {
    const currentInstance = getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const emit = __emit;
    const params = computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const scenarioOptions = ref([]);
    api.getModeNoList4Doc(ctx.$http).then((data) => {
      scenarioOptions.value = data.map((item) => ({
        label: item.modeName,
        value: item.modeNo
      }));
    });
    function addParam() {
      params.value.push({
        id: Date.now(),
        scenario: "",
        businessKey: null
      });
    }
    function removeParam(index) {
      params.value.splice(index, 1);
    }
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_option = ElOption;
      const _component_el_select = ElSelect;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        params.value.length === 0 ? (openBlock(), createBlock(_component_el_button, {
          key: 0,
          type: "primary",
          size: "small",
          icon: unref(plus_default),
          link: "",
          onClick: addParam
        }, {
          default: withCtx(() => _cache[0] || (_cache[0] = [
            createTextVNode(" 新增要件参数 ")
          ])),
          _: 1
        }, 8, ["icon"])) : (openBlock(), createElementBlock("div", _hoisted_2, [
          _cache[2] || (_cache[2] = createElementVNode("div", { class: "param-header" }, [
            createElementVNode("div", { class: "param-cell scenario-header" }, "业务场景"),
            createElementVNode("div", { class: "param-cell key-header" }, "业务主键"),
            createElementVNode("div", {
              class: "param-cell action-header",
              style: { "width": "50px" }
            })
          ], -1)),
          createElementVNode("div", _hoisted_3, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(params.value, (item, index) => {
              return openBlock(), createElementBlock("div", {
                key: item.id,
                class: "param-row"
              }, [
                createElementVNode("div", _hoisted_4, [
                  createVNode(_component_el_select, {
                    modelValue: item.scenario,
                    "onUpdate:modelValue": ($event) => item.scenario = $event,
                    placeholder: "选择业务场景",
                    size: "small",
                    style: { "width": "100%" },
                    clearable: ""
                  }, {
                    default: withCtx(() => [
                      (openBlock(true), createElementBlock(Fragment, null, renderList(unref(scenarioOptions), (scene) => {
                        return openBlock(), createBlock(_component_el_option, {
                          key: scene.value,
                          label: scene.label,
                          value: scene.value
                        }, null, 8, ["label", "value"]);
                      }), 128))
                    ]),
                    _: 2
                  }, 1032, ["modelValue", "onUpdate:modelValue"])
                ]),
                createElementVNode("div", _hoisted_5, [
                  createVNode(ValueSelector, {
                    modelValue: item.businessKey,
                    "onUpdate:modelValue": ($event) => item.businessKey = $event,
                    multiple: false,
                    placeholder: "选择业务主键"
                  }, null, 8, ["modelValue", "onUpdate:modelValue"])
                ]),
                createElementVNode("div", _hoisted_6, [
                  createVNode(_component_el_button, {
                    type: "danger",
                    size: "small",
                    icon: unref(delete_default),
                    text: "",
                    onClick: ($event) => removeParam(index)
                  }, null, 8, ["icon", "onClick"])
                ])
              ]);
            }), 128))
          ]),
          createElementVNode("div", _hoisted_7, [
            createVNode(_component_el_button, {
              type: "primary",
              size: "small",
              icon: unref(plus_default),
              link: "",
              onClick: addParam
            }, {
              default: withCtx(() => _cache[1] || (_cache[1] = [
                createTextVNode(" 新增要件参数 ")
              ])),
              _: 1
            }, 8, ["icon"])
          ])
        ]))
      ]);
    };
  }
};
const DocumentParam = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fef622ca"]]);
export {
  DocumentParam as default
};
