报警设置

This commit is contained in:
jingna 2026-05-18 17:18:21 +08:00
parent af977c85d4
commit c07a118964

View File

@ -1,26 +1,73 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, onMounted } from 'vue'
import { fetchAiAlarmSetting, saveAiAlarmSetting, verifyAccessPassword } from '@/api/platform'
import { ElMessage, ElMessageBox } from 'element-plus'
const channelList = ref([ const channelList = ref([
{ no: 1, type: '4~20mA', line: '开出一', down: 1, up: 8,delay:8,isInput:'0' }, { channel_no: 1, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 2, type: '1~5V', line: '开出一', down: 1, up: 8,delay:8,isInput:'0' }, { channel_no: 2, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 3, type: '4~20mA', line: '开出一', down: 1, up: 8,delay:8,isInput:'0' }, { channel_no: 3, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 4, type: '1~5V', line: '开出一', down: 1, up: 8,delay:8,isInput:'0' }, { channel_no: 4, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 5, type: '4~20mA', line: '开出一', down: 1, up: 8,delay:8,isInput:'0' }, { channel_no: 5, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 6, type: '1~5V', line: '开出一', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 6, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 7, type: '4~20mA', line: '开出一', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 7, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 8, type: '1~5V', line: '开出一', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 8, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 9, type: '1~5V', line: '开出二', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 9, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 10, type: '4~20mA', line: '开出二', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 10, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 11, type: '4~20mA', line: '开出二', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 11, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
{ no: 12, type: '4~20mA', line: '开出二', down: 1, up: 8,delay:8,isInput:'1' }, { channel_no: 12, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
]) ])
const nodeOptions = ref(['开出一', '开出二']) const nodeOptions = ref(['开出一', '开出二'])
const isswitch = ref(false)
const handleSave = () => { const handleSave = () => {
console.log('保存AI通道设置', channelList.value) ElMessageBox.prompt('请输入密码', '保存', {
confirmButtonText: '确定',
cancelButtonText: '取消',
closeOnClickModal: false,
// inputType: 'password',
})
.then(({ value }) => {
verifyAccessPassword(value).then((res: any) => {
if (res.code === 200) {
if (isswitch.value) {
return
}
isswitch.value = true
saveAiAlarmSetting(channelList.value).then(res => {
if (res.code === 200) {
ElMessage.success('保存成功')
init()
isswitch.value = false
}
})
}else{
ElMessage.error('密码错误')
}
})
})
} }
const init = () => {
fetchAiAlarmSetting().then(res => {
console.log(res, 989)
res.forEach(item => {
channelList.value.forEach((channel: any) => {
if (channel.channel_no === item.channel_no) {
channel.singal_type = item.singal_type
channel.output_node = item.output_node
channel.limit_low = item.limit_low
channel.limit_high = item.limit_high
channel.delay = item.delay
channel.enabled = item.enabled
}
})
})
})
}
onMounted(() => {
init()
})
</script> </script>
<template> <template>
@ -36,24 +83,24 @@ const handleSave = () => {
<div class="cell cell-high">是否投入</div> <div class="cell cell-high">是否投入</div>
</div> </div>
<div class="row" v-for="(item, idx) in channelList" :key="idx"> <div class="row" v-for="(item, idx) in channelList" :key="idx">
<div class="cell cell-no">{{ item.no }}</div> <div class="cell cell-no">{{ item.channel_no }}</div>
<div class="cell cell-type" style="background: #ffffff;">{{ item.type }}</div> <div class="cell cell-type" style="background: #ffffff;">{{ item.singal_type }}</div>
<div class="cell cell-line" style="background: #ffffff;"> <div class="cell cell-line" style="background: #ffffff;">
<el-input-number v-model="item.down" style="width: 100%;" :controls="false" /> <el-input-number v-model="item.limit_low" style="width: 100%;" :controls="false" />
</div> </div>
<div class="cell cell-low" style="background: #ffffff;"> <div class="cell cell-low" style="background: #ffffff;">
<el-input-number v-model="item.up" style="width: 100%;" :controls="false" /> <el-input-number v-model="item.limit_high" style="width: 100%;" :controls="false" />
</div> </div>
<div class="cell cell-high" style="background: #ffffff;"> <div class="cell cell-high" style="background: #ffffff;">
<el-input-number v-model="item.delay" style="width: 100%;" :controls="false" /> <el-input-number v-model="item.delay" style="width: 100%;" :controls="false" />
</div> </div>
<div class="cell cell-line" style="background: #ffffff;"> <div class="cell cell-line" style="background: #ffffff;">
<el-select v-model="item.line"> <el-select v-model="item.output_node">
<el-option v-for="line in nodeOptions" :key="line" :value="line" :label="line"></el-option> <el-option v-for="line in nodeOptions" :key="line" :value="line" :label="line"></el-option>
</el-select> </el-select>
</div> </div>
<div class="cell cell-category" style="background: #ffffff;"> <div class="cell cell-category" style="background: #ffffff;">
<el-switch v-model="item.isInput" active-value="1" inactive-value="0" /> <el-switch v-model="item.enabled" />
</div> </div>
</div> </div>
</div> </div>