DeviceModal.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. /></a-tab-pane>
  71. <!-- <a-tab-pane key="9" tab="预警指标修改">
  72. <template v-if="activeKey == '9'">
  73. <editWarnTable></editWarnTable>
  74. </template>
  75. </a-tab-pane> -->
  76. </a-tabs>
  77. <FormModal v-else :record="record" @saveOrUpdate="(values) => emit('saveOrUpdate', values)" />
  78. </BasicModal>
  79. </template>
  80. <script lang="ts" setup>
  81. import { computed, unref, inject, reactive, ref, watch } from 'vue';
  82. import { BasicModal, useModalInner } from '/@/components/Modal';
  83. import EditRowTable from '../../comment/EditRowTable.vue';
  84. import PointTable from './pointTabel/PointTable.vue';
  85. import WarningTable from './warningTabel/index.vue';
  86. import ManagerWarningTable from './warningTabel/index1.vue';
  87. import ManagerWarningDeviceTable from './warningTabel/index2.vue';
  88. import BackWindDeviceTable from './warningTabel/index3.vue';
  89. import WorkFacePointTable from './pointTabel/WorkFacePointTable.vue';
  90. import DeviceReportInfo from './DeviceReportInfo.vue';
  91. // import editWarnTable from './editWarnTable/index.vue'
  92. import FanLineModal from './FanLineModal .vue';
  93. import FormModal from './FormModal.vue';
  94. import { cloneDeep } from 'lodash-es';
  95. import { columns as pointColumns, workFaceColumns, simulationColumns } from './pointTabel/point.data';
  96. import { saveOrUpdate as pointSaveOrUpdate, deleteById as pointDeleteById } from './pointTabel/point.api';
  97. import { columns as cameraColumns } from './cameraTabel/camera.data';
  98. import { list as cameraList, saveOrUpdate as cameraSaveOrUpdate, deleteById as cameraDeleteById } from './cameraTabel/camera.api';
  99. const props = defineProps({
  100. showTab: { type: Boolean, required: true },
  101. // deviceType: { type: String },
  102. });
  103. // 声明Emits
  104. const emit = defineEmits(['saveOrUpdate', 'register', 'closeModal']);
  105. const isUpdate = inject('isUpdate');
  106. const deviceData = inject('formData') as any;
  107. const deviceType = inject('deviceType') as any;
  108. const record = reactive({});
  109. const activeKey = ref('1');
  110. const linkColumns = ref<any[]>([]);
  111. //表单赋值
  112. const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
  113. //重置表单
  114. setModalProps({ confirmLoading: false });
  115. Object.assign(deviceData, data.record);
  116. // 判断是否是关键阻力路线
  117. });
  118. //设置标题
  119. const title = computed(() => {
  120. if (!unref(isUpdate)) {
  121. if (deviceData.strname || deviceData.systemname) {
  122. return `新增(${deviceData.strname || deviceData.systemname})`;
  123. }
  124. return `新增`;
  125. } else {
  126. if (deviceData['strtype'] == 'sys_majorpath') {
  127. linkColumns.value = [
  128. ...workFaceColumns,
  129. ...[
  130. {
  131. title: '是否在关键通风路线上',
  132. width: 100,
  133. dataIndex: 'pathflag',
  134. edit: true,
  135. editComponent: 'Switch',
  136. editValueMap: (value) => {
  137. return value ? '是' : '否';
  138. },
  139. },
  140. {
  141. title: '传感器类型',
  142. width: 100,
  143. dataIndex: 'sensorType',
  144. edit: true,
  145. editComponent: 'Select',
  146. editComponentProps: {
  147. options: [
  148. {
  149. label: '多参',
  150. value: '1',
  151. },
  152. {
  153. label: '测风',
  154. value: '2',
  155. },
  156. ],
  157. },
  158. },
  159. {
  160. title: '风向',
  161. width: 100,
  162. dataIndex: 'winddir',
  163. edit: true,
  164. editComponent: 'Select',
  165. editComponentProps: {
  166. options: [
  167. {
  168. label: '进风',
  169. value: '1',
  170. },
  171. {
  172. label: '用风',
  173. value: '2',
  174. },
  175. {
  176. label: '回风',
  177. value: '3',
  178. },
  179. ],
  180. },
  181. },
  182. {
  183. title: '是否总风量',
  184. width: 100,
  185. dataIndex: 'windflag',
  186. edit: true,
  187. editComponent: 'Switch',
  188. editValueMap: (value) => {
  189. return value ? '是' : '否';
  190. },
  191. },
  192. {
  193. title: '路线名称',
  194. width: 100,
  195. dataIndex: 'des',
  196. edit: true,
  197. editComponent: 'Input',
  198. },
  199. {
  200. title: ' 阻力值',
  201. width: 100,
  202. dataIndex: 'testDrag',
  203. edit: true,
  204. editComponent: 'InputNumber',
  205. },
  206. ],
  207. ];
  208. } else {
  209. linkColumns.value = [...workFaceColumns];
  210. }
  211. if (deviceData.strname || deviceData.systemname) {
  212. return `编辑(${deviceData.strname || deviceData.systemname})`;
  213. }
  214. return `编辑`;
  215. }
  216. });
  217. const closeModalFn = () => {
  218. activeKey.value = '1';
  219. closeModal();
  220. emit('closeModal');
  221. };
  222. const savePointData = (data) => {
  223. const record = cloneDeep(data.editValueRefs);
  224. pointSaveOrUpdate(Object.assign(record, { id: data.id, deviceId: deviceData.id }), data.id);
  225. };
  226. const saveCameraData = (data: any, reload: Function) => {
  227. cameraSaveOrUpdate(Object.assign({ ...data }, { id: data.id, deviceid: deviceData.id }), data.id);
  228. };
  229. const deletePointById = (id, reload) => {
  230. pointDeleteById({ id: id }, reload);
  231. };
  232. const deleteCameraById = (id, reload) => {
  233. cameraDeleteById({ id: id }, reload);
  234. };
  235. </script>
  236. <style scoped lang="less">
  237. ::v-deep .suffix {
  238. height: 32px;
  239. line-height: 32px;
  240. margin-left: 5px;
  241. color: #fff;
  242. }
  243. </style>