wljjp 2024-05-09 18:03:28 +08:00
parent 3a0a82ac7e
commit 240fc2538d
2 changed files with 161 additions and 4 deletions

View File

@ -140,6 +140,10 @@ const infoApi = {
addPz(params) {
return postPBRequest("/driver", params, 54201, params.driver_name);
},
// com
getCom() {
return postPBRequest("/info", null, 51001);
},
// //
// getSc(params) {
// return getRequest('/sb/list', params)

View File

@ -1,6 +1,6 @@
<template>
<el-drawer v-model="visible" :title= "pztype + '类型 配置管理'" direction="rtl" :before-close="closeDialog">
<el-form :model="form" label-width="120px" :rules="rules" ref="ruleFormRef" v-if="pztypecode === 1">
<el-form :model="form" label-width="120px" :rules="rules" ref="ruleFormRef" v-if="pztypecode === 2">
<el-form-item label="轮询时间" prop="polling_time">
<el-input v-model="form.polling_time" clearable/><span></span>
</el-form-item>
@ -55,6 +55,70 @@
<el-button @click="closeDialog"></el-button>
</el-form-item>
</el-form>
<el-form :model="form1" label-width="120px" :rules="rules1" ref="ruleFormRef1" v-if="pztypecode === 1">
<el-form-item label="轮询时间" prop="polling_time">
<el-input v-model="form1.polling_time" clearable/><span></span>
</el-form-item>
<el-form-item label="失败重试时间" prop="faile_retry_time">
<el-input v-model="form1.faile_retry_time" clearable/><span></span>
</el-form-item>
<el-form-item label="COM" prop="driver_name">
<el-select v-model="form1.driver_name" clearable>
<el-option
v-for="item in comArr"
:label="item.name"
:value="item.name"
:key="item.name"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据位" prop="dataBits" clearable>
<el-select v-model="form1.dataBits">
<el-option
v-for="item in dataBitsArr"
:label="item.name"
:value="item.value"
:key="item.value"
clearable
></el-option>
</el-select>
</el-form-item>
<el-form-item label="波特率" prop="baudRate" clearable>
<el-select v-model="form1.baudRate">
<el-option
v-for="item in baudRateArr"
:label="item.name"
:value="item.value"
:key="item.value"
clearable
></el-option>
</el-select>
</el-form-item>
<el-form-item label="停止位" prop="stopBits" clearable>
<el-select v-model="form1.stopBits">
<el-option
v-for="item in stopBitsArr"
:label="item.name"
:value="item.value"
:key="item.value"
clearable
></el-option>
</el-select>
</el-form-item>
<el-form-item label="校验类型" prop="parity" clearable>
<el-select v-model="form1.parity">
<el-option
v-for="item in parityArr"
:label="item.name"
:value="item.value"
:key="item.value"
clearable
></el-option>
</el-select>
</el-form-item>
</el-form>
</el-drawer>
</template>
<script>
@ -74,6 +138,76 @@ export default {//2: 'modbus_rtu', 3: 'plc_s7'
port: '',
id: 1,
},
form1: {
polling_time: "",
faile_retry_time: "",
driver_name: '',
dataBits: '',
baudRate: '',
stopBits: '',
parity: ''
},
comArr: [],// com
baudRateArr: [{
name: 2480,
value: 2480
},{
name: 4880,
value: 4880
},
{
name:9600,
value: 9600
},
{
name:19200,
value: 19200
},
{
name:38400,
value: 38400
},
{
name:76800,
value: 76800
},
{
name:115200,
value: 115200
}],
dataBitsArr:[{
name: 5,
value: 5
},{
name: 6,
value: 6
},
{
name:7,
value: 7
},
{
name:8,
value: 8
}],
stopBitsArr: [{
name: 1,
value: 1
},{
name: 2,
value: 2
}],
parityArr: [{
name: "N",
value: "N"
},{
name: "E",
value: "E",
},{
name: "O",
value: "O",
}],
rules: {
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
@ -87,6 +221,15 @@ export default {//2: 'modbus_rtu', 3: 'plc_s7'
      }}, trigger: 'blur' }],
port: [{ required: true, message: "请输入端口号", trigger: "blur" }]
},
rules1: {
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
driver_name: [{ required: true, message: "请选择COM口", trigger: "blur" }],
dataBits: [{ required: true, message: "请选择数据位", trigger: "blur" }],
baudRate: [{ required: true, message: "请选择波特率", trigger: "blur" }],
stopBits: [{ required: true, message: "请选择停止位", trigger: "blur" }],
parity: [{ required: true, message: "请选择校验类型", trigger: "blur" }]
},
});
const onSubmit = async () => {
console.log(555, props.formData.name);
@ -118,8 +261,18 @@ export default {//2: 'modbus_rtu', 3: 'plc_s7'
});
onMounted(() => {
getCom();
});
const getCom = async () => {
const res = await infoApi.getCom();
if (res.code == 0) {
state.comArr = res.data;
console.log(44, state.comArr);
nextTick(() => {
drawEchart();
});
}
};
const closeDialog = () => {
ctx.emit("dialogClose");
};
@ -134,8 +287,8 @@ export default {//2: 'modbus_rtu', 3: 'plc_s7'
importData,
exportData,
onSubmit,
ruleFormRef
ruleFormRef,
getCom
};
},
};