main
wangqiujuan0808 2024-10-23 00:09:00 +08:00
parent 06f466773e
commit dbddfcb547
5 changed files with 68 additions and 105 deletions

View File

@ -17,36 +17,6 @@ const infoApi = {
reboot() {
return postPBRequest("/system", null, 57202);
},
// //
// getTc(params) {
// return getRequest('/tc', params)
// },
// //
// getSupport(params) {
// return getRequest('/tc/support', params)
// },
// //
// getFree(params) {
// return getRequest('/com/free', params)
// },
// // api/com
// getCom(params) {
// return getRequest('/com', params)
// },
// saveTx(params) {
// return postJsonRequest("/tx", params);
// },
// //
// stopTc(params) {
// return putRequest("/tc", params);
// },
// //
// delTc(params) {
// return deleteRequest("/tc", params);
// },
//
getMb(params) {
return postPBRequest('/template', params, 53000)
@ -170,7 +140,7 @@ const infoApi = {
},
// com
getCom(params) {
return postPBRequest("/info", null, 51001, params.name);
return postPBRequest("/system", null, 57002, params.name);
},
//
//

View File

@ -44,7 +44,7 @@
<fieldset class="box2">
<legend class="box-ht">通用配置</legend>
<el-form-item label="轮询时间" prop="polling_time">
<el-input-number v-model="form2.polling_time" :min="1" placeholder="(单位:秒)" clearable /><span></span>
<el-input-number v-model="form2.polling_time" :min="1" placeholder="(单位:秒)" clearable /><span></span>
</el-form-item>
<el-form-item label="失败重试时间" prop="faile_retry_time">
<el-input-number v-model="form2.faile_retry_time" :min="1" placeholder="(单位:秒)" clearable /><span></span>
@ -283,7 +283,7 @@ export default {
var header = {
driver_name: props.formData.driver_name
}
if (props.pztypecode === 2) {
if (props.pztypecode === 2) { //modbus_tcp
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
var param = {
@ -295,27 +295,17 @@ export default {
}
const res = await infoApi.addPz(param, header);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
} else {
ElMessage.error(res.message);
ElMessage.error(res.data);
}
} else {
}
});
} else if (props.pztypecode === 1) {
} else if (props.pztypecode === 1) { // modbus_rtu
await ruleFormRef2.value.validate(async (valid) => {
if (valid) {
// var param = {
// polling_time:Number(state.form2.polling_time),
// faile_retry_time: Number(state.form2.faile_retry_time),
// dataBits: Number(state.form2.dataBits),
// baudRate: Number(state.form2.baudRate),
// stopBits: Number(state.form2.stopBits),
// driver_name: state.form2.driver_name,
// parity: state.form2.parity,
// id: Number(state.form2.id)
// }
var param = {
name: props.formData.name,
polling_time: Number(state.form2.polling_time),
@ -330,10 +320,10 @@ export default {
}
const res = await infoApi.addPz(param, header);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
} else {
ElMessage.error(res.message);
ElMessage.error(res.data);
}
} else {
}
@ -351,10 +341,10 @@ export default {
}
const res = await infoApi.addPz(param, header);
if (res.code == 0) {
ElMessage.success(res.message || "请求成功");
ElMessage.success(res.data || "请求成功");
ctx.emit("dialogClose");
} else {
ElMessage.error(res.message);
ElMessage.error(res.data);
}
} else {
}
@ -368,7 +358,7 @@ export default {
onMounted(() => {
getD();
// getCom();
getCom();
});
const getD = async () => {
const parm = {
@ -376,8 +366,17 @@ export default {
}
const res = await infoApi.getD(parm);
if (res.code == 0) {
state.form = res.data;
console.log(state.form);
if (props.pztypecode === 2) {
state.form = res.data;
}
if (props.pztypecode === 1) {
state.form2 = res.data;
state.form2.com_name = res.data.com.name;
state.form2.dataBits = Number(res.data.com.dataBits);
state.form2.baudRate = Number(res.data.com.baudRate);
state.form2.stopBits = Number(res.data.com.stopBits);
state.form2.parity = res.data.com.parity;
}
}
};
const getCom = async () => {
@ -389,7 +388,6 @@ export default {
state.comArr = res.data.sort((a, b) => {
return (a.name > b.name ? 1 : -1)
});
state.form2.com_name = state.comArr[0].name;
}
};
const closeDialog = () => {

View File

@ -117,7 +117,7 @@
</template>
<script>
import { onMounted, reactive, ref, toRefs, nextTick } from "vue";
import { onMounted, reactive, ref, toRefs, nextTick,onUnmounted } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import De from "@/components/De.vue";
@ -153,15 +153,22 @@ export default {
dialogVisible1: false,
dialogVisible2: false,
txStatus: [], //
pointTypeOptions: {}
pointTypeOptions: {},
intervalId:null
});
onMounted(() => {
getDriverData();
getTxStatus();
getPointType();
state.intervalId = setInterval(() =>
getDriverData(), 1000);
});
onUnmounted(() => {
clearInterval(state.intervalId);
})
const getPointType = async () => {
const parm = {};
const res = await infoApi.getPointType(parm);

View File

@ -2,7 +2,7 @@
<el-card class="content-div">
<div class="all-content">
<div class="top-div">
<el-button type="primary" size="large" v-show="tableData && tableData.length>0" @click="addData"></el-button>
<el-button type="primary" size="large" @click="addData"></el-button>
</div>
<el-table :data="tableData" style="width: 100%" border stripe
:header-cell-style="{ background: '#F6F7FC' }" size="large">
@ -90,15 +90,15 @@ export default {
//
const endIndex = startIndex + state.listQuery.pageNum;
//
return state.tableData1.slice(startIndex, endIndex);
return state.tableData1 && state.tableData1.length > 0 && state.tableData1.slice(startIndex, endIndex);
});
const totalNum = computed(() => {
return state.tableData1.length;
return state.tableData1 && state.tableData1.length;
})
const total = computed(() => {
return Math.ceil(state.tableData1.length / state.listQuery.pageNum);
return state.tableData1 && Math.ceil(state.tableData1.length / state.listQuery.pageNum);
})
onMounted(() => {
@ -120,7 +120,7 @@ export default {
if (res.code == 0) {
//
state.tableData1 = res.data && res.data.length > 0 && res.data.sort((a,b) => {
return (a.name > b.name ? 1 : -1)
return (a.name > b.name ? 1 : -1) || []
});
} else {
}

View File

@ -4,7 +4,7 @@
<div class="top-div">
<el-button type="primary" size="large" @click="addData"></el-button>
</div>
<el-table :data="tableData" border :row-class-name="tableRowClassName"
<el-table :data="tableData" border :row-class-name="tableRowClassName"
:header-cell-style="{ background: '#F6F7FC' }" size="large">
<el-table-column type="index" label="序号" width="80" align="center" />
<el-table-column prop="driver_name" label="驱动名称" width="200" align="center" show-overflow-tooltip />
@ -18,7 +18,7 @@
</el-table-column>
<el-table-column prop="driver_status" label="驱动状态" width="200" align="center">
<template #default="scope">
<span> {{ txStatus[scope.row.driver_status] }} </span>
<span> {{ txStatus[scope.row.driver_status] }} </span>
</template>
</el-table-column>
<el-table-column prop="driver_enable" label="启停控制" width="200" align="center">
@ -26,7 +26,7 @@
<el-button type="primary" size="large" @click="changeStatus(scope.row)" v-if="!scope.row.driver_enable">
启用
</el-button>
<el-button size="large" @click="changeStatus(scope.row)" v-else>
<el-button size="large" @click="changeStatus(scope.row)" v-else>
停用
</el-button>
</template>
@ -39,7 +39,7 @@
<el-button type="warning" size="large" @click="openPz(scope.row)">
配置
</el-button>
<el-button size="large" @click="editData(scope.row)">
<el-button size="large" @click="editData(scope.row)">
编辑
</el-button>
<el-button type="danger" size="large" @click="delData(scope.row)">
@ -49,44 +49,24 @@
</el-table-column>
</el-table>
</div>
<AddData
:formData="formData"
:type="type"
:qudongOptions="qudongOptions"
:dialogVisible="dialogVisible"
v-if="dialogVisible"
@dialogClose="dialogClose"
@dialogSuccess="dialogSuccess"
></AddData>
<PzSet
:dialogVisible="dialogVisible3"
:formData="formData"
:pztype="pztype"
:pztypecode="pztypecode"
v-if="dialogVisible3"
@dialogClose="dialogClose3"
@dialogSuccess="dialogSuccess3"
>
<AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible"
v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData>
<PzSet :dialogVisible="dialogVisible3" :formData="formData" :pztype="pztype" :pztypecode="pztypecode"
v-if="dialogVisible3" @dialogClose="dialogClose3" @dialogSuccess="dialogSuccess3">
</PzSet>
<Details
:formData="formData"
:dialogVisible="dialogVisible4"
v-if="dialogVisible4"
@dialogClose="dialogClose4"
@dialogSuccess="dialogSuccess4"
>
<Details :formData="formData" :dialogVisible="dialogVisible4" v-if="dialogVisible4" @dialogClose="dialogClose4"
@dialogSuccess="dialogSuccess4">
</Details>
<AddData :formData="formData" :type="type" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible"
v-if="dialogVisible" @dialogClose="dialogClose" @dialogSuccess="dialogSuccess"></AddData>
<ViewSet :formData="formData" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible2" v-if="dialogVisible2" @dialogClose="dialogClose"
@dialogSuccess="dialogSuccess">
<ViewSet :formData="formData" :qudongOptions="qudongOptions" :dialogVisible="dialogVisible2" v-if="dialogVisible2"
@dialogClose="dialogClose" @dialogSuccess="dialogSuccess">
</ViewSet>
</el-card>
</template>
<script>
import { onMounted, reactive, ref, toRefs } from "vue";
import { onMounted, reactive, ref, toRefs, onUnmounted } from "vue";
import infoApi from "@/api/infoApi.js";
import { ElMessage, ElMessageBox } from "element-plus";
import AddData from "@/components/AddData.vue";
@ -114,14 +94,21 @@ export default {
type: '0', // 0 1
pztype: '',
pztypecode: '',
txStatus: [] //
txStatus: [], //
intervalId: null
});
onMounted(() => {
getTxSupport();
getTableData();
getTxStatus();
// getTableData();
state.intervalId = setInterval(() =>
getTableData(), 1000);
});
onUnmounted(() => {
clearInterval(state.intervalId);
})
//
const getTxSupport = async () => {
@ -145,7 +132,7 @@ export default {
const getTableData = async () => {
const res = await infoApi.getTx();
if (res.code == 0) {
state.tableData = res.data && res.data.length > 0 && res.data.sort((a,b) => {
state.tableData = res.data && res.data.length > 0 && res.data.sort((a, b) => {
return (a.driver_name > b.driver_name ? 1 : -1)
});
}
@ -203,7 +190,7 @@ export default {
};
const delData = (item) => {
if(item.status == 2) {
if (item.status == 2) {
ElMessage.warning("无法删除正在运行的驱动,请先手动停止后再删除");
return;
@ -262,20 +249,20 @@ export default {
const openDetails = (item) => {
state.formData = JSON.parse(JSON.stringify(item));
state.dialogVisible4 = true;
}
const tableRowClassName = ({ row, rowIndex }) => {
if(row.driver_status == 1) {
if (row.driver_status == 1) {
return ''
}
if(row.driver_status == 2) {
if (row.driver_status == 2) {
return 'green'
}
if(row.driver_status == 3) {
if (row.driver_status == 3) {
return 'red'
}
}
return {
@ -317,11 +304,12 @@ export default {
border-radius: 10px;
color: #fff;
}
.stop {
color: red;
}
.start {
color: #009fa4;
}
</style>