<template>
  <vxe-modal
    v-model="visible"
    size="small"
    v-if="visible"
    @close="closeModal"
    @cancel="closeModal"
    @hide="closeModal"
    :id="'md' + new Date().getTime()"
    :width="modalWidth"
    :height="modalHeight"
    :show-footer="showFooter"
    min-width="460" min-height="320"
    show-zoom resize remember storage transfer>
    <template #title>
      {{ modalTitle }}
    </template>
    <template #default>
      <slot></slot>
    </template>
    <template slot="footer">
      <slot name="footer">
        <cms-button size="small" @click="closeModal">{{ $t('common.button.close') }}</cms-button>
      </slot>
    </template>
  </vxe-modal>
</template>

<script>
import { CmsModalMix } from "./CmsModalMix";

export default {
  name: "CmsModal",
  mixins: [ CmsModalMix ],
  computed: {
    visible: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val); // 通过事件实现组件属性到父组件的传递
      },
    },
  },
  methods: {
    closeModal() {
      this.visible = false
      if (this.modalCallback) {
        this.modalCallback(false)
      }
      this.$emit('onCancel', false);
    }
  }
};
</script>

<style scoped lang="less">
/deep/ .ant-modal-body {
  padding: 0;
}
</style>
