modal.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <a-modal v-model:visible="visible" :title="title" @ok="handleOk" @cancel="handleCancel">
  3. <div class="modal-container">
  4. <div class="vent-flex-row">
  5. <ExclamationCircleFilled style="color: #ffb700; font-size: 30px" />
  6. <div class="warning-text">您是否要进行{{ title }}操作?</div>
  7. </div>
  8. <div v-if="type == '10' || type == '11'">
  9. <div class="vent-flex-row input-box">
  10. <div class="label">风窗开启角度:</div>
  11. <a-input-number size="small" placeholder="0" :min="0" v-model:value="value" />
  12. </div>
  13. </div>
  14. <div v-if="type == 'gasTest'">
  15. <div class="vent-flex-row input-box">
  16. <div class="label">{{ title }}:</div>
  17. <a-input-number size="small" placeholder="0" :min="0" v-model:value="value" />
  18. </div>
  19. </div>
  20. <div class="vent-flex-row input-box">
  21. <div class="label">操作密码:</div>
  22. <a-input size="small" type="password" v-model:value="passWord" />
  23. </div>
  24. </div>
  25. </a-modal>
  26. </template>
  27. <script setup lang="ts">
  28. import { watch, ref } from 'vue';
  29. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  30. const props = defineProps({
  31. modalIsShow: {
  32. type: Boolean,
  33. default: false,
  34. },
  35. modalTitle: {
  36. type: String,
  37. default: '',
  38. },
  39. modalType: {
  40. type: String,
  41. default: '',
  42. },
  43. });
  44. const emit = defineEmits(['handleOk', 'handleCancel']);
  45. const visible = ref<Boolean>(false);
  46. const title = ref<String>('');
  47. const type = ref<String>('');
  48. const passWord = ref('');
  49. const value = ref(0);
  50. watch([() => props.modalIsShow, () => props.modalTitle, () => props.modalType], ([newVal, newModalTitle, newModalType]) => {
  51. visible.value = newVal;
  52. if (newModalTitle) title.value = newModalTitle;
  53. if (newModalType) type.value = newModalType;
  54. passWord.value = '';
  55. });
  56. function handleOk() {
  57. //
  58. if (type.value == '10') {
  59. emit('handleOk', passWord.value, type.value, value.value);
  60. } else {
  61. emit('handleOk', passWord.value, type.value, value.value);
  62. }
  63. }
  64. function handleCancel() {
  65. //
  66. emit('handleCancel');
  67. }
  68. </script>
  69. <style scoped lang="less">
  70. @ventSpace: zxm;
  71. .label {
  72. width: 120px;
  73. }
  74. .@{ventSpace}-input {
  75. width: 150px;
  76. }
  77. .@{ventSpace}-input-number {
  78. width: 150px;
  79. }
  80. </style>