PostInfoModal.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <j-modal
  3. :fullscreen="true"
  4. :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
  5. :title="title"
  6. :visible="visible"
  7. :width="800"
  8. cancelText="关闭"
  9. maxHeight="500px"
  10. @cancel="handleCancel"
  11. @ok="handleOk"
  12. >
  13. <PostInfoForm ref="registerForm" :formBpm="false" :formDisabled="disableSubmit" @ok="submitCallback"></PostInfoForm>
  14. <template #footer>
  15. <a-button @click="handleCancel">取消</a-button>
  16. <a-button :class="{ 'jee-hidden': disableSubmit }" type="primary" @click="handleOk">确认</a-button>
  17. </template>
  18. </j-modal>
  19. </template>
  20. <script lang="ts" setup>
  21. import { defineExpose, nextTick, ref } from 'vue';
  22. import PostInfoForm from './PostInfoForm.vue';
  23. import JModal from '/@/components/Modal/src/JModal/JModal.vue';
  24. import { useMessage } from '/@/hooks/web/useMessage';
  25. const { createMessage } = useMessage();
  26. const title = ref<string>('');
  27. const width = ref<number>(800);
  28. const visible = ref<boolean>(false);
  29. const disableSubmit = ref<boolean>(false);
  30. const registerForm = ref();
  31. const emit = defineEmits(['register', 'success']);
  32. /**
  33. * 新增
  34. */
  35. function add() {
  36. title.value = '新增';
  37. visible.value = true;
  38. nextTick(() => {
  39. registerForm.value.add();
  40. });
  41. }
  42. /**
  43. * 编辑
  44. * @param record
  45. */
  46. function edit(record) {
  47. title.value = disableSubmit.value ? '详情' : '编辑';
  48. visible.value = true;
  49. nextTick(() => {
  50. registerForm.value.edit(record);
  51. });
  52. }
  53. /**
  54. * 确定按钮点击事件
  55. */
  56. function handleOk() {
  57. registerForm.value.submitForm();
  58. }
  59. /**
  60. * form保存回调事件
  61. */
  62. function submitCallback() {
  63. handleCancel();
  64. emit('success');
  65. }
  66. /**
  67. * 取消按钮回调事件
  68. */
  69. function handleCancel() {
  70. visible.value = false;
  71. }
  72. defineExpose({
  73. add,
  74. edit,
  75. disableSubmit,
  76. });
  77. </script>
  78. <style lang="less">
  79. /**隐藏样式-modal确定按钮 */
  80. .jee-hidden {
  81. display: none !important;
  82. }
  83. </style>
  84. <style lang="less" scoped></style>