emcp/frontend/src/views/aiChannelSetting/index.vue

243 lines
6.7 KiB
Vue
Raw Normal View History

2026-05-18 12:39:57 +08:00
<script setup lang="ts">
import { ref, onMounted } from 'vue'
2026-05-18 18:31:31 +08:00
import { fetchChannelConfig, saveChannelConfig, verifyAccessPassword } from '@/api/platform'
import { ElMessage, ElMessageBox } from 'element-plus'
const channelList: any = ref([
{ ch: 1, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 2, singal_type: '1~5V', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 3, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 4, singal_type: '1~5V', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 5, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 6, singal_type: '1~5V', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 7, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 8, singal_type: '1~5V', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 9, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 10, singal_type: '1~5V', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 11, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
{ ch: 12, singal_type: '4~20mA', line_no: 1, type: 'UA', limit_low: 1, limit_high: 8 },
2026-05-18 12:39:57 +08:00
])
2026-05-18 18:31:31 +08:00
const aoChannelList: any = ref([])
2026-05-19 09:22:08 +08:00
const lineOptions = ref([{ label: '线路一', value: 1 }, { label: '线路二', value: 2 }, { label: '线路三', value: 3 }, { label: '线路四', value: 4 }, { label: '线路五', value: 5 }])
2026-05-18 18:31:31 +08:00
const categoryOptions = ref(['UA', 'UB', 'UC'])
const isswitch = ref(false)
2026-05-18 12:39:57 +08:00
const handleSave = () => {
2026-05-18 18:31:31 +08:00
ElMessageBox.prompt('请输入密码', '保存', {
confirmButtonText: '确定',
cancelButtonText: '取消',
closeOnClickModal: false,
// inputType: 'password',
})
.then(({ value }) => {
verifyAccessPassword(value).then((res: any) => {
if (res.data) {
if (isswitch.value) {
return
}
isswitch.value = true
const params = {
ai_channel: channelList.value,
ao_channel: aoChannelList.value,
}
saveChannelConfig(params).then(res => {
if (res.data) {
ElMessage.success('保存成功')
isswitch.value = false
}
}).catch(err => {
isswitch.value = false
})
} else {
ElMessage.error('密码错误,不能修改!')
}
})
})
2026-05-18 12:39:57 +08:00
}
function init() {
2026-05-18 18:31:31 +08:00
fetchChannelConfig().then(res => {
aoChannelList.value = res.ao_channel
res.ai_channel.forEach(item => {
channelList.value.forEach((channel: any) => {
if (channel.ch === item.ch) {
channel.singal_type = item.singal_type
channel.line_no = item.line_no
channel.type = item.type
channel.limit_low = item.limit_low
channel.limit_high = item.limit_high
}
})
})
})
2026-05-18 12:39:57 +08:00
}
onMounted(() => {
2026-05-18 18:31:31 +08:00
init()
2026-05-18 12:39:57 +08:00
})
</script>
<template>
<div class="ai-channel-container">
<div class="title">AI通道设置</div>
<div class="panel">
<div class="row header-row">
<div class="cell cell-no">通道号</div>
<div class="cell cell-type" style="color: #787878;">信号类型</div>
<div class="cell cell-line">所属线路</div>
<div class="cell cell-category">类别</div>
<div class="cell cell-low">低端值</div>
<div class="cell cell-high">高端值</div>
</div>
<div class="row" v-for="(item, idx) in channelList" :key="idx">
2026-05-18 18:31:31 +08:00
<div class="cell cell-no">{{ item.ch }}</div>
<div class="cell cell-type" style="background: #ffffff;">{{ item.singal_type }}</div>
2026-05-18 12:39:57 +08:00
<div class="cell cell-line" style="background: #ffffff;">
2026-05-18 18:31:31 +08:00
<el-select v-model="item.line_no">
<el-option v-for="line in lineOptions" :key="line.value" :value="line.value"
:label="line.label"></el-option>
2026-05-18 12:39:57 +08:00
</el-select>
</div>
<div class="cell cell-category" style="background: #ffffff;">
2026-05-18 18:31:31 +08:00
<el-select v-model="item.type">
2026-05-18 12:39:57 +08:00
<el-option v-for="cat in categoryOptions" :key="cat" :value="cat" :label="cat"></el-option>
</el-select>
</div>
<div class="cell cell-low" style="background: #ffffff;">
2026-05-18 18:31:31 +08:00
<el-input-number v-model="item.limit_low" style="width: 100%;" :controls="false" />
2026-05-18 12:39:57 +08:00
</div>
<div class="cell cell-high" style="background: #ffffff;">
2026-05-18 18:31:31 +08:00
<el-input-number v-model="item.limit_high" style="width: 100%;" :controls="false" />
2026-05-18 12:39:57 +08:00
</div>
</div>
</div>
<div class="btn-wrap">
<button class="save-btn" @click="handleSave">保存</button>
</div>
</div>
</template>
<style scoped lang="scss">
.ai-channel-container {
width: 100%;
height: 100%;
2026-05-19 09:14:37 +08:00
padding: 15px;
2026-05-18 12:39:57 +08:00
.panel {
background: #fff;
border-radius: 6px;
2026-05-19 09:14:37 +08:00
padding: 12px;
2026-05-18 12:39:57 +08:00
box-shadow: 0px 0px 10px rgba(219, 225, 236, 1);
}
.title {
2026-05-19 09:14:37 +08:00
margin: 0 0 10px 0;
2026-05-18 12:39:57 +08:00
font-weight: 700;
font-style: normal;
font-size: 16px;
color: #363636;
}
.row {
display: flex;
margin-bottom: 8px;
&:last-child {
margin-bottom: 0;
}
}
.header-row .cell {
background-color: #f9fafe;
font-weight: 500;
}
.cell {
border: 1px solid #e4e4e4;
border-radius: 4px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
height: 37px;
box-sizing: border-box;
background-color: #f9fafe;
color: #787878;
2026-05-18 18:31:31 +08:00
&+.cell {
2026-05-18 12:39:57 +08:00
margin-left: 8px;
}
}
2026-05-18 18:31:31 +08:00
2026-05-18 12:39:57 +08:00
.cell-no {
width: 100px;
background: #f9fafe;
}
.cell-type {
flex: 1;
background: transparent;
color: #363636;
}
.cell-line {
flex: 1;
}
.cell-category {
flex: 1;
}
.cell-low {
flex: 1;
}
.cell-high {
flex: 1;
}
select,
input {
width: 85%;
height: 32px;
border: none;
outline: none;
text-align: center;
background: transparent;
font-size: 14px;
}
.btn-wrap {
2026-05-19 09:14:37 +08:00
margin-top: 10px;
2026-05-18 12:39:57 +08:00
}
.save-btn {
background-color: #0099ff;
color: #fff;
border: none;
border-radius: 4px;
width: 150px;
height: 40px;
font-size: 14px;
cursor: pointer;
}
}
2026-05-18 18:31:31 +08:00
// 去掉所有边框 + 阴影
:deep(.el-select__wrapper),
:deep(.el-input__wrapper) {
border: none !important;
box-shadow: none !important;
background: transparent !important;
text-align: center !important;
}
:deep(.el-select__wrapper.is-hover),
:deep(.el-input__wrapper.is-hover),
:deep(.el-select__wrapper.is-focused),
:deep(.el-input__wrapper.is-focused) {
box-shadow: none !important;
border: none !important;
}
:deep(.el-input__inner) {
text-align: center !important;
}
2026-05-18 12:39:57 +08:00
</style>