import { defineComponent, inject, ref, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, createVNode, createElementVNode, withCtx, Fragment, renderList, createBlock, createCommentVNode, toDisplayString, createTextVNode } from 'vue';
import '../config/index.mjs';
import '../../../../utils/index.mjs';
import './params-table-row.vue.mjs';
import { createNamespace } from '../../../../utils/create-namespace.mjs';
import _sfc_main$1 from './params-table-row.vue2.mjs';
import { paramsTableProps } from '../config/params-table.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlParamsTable" },
  __name: "params-table",
  props: paramsTableProps,
  setup(__props) {
    const bem = createNamespace("params-table");
    const props = __props;
    const disabled = inject("disabled");
    const addData = ref("");
    const handleAdd = (dataSource) => {
      if (addData.value && dataSource.find((e) => e.name !== addData.value) || !dataSource.length) {
        if (!addData.value) return;
        dataSource.push({
          name: addData.value,
          required: false,
          value: "",
          static: false,
          description: "",
          contentType: ""
        });
        addData.value = "";
      }
    };
    return (_ctx, _cache) => {
      const _component_ll_tooltip = resolveComponent("ll-tooltip");
      const _component_a_col = resolveComponent("a-col");
      const _component_a_row = resolveComponent("a-row");
      const _component_ll_input = resolveComponent("ll-input");
      return openBlock(), createElementBlock(
        "div",
        {
          class: normalizeClass(unref(bem).b())
        },
        [
          createVNode(_component_a_row, {
            class: normalizeClass(unref(bem).m("table-header")),
            gutter: 20
          }, {
            default: withCtx(() => [
              createVNode(_component_a_col, { span: 22 }, {
                default: withCtx(() => [
                  createVNode(_component_a_row, { gutter: 20 }, {
                    default: withCtx(() => [
                      (openBlock(true), createElementBlock(
                        Fragment,
                        null,
                        renderList(props.columns, (col, index) => {
                          return openBlock(), createBlock(_component_a_col, {
                            key: index,
                            span: col.span,
                            class: normalizeClass(unref(bem).e("table-header-col"))
                          }, {
                            default: withCtx(() => [
                              createElementVNode(
                                "span",
                                null,
                                toDisplayString(col.title),
                                1
                                /* TEXT */
                              ),
                              col.key === "static" ? (openBlock(), createBlock(_component_ll_tooltip, {
                                key: 0,
                                tip: "Content-Type \u5B57\u6BB5\u7528\u4E8E\u6307\u5B9A\u8BF7\u6C42\u90E8\u5206\u7684\u5A92\u4F53\u7C7B\u578B"
                              })) : createCommentVNode("v-if", true)
                            ]),
                            _: 2
                            /* DYNAMIC */
                          }, 1032, ["span", "class"]);
                        }),
                        128
                        /* KEYED_FRAGMENT */
                      ))
                    ]),
                    _: 1
                    /* STABLE */
                  })
                ]),
                _: 1
                /* STABLE */
              }),
              createVNode(_component_a_col, {
                class: normalizeClass(unref(bem).e("table-header-col")),
                span: 2
              }, {
                default: withCtx(() => [..._cache[2] || (_cache[2] = [
                  createTextVNode(
                    " \u64CD\u4F5C ",
                    -1
                    /* CACHED */
                  )
                ])]),
                _: 1
                /* STABLE */
              }, 8, ["class"])
            ]),
            _: 1
            /* STABLE */
          }, 8, ["class"]),
          createElementVNode(
            "div",
            {
              class: normalizeClass(unref(bem).m("table-body"))
            },
            [
              (openBlock(true), createElementBlock(
                Fragment,
                null,
                renderList(props.dataSource, (item, index) => {
                  return openBlock(), createBlock(_sfc_main$1, {
                    key: index,
                    data: item,
                    columns: props.columns,
                    "data-source": props.dataSource
                  }, null, 8, ["data", "columns", "data-source"]);
                }),
                128
                /* KEYED_FRAGMENT */
              )),
              createVNode(_component_a_row, {
                gutter: 20,
                class: normalizeClass(unref(bem).e("table-row"))
              }, {
                default: withCtx(() => [
                  (openBlock(true), createElementBlock(
                    Fragment,
                    null,
                    renderList(props.columns, (col, index) => {
                      return openBlock(), createBlock(_component_a_col, {
                        key: index,
                        span: col.span || 24 / props.columns.length,
                        class: normalizeClass(unref(bem).e("table-col"))
                      }, {
                        default: withCtx(() => [
                          col.key === "name" ? (openBlock(), createBlock(_component_ll_input, {
                            key: 0,
                            value: addData.value,
                            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => addData.value = $event),
                            placeholder: "\u6DFB\u52A0\u53C2\u6570",
                            disabled: unref(disabled),
                            bordered: false,
                            onBlur: _cache[1] || (_cache[1] = ($event) => handleAdd(props.dataSource))
                          }, null, 8, ["value", "disabled"])) : createCommentVNode("v-if", true)
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, 1032, ["span", "class"]);
                    }),
                    128
                    /* KEYED_FRAGMENT */
                  ))
                ]),
                _: 1
                /* STABLE */
              }, 8, ["class"])
            ],
            2
            /* CLASS */
          )
        ],
        2
        /* CLASS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=params-table.vue2.mjs.map
