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'
|
2026-06-12 15:10:02 +08:00
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
import PasswordDialog from '@/components/passwordValie.vue'
|
2026-06-12 14:35:11 +08:00
|
|
|
|
import NumericKeyboard from '@/components/NumericKeyboard.vue'
|
|
|
|
|
|
interface ChannelItem {
|
|
|
|
|
|
ch: number
|
|
|
|
|
|
singal_type: string
|
|
|
|
|
|
line_no: number
|
|
|
|
|
|
type: string
|
|
|
|
|
|
limit_low: number
|
|
|
|
|
|
limit_high: number
|
|
|
|
|
|
}
|
|
|
|
|
|
const channelList = ref<ChannelItem[]>([
|
2026-05-18 18:31:31 +08:00
|
|
|
|
{ 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-19 09:25:10 +08:00
|
|
|
|
const lineOptions = ref([{ label: '线路一', value: 1 }, { label: '线路二', value: 2 }, { label: '线路三', value: 3 }, { label: '线路四', value: 4 }])
|
2026-05-18 18:31:31 +08:00
|
|
|
|
const categoryOptions = ref(['UA', 'UB', 'UC'])
|
2026-05-19 10:46:30 +08:00
|
|
|
|
const categoryOptions2 = ref(['IA', 'IB', 'IC'])
|
|
|
|
|
|
const dialogVisible = ref(false)
|
2026-06-12 15:10:02 +08:00
|
|
|
|
const passwordDialogVisible = ref(false)
|
2026-05-18 18:31:31 +08:00
|
|
|
|
const aiChannelList = ref([])
|
2026-06-12 14:35:11 +08:00
|
|
|
|
const currentInputType = ref('')
|
|
|
|
|
|
const currentInputIndex = ref(-1)
|
|
|
|
|
|
const currentInputValue = ref()
|
|
|
|
|
|
const keyboardVisible = ref(false)
|
|
|
|
|
|
const openKeyboard = (index: number, value: number, type: string) => {
|
|
|
|
|
|
currentInputType.value = type
|
|
|
|
|
|
currentInputIndex.value = index
|
|
|
|
|
|
currentInputValue.value = value
|
|
|
|
|
|
keyboardVisible.value = true
|
|
|
|
|
|
}
|
2026-06-12 17:33:11 +08:00
|
|
|
|
const signalTypeOptions = ref(['1~5V', '4~20mA'])
|
2026-06-12 14:35:11 +08:00
|
|
|
|
const handleKeyboardConfirm = (value: string) => {
|
|
|
|
|
|
if (currentInputIndex.value >= 0) {
|
|
|
|
|
|
const channel = channelList.value[currentInputIndex.value]
|
|
|
|
|
|
const numValue = Number(value)
|
|
|
|
|
|
|
|
|
|
|
|
switch (currentInputType.value) {
|
|
|
|
|
|
case 'limit_low':
|
|
|
|
|
|
channel.limit_low = numValue
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'limit_high':
|
|
|
|
|
|
channel.limit_high = numValue
|
|
|
|
|
|
break
|
|
|
|
|
|
default:
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
keyboardVisible.value = false
|
|
|
|
|
|
}
|
2026-05-18 12:39:57 +08:00
|
|
|
|
function init() {
|
2026-05-18 18:31:31 +08:00
|
|
|
|
fetchChannelConfig().then((res: any) => {
|
|
|
|
|
|
aiChannelList.value = res.ao_channel
|
|
|
|
|
|
res.ao_channel.forEach((item: any) => {
|
|
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
const isswitch = ref(false)
|
|
|
|
|
|
const handleSave = () => {
|
2026-06-12 15:10:02 +08:00
|
|
|
|
passwordDialogVisible.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handlePasswordConfirm = () => {
|
|
|
|
|
|
passwordDialogVisible.value = false
|
|
|
|
|
|
if (isswitch.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
isswitch.value = true
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
ai_channel: aiChannelList.value,
|
|
|
|
|
|
ao_channel: channelList.value,
|
|
|
|
|
|
}
|
|
|
|
|
|
saveChannelConfig(params).then(res => {
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
|
isswitch.value = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ElMessage.error('保存失败')
|
2026-06-12 15:14:04 +08:00
|
|
|
|
isswitch.value = false
|
2026-06-12 15:10:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
isswitch.value = false
|
2026-05-18 18:31:31 +08:00
|
|
|
|
})
|
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="ao-channel-contaoner">
|
2026-05-26 15:11:03 +08:00
|
|
|
|
<!-- <div class="title">AO通道设置</div> -->
|
2026-05-18 12:39:57 +08:00
|
|
|
|
<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>
|
2026-05-19 10:46:30 +08:00
|
|
|
|
<div class="cell cell-type" style="background: #ffffff;">
|
2026-06-12 17:33:11 +08:00
|
|
|
|
<el-select v-model="item.singal_type">
|
|
|
|
|
|
<el-option v-for="line in signalTypeOptions" :key="line" :value="line" :label="line"></el-option>
|
|
|
|
|
|
</el-select>
|
2026-05-19 10:46:30 +08:00
|
|
|
|
</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-19 10:46:30 +08:00
|
|
|
|
<el-option v-for="cat in (item.singal_type.includes('mA') ? categoryOptions2 : categoryOptions)" :key="cat"
|
|
|
|
|
|
:value="cat" :label="cat"></el-option>
|
2026-05-18 12:39:57 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="cell cell-low" style="background: #ffffff;">
|
2026-06-12 14:35:11 +08:00
|
|
|
|
<el-input-number v-model="item.limit_low" @focus="openKeyboard(idx, item.limit_low, '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-06-12 14:35:11 +08:00
|
|
|
|
<el-input-number v-model="item.limit_high" @focus="openKeyboard(idx, item.limit_high, '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>
|
2026-05-19 10:46:30 +08:00
|
|
|
|
<el-dialog v-model="dialogVisible" :close-on-click-modal="false" :show-close="false" title="错误提示" width="300">
|
|
|
|
|
|
<div style="color: #FF4D4F;font-size: 16px;text-align: center;">原密码验证错误!</div>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
|
<el-button type="primary" @click="dialogVisible = false">
|
|
|
|
|
|
确定
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2026-06-12 14:35:11 +08:00
|
|
|
|
<NumericKeyboard v-model:visible="keyboardVisible" :model-value="currentInputValue"
|
|
|
|
|
|
@confirm="handleKeyboardConfirm" />
|
2026-06-12 15:10:02 +08:00
|
|
|
|
<PasswordDialog v-model:visible="passwordDialogVisible" title="密码验证" @confirm="handlePasswordConfirm" />
|
2026-05-18 12:39:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
.ao-channel-contaoner {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
2026-05-26 15:16:24 +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 12px 0;
|
2026-05-18 12:39:57 +08:00
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
font-style: normal;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
color: #363636;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.row {
|
|
|
|
|
|
display: flex;
|
2026-05-26 15:11:03 +08:00
|
|
|
|
margin-bottom: 5px;
|
2026-05-18 12:39:57 +08:00
|
|
|
|
|
|
|
|
|
|
&: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;
|
2026-05-26 15:11:03 +08:00
|
|
|
|
height: 28px;
|
2026-05-18 12:39:57 +08:00
|
|
|
|
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-06-12 14:35:11 +08:00
|
|
|
|
:deep(.el-input.is-disabled .el-input__inner) {
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
-webkit-text-fill-color: #606266;
|
|
|
|
|
|
}
|
2026-05-18 12:39:57 +08:00
|
|
|
|
</style>
|