DeviceModal.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="registerModal"
  5. :title="title"
  6. width="1000px"
  7. :showCancelBtn="false"
  8. :showOkBtn="false"
  9. :footer="null"
  10. destroyOnClose
  11. >
  12. <a-tabs v-if="props.showTab" v-model:activeKey="activeKey">
  13. <a-tab-pane key="1" tab="基本信息" force-render>
  14. <FormModal :record="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  15. </a-tab-pane>
  16. <a-tab-pane key="2" tab="点表关联">
  17. <PointTable
  18. v-if="record.strtype"
  19. :columns="pointColumns"
  20. :pointType="record.strtype"
  21. :deviceId="deviceData.id"
  22. @save="savePointData"
  23. @delete="deletePointById"
  24. />
  25. </a-tab-pane>
  26. <a-tab-pane key="3" tab="设备关联" v-if="deviceType == 'managesys'">
  27. <WorkFacePointTable :columns="pointColumns" :deviceId="deviceData.id" @save="savePointData" @delete="deletePointById" />
  28. </a-tab-pane>
  29. <a-tab-pane v-if="deviceType == 'managesys'" key = "4" tab="预警条目管理">
  30. <ManagerWarningDeviceTable v-if="activeKey == '4'" :deviceId="deviceData.id" />
  31. </a-tab-pane>
  32. <a-tab-pane key="5" :tab="deviceType !== 'managesys' ? '报警配置' : '配置预警设备'">
  33. <template v-if="activeKey == '5'">
  34. <WarningTable v-if="deviceType !== 'managesys'" :deviceId="deviceData.id" :pointType="record.strtype" />
  35. <BackWindDeviceTable v-else :deviceId="deviceData.id" />
  36. </template>
  37. </a-tab-pane>
  38. <a-tab-pane v-if="deviceType == 'managesys'" key = "6" tab="配置控制设备">
  39. <template v-if="activeKey == '6'">
  40. <WarningTable v-if="deviceType !== 'managesys'" :deviceId="deviceData.id" :pointType="record.strtype" />
  41. <ManagerWarningTable v-else :deviceId="deviceData.id" />
  42. </template>
  43. </a-tab-pane>
  44. <a-tab-pane key="7" tab="摄像头配置"
  45. ><EditRowTable
  46. :columns="cameraColumns"
  47. :list="cameraList.bind(null, { deviceid: deviceData.id })"
  48. @saveOrUpdate="saveCameraData"
  49. @deleteById="deleteCameraById"
  50. :isAdd="true"
  51. /></a-tab-pane>
  52. </a-tabs>
  53. <FormModal v-else :record="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  54. </BasicModal>
  55. </template>
  56. <script lang="ts" setup>
  57. import { computed, unref, inject, reactive, ref } from 'vue';
  58. import { BasicModal, useModalInner } from '/@/components/Modal';
  59. import EditRowTable from '../../comment/EditRowTable.vue';
  60. import PointTable from './pointTabel/PointTable.vue';
  61. import WarningTable from './warningTabel/index.vue';
  62. import ManagerWarningTable from './warningTabel/index1.vue';
  63. import ManagerWarningDeviceTable from './warningTabel/index2.vue';
  64. import BackWindDeviceTable from './warningTabel/index3.vue';
  65. import WorkFacePointTable from './pointTabel/WorkFacePointTable.vue';
  66. import FormModal from './FormModal.vue';
  67. import { cloneDeep } from 'lodash-es';
  68. import { columns as pointColumns } from './pointTabel/point.data';
  69. import { saveOrUpdate as pointSaveOrUpdate, deleteById as pointDeleteById } from './pointTabel/point.api';
  70. import { columns as cameraColumns } from './cameraTabel/camera.data';
  71. import { list as cameraList, saveOrUpdate as cameraSaveOrUpdate, deleteById as cameraDeleteById } from './cameraTabel/camera.api';
  72. const props = defineProps({
  73. showTab: { type: Boolean, required: true },
  74. deviceType: { type: String },
  75. });
  76. // 声明Emits
  77. const emit = defineEmits(['saveOrUpdate', 'register']);
  78. const isUpdate = inject('isUpdate');
  79. const deviceData = inject('formData') as any;
  80. const record = reactive({ strtype: '', strname: '' });
  81. const activeKey = ref('1')
  82. //表单赋值
  83. const [registerModal, { setModalProps }] = useModalInner(async (data) => {
  84. //重置表单
  85. setModalProps({ confirmLoading: false });
  86. Object.assign(record, data.record);
  87. });
  88. //设置标题
  89. const title = computed(
  90. () => {
  91. if (!unref(isUpdate)) {
  92. if (record.strname || record.systemname) {
  93. return `新增(${record.strname || record.systemname})`;
  94. }
  95. return `新增`;
  96. } else {
  97. if (record.strname || record.systemname) {
  98. return `编辑(${record.strname || record.systemname})`;
  99. }
  100. return `编辑`;
  101. }
  102. }
  103. // !unref(isUpdate) ? `新增(${record.strname || record.systemname})` : `编辑(${record.strname || record.systemname})`
  104. );
  105. const savePointData = (data) => {
  106. const record = cloneDeep(data.editValueRefs);
  107. pointSaveOrUpdate(Object.assign(record, { id: data.id, deviceId: deviceData.id }), data.id);
  108. };
  109. const saveCameraData = (data: any) => {
  110. const record = cloneDeep(data.editValueRefs);
  111. cameraSaveOrUpdate(Object.assign(record, { id: data.id, deviceid: deviceData.id }), data.id);
  112. };
  113. const deletePointById = (id, reload) => {
  114. pointDeleteById({ id: id }, reload);
  115. };
  116. const deleteCameraById = (id, reload) => {
  117. cameraDeleteById({ id: id }, reload);
  118. };
  119. </script>
  120. <style scoped lang="less">
  121. ::v-deep .suffix {
  122. height: 32px;
  123. line-height: 32px;
  124. margin-left: 5px;
  125. color: #fff;
  126. }
  127. </style>