DeviceModal.vue 8.1 KB

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