DeviceModal.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. @cancel="closeModalFn"
  12. >
  13. <a-tabs v-if="props.showTab" v-model:activeKey="activeKey">
  14. <a-tab-pane key="1" tab="基本信息" force-render>
  15. <FormModal :record="deviceData" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  16. </a-tab-pane>
  17. <a-tab-pane key="2" tab="点表关联">
  18. <PointTable
  19. :columns="pointColumns"
  20. :pointType="deviceData.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="linkColumns" :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="deviceData.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="deviceData.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, watch } 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, workFaceColumns } 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', 'closeModal']);
  78. const isUpdate = inject('isUpdate');
  79. const deviceData = inject('formData') as any;
  80. const deviceType = inject('deviceType') as any;
  81. const record = reactive({ strtype: '', strname: '' });
  82. const activeKey = ref('1')
  83. const linkColumns = ref<any[]>([])
  84. //表单赋值
  85. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  86. //重置表单
  87. setModalProps({ confirmLoading: false });
  88. Object.assign(record, data.record);
  89. // 判断是否是关键阻力路线
  90. });
  91. //设置标题
  92. const title = computed(
  93. () => {
  94. if (!unref(isUpdate)) {
  95. if (deviceData.strname || deviceData.systemname) {
  96. return `新增(${deviceData.strname || deviceData.systemname})`;
  97. }
  98. return `新增`;
  99. } else {
  100. if (deviceData['strtype'] == 'sys_majorpath') {
  101. linkColumns.value = [...workFaceColumns, ...[
  102. {
  103. title: '是否在关键通风路线上',
  104. width: 100,
  105. dataIndex: 'pathflag',
  106. edit: true,
  107. editComponent: 'Switch',
  108. editValueMap: (value) => {
  109. return value ? '是' : '否';
  110. },
  111. },
  112. {
  113. title: '传感器类型',
  114. width: 100,
  115. dataIndex: 'sensorType',
  116. edit: true,
  117. editComponent: 'Select',
  118. editComponentProps: {
  119. options: [
  120. {
  121. label: '多参',
  122. value: '1',
  123. },
  124. {
  125. label: '测风',
  126. value: '2',
  127. },
  128. ],
  129. },
  130. },
  131. {
  132. title: '风向',
  133. width: 100,
  134. dataIndex: 'winddir',
  135. edit: true,
  136. editComponent: 'Select',
  137. editComponentProps: {
  138. options: [
  139. {
  140. label: '进风',
  141. value: '1',
  142. },
  143. {
  144. label: '用风',
  145. value: '2',
  146. },
  147. {
  148. label: '回风',
  149. value: '3',
  150. },
  151. ],
  152. },
  153. },
  154. {
  155. title: '是否总风量',
  156. width: 100,
  157. dataIndex: 'windflag',
  158. edit: true,
  159. editComponent: 'Switch',
  160. editValueMap: (value) => {
  161. return value ? '是' : '否';
  162. },
  163. },
  164. {
  165. title: '路线名称',
  166. width: 100,
  167. dataIndex: 'des',
  168. edit: true,
  169. editComponent: 'Input',
  170. },
  171. {
  172. title: ' 阻力值',
  173. width: 100,
  174. dataIndex: 'testDrag',
  175. edit: true,
  176. editComponent: 'InputNumber',
  177. },
  178. ]]
  179. } else {
  180. linkColumns.value = [...workFaceColumns]
  181. }
  182. if (deviceData.strname || deviceData.systemname) {
  183. return `编辑(${deviceData.strname || deviceData.systemname})`;
  184. }
  185. return `编辑`;
  186. }
  187. }
  188. );
  189. const closeModalFn = () => {
  190. closeModal()
  191. emit('closeModal')
  192. }
  193. const savePointData = (data) => {
  194. const record = cloneDeep(data.editValueRefs);
  195. pointSaveOrUpdate(Object.assign(record, { id: data.id, deviceId: deviceData.id }), data.id);
  196. };
  197. const saveCameraData = (data: any, reload:Function) => {
  198. cameraSaveOrUpdate(Object.assign({...data}, { id: data.id, deviceid: deviceData.id }), data.id)
  199. };
  200. const deletePointById = (id, reload) => {
  201. pointDeleteById({ id: id }, reload);
  202. };
  203. const deleteCameraById = (id, reload) => {
  204. cameraDeleteById({ id: id }, reload);
  205. };
  206. </script>
  207. <style scoped lang="less">
  208. ::v-deep .suffix {
  209. height: 32px;
  210. line-height: 32px;
  211. margin-left: 5px;
  212. color: #fff;
  213. }
  214. </style>