"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                                                                        */
;/* empty css                                                                    */
require("../../../../../node_modules/element-plus/theme-chalk/el-dropdown-menu.css.js");
require("../../../../../node_modules/element-plus/theme-chalk/el-dropdown-item.css.js");
;/* empty css                                                                 */
;/* empty css                                                                        */
;/* empty css                                                               */
;/* empty css                                                                  */
;/* empty css                                                                        */
;/* empty css                                                                  */
;/* empty css                                                                  */
;/* empty css                                                                 */
;/* empty css                                                                       */
;/* empty css                                                                        */
;/* empty css                                                                     */
const Vue = require("vue");
const common = require("../../utils/common.js");
const TemplateSelector = require("../../../components/TemplateSelector.vue2.js");
const eventBus = require("../../utils/eventBus.js");
const ParamsConfig = require("../../../components/ParamsConfig.vue2.js");
const index = require("../../../api/index.js");
const OnlyFLowConfigButton = ;/* empty css                                             */
;/* empty css               */
const _pluginVue_exportHelper = require("../../../../../_virtual/_plugin-vue_export-helper.js");
const index$1 = require("../../../../../node_modules/element-plus/es/components/collapse/index.js");
const index$2 = require("../../../../../node_modules/element-plus/es/components/form/index.js");
const index$3 = require("../../../../../node_modules/element-plus/es/components/input/index.js");
const index$4 = require("../../../../../node_modules/element-plus/es/components/radio/index.js");
const index$5 = require("../../../../../node_modules/element-plus/es/components/switch/index.js");
const index$6 = require("../../../../../node_modules/element-plus/es/components/select/index.js");
const index$7 = require("../../../../../node_modules/element-plus/es/components/input-number/index.js");
const index$8 = require("../../../../../node_modules/element-plus/es/components/button/index.js");
const index$9 = require("../../../../../node_modules/element-plus/es/components/dropdown/index.js");
const _hoisted_1 = { class: "buttons-config-container" };
const _hoisted_2 = {
  key: 0,
  class: "buttons-table"
};
const _hoisted_3 = { class: "buttons-body" };
const _hoisted_4 = { class: "buttons-cell name-cell" };
const _hoisted_5 = { class: "buttons-cell action-cell" };
const _hoisted_6 = { class: "buttons-footer" };
const _hoisted_7 = { class: "button-dropdown-content" };
const _hoisted_8 = { class: "button-name" };
const _hoisted_9 = { class: "button-type" };
const _sfc_main = {
  __name: "subTable",
  setup(__props) {
    const currentInstance = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const currentItem = Vue.computed(() => {
      const item = common.getCurrentItem();
      if (!item.btnRollback) {
        item.btnRollback = [];
      }
      if (!item.subTableHeightType) {
        item.subTableHeightType = "auto";
      }
      if (!item.subTableMaxHeight) {
        item.subTableMaxHeight = 300;
      }
      return item;
    });
    const activeName = Vue.ref(["common"]);
    const subTableOptions = Vue.ref(null);
    const subTableBtns = Vue.computed(() => {
      var _a, _b, _c;
      const customBtns = ((_b = subTableOptions.value) == null ? void 0 : _b.customBtns.left.concat(
        (_a = subTableOptions.value) == null ? void 0 : _a.customBtns.right
      )) || [];
      return customBtns.concat(((_c = subTableOptions.value) == null ? void 0 : _c.optBtns) || []);
    });
    Vue.watch(
      () => {
        var _a;
        return (_a = currentItem.value) == null ? void 0 : _a.subTableId;
      },
      (pkId) => {
        if (pkId) {
          index.default.getById(ctx.$http, pkId).then((data) => {
            subTableOptions.value = JSON.parse(data.context);
          });
        }
      },
      {
        immediate: true
      }
    );
    function templateSelectorConfirm(data) {
      subTableOptions.value = data;
      currentItem.value.subTableMode = null;
    }
    const tableMode = Vue.computed(() => {
      var _a;
      return ((_a = subTableOptions.value) == null ? void 0 : _a.mode) || [];
    });
    function handleTitleModeChange(value) {
      const item = currentItem.value;
      const fieldsData = common.getEditConfigData().fieldsData;
      const fieldInData = fieldsData == null ? void 0 : fieldsData.find((f) => {
        var _a;
        return ((_a = f.component) == null ? void 0 : _a.id) === item.id;
      });
      if (fieldInData) {
        fieldInData.h = value === "none" ? 2 : 3;
        eventBus.default.emit("resizeEvent");
      }
    }
    function handleButtonSelect(buttonConfig) {
      addButton(buttonConfig);
    }
    function addButton(buttonConfig) {
      if (!currentItem.value.btnRollback) {
        currentItem.value.btnRollback = [];
      }
      currentItem.value.btnRollback.push({
        id: buttonConfig.id,
        label: buttonConfig.label,
        type: buttonConfig.type
      });
    }
    function removeButton(index2) {
      if (currentItem.value.btnRollback && index2 >= 0 && index2 < currentItem.value.btnRollback.length) {
        currentItem.value.btnRollback.splice(index2, 1);
      }
    }
    function handleOnlyFlowConfirm(button, data) {
      button.callbackEventConfig = data;
    }
    return (_ctx, _cache) => {
      const _component_el_input = index$3.ElInput;
      const _component_el_form_item = index$2.ElFormItem;
      const _component_el_radio_button = index$4.ElRadioButton;
      const _component_el_radio_group = index$4.ElRadioGroup;
      const _component_el_switch = index$5.ElSwitch;
      const _component_el_option = index$6.ElOption;
      const _component_el_select = index$6.ElSelect;
      const _component_el_input_number = index$7.ElInputNumber;
      const _component_el_button = index$8.ElButton;
      const _component_el_dropdown_item = index$9.ElDropdownItem;
      const _component_el_dropdown_menu = index$9.ElDropdownMenu;
      const _component_el_dropdown = index$9.ElDropdown;
      const _component_el_form = index$2.ElForm;
      const _component_el_collapse_item = index$1.ElCollapseItem;
      const _component_el_collapse = index$1.ElCollapse;
      return Vue.openBlock(), Vue.createBlock(_component_el_collapse, {
        class: "setting",
        modelValue: activeName.value,
        "onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => activeName.value = $event)
      }, {
        default: Vue.withCtx(() => [
          Vue.createVNode(_component_el_collapse_item, {
            name: "common",
            title: "基本属性"
          }, {
            default: Vue.withCtx(() => [
              (Vue.openBlock(), Vue.createBlock(_component_el_form, {
                "label-position": "top",
                "label-width": "auto",
                model: currentItem.value,
                key: currentItem.value.id
              }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_form_item, {
                    label: "标题",
                    required: ""
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(_component_el_input, {
                        modelValue: currentItem.value.label,
                        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => currentItem.value.label = $event)
                      }, null, 8, ["modelValue"])
                    ]),
                    _: 1
                  }),
                  Vue.createVNode(_component_el_form_item, { label: "标题模式" }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(_component_el_radio_group, {
                        modelValue: currentItem.value.titleMode,
                        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => currentItem.value.titleMode = $event),
                        size: "small",
                        onChange: handleTitleModeChange
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(_component_el_radio_button, { value: "none" }, {
                            default: Vue.withCtx(() => _cache[17] || (_cache[17] = [
                              Vue.createTextVNode("无")
                            ])),
                            _: 1
                          }),
                          Vue.createVNode(_component_el_radio_button, { value: "label" }, {
                            default: Vue.withCtx(() => _cache[18] || (_cache[18] = [
                              Vue.createTextVNode("标题")
                            ])),
                            _: 1
                          }),
                          Vue.createVNode(_component_el_radio_button, { value: "subLabel" }, {
                            default: Vue.withCtx(() => _cache[19] || (_cache[19] = [
                              Vue.createTextVNode("子标题")
                            ])),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["modelValue"])
                    ]),
                    _: 1
                  }),
                  currentItem.value.titleMode != "none" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
                    currentItem.value.titleMode == "label" ? (Vue.openBlock(), Vue.createBlock(_component_el_form_item, {
                      key: 0,
                      label: "副标题"
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_input, {
                          modelValue: currentItem.value.subLabel,
                          "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => currentItem.value.subLabel = $event),
                          rows: 2,
                          type: "textarea",
                          resize: "none"
                        }, null, 8, ["modelValue"])
                      ]),
                      _: 1
                    })) : Vue.createCommentVNode("", true)
                  ], 64)) : Vue.createCommentVNode("", true),
                  Vue.createVNode(_component_el_form_item, { label: "数据来源" }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(_component_el_radio_group, {
                        modelValue: currentItem.value.dataSourceFrom,
                        "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => currentItem.value.dataSourceFrom = $event),
                        size: "small"
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(_component_el_radio_button, { value: "main" }, {
                            default: Vue.withCtx(() => _cache[20] || (_cache[20] = [
                              Vue.createTextVNode("主页面获取")
                            ])),
                            _: 1
                          }),
                          Vue.createVNode(_component_el_radio_button, { value: "self" }, {
                            default: Vue.withCtx(() => _cache[21] || (_cache[21] = [
                              Vue.createTextVNode("子列表自加载")
                            ])),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["modelValue"])
                    ]),
                    _: 1
                  }),
                  currentItem.value.dataSourceFrom == "main" ? (Vue.openBlock(), Vue.createBlock(_component_el_form_item, {
                    key: 1,
                    label: "字段名称"
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(_component_el_input, {
                        modelValue: currentItem.value.fieldName,
                        "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => currentItem.value.fieldName = $event),
                        placeholder: "主页面数据中存储子列表数据的字段名"
                      }, null, 8, ["modelValue"])
                    ]),
                    _: 1
                  })) : Vue.createCommentVNode("", true),
                  currentItem.value.dataSourceFrom == "self" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 2 }, [
                    Vue.createVNode(_component_el_form_item, { label: "列表参数" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(ParamsConfig.default, {
                          modelValue: currentItem.value.subTableParams,
                          "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => currentItem.value.subTableParams = $event)
                        }, null, 8, ["modelValue"])
                      ]),
                      _: 1
                    }),
                    Vue.createVNode(_component_el_form_item, { label: "参数更新重新加载列表" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_switch, {
                          modelValue: currentItem.value.reloadOnParamsChange,
                          "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => currentItem.value.reloadOnParamsChange = $event)
                        }, null, 8, ["modelValue"])
                      ]),
                      _: 1
                    })
                  ], 64)) : Vue.createCommentVNode("", true),
                  Vue.createVNode(_component_el_form_item, { label: "选择子列表" }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(TemplateSelector.default, {
                        modelValue: currentItem.value.subTableName,
                        "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => currentItem.value.subTableName = $event),
                        templateKey: currentItem.value.subTableKey,
                        "onUpdate:templateKey": _cache[8] || (_cache[8] = ($event) => currentItem.value.subTableKey = $event),
                        templateId: currentItem.value.subTableId,
                        "onUpdate:templateId": _cache[9] || (_cache[9] = ($event) => currentItem.value.subTableId = $event),
                        templateType: "table",
                        onConfirm: templateSelectorConfirm
                      }, null, 8, ["modelValue", "templateKey", "templateId"])
                    ]),
                    _: 1
                  }),
                  currentItem.value.subTableId ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 3 }, [
                    Vue.createVNode(_component_el_form_item, { label: "列表模式" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_select, {
                          modelValue: currentItem.value.subTableMode,
                          "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => currentItem.value.subTableMode = $event),
                          clearable: ""
                        }, {
                          default: Vue.withCtx(() => [
                            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(tableMode.value, (mode) => {
                              return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                                key: mode.key,
                                label: mode.name,
                                value: mode.key
                              }, null, 8, ["label", "value"]);
                            }), 128))
                          ]),
                          _: 1
                        }, 8, ["modelValue"])
                      ]),
                      _: 1
                    }),
                    Vue.createVNode(_component_el_form_item, { label: "列表高度" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_radio_group, {
                          modelValue: currentItem.value.subTableHeightType,
                          "onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => currentItem.value.subTableHeightType = $event),
                          size: "small"
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_el_radio_button, { value: "auto" }, {
                              default: Vue.withCtx(() => _cache[22] || (_cache[22] = [
                                Vue.createTextVNode("自适应")
                              ])),
                              _: 1
                            }),
                            Vue.createVNode(_component_el_radio_button, { value: "max" }, {
                              default: Vue.withCtx(() => _cache[23] || (_cache[23] = [
                                Vue.createTextVNode("最大高度")
                              ])),
                              _: 1
                            }),
                            Vue.createVNode(_component_el_radio_button, { value: "fixed" }, {
                              default: Vue.withCtx(() => _cache[24] || (_cache[24] = [
                                Vue.createTextVNode("固定高度")
                              ])),
                              _: 1
                            })
                          ]),
                          _: 1
                        }, 8, ["modelValue"])
                      ]),
                      _: 1
                    }),
                    currentItem.value.subTableHeightType == "max" ? (Vue.openBlock(), Vue.createBlock(_component_el_form_item, {
                      key: 0,
                      label: "最大高度"
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_input_number, {
                          modelValue: currentItem.value.subTableMaxHeight,
                          "onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => currentItem.value.subTableMaxHeight = $event),
                          min: 100,
                          "controls-position": "right",
                          controls: false,
                          style: { "width": "100%" }
                        }, {
                          suffix: Vue.withCtx(() => _cache[25] || (_cache[25] = [
                            Vue.createTextVNode("px")
                          ])),
                          _: 1
                        }, 8, ["modelValue"])
                      ]),
                      _: 1
                    })) : Vue.createCommentVNode("", true),
                    currentItem.value.subTableHeightType == "fixed" ? (Vue.openBlock(), Vue.createBlock(_component_el_form_item, {
                      key: 1,
                      label: "固定高度"
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_input_number, {
                          modelValue: currentItem.value.subTableHeight,
                          "onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => currentItem.value.subTableHeight = $event),
                          min: 100,
                          "controls-position": "right",
                          controls: false,
                          style: { "width": "100%" }
                        }, {
                          suffix: Vue.withCtx(() => _cache[26] || (_cache[26] = [
                            Vue.createTextVNode("px")
                          ])),
                          _: 1
                        }, 8, ["modelValue"])
                      ]),
                      _: 1
                    })) : Vue.createCommentVNode("", true),
                    Vue.createVNode(_component_el_form_item, { label: "是否翻页" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_switch, {
                          modelValue: currentItem.value.isSubTablePagination,
                          "onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => currentItem.value.isSubTablePagination = $event)
                        }, null, 8, ["modelValue"])
                      ]),
                      _: 1
                    }),
                    Vue.createVNode(_component_el_form_item, { label: "是否只读" }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_switch, {
                          modelValue: currentItem.value.isSubTableReadOnly,
                          "onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => currentItem.value.isSubTableReadOnly = $event)
                        }, null, 8, ["modelValue"])
                      ]),
                      _: 1
                    }),
                    Vue.createVNode(_component_el_form_item, { label: "列表按钮回调事件" }, {
                      default: Vue.withCtx(() => [
                        Vue.createElementVNode("div", _hoisted_1, [
                          currentItem.value.btnRollback && currentItem.value.btnRollback.length > 0 ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, [
                            _cache[27] || (_cache[27] = Vue.createElementVNode("div", { class: "buttons-header" }, [
                              Vue.createElementVNode("div", { class: "buttons-cell name-header" }, "按钮"),
                              Vue.createElementVNode("div", { class: "buttons-cell action-header" }, "回调事件")
                            ], -1)),
                            Vue.createElementVNode("div", _hoisted_3, [
                              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(currentItem.value.btnRollback, (button, index2) => {
                                return Vue.openBlock(), Vue.createElementBlock("div", {
                                  key: button.id,
                                  class: "buttons-row"
                                }, [
                                  Vue.createElementVNode("div", _hoisted_4, [
                                    Vue.createElementVNode("span", null, Vue.toDisplayString(button.label), 1)
                                  ]),
                                  Vue.createElementVNode("div", _hoisted_5, [
                                    Vue.createVNode(OnlyFLowConfigButton.default, {
                                      size: "small",
                                      config: button.callbackEventConfig,
                                      onConfirm: (data) => {
                                        handleOnlyFlowConfirm(button, data);
                                      }
                                    }, null, 8, ["config", "onConfirm"]),
                                    Vue.createVNode(_component_el_button, {
                                      type: "danger",
                                      size: "small",
                                      onClick: ($event) => removeButton(index2),
                                      icon: "Delete",
                                      text: "",
                                      style: { "padding": "0", "background": "transparent" }
                                    }, null, 8, ["onClick"])
                                  ])
                                ]);
                              }), 128))
                            ])
                          ])) : Vue.createCommentVNode("", true),
                          Vue.createElementVNode("div", _hoisted_6, [
                            Vue.createVNode(_component_el_dropdown, {
                              onCommand: handleButtonSelect,
                              trigger: "click",
                              size: "small"
                            }, {
                              dropdown: Vue.withCtx(() => [
                                Vue.createVNode(_component_el_dropdown_menu, null, {
                                  default: Vue.withCtx(() => [
                                    (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(subTableBtns.value, (button) => {
                                      return Vue.openBlock(), Vue.createBlock(_component_el_dropdown_item, {
                                        key: button.id,
                                        command: button,
                                        class: "button-dropdown-item"
                                      }, {
                                        default: Vue.withCtx(() => [
                                          Vue.createElementVNode("div", _hoisted_7, [
                                            Vue.createElementVNode("span", _hoisted_8, Vue.toDisplayString(button.label), 1),
                                            Vue.createElementVNode("span", _hoisted_9, Vue.toDisplayString(button.type === "optBtn" ? "行级" : "自定义"), 1)
                                          ])
                                        ]),
                                        _: 2
                                      }, 1032, ["command"]);
                                    }), 128))
                                  ]),
                                  _: 1
                                })
                              ]),
                              default: Vue.withCtx(() => [
                                Vue.createVNode(_component_el_button, {
                                  type: "primary",
                                  size: "small",
                                  icon: "Plus",
                                  link: ""
                                }, {
                                  default: Vue.withCtx(() => _cache[28] || (_cache[28] = [
                                    Vue.createTextVNode(" 新增按钮 ")
                                  ])),
                                  _: 1
                                })
                              ]),
                              _: 1
                            })
                          ])
                        ])
                      ]),
                      _: 1
                    })
                  ], 64)) : Vue.createCommentVNode("", true)
                ]),
                _: 1
              }, 8, ["model"]))
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
const subTable = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-f81c0a82"]]);
exports.default = subTable;
