DeviceGasModal.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="1000px" :showCancelBtn="false"
  3. :showOkBtn="false" :footer="null" :destroyOnClose="true" :mask-closable="false" @cancel="closeModalFn">
  4. <FormModal :deviceType="deviceType" :record="deviceData" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  5. </BasicModal>
  6. </template>
  7. <script lang="ts" setup>
  8. import { computed, unref, inject, reactive, ref, watch } from 'vue';
  9. import { BasicModal, useModalInner } from '/@/components/Modal';
  10. import FormModal from './FormModal.vue';
  11. const props = defineProps({
  12. // showTab: { type: Boolean, required: true },
  13. // deviceType: { type: String },
  14. });
  15. // 声明Emits
  16. const emit = defineEmits(['saveOrUpdate', 'register', 'closeModal']);
  17. const isUpdate = inject('isUpdate');
  18. const deviceData = inject('formData') as any;
  19. const deviceType = inject('deviceType') as any;
  20. const record = reactive({});
  21. //表单赋值
  22. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  23. //重置表单
  24. setModalProps({ confirmLoading: false });
  25. Object.assign(deviceData, data.record);
  26. // 判断是否是关键阻力路线
  27. });
  28. //设置标题
  29. const title = computed(() => {
  30. if (!unref(isUpdate)) {
  31. if (deviceData.strname || deviceData.systemname) {
  32. return `新增(${deviceData.strname || deviceData.systemname})`;
  33. }
  34. return `新增`;
  35. }
  36. });
  37. const closeModalFn = () => {
  38. closeModal();
  39. emit('closeModal');
  40. };
  41. </script>
  42. <style scoped lang="less">
  43. ::v-deep .suffix {
  44. height: 32px;
  45. line-height: 32px;
  46. margin-left: 5px;
  47. color: #fff;
  48. }
  49. </style>