DeviceModal.vue 8.8 KB

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