修改AI报警设置的信号类型读取、上限和下限值范围
This commit is contained in:
parent
4de46910ce
commit
961269ef99
@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { fetchAiAlarmSetting, saveAiAlarmSetting, verifyAccessPassword } from '@/api/platform'
|
||||
import { fetchAiAlarmSetting, saveAiAlarmSetting, verifyAccessPassword, fetchChannelConfig } from '@/api/platform'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import PasswordDialog from '@/components/passwordValie.vue'
|
||||
import NumericKeyboard from '@/components/NumericKeyboard.vue'
|
||||
@ -17,18 +17,18 @@ interface ChannelItem {
|
||||
}
|
||||
|
||||
const channelList = ref<ChannelItem[]>([
|
||||
{ channel_no: 1, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 2, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 3, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 4, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 5, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 6, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 7, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 8, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 9, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 10, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 11, singal_type: '4~20mA', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 12, singal_type: '1~5V', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 1, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 2, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 3, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 4, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 5, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 6, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 7, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 8, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 9, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 10, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 11, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
{ channel_no: 12, singal_type: '', output_node: '', limit_low: 0, limit_high: 8, delay: 8, enabled: false },
|
||||
])
|
||||
const signalTypeOptions = ref(['1~5V', '4~20mA'])
|
||||
const nodeOptions = ref(['开出一', '开出二', '开出三', '开出四', '开出五', '开出六', '开出七', '开出八', '开出九', '开出十', '开出十一', '开出十二'])
|
||||
@ -39,6 +39,7 @@ const keyboardVisible = ref(false)
|
||||
const currentInputValue = ref('')
|
||||
const currentInputIndex = ref(-1)
|
||||
const currentInputType = ref('')
|
||||
const configList: any = ref([])
|
||||
const openKeyboard = (index: number, value: any, type: string) => {
|
||||
currentInputType.value = type
|
||||
currentInputIndex.value = index
|
||||
@ -47,7 +48,33 @@ const openKeyboard = (index: number, value: any, type: string) => {
|
||||
}
|
||||
|
||||
const handleKeyboardConfirm = (value: any) => {
|
||||
const currentval = Number(value)
|
||||
if (currentInputIndex.value >= 0) {
|
||||
const channel = channelList.value[currentInputIndex.value]
|
||||
const signalType = channel.singal_type
|
||||
if (signalType === '1~5V') {
|
||||
if (currentval < 1 || currentval > 5) {
|
||||
ElMessage.warning('1~5V 信号类型,输入值必须在 1~5 范围内')
|
||||
keyboardVisible.value = false
|
||||
return
|
||||
}
|
||||
} else if (signalType === '4~20mA') {
|
||||
if (currentval < 4 || currentval > 20) {
|
||||
ElMessage.warning('4~20mA 信号类型,输入值必须在 4~20 范围内')
|
||||
keyboardVisible.value = false
|
||||
return
|
||||
}
|
||||
}
|
||||
if (currentInputType.value === 'limit_high' && value < channel.limit_low) {
|
||||
ElMessage.warning(`上限值不能低于下限值 ${channel.limit_low}`)
|
||||
keyboardVisible.value = false
|
||||
return
|
||||
}
|
||||
if (currentInputType.value === 'limit_low' && value > channel.limit_high) {
|
||||
ElMessage.warning(`下限值不能高于上限值 ${channel.limit_high}`)
|
||||
keyboardVisible.value = false
|
||||
return
|
||||
}
|
||||
channelList.value[currentInputIndex.value][currentInputType.value] = value
|
||||
}
|
||||
keyboardVisible.value = false
|
||||
@ -62,6 +89,32 @@ const handlePasswordConfirm = () => {
|
||||
if (isswitch.value) {
|
||||
return
|
||||
}
|
||||
for (const channel of channelList.value) {
|
||||
const signalType = channel.singal_type
|
||||
if (signalType === '1~5V') {
|
||||
if (channel.limit_low < 1 || channel.limit_low > 5) {
|
||||
ElMessage.warning(`通道${channel.channel_no}:1~5V 下限值必须在 1~5 范围内`)
|
||||
return
|
||||
}
|
||||
if (channel.limit_high < 1 || channel.limit_high > 5) {
|
||||
ElMessage.warning(`通道${channel.channel_no}:1~5V 上限值必须在 1~5 范围内`)
|
||||
return
|
||||
}
|
||||
} else if (signalType === '4~20mA') {
|
||||
if (channel.limit_low < 4 || channel.limit_low > 20) {
|
||||
ElMessage.warning(`通道${channel.channel_no}:4~20mA 下限值必须在 4~20 范围内`)
|
||||
return
|
||||
}
|
||||
if (channel.limit_high < 4 || channel.limit_high > 20) {
|
||||
ElMessage.warning(`通道${channel.channel_no}:4~20mA 上限值必须在 4~20 范围内`)
|
||||
return
|
||||
}
|
||||
}
|
||||
if (channel.limit_low > channel.limit_high) {
|
||||
ElMessage.warning(`通道${channel.channel_no}:下限值不能高于上限值`)
|
||||
return
|
||||
}
|
||||
}
|
||||
isswitch.value = true
|
||||
saveAiAlarmSetting(channelList.value).then(res => {
|
||||
if (res.code === 200) {
|
||||
@ -80,7 +133,6 @@ const init = () => {
|
||||
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
|
||||
@ -91,7 +143,20 @@ const init = () => {
|
||||
})
|
||||
})
|
||||
}
|
||||
const queryChannelConfig = () => {
|
||||
fetchChannelConfig().then(res => {
|
||||
configList.value = res.ai_channel
|
||||
configList.value.forEach((configItem: any) => {
|
||||
channelList.value.forEach((channel: any) => {
|
||||
if (channel.channel_no === configItem.ch) {
|
||||
channel.singal_type = configItem.singal_type
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
queryChannelConfig()
|
||||
init()
|
||||
})
|
||||
</script>
|
||||
@ -110,25 +175,20 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="row" v-for="(item, idx) in channelList" :key="idx">
|
||||
<div class="cell cell-no">{{ item.channel_no }}</div>
|
||||
<div class="cell cell-type" style="background: #ffffff;">
|
||||
<!-- <el-input
|
||||
v-model="item.singal_type"
|
||||
placeholder=""
|
||||
disabled
|
||||
/> -->
|
||||
<el-select v-model="item.singal_type">
|
||||
<el-option v-for="line in signalTypeOptions" :key="line" :value="line" :label="line"></el-option>
|
||||
</el-select>
|
||||
<div class="cell cell-type" style="background: #ffffff;font-size: 14px;color: #606266;">
|
||||
{{ item.singal_type }}
|
||||
</div>
|
||||
<div class="cell cell-line" style="background: #ffffff;">
|
||||
<el-input-number v-model="item.limit_low"
|
||||
@focus="openKeyboard(idx, item.limit_low, 'limit_low')" style="width: 100%;" :controls="false" />
|
||||
<el-input-number v-model="item.limit_low" @focus="openKeyboard(idx, item.limit_low, 'limit_low')"
|
||||
style="width: 100%;" :controls="false" />
|
||||
</div>
|
||||
<div class="cell cell-low" style="background: #ffffff;">
|
||||
<el-input-number v-model="item.limit_high" style="width: 100%;" @focus="openKeyboard(idx, item.limit_high, 'limit_high')" :controls="false" />
|
||||
<el-input-number v-model="item.limit_high" style="width: 100%;"
|
||||
@focus="openKeyboard(idx, item.limit_high, 'limit_high')" :controls="false" />
|
||||
</div>
|
||||
<div class="cell cell-high" style="background: #ffffff;">
|
||||
<el-input-number v-model="item.delay" @focus="openKeyboard(idx, item.delay, 'delay')" style="width: 100%;" :controls="false" />
|
||||
<el-input-number v-model="item.delay" @focus="openKeyboard(idx, item.delay, 'delay')"
|
||||
style="width: 100%;" :controls="false" />
|
||||
</div>
|
||||
<div class="cell cell-line" style="background: #ffffff;">
|
||||
<el-select v-model="item.output_node">
|
||||
@ -151,11 +211,8 @@ onMounted(() => {
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<NumericKeyboard
|
||||
v-model:visible="keyboardVisible"
|
||||
:model-value="currentInputValue"
|
||||
@confirm="handleKeyboardConfirm"
|
||||
/>
|
||||
<NumericKeyboard v-model:visible="keyboardVisible" :model-value="currentInputValue"
|
||||
@confirm="handleKeyboardConfirm" />
|
||||
<PasswordDialog v-model:visible="passwordDialogVisible" title="密码验证" @confirm="handlePasswordConfirm" />
|
||||
</div>
|
||||
</template>
|
||||
@ -286,6 +343,7 @@ onMounted(() => {
|
||||
:deep(.el-input__inner) {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
:deep(.el-input.is-disabled .el-input__inner) {
|
||||
color: #606266;
|
||||
-webkit-text-fill-color: #606266;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user