"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../node_modules/element-plus/es/index.js");
;/* empty css                                                       */
;/* empty css                                                               */
;/* empty css                                                            */
;/* empty css                                                         */
;/* empty css                                                            */
;/* empty css                                                                  */
;/* empty css                                                            */
;/* empty css                                                            */
const Vue = require("vue");
const index$2 = require("../../../node_modules/@element-plus/icons-vue/dist/index.js");
const ValueSelector = require("./ValueSelector.vue.js");
const index = require("../api/index.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 index$3 = require("../../../node_modules/element-plus/es/components/select/index.js");
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 = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const emit = __emit;
    const params = Vue.computed({
      get: () => props.modelValue,
      set: (val) => emit("update:modelValue", val)
    });
    const scenarioOptions = Vue.ref([]);
    index.default.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(index2) {
      params.value.splice(index2, 1);
    }
    return (_ctx, _cache) => {
      const _component_el_button = index$1.ElButton;
      const _component_el_option = index$3.ElOption;
      const _component_el_select = index$3.ElSelect;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        params.value.length === 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_button, {
          key: 0,
          type: "primary",
          size: "small",
          icon: Vue.unref(index$2.Plus),
          link: "",
          onClick: addParam
        }, {
          default: Vue.withCtx(() => _cache[0] || (_cache[0] = [
            Vue.createTextVNode(" 新增要件参数 ")
          ])),
          _: 1
        }, 8, ["icon"])) : (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, [
          _cache[2] || (_cache[2] = Vue.createElementVNode("div", { class: "param-header" }, [
            Vue.createElementVNode("div", { class: "param-cell scenario-header" }, "业务场景"),
            Vue.createElementVNode("div", { class: "param-cell key-header" }, "业务主键"),
            Vue.createElementVNode("div", {
              class: "param-cell action-header",
              style: { "width": "50px" }
            })
          ], -1)),
          Vue.createElementVNode("div", _hoisted_3, [
            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(params.value, (item, index2) => {
              return Vue.openBlock(), Vue.createElementBlock("div", {
                key: item.id,
                class: "param-row"
              }, [
                Vue.createElementVNode("div", _hoisted_4, [
                  Vue.createVNode(_component_el_select, {
                    modelValue: item.scenario,
                    "onUpdate:modelValue": ($event) => item.scenario = $event,
                    placeholder: "选择业务场景",
                    size: "small",
                    style: { "width": "100%" },
                    clearable: ""
                  }, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(scenarioOptions), (scene) => {
                        return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                          key: scene.value,
                          label: scene.label,
                          value: scene.value
                        }, null, 8, ["label", "value"]);
                      }), 128))
                    ]),
                    _: 2
                  }, 1032, ["modelValue", "onUpdate:modelValue"])
                ]),
                Vue.createElementVNode("div", _hoisted_5, [
                  Vue.createVNode(ValueSelector.default, {
                    modelValue: item.businessKey,
                    "onUpdate:modelValue": ($event) => item.businessKey = $event,
                    multiple: false,
                    placeholder: "选择业务主键"
                  }, null, 8, ["modelValue", "onUpdate:modelValue"])
                ]),
                Vue.createElementVNode("div", _hoisted_6, [
                  Vue.createVNode(_component_el_button, {
                    type: "danger",
                    size: "small",
                    icon: Vue.unref(index$2.Delete),
                    text: "",
                    onClick: ($event) => removeParam(index2)
                  }, null, 8, ["icon", "onClick"])
                ])
              ]);
            }), 128))
          ]),
          Vue.createElementVNode("div", _hoisted_7, [
            Vue.createVNode(_component_el_button, {
              type: "primary",
              size: "small",
              icon: Vue.unref(index$2.Plus),
              link: "",
              onClick: addParam
            }, {
              default: Vue.withCtx(() => _cache[1] || (_cache[1] = [
                Vue.createTextVNode(" 新增要件参数 ")
              ])),
              _: 1
            }, 8, ["icon"])
          ])
        ]))
      ]);
    };
  }
};
const DocumentParam = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-fef622ca"]]);
exports.default = DocumentParam;
