DeviceModal.vue 7.9 KB

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