FormDlg.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div :class="['modal', {fade: fade}]" data-backdrop="static" data-disable="false" data-keyboard="true" tabindex="-1">
  3. <div :class="['modal-dialog', size]">
  4. <div class="modal-content">
  5. <div class="modal-header">
  6. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  7. <span aria-hidden="true">&times;</span>
  8. </button>
  9. <h4 class="modal-title text-center text-primary"><span>{{title}}</span></h4>
  10. </div>
  11. <form class="form-horizontal" autocomplete="off" ref="form" :enctype="enctype" spellcheck="false">
  12. <div class="modal-body">
  13. <slot></slot>
  14. </div>
  15. <div class="modal-footer">
  16. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  17. <button type="button" class="btn btn-primary" @click.prevent="doSubmit" :disabled="disabled">确定</button>
  18. </div>
  19. </form>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import 'jquery-ui/ui/widgets/draggable'
  26. import $ from 'jquery'
  27. export default {
  28. props: {
  29. enctype: {
  30. default: ''
  31. },
  32. title: {
  33. default: ''
  34. },
  35. size: {
  36. type: String,
  37. default: ''
  38. },
  39. fade: {
  40. type: Boolean,
  41. default: false
  42. },
  43. disabled: {
  44. type: Boolean,
  45. default: false
  46. }
  47. },
  48. mounted() {
  49. $(this.$el).find('.modal-content').draggable({
  50. handle: '.modal-header',
  51. cancel: ".modal-title span",
  52. addClasses: false,
  53. containment: 'document',
  54. delay: 100,
  55. opacity: 0.5
  56. });
  57. $(this.$el).on("shown.bs.modal", () => {
  58. this.$emit("show");
  59. }).on("hidden.bs.modal", () => {
  60. this.errors.clear();
  61. this.$emit("hide");
  62. })
  63. },
  64. methods: {
  65. show() {
  66. $(this.$el).modal("show");
  67. },
  68. hide() {
  69. $(this.$el).modal("hide");
  70. },
  71. doSubmit() {
  72. this.$emit("submit");
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="less" scoped>
  78. label.el-switch {
  79. margin-bottom: -10px;
  80. }
  81. .modal-content {
  82. overflow: hidden;
  83. }
  84. @media screen and(min-width: 992px){
  85. .modal-dialog.modal-lgg {
  86. width: 90%;
  87. }
  88. }
  89. @media screen and(min-width: 1200px){
  90. .modal-dialog.modal-lgg {
  91. width: 1200px;
  92. }
  93. }
  94. </style>