瓶中沙 2024-06-24 15:53:10 +08:00
parent 72a880cf70
commit b026d8f8cf
5 changed files with 57 additions and 29 deletions

View File

@ -109,6 +109,10 @@ const infoApi = {
delTx(params) {
return postPBRequest(`/driver`, params, 54300);
},
//
getTxStatus(params) {
return postPBRequest(`/driver`, params, 54004);
},
//
getTxSupport() {
@ -139,11 +143,11 @@ const infoApi = {
// ,
startStatus(params) {
return postPBRequest("/driver", params, 53201);
return postPBRequest("/driver", params, 54202,params.name);
},
//
stopStatus(params) {
return postPBRequest("/driver", params, 53202);
return postPBRequest("/driver", params, 54203,params.name);
},
//
addPz(params, header) {

View File

@ -270,18 +270,18 @@ export default {
};
const driveChange = () => {
//
if (props.formData.drive.serial) {
state.serialConfig = true;
state.modbusTCPConfig = false;
// com
getCom();
// if (props.formData.drive.serial) {
// state.serialConfig = true;
// state.modbusTCPConfig = false;
// // com
// getCom();
} else {
state.serialConfig = false;
if (props.formData.drive.name == "modbusTCP") {
state.modbusTCPConfig = true;
}
}
// } else {
// state.serialConfig = false;
// if (props.formData.drive.name == "modbusTCP") {
// state.modbusTCPConfig = true;
// }
// }
}
// com
const getCom = async () => {

View File

@ -1,6 +1,6 @@
<template>
<el-drawer v-model="visible" :title= "pztype + '类型 配置管理'" direction="rtl" :before-close="closeDialog">
<!-- 1 -->
<!-- 1 modbus_tcp -->
<el-form :model="form" label-width="120px" :rules="rules" ref="ruleFormRef" v-if="pztypecode === 1">
<el-form-item label="轮询时间" prop="polling_time">
<el-input-number v-model="form.polling_time" :min="1" placeholder="(单位:秒)" clearable/><span></span>
@ -130,7 +130,7 @@ export default {
id: 1,
},
form2: {
polling_time: "",
polling_time: "",
faile_retry_time: "",
driver_name: '',
dataBits: 5,
@ -212,13 +212,13 @@ export default {
polling_time: [{ required: true, message: "请输入轮询时间", trigger: "blur" }],
faile_retry_time: [{ required: true, message: "请输入失败重试时间", trigger: "blur" }],
host: [{ required: true, validator: (rule, value, callback) => {
  //
      var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
      if (value && reg.test(value) ) {
        callback();
      } else {
        callback(new Error("请输入正确的ip地址"));
      }}, trigger: 'blur' }],
//
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
if (value && reg.test(value) ) {
callback();
} else {
callback(new Error("请输入正确的ip地址"));
}}, trigger: 'blur' }],
port: [{ required: true, message: "请输入端口号", trigger: "blur" }]
},
rules2: {

View File

@ -61,7 +61,7 @@ axios.interceptors.response.use(
}
);
// post
export function postPBRequest(url, params, actionNum,name) {
export function postPBRequest(url, params, actionNum, name) {
const title = url === '/driver' ? {'driver_name': Base64.encode(name) }: {'template_name': Base64.encode(name)}
return axios({
method: "post",

View File

@ -23,15 +23,20 @@
/> -->
<el-table-column prop="status" label="通讯状态" width="200" align="center">
<template #default="scope">
<span class="txStatusDiv" :style="{
background: scope.row.status == 1 ? '#13ce66' : '#f8cecc',
}">{{ scope.row.status == 1 ? "正常" : "未连接" }}</span>
<span> {{ txStatus[scope.row.status] }} </span>
</template>
</el-table-column>
<el-table-column prop="enable" label="启用状态" width="350" align="center">
<template #default="scope">
<el-switch v-model="scope.row.enable" inline-prompt active-text="" inactive-text="" :active-value="false"
:inactive-value="true" active-color="#13ce66" inactive-color="red" @change="changeStatus(scope.row)" />
现在是 <el-tag :class="!scope.row.enable? 'stop':'start'">{{!scope.row.enable? '停用状态' : '启用状态'}} </el-tag>
<el-button type="primary" size="mini" @click="changeStatus(scope.row)" v-if="!scope.row.enable">
启用
</el-button>
<el-button size="mini" @click="changeStatus(scope.row)" v-else>
停用
</el-button>
<!-- <el-switch v-model="scope.row.enable" inline-prompt active-text="" inactive-text="" :active-value="true"
:inactive-value="false" active-color="#13ce66" inactive-color="#ddd" @change="changeStatus(scope.row)" /> -->
</template>
</el-table-column>
<el-table-column label="操作" align="center" show-overflow-tooltip>
@ -105,12 +110,14 @@ export default {
dialogVisible3: false,
type: '0', // 0 1
pztype: '',
pztypecode: ''
pztypecode: '',
txStatus: [] //
});
onMounted(() => {
getTxSupport();
getTableData();
getTxStatus();
});
//
const getTxSupport = async () => {
@ -122,6 +129,17 @@ export default {
}
};
//
const getTxStatus = async () => {
const res = await infoApi.getTxStatus();
if (res.code == 0) {
state.txStatus = res.data;
console.log(456, state.txStatus)
}
};
const getTableData = async () => {
const param = {
@ -269,4 +287,10 @@ export default {
border-radius: 10px;
color: #fff;
}
.stop {
color: red;
}
.start {
color: #009fa4;
}
</style>