modal.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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' || type == '12' || type == '13' || type == '14' || type == '15'">
  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. emit('handleOk', passWord.value, type.value, value.value);
  59. }
  60. function handleCancel() {
  61. //
  62. emit('handleCancel');
  63. }
  64. </script>
  65. <style scoped lang="less">
  66. @ventSpace: zxm;
  67. .label {
  68. width: 120px;
  69. }
  70. .@{ventSpace}-input {
  71. width: 150px;
  72. }
  73. .@{ventSpace}-input-number {
  74. width: 150px;
  75. }
  76. </style>