'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var core = require('@vueuse/core');
var elementPlus = require('element-plus');
require('./tree-menu-card.vue.js');
var index = require('../../icon-selector/index.js');
var index$1 = require('../../upload-image/index.js');
var treeMenuCard_vue_vue_type_script_setup_true_lang = require('./tree-menu-card.vue2.js');

"use strict";
const _hoisted_1 = {
  class: "edit",
  style: { "padding": "20px" }
};
var script = /* @__PURE__ */ vue.defineComponent({
  __name: "tree-menu-edit",
  props: {
    list: { type: Array, required: true },
    form: { type: null, required: true },
    titleType: { type: String, required: false },
    label: { type: String, required: false },
    title: { type: String, required: false },
    uploadImageProps: { type: Object, required: false, default: () => ({
      url: "",
      uploadRequest: () => Promise.resolve(),
      imgUrlRequest: () => Promise.resolve(),
      title: "\u4E0A\u4F20\u56FE\u7247",
      maxCount: 1,
      width: 100,
      height: 100,
      closeEvent: () => {
      },
      uploadRules: [
        { name: "jpg", size: 1024 * 1024 * 5 },
        { name: "jpeg", size: 1024 * 1024 * 5 },
        { name: "png", size: 1024 * 1024 * 1 },
        { name: "gif", size: 1024 * 1024 * 1 }
      ],
      previewImg: false
    }) }
  },
  setup(__props, { expose: __expose }) {
    const props = __props;
    console.log(props.form);
    const slots = vue.useSlots();
    const isMeta = slots.default && slots.default()[0].children?.length ? true : false;
    const refForm = vue.ref();
    const getModelValue = vue.computed({
      get: () => {
        return [props.form.parentId];
      },
      set: (val) => {
        ;
        [props.form.parentId] = val;
        console.log(val);
      }
    });
    const isOpen = vue.ref(false);
    const open = (state, data) => {
      isOpen.value = true;
    };
    const { copy } = core.useClipboard({ legacy: true });
    const getProps = vue.computed(() => {
      const res = {
        label: "title",
        class: (data) => {
          if (props.form.id === data.id) {
            console.log(props.form.id, data.id);
            return "is-hidden";
          }
        }
      };
      return res;
    });
    const title = vue.computed(() => {
      switch (props.titleType) {
        case "copy":
          return "\u590D\u5236\u6DFB\u52A0" + props.label;
        case "create":
          return "\u65B0\u5EFA" + props.label;
        case "create-child":
          return "\u6DFB\u52A0\u5B50" + props.label;
        case "edit":
          return "\u7F16\u8F91" + props.label;
      }
    });
    const rules = vue.reactive({
      title: [{ required: true, message: "\u8BF7\u8F93\u5165\u540D\u79F0", trigger: "blur" }]
    });
    const selectMenuList = vue.computed(() => {
      console.log(props.list);
      return [
        {
          title: "\u9876\u7EA7" + props.label,
          id: "0",
          children: props.list
        }
      ];
    });
    const hasFormKey = (key) => {
      return Object.keys(props.form).includes(key);
    };
    const close = () => {
      isOpen.value = false;
    };
    const validate = () => {
      return refForm.value?.validate();
    };
    __expose({ open, close, validate });
    return (_ctx, _cache) => {
      return vue.withDirectives((vue.openBlock(), vue.createBlock(treeMenuCard_vue_vue_type_script_setup_true_lang.default, {
        title: props.title || title.value,
        style: { "height": "100%" }
      }, {
        "header-right": vue.withCtx(() => [
          vue.renderSlot(_ctx.$slots, "header-submit")
        ]),
        default: vue.withCtx(() => [
          vue.createVNode(vue.unref(elementPlus.ElScrollbar), null, {
            default: vue.withCtx(() => [
              vue.createElementVNode("div", _hoisted_1, [
                vue.createVNode(vue.unref(elementPlus.ElForm), {
                  ref_key: "refForm",
                  ref: refForm,
                  "label-suffix": "\uFF1A",
                  "label-width": 120,
                  model: __props.form,
                  rules
                }, {
                  default: vue.withCtx(() => [
                    vue.createVNode(vue.unref(elementPlus.ElRow), null, {
                      default: vue.withCtx(() => [
                        hasFormKey("id") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 0,
                          span: 24
                        }, {
                          default: vue.withCtx(() => [
                            __props.titleType === "edit" ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElFormItem), {
                              key: 0,
                              label: "id",
                              prop: "id"
                            }, {
                              default: vue.withCtx(() => [
                                vue.createTextVNode(
                                  vue.toDisplayString(__props.form.id),
                                  1
                                  /* TEXT */
                                )
                              ]),
                              _: 1
                              /* STABLE */
                            })) : vue.createCommentVNode("v-if", true)
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        hasFormKey("parentId") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 1,
                          span: 24
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), {
                              label: "\u4E0A\u7EA7" + __props.label,
                              prop: "parentId"
                            }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElTreeSelect), {
                                  modelValue: __props.form.parentId,
                                  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.form.parentId = $event),
                                  "check-strictly": "",
                                  filterable: "",
                                  "default-expanded-keys": getModelValue.value,
                                  data: selectMenuList.value,
                                  "node-key": "id",
                                  props: getProps.value
                                }, null, 8, ["modelValue", "default-expanded-keys", "data", "props"])
                              ]),
                              _: 1
                              /* STABLE */
                            }, 8, ["label"])
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        hasFormKey("title") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 2,
                          span: 12
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), {
                              label: "\u540D\u79F0",
                              prop: "title"
                            }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElInput), {
                                  modelValue: __props.form.title,
                                  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => __props.form.title = $event),
                                  clearable: ""
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        hasFormKey("enTitle") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 3,
                          span: 12
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u82F1\u6587\u540D\u79F0" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElInput), {
                                  modelValue: __props.form.enTitle,
                                  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => __props.form.enTitle = $event),
                                  clearable: ""
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        vue.createVNode(vue.unref(elementPlus.ElCol), { span: 12 }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), {
                              label: "\u522B\u540D",
                              prop: ""
                            }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElInput), {
                                  modelValue: __props.form.aliasTitle,
                                  "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => __props.form.aliasTitle = $event),
                                  clearable: ""
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        }),
                        vue.createVNode(vue.unref(elementPlus.ElCol), { span: 12 }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u82F1\u6587\u522B\u540D" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElInput), {
                                  modelValue: __props.form.aliasEnTitle,
                                  "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => __props.form.aliasEnTitle = $event),
                                  clearable: ""
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        }),
                        hasFormKey("icon") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 4,
                          span: 12
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u56FE\u6807" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(index.MeIconSelector), {
                                  modelValue: __props.form.icon,
                                  "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => __props.form.icon = $event),
                                  style: { "width": "400px" }
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        hasFormKey("sort") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 5,
                          span: 12
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u6392\u5E8F" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElInputNumber), {
                                  modelValue: __props.form.sort,
                                  "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => __props.form.sort = $event),
                                  "controls-position": "right"
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        hasFormKey("cover") ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElCol), {
                          key: 6,
                          span: 24
                        }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u5C01\u9762" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(index$1.MeUploadImage), {
                                  url: "url",
                                  modelValue: __props.form.cover,
                                  "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => __props.form.cover = $event),
                                  width: 80,
                                  height: 80,
                                  "max-count": 1
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        vue.createVNode(vue.unref(elementPlus.ElCol), { span: 12 }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u9690\u85CF" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElSwitch), {
                                  modelValue: __props.form.hideFlag,
                                  "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => __props.form.hideFlag = $event)
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        }),
                        vue.createVNode(vue.unref(elementPlus.ElCol), { span: 12 }, {
                          default: vue.withCtx(() => [
                            vue.createVNode(vue.unref(elementPlus.ElFormItem), { label: "\u542F\u7528" }, {
                              default: vue.withCtx(() => [
                                vue.createVNode(vue.unref(elementPlus.ElSwitch), {
                                  modelValue: __props.form.enableFlag,
                                  "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => __props.form.enableFlag = $event)
                                }, null, 8, ["modelValue"])
                              ]),
                              _: 1
                              /* STABLE */
                            })
                          ]),
                          _: 1
                          /* STABLE */
                        }),
                        vue.unref(isMeta) ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElDivider), { key: 7 }, {
                          default: vue.withCtx(() => [..._cache[10] || (_cache[10] = [
                            vue.createTextVNode(
                              " Meta ",
                              -1
                              /* CACHED */
                            )
                          ])]),
                          _: 1
                          /* STABLE */
                        })) : vue.createCommentVNode("v-if", true),
                        vue.renderSlot(_ctx.$slots, "default")
                      ]),
                      _: 3
                      /* FORWARDED */
                    })
                  ]),
                  _: 3
                  /* FORWARDED */
                }, 8, ["model", "rules"])
              ])
            ]),
            _: 3
            /* FORWARDED */
          })
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["title"])), [
        [vue.vShow, isOpen.value]
      ]);
    };
  }
});

exports.default = script;
//# sourceMappingURL=tree-menu-edit.vue2.js.map
