DeviceModal.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  16. </a-tab-pane>
  17. <a-tab-pane key="2" tab="点表关联">
  18. <PointTable
  19. v-if="record.strtype"
  20. :columns="pointColumns"
  21. :pointType="record.strtype"
  22. :deviceId="deviceData.id"
  23. @save="savePointData"
  24. @delete="deletePointById"
  25. />
  26. </a-tab-pane>
  27. <a-tab-pane key="3" tab="设备关联" v-if="deviceType == 'managesys'">
  28. <WorkFacePointTable :columns="linkColumns" :deviceId="deviceData.id" @save="savePointData" @delete="deletePointById" />
  29. </a-tab-pane>
  30. <a-tab-pane v-if="deviceType == 'managesys'" key = "4" tab="预警条目管理">
  31. <ManagerWarningDeviceTable v-if="activeKey == '4'" :deviceId="deviceData.id" />
  32. </a-tab-pane>
  33. <a-tab-pane key="5" :tab="deviceType !== 'managesys' ? '报警配置' : '配置预警设备'">
  34. <template v-if="activeKey == '5'">
  35. <WarningTable v-if="deviceType !== 'managesys'" :deviceId="deviceData.id" :pointType="record.strtype" />
  36. <BackWindDeviceTable v-else :deviceId="deviceData.id" />
  37. </template>
  38. </a-tab-pane>
  39. <a-tab-pane v-if="deviceType == 'managesys'" key = "6" tab="配置控制设备">
  40. <template v-if="activeKey == '6'">
  41. <WarningTable v-if="deviceType !== 'managesys'" :deviceId="deviceData.id" :pointType="record.strtype" />
  42. <ManagerWarningTable v-else :deviceId="deviceData.id" />
  43. </template>
  44. </a-tab-pane>
  45. <a-tab-pane key="7" tab="摄像头配置"
  46. ><EditRowTable
  47. :columns="cameraColumns"
  48. :list="cameraList.bind(null, { deviceid: deviceData.id })"
  49. @saveOrUpdate="saveCameraData"
  50. @deleteById="deleteCameraById"
  51. :isAdd="true"
  52. /></a-tab-pane>
  53. </a-tabs>
  54. <FormModal v-else :record="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  55. </BasicModal>
  56. </template>
  57. <script lang="ts" setup>
  58. import { computed, unref, inject, reactive, ref, watch } from 'vue';
  59. import { BasicModal, useModalInner } from '/@/components/Modal';
  60. import EditRowTable from '../../comment/EditRowTable.vue';
  61. import PointTable from './pointTabel/PointTable.vue';
  62. import WarningTable from './warningTabel/index.vue';
  63. import ManagerWarningTable from './warningTabel/index1.vue';
  64. import ManagerWarningDeviceTable from './warningTabel/index2.vue';
  65. import BackWindDeviceTable from './warningTabel/index3.vue';
  66. import WorkFacePointTable from './pointTabel/WorkFacePointTable.vue';
  67. import FormModal from './FormModal.vue';
  68. import { cloneDeep } from 'lodash-es';
  69. import { columns as pointColumns, workFaceColumns } from './pointTabel/point.data';
  70. import { saveOrUpdate as pointSaveOrUpdate, deleteById as pointDeleteById } from './pointTabel/point.api';
  71. import { columns as cameraColumns } from './cameraTabel/camera.data';
  72. import { list as cameraList, saveOrUpdate as cameraSaveOrUpdate, deleteById as cameraDeleteById } from './cameraTabel/camera.api';
  73. const props = defineProps({
  74. showTab: { type: Boolean, required: true },
  75. // deviceType: { type: String },
  76. });
  77. // 声明Emits
  78. const emit = defineEmits(['saveOrUpdate', 'register', 'closeModal']);
  79. const isUpdate = inject('isUpdate');
  80. const deviceData = inject('formData') as any;
  81. const deviceType = inject('deviceType') as any;
  82. const record = reactive({ strtype: '', strname: '' });
  83. const activeKey = ref('1')
  84. const linkColumns = ref<any[]>([])
  85. //表单赋值
  86. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  87. //重置表单
  88. setModalProps({ confirmLoading: false });
  89. Object.assign(record, data.record);
  90. // 判断是否是关键阻力路线
  91. });
  92. //设置标题
  93. const title = computed(
  94. () => {
  95. if (!unref(isUpdate)) {
  96. if (deviceData.strname || deviceData.systemname) {
  97. return `新增(${deviceData.strname || deviceData.systemname})`;
  98. }
  99. return `新增`;
  100. } else {
  101. if (deviceData['strtype'] == 'sys_majorpath') {
  102. linkColumns.value = [...workFaceColumns, ...[
  103. {
  104. title: '是否在关键通风路线上',
  105. width: 100,
  106. dataIndex: 'pathflag',
  107. edit: true,
  108. editComponent: 'Switch',
  109. editValueMap: (value) => {
  110. return value ? '是' : '否';
  111. },
  112. },
  113. {
  114. title: '传感器类型',
  115. width: 100,
  116. dataIndex: 'sensorType',
  117. edit: true,
  118. editComponent: 'Select',
  119. editComponentProps: {
  120. options: [
  121. {
  122. label: '多参',
  123. value: '1',
  124. },
  125. {
  126. label: '测风',
  127. value: '2',
  128. },
  129. ],
  130. },
  131. },
  132. {
  133. title: '风向',
  134. width: 100,
  135. dataIndex: 'winddir',
  136. edit: true,
  137. editComponent: 'Select',
  138. editComponentProps: {
  139. options: [
  140. {
  141. label: '进风',
  142. value: '1',
  143. },
  144. {
  145. label: '用风',
  146. value: '2',
  147. },
  148. {
  149. label: '回风',
  150. value: '3',
  151. },
  152. ],
  153. },
  154. },
  155. {
  156. title: '是否总风量',
  157. width: 100,
  158. dataIndex: 'windflag',
  159. edit: true,
  160. editComponent: 'Switch',
  161. editValueMap: (value) => {
  162. return value ? '是' : '否';
  163. },
  164. },
  165. {
  166. title: '路线名称',
  167. width: 100,
  168. dataIndex: 'des',
  169. edit: true,
  170. editComponent: 'Input',
  171. },
  172. {
  173. title: ' 阻力值',
  174. width: 100,
  175. dataIndex: 'testDrag',
  176. edit: true,
  177. editComponent: 'InputNumber',
  178. },
  179. ]]
  180. } else {
  181. linkColumns.value = [...workFaceColumns]
  182. }
  183. if (deviceData.strname || deviceData.systemname) {
  184. return `编辑(${deviceData.strname || deviceData.systemname})`;
  185. }
  186. return `编辑`;
  187. }
  188. }
  189. );
  190. const closeModalFn = () => {
  191. closeModal()
  192. emit('closeModal')
  193. }
  194. const savePointData = (data) => {
  195. const record = cloneDeep(data.editValueRefs);
  196. pointSaveOrUpdate(Object.assign(record, { id: data.id, deviceId: deviceData.id }), data.id);
  197. };
  198. const saveCameraData = (data: any, reload:Function) => {
  199. cameraSaveOrUpdate(Object.assign({...data}, { id: data.id, deviceid: deviceData.id }), data.id)
  200. };
  201. const deletePointById = (id, reload) => {
  202. pointDeleteById({ id: id }, reload);
  203. };
  204. const deleteCameraById = (id, reload) => {
  205. cameraDeleteById({ id: id }, reload);
  206. };
  207. </script>
  208. <style scoped lang="less">
  209. ::v-deep .suffix {
  210. height: 32px;
  211. line-height: 32px;
  212. margin-left: 5px;
  213. color: #fff;
  214. }
  215. </style>