瓶中沙 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) { delTx(params) {
return postPBRequest(`/driver`, params, 54300); return postPBRequest(`/driver`, params, 54300);
}, },
//
getTxStatus(params) {
return postPBRequest(`/driver`, params, 54004);
},
// //
getTxSupport() { getTxSupport() {
@ -139,11 +143,11 @@ const infoApi = {
// , // ,
startStatus(params) { startStatus(params) {
return postPBRequest("/driver", params, 53201); return postPBRequest("/driver", params, 54202,params.name);
}, },
// //
stopStatus(params) { stopStatus(params) {
return postPBRequest("/driver", params, 53202); return postPBRequest("/driver", params, 54203,params.name);
}, },
// //
addPz(params, header) { addPz(params, header) {

View File

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

View File

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

View File

@ -61,7 +61,7 @@ axios.interceptors.response.use(
} }
); );
// post // 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)} const title = url === '/driver' ? {'driver_name': Base64.encode(name) }: {'template_name': Base64.encode(name)}
return axios({ return axios({
method: "post", method: "post",

View File

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