Confirm.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <ui-dialog>
  3. <template v-if="$slots.content">
  4. <slot name="content" />
  5. </template>
  6. <template v-else>
  7. <img :src="centerIcon" alt="">
  8. <div class="message" v-html="content"></div>
  9. </template>
  10. <template v-slot:footer v-if="!hideFoot">
  11. <img class="button" v-if="!single" type="cancel" @click="close('no')" :src="noImg" alt="">
  12. <img class="button" @click="close('ok')" :src="okImg" alt="">
  13. </template>
  14. <template v-slot:closeIcon>
  15. <img :src="closeImg" @click="close('no')" class="close" alt="">
  16. </template>
  17. </ui-dialog>
  18. </template>
  19. <script>
  20. import { defineComponent } from 'vue'
  21. import { isFunction, omit } from '../../utils'
  22. export default defineComponent({
  23. name: 'ui-confirm',
  24. props: {
  25. centerIcon: {
  26. type: String,
  27. default: `${config.cdn_url}images/icon_tip3.png`,
  28. },
  29. okImg: {
  30. type: String,
  31. default: `${config.cdn_url}images/btn_giveup.png`,
  32. },
  33. noImg: {
  34. type: String,
  35. default: `${config.cdn_url}images/btn_cancel2.png`,
  36. },
  37. closeImg: {
  38. type: String,
  39. default: `${config.cdn_url}images/icon_cancel_b.png`,
  40. },
  41. single: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. hideFoot: {
  46. type: Boolean,
  47. default: false,
  48. },
  49. func: Function,
  50. content: String,
  51. destroy: Function,
  52. },
  53. setup: function (props, ctx) {
  54. const close = result => {
  55. if (isFunction(props.func) && props.func(result) === false) {
  56. return
  57. }
  58. isFunction(props.destroy) && props.destroy()
  59. }
  60. return {
  61. ...omit(props, 'destroy', 'func'),
  62. close,
  63. }
  64. },
  65. })
  66. </script>