Alert.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <ui-dialog>
  3. <template v-slot:header>
  4. <span>{{ title }}</span>
  5. <i class="iconfont icon-close fun-ctrl" @click="close"></i>
  6. </template>
  7. {{ content }}
  8. <template v-slot:footer>
  9. <ui-button type="submit" @click="close">{{ okText }}</ui-button>
  10. </template>
  11. </ui-dialog>
  12. </template>
  13. <script>
  14. import { defineComponent } from "vue";
  15. import { isFunction, omit } from "../../utils";
  16. import { ui18n } from "@/lang";
  17. export default defineComponent({
  18. name: "ui-alert",
  19. props: {
  20. title: {
  21. type: String,
  22. default: ui18n.t('sys.tip'),
  23. },
  24. okText: {
  25. type: String,
  26. default: ui18n.t('sys.enter'),
  27. },
  28. func: Function,
  29. content: String,
  30. destroy: Function,
  31. },
  32. setup: function (props, ctx) {
  33. const close = () => {
  34. if (isFunction(props.func) && props.func() === false) {
  35. return;
  36. }
  37. isFunction(props.destroy) && props.destroy();
  38. };
  39. return {
  40. ...omit(props, "destroy", "func"),
  41. close,
  42. };
  43. },
  44. });
  45. </script>