|
|
@@ -1,688 +0,0 @@
|
|
|
-<template>
|
|
|
- <a-card>
|
|
|
- <a-row justify="space-between" >
|
|
|
- <a-col>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <a-space>
|
|
|
- <a-button type="primary" @click="state.visible = true" >创建规则</a-button>
|
|
|
- </a-space>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- <a-table
|
|
|
- style="margin-top: 20px;"
|
|
|
- :columns="columns"
|
|
|
- :data-source="state.dataSource"
|
|
|
- :loading="state.loading"
|
|
|
- :pagination="queryParamsState"
|
|
|
- @change="changePage"
|
|
|
- >
|
|
|
- <template #bodyCell="{column, record}" >
|
|
|
- <template v-if="column.key === 'status'" >
|
|
|
- <a-switch
|
|
|
- v-model:checked="record.status"
|
|
|
- checked-children="运行中"
|
|
|
- un-checked-children="已停止"
|
|
|
- @click="changeStatus(record)"
|
|
|
- />
|
|
|
- </template>
|
|
|
- <template v-if="column.key === 'action'" >
|
|
|
- <a-space>
|
|
|
- <!-- <a>编辑</a> -->
|
|
|
- <a-popconfirm
|
|
|
- title="确实要删除吗?"
|
|
|
- ok-text="确定"
|
|
|
- cancel-text="取消"
|
|
|
- @confirm="delLinkRule(record.id)"
|
|
|
- >
|
|
|
- <a>删除</a>
|
|
|
- </a-popconfirm>
|
|
|
- </a-space>
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- </a-table>
|
|
|
- </a-card>
|
|
|
-
|
|
|
- <modal-pro
|
|
|
- style="width: 1400px;"
|
|
|
- label="创建转发规则"
|
|
|
- :visible="state.visible"
|
|
|
- @cancel="state.visible = false"
|
|
|
- @ok="ok"
|
|
|
- >
|
|
|
- <div style="height: 750px;overflow: hidden;overflow-y: auto;">
|
|
|
- <a-card
|
|
|
- title="基本信息"
|
|
|
- :bordered="false"
|
|
|
- >
|
|
|
- <form-pro
|
|
|
- :labelCol="{span: 2}"
|
|
|
- :formProps="formProps"
|
|
|
- ref="formProRef"
|
|
|
- />
|
|
|
- </a-card>
|
|
|
- <a-card
|
|
|
- title="触发条件"
|
|
|
- :bordered="false"
|
|
|
- >
|
|
|
- <a-row class="condition" >
|
|
|
- <a-col span="12" >
|
|
|
- 需满足
|
|
|
- <a-dropdown >
|
|
|
- <a class="ant-dropdown-link" @click.prevent>
|
|
|
- {{bodyParamsState.conditionLogic === 'AND' ? '全部' : '任意一个'}}
|
|
|
- <DownOutlined />
|
|
|
- </a>
|
|
|
- <template #overlay>
|
|
|
- <a-menu>
|
|
|
- <a-menu-item @click="changeConditionLogic('AND')" >
|
|
|
- <a >全部</a>
|
|
|
- </a-menu-item>
|
|
|
- <a-menu-item @click="changeConditionLogic('ALL')">
|
|
|
- <a >任意一个</a>
|
|
|
- </a-menu-item>
|
|
|
- </a-menu>
|
|
|
- </template>
|
|
|
- </a-dropdown>
|
|
|
- 以下条件:
|
|
|
- </a-col>
|
|
|
- <a-col class="df" span="12" >
|
|
|
- <a-button type="primary" @click="addCondition">添加条件</a-button>
|
|
|
- </a-col>
|
|
|
- <a-col span="24" >
|
|
|
- <a-row style="margin-top: 20px;" v-if="bodyParamsState.conditions.length" >
|
|
|
- <a-col
|
|
|
- :span="24"
|
|
|
- style="margin-top: 5px;"
|
|
|
- v-for="(item, index) in bodyParamsState.conditions"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
- <a-row>
|
|
|
- <a-col
|
|
|
- :span="22"
|
|
|
- >
|
|
|
- <a-row :gutter="[8, 8]" >
|
|
|
- <a-col>
|
|
|
- <!-- 选择条件 -->
|
|
|
- <a-select
|
|
|
- style="width: 170px"
|
|
|
- v-model:value="item.conditionType"
|
|
|
- @change="changeConditionAndActionType(index, 'conditions')"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="itemType in conditionTypeList"
|
|
|
- :key="itemType.key"
|
|
|
- :value="itemType.key"
|
|
|
- >
|
|
|
- {{itemType.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col>
|
|
|
- <!-- 选择产品 -->
|
|
|
- <a-select
|
|
|
- v-if="['DEVICE_DATA', 'DEVICE_SESSION'].includes(item.conditionType)"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择产品"
|
|
|
- v-model:value="item.modelId"
|
|
|
- @change="changeModel"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="model in state.modelList"
|
|
|
- :key="model.id"
|
|
|
- :value="model.id"
|
|
|
- >
|
|
|
- {{model.modelLabel}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col>
|
|
|
- <!-- 选择设备类型 -->
|
|
|
- <a-select
|
|
|
- v-if="item.modelId"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择设备"
|
|
|
- v-model:value="item.deviceType"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="deviceItem in selectDeviceList"
|
|
|
- :key="deviceItem.key"
|
|
|
- :value="deviceItem.key"
|
|
|
- >
|
|
|
- {{deviceItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col>
|
|
|
- <span v-if="item.deviceId" >{{item.deviceLabel}}</span>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col>
|
|
|
- <a-button
|
|
|
- type="primary"
|
|
|
- v-if="item.deviceType === 'target'"
|
|
|
- @click="openDeviceModal(index ,'conditions')"
|
|
|
- >
|
|
|
- {{item.deviceId ? '重新选择' : '请选择设备'}}
|
|
|
- </a-button>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col>
|
|
|
- <!-- 选择属性key 填写操作符 -->
|
|
|
- <a-select
|
|
|
- v-if="item.modelId && item.conditionType === 'DEVICE_DATA'"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择属性key"
|
|
|
- v-model:value="item.attributeKey"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="attrItem in state.attrList"
|
|
|
- :key="attrItem.attributeKey"
|
|
|
- :value="attrItem.attributeKey"
|
|
|
- >
|
|
|
- {{attrItem.attributeKey}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <a-select
|
|
|
- v-if="item.modelId && item.conditionType === 'DEVICE_DATA'"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择操作符"
|
|
|
- v-model:value="item.operator"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="operaItem in operatorList"
|
|
|
- :key="operaItem"
|
|
|
- :value="operaItem"
|
|
|
- >
|
|
|
- {{operaItem}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <a-col v-if=" item.operator && item.conditionType === 'DEVICE_DATA'">
|
|
|
- <a-input v-if="item.operator !== 'BETWEEN'" style="width: 170px;" placeholder="请选择触发值" v-model:value="item.value" ></a-input>
|
|
|
- <a-input-group compact v-else >
|
|
|
- <a-input v-model:value="item.v1" style="width: 20%" />
|
|
|
- <a-input v-model:value="item.v2" style="width: 30%" />
|
|
|
- </a-input-group>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <!-- sessionEventType -->
|
|
|
- <a-select
|
|
|
- v-if="item.deviceType && item.conditionType === 'DEVICE_SESSION'"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择session"
|
|
|
- v-model:value="item.sessionEventType"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="essionEventTypeItem in sessionEventTypeList"
|
|
|
- :key="essionEventTypeItem.key"
|
|
|
- :value="essionEventTypeItem.key"
|
|
|
- >
|
|
|
- {{essionEventTypeItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- <!-- DAILY_TIMER -->
|
|
|
- <span v-if="item.conditionType === 'DAILY_TIMER'" >
|
|
|
- <a-space>
|
|
|
- <a-checkbox-group v-model:value="item.dayOfWeek" :options="dayOptions" />
|
|
|
- <a-time-picker v-model:value="item.time" value-format="HH:mm:ss" />
|
|
|
- </a-space>
|
|
|
- </span>
|
|
|
-
|
|
|
- </a-row>
|
|
|
- <a-space>
|
|
|
-
|
|
|
- </a-space>
|
|
|
- <a-divider style="height: 2px;" />
|
|
|
- </a-col>
|
|
|
- <a-col :span="2" >
|
|
|
- <a-button @click="delConditionAndAction(index, 'conditions')" type="link" danger >删除</a-button>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- </a-col>
|
|
|
-
|
|
|
- </a-row>
|
|
|
- <div v-else class="content" >尚未设置条件</div>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- </a-card>
|
|
|
- <a-card
|
|
|
- title="执行动作"
|
|
|
- :bordered="false"
|
|
|
- >
|
|
|
- <a-row>
|
|
|
- <a-col :span="24" class="df" ><a-button type="primary" @click="addAction" >添加动作</a-button></a-col>
|
|
|
- <a-col :span="24" v-if="bodyParamsState.actions.length" >
|
|
|
- <a-row style="margin-top: 10px;" >
|
|
|
- <template
|
|
|
- v-for="(item, index) in bodyParamsState.actions"
|
|
|
- :key="index"
|
|
|
- >
|
|
|
- <a-col
|
|
|
- style="margin-top: 10px;"
|
|
|
- :span="22"
|
|
|
- >
|
|
|
- <a-row :gutter="[8, 8]" >
|
|
|
- <a-col>
|
|
|
- <a-select
|
|
|
- style="width: 170px"
|
|
|
- v-model:value="item.actionType"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="actionItem in actionTypeList"
|
|
|
- :key="actionItem.key"
|
|
|
- :value="actionItem.key"
|
|
|
- >
|
|
|
- {{actionItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
-
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <!-- 选择产品 -->
|
|
|
- <a-select
|
|
|
- v-if="item.actionType === 'DEVICE_CMD'"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择产品"
|
|
|
- v-model:value="item.modelId"
|
|
|
- @change="changeModel"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="model in state.modelList"
|
|
|
- :key="model.id"
|
|
|
- :value="model.id"
|
|
|
- >
|
|
|
- {{model.modelLabel}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <a-select
|
|
|
- v-if=" item.actionType !== 'NOTICE' || (item.actionType === 'DEVICE_CMD' && item.modelId)"
|
|
|
- style="width: 170px"
|
|
|
- placeholder="请选择设备"
|
|
|
- v-model:value="item.deviceType"
|
|
|
- >
|
|
|
- <a-select-option
|
|
|
- v-for="deviceItem in selectDeviceList"
|
|
|
- :key="deviceItem.key"
|
|
|
- :value="deviceItem.key"
|
|
|
- >
|
|
|
- {{deviceItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <span v-if="item.deviceId" >{{item.deviceLabel}}</span>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <a-button
|
|
|
- type="primary"
|
|
|
- v-if="item.deviceType === 'target'"
|
|
|
- @click="openDeviceModal(index, 'actions')"
|
|
|
- >
|
|
|
- {{item.deviceId ? '重新选择' : '请选择设备'}}
|
|
|
- </a-button>
|
|
|
- </a-col>
|
|
|
- <!-- 选择设备指令 -->
|
|
|
- <!-- <a-col v-if="item.actionType === 'DEVICE_CMD'" >
|
|
|
- <a-select style="width: 170px;" @change="changeCmd(item, index)">
|
|
|
- <a-select-option
|
|
|
- v-for="cmdItem in state.cmdList"
|
|
|
- :key="cmdItem.id"
|
|
|
- :value="cmdItem.id"
|
|
|
- >
|
|
|
- {{cmdItem.cmdLabel}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-col> -->
|
|
|
- <a-col>
|
|
|
- <!-- <a-input-group compact v-for="cmdParameter in " >
|
|
|
- <a-input v-model:value="item.v1" style="width: 20%" />
|
|
|
- <a-input v-model:value="item.v2" style="width: 30%" />
|
|
|
- </a-input-group> -->
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <span v-if="['REPORT_WARN', 'RESUME_WARN'].includes(item.actionType) && item.deviceType" >
|
|
|
- <a-space>
|
|
|
- <a-input placeholder="请填写告警名称" v-model:value="item.warnLabel" ></a-input>
|
|
|
- <a-input v-if="item.actionType === 'REPORT_WARN'" placeholder="请填写告警描述" v-model:value="item.warnDescription" ></a-input>
|
|
|
- <a-select placeholder="请选择告警级别" style="width: 170px" v-model:value="item.warnSeverity" >
|
|
|
- <a-select-option v-for="warnItem in warnSeverityList" :key="warnItem.key" :value ='warnItem.key'>
|
|
|
- {{warnItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-space>
|
|
|
- </span>
|
|
|
- </a-col>
|
|
|
- <a-col>
|
|
|
- <span v-if="item.actionType ==='NOTICE'">
|
|
|
- <a-space>
|
|
|
- <a-input placeholder="请填写提示名称" style="width: 170px" v-model:value="item.noticeLabel" ></a-input>
|
|
|
- <a-input placeholder="请填写提示描述" style="width: 170px" v-model:value="item.noticeDescription" ></a-input>
|
|
|
- <a-select placeholder="请选择用户" style="width: 170px" v-model:value="item.userId" >
|
|
|
- <a-select-option v-for="warnItem in warnSeverityList" :key="warnItem.key" :value ='warnItem.key'>
|
|
|
- {{warnItem.name}}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
- </a-space>
|
|
|
- </span>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- </a-col>
|
|
|
- <a-col :span="2" >
|
|
|
- <a-button @click="delConditionAndAction(index, 'actions')" type="link" danger >删除</a-button>
|
|
|
- </a-col>
|
|
|
- <a-divider style="height: 2px;" />
|
|
|
- </template>
|
|
|
- </a-row>
|
|
|
- </a-col>
|
|
|
- <div class="content" v-else >尚未设置动作</div>
|
|
|
- </a-row>
|
|
|
- </a-card>
|
|
|
- </div>
|
|
|
- </modal-pro>
|
|
|
-
|
|
|
- <modal-pro
|
|
|
- style="width: 700px"
|
|
|
- label="选择设备"
|
|
|
- :visible="state.deviceModalVisible"
|
|
|
- @cancel="state.deviceModalVisible = false"
|
|
|
- @ok="selectDevice"
|
|
|
- >
|
|
|
- <SelectDevice
|
|
|
- ref="selectDeviceRef"
|
|
|
- />
|
|
|
- </modal-pro>
|
|
|
-</template>
|
|
|
-<script lang='ts' setup >
|
|
|
-import { FormItemProps } from '@/components/FormPro/index.vue'
|
|
|
-import { ModelAttrController, ModelCmdController, ModelController, RuleController } from '@/controller'
|
|
|
-import { onMounted, reactive, ref } from 'vue'
|
|
|
-import { DownOutlined } from '@ant-design/icons-vue'
|
|
|
-import SelectDevice from './components/selectDevice.vue'
|
|
|
-
|
|
|
-const columns = [
|
|
|
- {
|
|
|
- title: '状态',
|
|
|
- dataIndex: 'status',
|
|
|
- key: 'status'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '规则ID',
|
|
|
- dataIndex: 'id',
|
|
|
- key: 'id'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '规则名称',
|
|
|
- dataIndex: 'ruleLabel',
|
|
|
- key: 'ruleLabel'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '规则描述',
|
|
|
- dataIndex: 'ruleDescription',
|
|
|
- key: 'ruleDescription'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- key: 'action'
|
|
|
- }
|
|
|
-]
|
|
|
-
|
|
|
-const formProps: FormItemProps[] = [
|
|
|
- {
|
|
|
- label: '规则名称',
|
|
|
- key: 'ruleLabel',
|
|
|
- value: '',
|
|
|
- type: 'input',
|
|
|
- rules: true
|
|
|
- },
|
|
|
- {
|
|
|
- label: '规则描述',
|
|
|
- key: 'ruleDescription',
|
|
|
- value: '',
|
|
|
- type: 'textarea',
|
|
|
- rules: false
|
|
|
- }
|
|
|
-]
|
|
|
-
|
|
|
-const conditionTypeList = [
|
|
|
- { key: 'DEVICE_DATA', name: '设备数据触发' },
|
|
|
- { key: 'DEVICE_SESSION', name: '设备状态触发' },
|
|
|
- { key: 'DAILY_TIMER', name: '周期时间条件' }
|
|
|
-]
|
|
|
-
|
|
|
-const selectDeviceList = [
|
|
|
- { key: 'all', name: '全部设备' },
|
|
|
- { key: 'target', name: '指定设备' }
|
|
|
-]
|
|
|
-
|
|
|
-const sessionEventTypeList = [
|
|
|
- { key: 'CONNECT', name: '连接' },
|
|
|
- { key: 'DISCONNECT', name: '断开连接' }
|
|
|
-]
|
|
|
-
|
|
|
-const dayOptions = [
|
|
|
- { value: 1, label: '周一' },
|
|
|
- { value: 2, label: '周二' },
|
|
|
- { value: 3, label: '周三' },
|
|
|
- { value: 4, label: '周四' },
|
|
|
- { value: 5, label: '周五' },
|
|
|
- { value: 6, label: '周六' },
|
|
|
- { value: 7, label: '周日' }
|
|
|
-]
|
|
|
-
|
|
|
-const actionTypeList = [
|
|
|
- { key: 'DEVICE_CMD', name: '设备命令' },
|
|
|
- { key: 'REPORT_WARN', name: '上报告警' },
|
|
|
- { key: 'RESUME_WARN', name: '恢复告警' },
|
|
|
- { key: 'NOTICE', name: '通知' }
|
|
|
-]
|
|
|
-
|
|
|
-const warnSeverityList = [
|
|
|
- { key: 'NOTICE', name: '提示' },
|
|
|
- { key: 'MINOR', name: '次要' },
|
|
|
- { key: 'MJAJOP', name: '重要' },
|
|
|
- { key: 'EMERGENCY', name: '紧急' }
|
|
|
-]
|
|
|
-
|
|
|
-const operatorList = [
|
|
|
- 'EQ', 'NE', 'GT', 'GE', 'LT', 'LE', 'BETWEEN'
|
|
|
-]
|
|
|
-
|
|
|
-const selectDeviceRef = ref('')
|
|
|
-
|
|
|
-const formProRef = ref('')
|
|
|
-
|
|
|
-const queryParamsState = reactive({
|
|
|
- page: 1,
|
|
|
- pageSize: 10,
|
|
|
- total: 0,
|
|
|
- ruleLabel: ''
|
|
|
-})
|
|
|
-
|
|
|
-const initConditionsData = reactive({
|
|
|
- conditionType: 'DEVICE_DATA',
|
|
|
- modelId: '',
|
|
|
- deviceType: '',
|
|
|
- deviceLabel: '',
|
|
|
- deviceId: '',
|
|
|
- sessionEventType: 'CONNECT',
|
|
|
- dayOfWeek: [],
|
|
|
- time: '',
|
|
|
- noticeLabel: '',
|
|
|
- noticeDescription: '',
|
|
|
- userId: '',
|
|
|
- attributeKey: '',
|
|
|
- operator: 'EQ',
|
|
|
- value: '',
|
|
|
- v1: '',
|
|
|
- v2: ''
|
|
|
-})
|
|
|
-
|
|
|
-const initActionsData = {
|
|
|
- actionType: 'DEVICE_CMD',
|
|
|
- modelId: '',
|
|
|
- deviceId: '',
|
|
|
- deviceType: '',
|
|
|
- cmdLabel: '',
|
|
|
- cmdParameters: {},
|
|
|
- warnLabel: '',
|
|
|
- warnDescription: '',
|
|
|
- warnSeverity: ''
|
|
|
-}
|
|
|
-
|
|
|
-const bodyParamsState = reactive<{
|
|
|
- conditions: any,
|
|
|
- actions: any,
|
|
|
- conditionLogic: string
|
|
|
-}>({
|
|
|
- conditionLogic: 'AND',
|
|
|
- conditions: [],
|
|
|
- actions: []
|
|
|
-})
|
|
|
-
|
|
|
-const state = reactive({
|
|
|
- loading: false,
|
|
|
- dataSource: [],
|
|
|
- visible: false,
|
|
|
- deviceModalVisible: false,
|
|
|
- opraState: 'add',
|
|
|
- modelList: [],
|
|
|
- cmdList: [],
|
|
|
- attrList: [],
|
|
|
- opraIndex: 0, // 点击 条件 与 动作 时的下标
|
|
|
- opraKey: ''
|
|
|
-})
|
|
|
-
|
|
|
-// const cmdDetail = computed(() => {})
|
|
|
-
|
|
|
-const changeCmd = (id: string, index: string) => {
|
|
|
- console.log(id, index)
|
|
|
-}
|
|
|
-
|
|
|
-const changePage = ({ current }) => {
|
|
|
- queryParamsState.page = current
|
|
|
- getLinkPage()
|
|
|
-}
|
|
|
-
|
|
|
-const changeConditionAndActionType = (index: string, key: 'conditions' | 'actions') => {
|
|
|
- console.log('changeConditionType')
|
|
|
- bodyParamsState[key].splice(index, initActionsData)
|
|
|
-}
|
|
|
-
|
|
|
-const delConditionAndAction = (index: number, key: string) => {
|
|
|
- bodyParamsState[key].splice(index, 1)
|
|
|
-}
|
|
|
-
|
|
|
-const openDeviceModal = (index: number, key: 'conditions' | 'actions') => {
|
|
|
- state.opraIndex = index
|
|
|
- state.deviceModalVisible = true
|
|
|
- state.opraKey = key
|
|
|
-}
|
|
|
-
|
|
|
-const addAction = () => {
|
|
|
- bodyParamsState.actions.push({ ...initActionsData })
|
|
|
-}
|
|
|
-
|
|
|
-const addCondition = () => {
|
|
|
- bodyParamsState.conditions.push({ ...initConditionsData })
|
|
|
-}
|
|
|
-
|
|
|
-const changeModel = (id: string) => {
|
|
|
- getAttrList(id)
|
|
|
- getCmdList(id)
|
|
|
-}
|
|
|
-
|
|
|
-// 获取命令
|
|
|
-const getCmdList = async (id: string) => {
|
|
|
- const { data } = await ModelCmdController.list({ modelId: id })
|
|
|
- state.cmdList = data
|
|
|
-}
|
|
|
-// 获取属性
|
|
|
-const getAttrList = async (id: string) => {
|
|
|
- const { data } = await ModelAttrController.list({ modelId: id })
|
|
|
- state.attrList = data
|
|
|
-}
|
|
|
-
|
|
|
-const selectDevice = () => {
|
|
|
- console.log('selectDeviceref.value.rowKey:', selectDeviceRef.value.getSelectDevice())
|
|
|
- const _device = selectDeviceRef.value.getSelectDevice()
|
|
|
- state.deviceModalVisible = false
|
|
|
- bodyParamsState[state.opraKey][state.opraIndex].deviceId = _device.id
|
|
|
- bodyParamsState[state.opraKey][state.opraIndex].deviceLabel = _device.deviceLabel
|
|
|
-}
|
|
|
-
|
|
|
-const delLinkRule = async (id: string) => {
|
|
|
- await RuleController.delLink(id)
|
|
|
- getLinkPage()
|
|
|
-}
|
|
|
-
|
|
|
-const ok = async () => {
|
|
|
- const r = await formProRef.value.onSubmit()
|
|
|
- const params: any = {}
|
|
|
- if (r) {
|
|
|
- console.log(r)
|
|
|
- Object.keys(r).forEach(key => params[key] = r[key])
|
|
|
- bodyParamsState.conditions.forEach(item => {
|
|
|
- if (item.operator === 'BETWEEN') {
|
|
|
- item.value = `{${item.v1}, ${item.v2}}`
|
|
|
- }
|
|
|
- })
|
|
|
- await RuleController.addLink({ ...params, ...bodyParamsState })
|
|
|
- state.visible = false
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-const changeConditionLogic = (record: string) => {
|
|
|
- bodyParamsState.conditionLogic = record
|
|
|
-}
|
|
|
-
|
|
|
-const changeStatus = async (record) => RuleController.updateLinkStatus({ id: record.id, status: record.status })
|
|
|
-
|
|
|
-const getLinkPage = async () => {
|
|
|
- state.loading = true
|
|
|
- const { data, sum } = await RuleController.pageLink(queryParamsState)
|
|
|
- state.dataSource = data
|
|
|
- queryParamsState.total = sum
|
|
|
- state.loading = false
|
|
|
-}
|
|
|
-
|
|
|
-const getModelList = async () => {
|
|
|
- const { data } = await ModelController.list()
|
|
|
- state.modelList = data
|
|
|
-}
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- getLinkPage()
|
|
|
- getModelList()
|
|
|
-})
|
|
|
-
|
|
|
-</script>
|
|
|
-<style lang='less' scoped >
|
|
|
-
|
|
|
-.content {
|
|
|
- width: 100%;
|
|
|
- height: 45px;
|
|
|
- background-color: #F2F5FC;
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- margin: 20px 0;
|
|
|
-}
|
|
|
-
|
|
|
-.df {
|
|
|
- display: flex;
|
|
|
- justify-content: end;
|
|
|
-}
|
|
|
-
|
|
|
-</style>
|