DeviceModal.vue 7.9 KB

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