DeviceModal.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="registerModal"
  5. :title="title"
  6. width="900px"
  7. :showCancelBtn="false"
  8. :showOkBtn="false"
  9. :footer="null"
  10. destroyOnClose
  11. >
  12. <FormModal :record="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  13. </BasicModal>
  14. </template>
  15. <script lang="ts" setup>
  16. import { computed, unref, inject, reactive } from 'vue';
  17. import { BasicModal, useModalInner } from '/@/components/Modal';
  18. import FormModal from './FormModal.vue';
  19. // 声明Emits
  20. const emit = defineEmits(['saveOrUpdate', 'register']);
  21. const isUpdate = inject('isUpdate');
  22. const record = reactive({ strtype: '', strname: '' });
  23. //表单赋值
  24. const [registerModal, { setModalProps }] = useModalInner(async (data) => {
  25. //重置表单
  26. setModalProps({ confirmLoading: false });
  27. Object.assign(record, data.record);
  28. });
  29. //设置标题
  30. const title = computed(
  31. () => {
  32. if (!unref(isUpdate)) {
  33. if (record.strname || record.systemname) {
  34. return `新增(${record.strname || record.systemname})`;
  35. }
  36. return `新增`;
  37. } else {
  38. if (record.strname || record.systemname) {
  39. return `编辑(${record.strname || record.systemname})`;
  40. }
  41. return `编辑`;
  42. }
  43. }
  44. // !unref(isUpdate) ? `新增(${record.strname || record.systemname})` : `编辑(${record.strname || record.systemname})`
  45. );
  46. </script>
  47. <style scoped lang="less">
  48. ::v-deep .suffix {
  49. height: 32px;
  50. line-height: 32px;
  51. margin-left: 5px;
  52. color: #fff;
  53. }
  54. </style>