Browse Source

[Feat 0000] 预警联动控制添加预案管理项

houzekong 3 months ago
parent
commit
6a056c1690

+ 10 - 3
src/views/vent/deviceManager/comment/DeviceModal.vue

@@ -59,15 +59,21 @@
           <ManagerWarningTable v-else :deviceId="deviceData.id" />
         </template>
       </a-tab-pane>
-      <a-tab-pane key="7" tab="摄像头配置"
-        ><EditRowTable
+      <a-tab-pane key="7" tab="摄像头配置">
+        <EditRowTable
           :columns="cameraColumns"
           :list="cameraList"
           :params="{ deviceid: deviceData.id }"
           @saveOrUpdate="saveCameraData"
           @deleteById="deleteCameraById"
           :isAdd="true"
-      /></a-tab-pane>
+        />
+      </a-tab-pane>
+      <a-tab-pane key="9" :tab="'预案管理'">
+        <template v-if="activeKey == '9'">
+          <AccidentPlanTable :deviceId="deviceData.id" />
+        </template>
+      </a-tab-pane>
       <!-- <a-tab-pane key="9" tab="预警指标修改">
         <template v-if="activeKey == '9'">
         <editWarnTable></editWarnTable>
@@ -86,6 +92,7 @@
   import ManagerWarningTable from './warningTabel/index1.vue';
   import ManagerWarningDeviceTable from './warningTabel/index2.vue';
   import BackWindDeviceTable from './warningTabel/index3.vue';
+  import AccidentPlanTable from './warningTabel/index4.vue';
   import WorkFacePointTable from './pointTabel/WorkFacePointTable.vue';
   import DeviceReportInfo from './DeviceReportInfo.vue';
   // import editWarnTable from './editWarnTable/index.vue'

+ 177 - 0
src/views/vent/deviceManager/comment/warningTabel/index4.vue

@@ -0,0 +1,177 @@
+<!-- eslint-disable vue/multi-word-component-names -->
+<template>
+  <!-- 配置预警设备 -->
+  <div class="warning-device-box">
+    <div class="warning-box">
+      <div v-for="item in warningList" class="link-item" :class="{ 'active-device-title': item.id == activeID }" :key="item.id">
+        <span class="" @click="selectWarning(item.id)">{{ item.alarmName }}</span>
+      </div>
+    </div>
+    <div class="device-box">
+      <a-button class="vent-margin-b-5" type="primary" @click="handleOpen(true, {})"> 新增 </a-button>
+      <a-table :columns="modelAlarmColumns" :data-source="dataSource" bordered :scroll="{ y: 500 }" :pagination="false" showIndexColumn>
+        <template v-if="show" #bodyCell="{ column, record }">
+          <template v-if="column.dataIndex === 'operation'">
+            <a class="action-link" @click="handleOpen('update', record)">编辑</a>
+            <a-popconfirm title="确认删除" @confirm="handleDelete(record)">
+              <a class="action-link vent-margin-l-10">删除</a>
+            </a-popconfirm>
+          </template>
+        </template>
+      </a-table>
+    </div>
+  </div>
+  <BasicModal @register="register" :width="800" :min-height="600" @ok="onSubmit">
+    <BasicForm @register="registerForm" />
+  </BasicModal>
+  <!-- <BaseModal @register="register" @add="onSubmit" @update="onSubmit" :form-schemas="formSchemas" :monitor-type="'2,3,9'" /> -->
+</template>
+
+<script lang="ts" setup>
+  import { ref, onMounted, nextTick } from 'vue';
+  import { modelAlarmColumns, modelAlarmFormSchemas } from './warning.data';
+  import { warningLogList, modelAlarmAutoList, modelAlarmAutoAdd, modelAlarmAutoEdit, modelAlarmAutoDelete } from './warning.api';
+  // import BaseModal from './BaseModal.vue';
+  import { message } from 'ant-design-vue';
+  import { BasicForm, useForm } from '/@/components/Form';
+  import { BasicModal, useModal } from '/@/components/Modal';
+
+  defineEmits(['register']);
+
+  const props = defineProps({
+    deviceId: { type: String },
+  });
+
+  const show = ref(false);
+  const formSchemas = modelAlarmFormSchemas();
+  const activeID = ref('');
+  const warningList = ref<{ id: string; alarmName: string }[]>([]);
+  const dataSource = ref<any[]>([]);
+
+  function selectWarning(id) {
+    activeID.value = id;
+    // 查询该条目的下预警设备列表
+    getDataSource();
+  }
+
+  async function getWarningList() {
+    const result = await warningLogList({ sysId: props.deviceId, pageSize: 100000 }); //id: props.deviceId
+    warningList.value = result.records;
+    activeID.value = warningList.value[0]['id'];
+  }
+
+  async function getDataSource() {
+    show.value = false;
+    const result = await modelAlarmAutoList({ sysId: props.deviceId, alarmId: activeID.value, pageSize: 100000 });
+    // const result = await Promise.resolve({
+    //   records: [
+    //     {
+    //       id: 0,
+    //       deviceName: '设备名称',
+    //       maxArea: '最大过风面积',
+    //       des: '灾变时动作描述',
+    //     },
+    //   ],
+    // });
+    show.value = true;
+    dataSource.value = result.records;
+  }
+
+  async function handleDelete(record) {
+    await modelAlarmAutoDelete({ id: record.id });
+    getDataSource();
+  }
+
+  const [register, { openModal, closeModal }] = useModal();
+  const [registerForm, { setFieldsValue, resetFields, validateFields, getFieldsValue }] = useForm({
+    schemas: formSchemas,
+    showActionButtonGroup: false,
+  });
+
+  async function handleOpen(flag, record) {
+    if (!activeID.value) {
+      message.warning('请先选择预警条目!');
+      return;
+    }
+    openModal(true, {
+      isUpdate: flag == 'update',
+    });
+    nextTick(() => {
+      resetFields();
+      setFieldsValue(record);
+    });
+  }
+
+  async function onSubmit() {
+    if (activeID.value) {
+      await validateFields();
+      const values = getFieldsValue();
+      // 提交数据弹窗
+      if (values.id) {
+        await modelAlarmAutoEdit({ ...values });
+      } else {
+        await modelAlarmAutoAdd({ ...values, sysId: props.deviceId, alarmId: activeID.value });
+      }
+      getDataSource();
+    }
+    closeModal();
+  }
+
+  onMounted(async () => {
+    await getWarningList();
+    await getDataSource();
+  });
+</script>
+
+<style lang="less" scoped>
+  @import '/@/design/theme.less';
+  @ventSpace: zxm;
+
+  .warning-device-box {
+    width: 100%;
+    height: 600px;
+    overflow-y: auto;
+    display: flex;
+    .warning-box {
+      width: 200px;
+      height: 100%;
+      overflow-y: auto;
+      background: #ffffff11;
+      padding: 5px;
+      border-radius: 5px;
+
+      .link-item {
+        position: relative;
+        cursor: pointer;
+        line-height: 30px;
+        padding-left: 30px;
+        color: var(--vent-font-color);
+        span:hover {
+          color: var(--vent-font-action-link);
+        }
+        &::after {
+          content: '';
+          position: absolute;
+          display: block;
+          width: 8px;
+          height: 8px;
+          top: 12px;
+          left: 10px;
+          transform: rotateZ(45deg) skew(10deg, 10deg);
+          background: var(--vent-base-light-bg);
+        }
+      }
+      .active-device-title {
+        color: var(--vent-font-action-link);
+      }
+    }
+    .device-box {
+      flex: 1;
+      margin-left: 10px;
+    }
+
+    .action-link {
+      color: var(--vent-font-action-link);
+    }
+  }
+</style>

