FocusPersonnelModal.vue 2.8 KB

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