+ 15 - 0
src/views/vent/deviceManager/comment/warningTabel/warning.api.ts

@@ -38,6 +38,13 @@ enum Api {
   backWindControlDevicePointBatchAdd = '/safety/managesysAuto/addBatch',
   backWindControlDevicePointDelete = '/safety/managesysAuto/delete',
   backWindControlDevicePointEdit = '/safety/managesysAuto/edit',
+
+  modelAlarmAutoList = '/ventanaly-device/safety/modelAlarmAuto/list',
+  modelAlarmAutoEdit = '/ventanaly-device/safety/modelAlarmAuto/edit',
+  modelAlarmAutoDelete = '/ventanaly-device/safety/modelAlarmAuto/delete',
+  modelAlarmAutoAdd = '/ventanaly-device/safety/modelAlarmAuto/add',
+  modelAlarmAutoDeleteBatch = '/ventanaly-device/safety/modelAlarmAuto/deleteBatch',
+  modelAlarmAutoAddBatch = '/ventanaly-device/safety/modelAlarmAuto/addBatch',
 }
 /**
  * 导出api
@@ -132,3 +139,11 @@ export const warningLogList = (params) => defHttp.get({ url: Api.warningLogList,
 export const warningLogAdd = (params) => defHttp.post({ url: Api.warningLogAdd, params });
 export const warningLogEdit = (params) => defHttp.put({ url: Api.warningLogEdit, params });
 export const warningLogDeleteById = (params) => defHttp.delete({ url: Api.warningLogDeleteById, params });
+
+// 模型灾变预案配置
+export const modelAlarmAutoList = (params) => defHttp.get({ url: Api.modelAlarmAutoList, params });
+export const modelAlarmAutoAdd = (params) => defHttp.post({ url: Api.modelAlarmAutoAdd, params });
+export const modelAlarmAutoAddBatch = (params) => defHttp.post({ url: Api.modelAlarmAutoAddBatch, params });
+export const modelAlarmAutoDelete = (params) => defHttp.delete({ url: Api.modelAlarmAutoDelete, params }, { joinParamsToUrl: true });
+export const modelAlarmAutoDeleteBatch = (params) => defHttp.delete({ url: Api.modelAlarmAutoDeleteBatch, params });
+export const modelAlarmAutoEdit = (params) => defHttp.post({ url: Api.modelAlarmAutoEdit, params });

+ 155 - 0
src/views/vent/deviceManager/comment/warningTabel/warning.data.ts

@@ -338,6 +338,11 @@ export const controlFormSchemas = (param) =>
       field: 'orderNum',
       component: 'InputNumber',
     },
+    {
+      label: '操作描述',
+      field: 'remark',
+      component: 'Input',
+    },
   ];
 
 export const controlDevicePointColumns: BasicColumn[] = [
@@ -754,3 +759,153 @@ export const testData1 = [
     updateBy: 'Dublin No. 2 Lake Park',
   },
 ];
+
+export const modelAlarmFormSchemas = () =>
+  <FormSchema[]>[
+    {
+      label: 'ID',
+      field: 'id',
+      component: 'Input',
+      show: false,
+    },
+    {
+      label: '灾变时过风面积',
+      field: 'alarmArea',
+      component: 'InputNumber',
+    },
+    {
+      label: '灾变时状态',
+      field: 'alarmState',
+      component: 'Select',
+      componentProps: {
+        options: [
+          {
+            label: '开启',
+            value: 1,
+          },
+          {
+            label: '关闭',
+            value: 0,
+          },
+        ],
+      },
+      // required: true,
+    },
+    {
+      label: '灾变时动作描述',
+      field: 'des',
+      component: 'Input',
+    },
+    {
+      label: '恢复时动作描述',
+      field: 'des2',
+      component: 'Input',
+    },
+    {
+      label: '设备类型',
+      field: 'deviceKind',
+      component: 'Select',
+      componentProps: {
+        options: [
+          {
+            label: '风门',
+            value: 'gate',
+          },
+          {
+            label: '风窗',
+            value: 'window',
+          },
+          {
+            label: '局部风机',
+            value: 'fanlocal',
+          },
+          {
+            label: '主风机',
+            value: 'fanmain',
+          },
+        ],
+      },
+      // required: true,
+    },
+    {
+      label: '设备名称',
+      field: 'deviceName',
+      component: 'Input',
+    },
+    {
+      label: '控制设备ID',
+      field: 'modelDevId',
+      component: 'Input',
+    },
+    {
+      label: '最大过风面积',
+      field: 'maxArea',
+      component: 'InputNumber',
+    },
+    {
+      label: '正常过风面积',
+      field: 'normalArea',
+      component: 'InputNumber',
+    },
+    {
+      label: '正常时状态',
+      field: 'normalState',
+      component: 'Select',
+      componentProps: {
+        options: [
+          {
+            label: '开启',
+            value: 1,
+          },
+          {
+            label: '关闭',
+            value: 0,
+          },
+        ],
+      },
+      // required: true,
+    },
+    {
+      label: '巷道ID',
+      field: 'tunId',
+      component: 'Input',
+    },
+    {
+      label: '执行顺序',
+      field: 'orderNum',
+      component: 'InputNumber',
+    },
+  ];
+
+export const modelAlarmColumns: TableColumnType[] = [
+  {
+    title: '序号',
+    width: 80,
+    align: 'center',
+    customRender: ({ index }: { index: number }) => `${index + 1}`,
+  },
+  // { dataIndex: 'alarmArea', title: '灾变时过风面积' },
+  // { dataIndex: 'alarmId', title: '报警条目id' },
+  // { dataIndex: 'alarmName', title: '预警名称' },
+  // { dataIndex: 'alarmState', title: '灾变时状态' },
+  // { dataIndex: 'bpmStatus', title: '审批状态' },
+  // { dataIndex: 'createBy', title: '创建人' },
+  // { dataIndex: 'createTime', title: '创建日期' },
+  // { dataIndex: 'des2', title: '恢复正常时动作描述' },
+  // { dataIndex: 'deviceId', title: '关联设备id' },
+  // { dataIndex: 'deviceKind', title: '设备类型' },
+  { dataIndex: 'deviceName', title: '设备名称' },
+  { dataIndex: 'maxArea', title: '最大过风面积' },
+  { dataIndex: 'des', title: '灾变时动作描述' },
+  // { dataIndex: 'modelDevId', title: '控制设备id' },
+  // { dataIndex: 'normalArea', title: '正常过风面积' },
+  // { dataIndex: 'normalState', title: '正常时状态' },
+  // { dataIndex: 'orderNum', title: '执行顺序' },
+  // { dataIndex: 'sysId', title: '场景ID' },
+  // { dataIndex: 'sysName', title: '场景名称' },
+  // { dataIndex: 'sysOrgCode', title: '所属部门' },
+  // { dataIndex: 'tunId', title: '巷道id' },
+  // { dataIndex: 'updateBy', title: '更新人' },
+  // { dataIndex: 'updateTime', title: '更新日期' },
+  { dataIndex: 'operation', title: '操作' },
+];